00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019 static real c_b12 = -1.f;
00020 static real c_b14 = 1.f;
00021
00022 int spprfs_(char *uplo, integer *n, integer *nrhs, real *ap,
00023 real *afp, real *b, integer *ldb, real *x, integer *ldx, real *ferr,
00024 real *berr, real *work, integer *iwork, integer *info)
00025 {
00026
00027 integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3;
00028 real r__1, r__2, r__3;
00029
00030
00031 integer i__, j, k;
00032 real s;
00033 integer ik, kk;
00034 real xk;
00035 integer nz;
00036 real eps;
00037 integer kase;
00038 real safe1, safe2;
00039 extern logical lsame_(char *, char *);
00040 integer isave[3], count;
00041 logical upper;
00042 extern int scopy_(integer *, real *, integer *, real *,
00043 integer *), saxpy_(integer *, real *, real *, integer *, real *,
00044 integer *), sspmv_(char *, integer *, real *, real *, real *,
00045 integer *, real *, real *, integer *), slacn2_(integer *,
00046 real *, real *, integer *, real *, integer *, integer *);
00047 extern doublereal slamch_(char *);
00048 real safmin;
00049 extern int xerbla_(char *, integer *);
00050 real lstres;
00051 extern int spptrs_(char *, integer *, integer *, real *,
00052 real *, integer *, integer *);
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 --ap;
00162 --afp;
00163 b_dim1 = *ldb;
00164 b_offset = 1 + b_dim1;
00165 b -= b_offset;
00166 x_dim1 = *ldx;
00167 x_offset = 1 + x_dim1;
00168 x -= x_offset;
00169 --ferr;
00170 --berr;
00171 --work;
00172 --iwork;
00173
00174
00175 *info = 0;
00176 upper = lsame_(uplo, "U");
00177 if (! upper && ! lsame_(uplo, "L")) {
00178 *info = -1;
00179 } else if (*n < 0) {
00180 *info = -2;
00181 } else if (*nrhs < 0) {
00182 *info = -3;
00183 } else if (*ldb < max(1,*n)) {
00184 *info = -7;
00185 } else if (*ldx < max(1,*n)) {
00186 *info = -9;
00187 }
00188 if (*info != 0) {
00189 i__1 = -(*info);
00190 xerbla_("SPPRFS", &i__1);
00191 return 0;
00192 }
00193
00194
00195
00196 if (*n == 0 || *nrhs == 0) {
00197 i__1 = *nrhs;
00198 for (j = 1; j <= i__1; ++j) {
00199 ferr[j] = 0.f;
00200 berr[j] = 0.f;
00201
00202 }
00203 return 0;
00204 }
00205
00206
00207
00208 nz = *n + 1;
00209 eps = slamch_("Epsilon");
00210 safmin = slamch_("Safe minimum");
00211 safe1 = nz * safmin;
00212 safe2 = safe1 / eps;
00213
00214
00215
00216 i__1 = *nrhs;
00217 for (j = 1; j <= i__1; ++j) {
00218
00219 count = 1;
00220 lstres = 3.f;
00221 L20:
00222
00223
00224
00225
00226
00227 scopy_(n, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1);
00228 sspmv_(uplo, n, &c_b12, &ap[1], &x[j * x_dim1 + 1], &c__1, &c_b14, &
00229 work[*n + 1], &c__1);
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 i__2 = *n;
00241 for (i__ = 1; i__ <= i__2; ++i__) {
00242 work[i__] = (r__1 = b[i__ + j * b_dim1], dabs(r__1));
00243
00244 }
00245
00246
00247
00248 kk = 1;
00249 if (upper) {
00250 i__2 = *n;
00251 for (k = 1; k <= i__2; ++k) {
00252 s = 0.f;
00253 xk = (r__1 = x[k + j * x_dim1], dabs(r__1));
00254 ik = kk;
00255 i__3 = k - 1;
00256 for (i__ = 1; i__ <= i__3; ++i__) {
00257 work[i__] += (r__1 = ap[ik], dabs(r__1)) * xk;
00258 s += (r__1 = ap[ik], dabs(r__1)) * (r__2 = x[i__ + j *
00259 x_dim1], dabs(r__2));
00260 ++ik;
00261
00262 }
00263 work[k] = work[k] + (r__1 = ap[kk + k - 1], dabs(r__1)) * xk
00264 + s;
00265 kk += k;
00266
00267 }
00268 } else {
00269 i__2 = *n;
00270 for (k = 1; k <= i__2; ++k) {
00271 s = 0.f;
00272 xk = (r__1 = x[k + j * x_dim1], dabs(r__1));
00273 work[k] += (r__1 = ap[kk], dabs(r__1)) * xk;
00274 ik = kk + 1;
00275 i__3 = *n;
00276 for (i__ = k + 1; i__ <= i__3; ++i__) {
00277 work[i__] += (r__1 = ap[ik], dabs(r__1)) * xk;
00278 s += (r__1 = ap[ik], dabs(r__1)) * (r__2 = x[i__ + j *
00279 x_dim1], dabs(r__2));
00280 ++ik;
00281
00282 }
00283 work[k] += s;
00284 kk += *n - k + 1;
00285
00286 }
00287 }
00288 s = 0.f;
00289 i__2 = *n;
00290 for (i__ = 1; i__ <= i__2; ++i__) {
00291 if (work[i__] > safe2) {
00292
00293 r__2 = s, r__3 = (r__1 = work[*n + i__], dabs(r__1)) / work[
00294 i__];
00295 s = dmax(r__2,r__3);
00296 } else {
00297
00298 r__2 = s, r__3 = ((r__1 = work[*n + i__], dabs(r__1)) + safe1)
00299 / (work[i__] + safe1);
00300 s = dmax(r__2,r__3);
00301 }
00302
00303 }
00304 berr[j] = s;
00305
00306
00307
00308
00309
00310
00311
00312 if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) {
00313
00314
00315
00316 spptrs_(uplo, n, &c__1, &afp[1], &work[*n + 1], n, info);
00317 saxpy_(n, &c_b14, &work[*n + 1], &c__1, &x[j * x_dim1 + 1], &c__1)
00318 ;
00319 lstres = berr[j];
00320 ++count;
00321 goto L20;
00322 }
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346 i__2 = *n;
00347 for (i__ = 1; i__ <= i__2; ++i__) {
00348 if (work[i__] > safe2) {
00349 work[i__] = (r__1 = work[*n + i__], dabs(r__1)) + nz * eps *
00350 work[i__];
00351 } else {
00352 work[i__] = (r__1 = work[*n + i__], dabs(r__1)) + nz * eps *
00353 work[i__] + safe1;
00354 }
00355
00356 }
00357
00358 kase = 0;
00359 L100:
00360 slacn2_(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], &
00361 kase, isave);
00362 if (kase != 0) {
00363 if (kase == 1) {
00364
00365
00366
00367 spptrs_(uplo, n, &c__1, &afp[1], &work[*n + 1], n, info);
00368 i__2 = *n;
00369 for (i__ = 1; i__ <= i__2; ++i__) {
00370 work[*n + i__] = work[i__] * work[*n + i__];
00371
00372 }
00373 } else if (kase == 2) {
00374
00375
00376
00377 i__2 = *n;
00378 for (i__ = 1; i__ <= i__2; ++i__) {
00379 work[*n + i__] = work[i__] * work[*n + i__];
00380
00381 }
00382 spptrs_(uplo, n, &c__1, &afp[1], &work[*n + 1], n, info);
00383 }
00384 goto L100;
00385 }
00386
00387
00388
00389 lstres = 0.f;
00390 i__2 = *n;
00391 for (i__ = 1; i__ <= i__2; ++i__) {
00392
00393 r__2 = lstres, r__3 = (r__1 = x[i__ + j * x_dim1], dabs(r__1));
00394 lstres = dmax(r__2,r__3);
00395
00396 }
00397 if (lstres != 0.f) {
00398 ferr[j] /= lstres;
00399 }
00400
00401
00402 }
00403
00404 return 0;
00405
00406
00407
00408 }