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 doublereal c_b12 = -1.;
00020 static doublereal c_b14 = 1.;
00021
00022 int dpprfs_(char *uplo, integer *n, integer *nrhs,
00023 doublereal *ap, doublereal *afp, doublereal *b, integer *ldb,
00024 doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr,
00025 doublereal *work, integer *iwork, integer *info)
00026 {
00027
00028 integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3;
00029 doublereal d__1, d__2, d__3;
00030
00031
00032 integer i__, j, k;
00033 doublereal s;
00034 integer ik, kk;
00035 doublereal xk;
00036 integer nz;
00037 doublereal eps;
00038 integer kase;
00039 doublereal safe1, safe2;
00040 extern logical lsame_(char *, char *);
00041 integer isave[3];
00042 extern int dcopy_(integer *, doublereal *, integer *,
00043 doublereal *, integer *), daxpy_(integer *, doublereal *,
00044 doublereal *, integer *, doublereal *, integer *);
00045 integer count;
00046 extern int dspmv_(char *, integer *, doublereal *,
00047 doublereal *, doublereal *, integer *, doublereal *, doublereal *,
00048 integer *);
00049 logical upper;
00050 extern int dlacn2_(integer *, doublereal *, doublereal *,
00051 integer *, doublereal *, integer *, integer *);
00052 extern doublereal dlamch_(char *);
00053 doublereal safmin;
00054 extern int xerbla_(char *, integer *);
00055 doublereal lstres;
00056 extern int dpptrs_(char *, integer *, integer *,
00057 doublereal *, doublereal *, integer *, integer *);
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
00162
00163
00164
00165
00166 --ap;
00167 --afp;
00168 b_dim1 = *ldb;
00169 b_offset = 1 + b_dim1;
00170 b -= b_offset;
00171 x_dim1 = *ldx;
00172 x_offset = 1 + x_dim1;
00173 x -= x_offset;
00174 --ferr;
00175 --berr;
00176 --work;
00177 --iwork;
00178
00179
00180 *info = 0;
00181 upper = lsame_(uplo, "U");
00182 if (! upper && ! lsame_(uplo, "L")) {
00183 *info = -1;
00184 } else if (*n < 0) {
00185 *info = -2;
00186 } else if (*nrhs < 0) {
00187 *info = -3;
00188 } else if (*ldb < max(1,*n)) {
00189 *info = -7;
00190 } else if (*ldx < max(1,*n)) {
00191 *info = -9;
00192 }
00193 if (*info != 0) {
00194 i__1 = -(*info);
00195 xerbla_("DPPRFS", &i__1);
00196 return 0;
00197 }
00198
00199
00200
00201 if (*n == 0 || *nrhs == 0) {
00202 i__1 = *nrhs;
00203 for (j = 1; j <= i__1; ++j) {
00204 ferr[j] = 0.;
00205 berr[j] = 0.;
00206
00207 }
00208 return 0;
00209 }
00210
00211
00212
00213 nz = *n + 1;
00214 eps = dlamch_("Epsilon");
00215 safmin = dlamch_("Safe minimum");
00216 safe1 = nz * safmin;
00217 safe2 = safe1 / eps;
00218
00219
00220
00221 i__1 = *nrhs;
00222 for (j = 1; j <= i__1; ++j) {
00223
00224 count = 1;
00225 lstres = 3.;
00226 L20:
00227
00228
00229
00230
00231
00232 dcopy_(n, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1);
00233 dspmv_(uplo, n, &c_b12, &ap[1], &x[j * x_dim1 + 1], &c__1, &c_b14, &
00234 work[*n + 1], &c__1);
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 i__2 = *n;
00246 for (i__ = 1; i__ <= i__2; ++i__) {
00247 work[i__] = (d__1 = b[i__ + j * b_dim1], abs(d__1));
00248
00249 }
00250
00251
00252
00253 kk = 1;
00254 if (upper) {
00255 i__2 = *n;
00256 for (k = 1; k <= i__2; ++k) {
00257 s = 0.;
00258 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00259 ik = kk;
00260 i__3 = k - 1;
00261 for (i__ = 1; i__ <= i__3; ++i__) {
00262 work[i__] += (d__1 = ap[ik], abs(d__1)) * xk;
00263 s += (d__1 = ap[ik], abs(d__1)) * (d__2 = x[i__ + j *
00264 x_dim1], abs(d__2));
00265 ++ik;
00266
00267 }
00268 work[k] = work[k] + (d__1 = ap[kk + k - 1], abs(d__1)) * xk +
00269 s;
00270 kk += k;
00271
00272 }
00273 } else {
00274 i__2 = *n;
00275 for (k = 1; k <= i__2; ++k) {
00276 s = 0.;
00277 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00278 work[k] += (d__1 = ap[kk], abs(d__1)) * xk;
00279 ik = kk + 1;
00280 i__3 = *n;
00281 for (i__ = k + 1; i__ <= i__3; ++i__) {
00282 work[i__] += (d__1 = ap[ik], abs(d__1)) * xk;
00283 s += (d__1 = ap[ik], abs(d__1)) * (d__2 = x[i__ + j *
00284 x_dim1], abs(d__2));
00285 ++ik;
00286
00287 }
00288 work[k] += s;
00289 kk += *n - k + 1;
00290
00291 }
00292 }
00293 s = 0.;
00294 i__2 = *n;
00295 for (i__ = 1; i__ <= i__2; ++i__) {
00296 if (work[i__] > safe2) {
00297
00298 d__2 = s, d__3 = (d__1 = work[*n + i__], abs(d__1)) / work[
00299 i__];
00300 s = max(d__2,d__3);
00301 } else {
00302
00303 d__2 = s, d__3 = ((d__1 = work[*n + i__], abs(d__1)) + safe1)
00304 / (work[i__] + safe1);
00305 s = max(d__2,d__3);
00306 }
00307
00308 }
00309 berr[j] = s;
00310
00311
00312
00313
00314
00315
00316
00317 if (berr[j] > eps && berr[j] * 2. <= lstres && count <= 5) {
00318
00319
00320
00321 dpptrs_(uplo, n, &c__1, &afp[1], &work[*n + 1], n, info);
00322 daxpy_(n, &c_b14, &work[*n + 1], &c__1, &x[j * x_dim1 + 1], &c__1)
00323 ;
00324 lstres = berr[j];
00325 ++count;
00326 goto L20;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 i__2 = *n;
00352 for (i__ = 1; i__ <= i__2; ++i__) {
00353 if (work[i__] > safe2) {
00354 work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps *
00355 work[i__];
00356 } else {
00357 work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps *
00358 work[i__] + safe1;
00359 }
00360
00361 }
00362
00363 kase = 0;
00364 L100:
00365 dlacn2_(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], &
00366 kase, isave);
00367 if (kase != 0) {
00368 if (kase == 1) {
00369
00370
00371
00372 dpptrs_(uplo, n, &c__1, &afp[1], &work[*n + 1], n, info);
00373 i__2 = *n;
00374 for (i__ = 1; i__ <= i__2; ++i__) {
00375 work[*n + i__] = work[i__] * work[*n + i__];
00376
00377 }
00378 } else if (kase == 2) {
00379
00380
00381
00382 i__2 = *n;
00383 for (i__ = 1; i__ <= i__2; ++i__) {
00384 work[*n + i__] = work[i__] * work[*n + i__];
00385
00386 }
00387 dpptrs_(uplo, n, &c__1, &afp[1], &work[*n + 1], n, info);
00388 }
00389 goto L100;
00390 }
00391
00392
00393
00394 lstres = 0.;
00395 i__2 = *n;
00396 for (i__ = 1; i__ <= i__2; ++i__) {
00397
00398 d__2 = lstres, d__3 = (d__1 = x[i__ + j * x_dim1], abs(d__1));
00399 lstres = max(d__2,d__3);
00400
00401 }
00402 if (lstres != 0.) {
00403 ferr[j] /= lstres;
00404 }
00405
00406
00407 }
00408
00409 return 0;
00410
00411
00412
00413 }