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_b19 = -1.;
00020
00021 int dtprfs_(char *uplo, char *trans, char *diag, integer *n,
00022 integer *nrhs, doublereal *ap, doublereal *b, integer *ldb,
00023 doublereal *x, integer *ldx, doublereal *ferr, doublereal *berr,
00024 doublereal *work, integer *iwork, integer *info)
00025 {
00026
00027 integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3;
00028 doublereal d__1, d__2, d__3;
00029
00030
00031 integer i__, j, k;
00032 doublereal s;
00033 integer kc;
00034 doublereal xk;
00035 integer nz;
00036 doublereal eps;
00037 integer kase;
00038 doublereal safe1, safe2;
00039 extern logical lsame_(char *, char *);
00040 integer isave[3];
00041 extern int dcopy_(integer *, doublereal *, integer *,
00042 doublereal *, integer *), daxpy_(integer *, doublereal *,
00043 doublereal *, integer *, doublereal *, integer *), dtpmv_(char *,
00044 char *, char *, integer *, doublereal *, doublereal *, integer *);
00045 logical upper;
00046 extern int dtpsv_(char *, char *, char *, integer *,
00047 doublereal *, doublereal *, integer *),
00048 dlacn2_(integer *, doublereal *, doublereal *, integer *,
00049 doublereal *, integer *, integer *);
00050 extern doublereal dlamch_(char *);
00051 doublereal safmin;
00052 extern int xerbla_(char *, integer *);
00053 logical notran;
00054 char transt[1];
00055 logical nounit;
00056 doublereal lstres;
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
00162
00163
00164
00165
00166
00167
00168 --ap;
00169 b_dim1 = *ldb;
00170 b_offset = 1 + b_dim1;
00171 b -= b_offset;
00172 x_dim1 = *ldx;
00173 x_offset = 1 + x_dim1;
00174 x -= x_offset;
00175 --ferr;
00176 --berr;
00177 --work;
00178 --iwork;
00179
00180
00181 *info = 0;
00182 upper = lsame_(uplo, "U");
00183 notran = lsame_(trans, "N");
00184 nounit = lsame_(diag, "N");
00185
00186 if (! upper && ! lsame_(uplo, "L")) {
00187 *info = -1;
00188 } else if (! notran && ! lsame_(trans, "T") && !
00189 lsame_(trans, "C")) {
00190 *info = -2;
00191 } else if (! nounit && ! lsame_(diag, "U")) {
00192 *info = -3;
00193 } else if (*n < 0) {
00194 *info = -4;
00195 } else if (*nrhs < 0) {
00196 *info = -5;
00197 } else if (*ldb < max(1,*n)) {
00198 *info = -8;
00199 } else if (*ldx < max(1,*n)) {
00200 *info = -10;
00201 }
00202 if (*info != 0) {
00203 i__1 = -(*info);
00204 xerbla_("DTPRFS", &i__1);
00205 return 0;
00206 }
00207
00208
00209
00210 if (*n == 0 || *nrhs == 0) {
00211 i__1 = *nrhs;
00212 for (j = 1; j <= i__1; ++j) {
00213 ferr[j] = 0.;
00214 berr[j] = 0.;
00215
00216 }
00217 return 0;
00218 }
00219
00220 if (notran) {
00221 *(unsigned char *)transt = 'T';
00222 } else {
00223 *(unsigned char *)transt = 'N';
00224 }
00225
00226
00227
00228 nz = *n + 1;
00229 eps = dlamch_("Epsilon");
00230 safmin = dlamch_("Safe minimum");
00231 safe1 = nz * safmin;
00232 safe2 = safe1 / eps;
00233
00234
00235
00236 i__1 = *nrhs;
00237 for (j = 1; j <= i__1; ++j) {
00238
00239
00240
00241
00242 dcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[*n + 1], &c__1);
00243 dtpmv_(uplo, trans, diag, n, &ap[1], &work[*n + 1], &c__1);
00244 daxpy_(n, &c_b19, &b[j * b_dim1 + 1], &c__1, &work[*n + 1], &c__1);
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255 i__2 = *n;
00256 for (i__ = 1; i__ <= i__2; ++i__) {
00257 work[i__] = (d__1 = b[i__ + j * b_dim1], abs(d__1));
00258
00259 }
00260
00261 if (notran) {
00262
00263
00264
00265 if (upper) {
00266 kc = 1;
00267 if (nounit) {
00268 i__2 = *n;
00269 for (k = 1; k <= i__2; ++k) {
00270 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00271 i__3 = k;
00272 for (i__ = 1; i__ <= i__3; ++i__) {
00273 work[i__] += (d__1 = ap[kc + i__ - 1], abs(d__1))
00274 * xk;
00275
00276 }
00277 kc += k;
00278
00279 }
00280 } else {
00281 i__2 = *n;
00282 for (k = 1; k <= i__2; ++k) {
00283 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00284 i__3 = k - 1;
00285 for (i__ = 1; i__ <= i__3; ++i__) {
00286 work[i__] += (d__1 = ap[kc + i__ - 1], abs(d__1))
00287 * xk;
00288
00289 }
00290 work[k] += xk;
00291 kc += k;
00292
00293 }
00294 }
00295 } else {
00296 kc = 1;
00297 if (nounit) {
00298 i__2 = *n;
00299 for (k = 1; k <= i__2; ++k) {
00300 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00301 i__3 = *n;
00302 for (i__ = k; i__ <= i__3; ++i__) {
00303 work[i__] += (d__1 = ap[kc + i__ - k], abs(d__1))
00304 * xk;
00305
00306 }
00307 kc = kc + *n - k + 1;
00308
00309 }
00310 } else {
00311 i__2 = *n;
00312 for (k = 1; k <= i__2; ++k) {
00313 xk = (d__1 = x[k + j * x_dim1], abs(d__1));
00314 i__3 = *n;
00315 for (i__ = k + 1; i__ <= i__3; ++i__) {
00316 work[i__] += (d__1 = ap[kc + i__ - k], abs(d__1))
00317 * xk;
00318
00319 }
00320 work[k] += xk;
00321 kc = kc + *n - k + 1;
00322
00323 }
00324 }
00325 }
00326 } else {
00327
00328
00329
00330 if (upper) {
00331 kc = 1;
00332 if (nounit) {
00333 i__2 = *n;
00334 for (k = 1; k <= i__2; ++k) {
00335 s = 0.;
00336 i__3 = k;
00337 for (i__ = 1; i__ <= i__3; ++i__) {
00338 s += (d__1 = ap[kc + i__ - 1], abs(d__1)) * (d__2
00339 = x[i__ + j * x_dim1], abs(d__2));
00340
00341 }
00342 work[k] += s;
00343 kc += k;
00344
00345 }
00346 } else {
00347 i__2 = *n;
00348 for (k = 1; k <= i__2; ++k) {
00349 s = (d__1 = x[k + j * x_dim1], abs(d__1));
00350 i__3 = k - 1;
00351 for (i__ = 1; i__ <= i__3; ++i__) {
00352 s += (d__1 = ap[kc + i__ - 1], abs(d__1)) * (d__2
00353 = x[i__ + j * x_dim1], abs(d__2));
00354
00355 }
00356 work[k] += s;
00357 kc += k;
00358
00359 }
00360 }
00361 } else {
00362 kc = 1;
00363 if (nounit) {
00364 i__2 = *n;
00365 for (k = 1; k <= i__2; ++k) {
00366 s = 0.;
00367 i__3 = *n;
00368 for (i__ = k; i__ <= i__3; ++i__) {
00369 s += (d__1 = ap[kc + i__ - k], abs(d__1)) * (d__2
00370 = x[i__ + j * x_dim1], abs(d__2));
00371
00372 }
00373 work[k] += s;
00374 kc = kc + *n - k + 1;
00375
00376 }
00377 } else {
00378 i__2 = *n;
00379 for (k = 1; k <= i__2; ++k) {
00380 s = (d__1 = x[k + j * x_dim1], abs(d__1));
00381 i__3 = *n;
00382 for (i__ = k + 1; i__ <= i__3; ++i__) {
00383 s += (d__1 = ap[kc + i__ - k], abs(d__1)) * (d__2
00384 = x[i__ + j * x_dim1], abs(d__2));
00385
00386 }
00387 work[k] += s;
00388 kc = kc + *n - k + 1;
00389
00390 }
00391 }
00392 }
00393 }
00394 s = 0.;
00395 i__2 = *n;
00396 for (i__ = 1; i__ <= i__2; ++i__) {
00397 if (work[i__] > safe2) {
00398
00399 d__2 = s, d__3 = (d__1 = work[*n + i__], abs(d__1)) / work[
00400 i__];
00401 s = max(d__2,d__3);
00402 } else {
00403
00404 d__2 = s, d__3 = ((d__1 = work[*n + i__], abs(d__1)) + safe1)
00405 / (work[i__] + safe1);
00406 s = max(d__2,d__3);
00407 }
00408
00409 }
00410 berr[j] = s;
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 i__2 = *n;
00435 for (i__ = 1; i__ <= i__2; ++i__) {
00436 if (work[i__] > safe2) {
00437 work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps *
00438 work[i__];
00439 } else {
00440 work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps *
00441 work[i__] + safe1;
00442 }
00443
00444 }
00445
00446 kase = 0;
00447 L210:
00448 dlacn2_(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], &
00449 kase, isave);
00450 if (kase != 0) {
00451 if (kase == 1) {
00452
00453
00454
00455 dtpsv_(uplo, transt, diag, n, &ap[1], &work[*n + 1], &c__1);
00456 i__2 = *n;
00457 for (i__ = 1; i__ <= i__2; ++i__) {
00458 work[*n + i__] = work[i__] * work[*n + i__];
00459
00460 }
00461 } else {
00462
00463
00464
00465 i__2 = *n;
00466 for (i__ = 1; i__ <= i__2; ++i__) {
00467 work[*n + i__] = work[i__] * work[*n + i__];
00468
00469 }
00470 dtpsv_(uplo, trans, diag, n, &ap[1], &work[*n + 1], &c__1);
00471 }
00472 goto L210;
00473 }
00474
00475
00476
00477 lstres = 0.;
00478 i__2 = *n;
00479 for (i__ = 1; i__ <= i__2; ++i__) {
00480
00481 d__2 = lstres, d__3 = (d__1 = x[i__ + j * x_dim1], abs(d__1));
00482 lstres = max(d__2,d__3);
00483
00484 }
00485 if (lstres != 0.) {
00486 ferr[j] /= lstres;
00487 }
00488
00489
00490 }
00491
00492 return 0;
00493
00494
00495
00496 }