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