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
00020 int stpt05_(char *uplo, char *trans, char *diag, integer *n,
00021 integer *nrhs, real *ap, real *b, integer *ldb, real *x, integer *ldx,
00022 real *xact, integer *ldxact, real *ferr, real *berr, real *reslts)
00023 {
00024
00025 integer b_dim1, b_offset, x_dim1, x_offset, xact_dim1, xact_offset, i__1,
00026 i__2, i__3;
00027 real r__1, r__2, r__3;
00028
00029
00030 integer i__, j, k, jc, ifu;
00031 real eps, tmp, diff, axbi;
00032 integer imax;
00033 real unfl, ovfl;
00034 logical unit;
00035 extern logical lsame_(char *, char *);
00036 logical upper;
00037 real xnorm;
00038 extern doublereal slamch_(char *);
00039 real errbnd;
00040 extern integer isamax_(integer *, real *, integer *);
00041 logical notran;
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
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 --ap;
00158 b_dim1 = *ldb;
00159 b_offset = 1 + b_dim1;
00160 b -= b_offset;
00161 x_dim1 = *ldx;
00162 x_offset = 1 + x_dim1;
00163 x -= x_offset;
00164 xact_dim1 = *ldxact;
00165 xact_offset = 1 + xact_dim1;
00166 xact -= xact_offset;
00167 --ferr;
00168 --berr;
00169 --reslts;
00170
00171
00172 if (*n <= 0 || *nrhs <= 0) {
00173 reslts[1] = 0.f;
00174 reslts[2] = 0.f;
00175 return 0;
00176 }
00177
00178 eps = slamch_("Epsilon");
00179 unfl = slamch_("Safe minimum");
00180 ovfl = 1.f / unfl;
00181 upper = lsame_(uplo, "U");
00182 notran = lsame_(trans, "N");
00183 unit = lsame_(diag, "U");
00184
00185
00186
00187
00188
00189 errbnd = 0.f;
00190 i__1 = *nrhs;
00191 for (j = 1; j <= i__1; ++j) {
00192 imax = isamax_(n, &x[j * x_dim1 + 1], &c__1);
00193
00194 r__2 = (r__1 = x[imax + j * x_dim1], dabs(r__1));
00195 xnorm = dmax(r__2,unfl);
00196 diff = 0.f;
00197 i__2 = *n;
00198 for (i__ = 1; i__ <= i__2; ++i__) {
00199
00200 r__2 = diff, r__3 = (r__1 = x[i__ + j * x_dim1] - xact[i__ + j *
00201 xact_dim1], dabs(r__1));
00202 diff = dmax(r__2,r__3);
00203
00204 }
00205
00206 if (xnorm > 1.f) {
00207 goto L20;
00208 } else if (diff <= ovfl * xnorm) {
00209 goto L20;
00210 } else {
00211 errbnd = 1.f / eps;
00212 goto L30;
00213 }
00214
00215 L20:
00216 if (diff / xnorm <= ferr[j]) {
00217
00218 r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00219 errbnd = dmax(r__1,r__2);
00220 } else {
00221 errbnd = 1.f / eps;
00222 }
00223 L30:
00224 ;
00225 }
00226 reslts[1] = errbnd;
00227
00228
00229
00230
00231 ifu = 0;
00232 if (unit) {
00233 ifu = 1;
00234 }
00235 i__1 = *nrhs;
00236 for (k = 1; k <= i__1; ++k) {
00237 i__2 = *n;
00238 for (i__ = 1; i__ <= i__2; ++i__) {
00239 tmp = (r__1 = b[i__ + k * b_dim1], dabs(r__1));
00240 if (upper) {
00241 jc = (i__ - 1) * i__ / 2;
00242 if (! notran) {
00243 i__3 = i__ - ifu;
00244 for (j = 1; j <= i__3; ++j) {
00245 tmp += (r__1 = ap[jc + j], dabs(r__1)) * (r__2 = x[j
00246 + k * x_dim1], dabs(r__2));
00247
00248 }
00249 if (unit) {
00250 tmp += (r__1 = x[i__ + k * x_dim1], dabs(r__1));
00251 }
00252 } else {
00253 jc += i__;
00254 if (unit) {
00255 tmp += (r__1 = x[i__ + k * x_dim1], dabs(r__1));
00256 jc += i__;
00257 }
00258 i__3 = *n;
00259 for (j = i__ + ifu; j <= i__3; ++j) {
00260 tmp += (r__1 = ap[jc], dabs(r__1)) * (r__2 = x[j + k *
00261 x_dim1], dabs(r__2));
00262 jc += j;
00263
00264 }
00265 }
00266 } else {
00267 if (notran) {
00268 jc = i__;
00269 i__3 = i__ - ifu;
00270 for (j = 1; j <= i__3; ++j) {
00271 tmp += (r__1 = ap[jc], dabs(r__1)) * (r__2 = x[j + k *
00272 x_dim1], dabs(r__2));
00273 jc = jc + *n - j;
00274
00275 }
00276 if (unit) {
00277 tmp += (r__1 = x[i__ + k * x_dim1], dabs(r__1));
00278 }
00279 } else {
00280 jc = (i__ - 1) * (*n - i__) + i__ * (i__ + 1) / 2;
00281 if (unit) {
00282 tmp += (r__1 = x[i__ + k * x_dim1], dabs(r__1));
00283 }
00284 i__3 = *n;
00285 for (j = i__ + ifu; j <= i__3; ++j) {
00286 tmp += (r__1 = ap[jc + j - i__], dabs(r__1)) * (r__2 =
00287 x[j + k * x_dim1], dabs(r__2));
00288
00289 }
00290 }
00291 }
00292 if (i__ == 1) {
00293 axbi = tmp;
00294 } else {
00295 axbi = dmin(axbi,tmp);
00296 }
00297
00298 }
00299
00300 r__1 = axbi, r__2 = (*n + 1) * unfl;
00301 tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / dmax(r__1,r__2));
00302 if (k == 1) {
00303 reslts[2] = tmp;
00304 } else {
00305 reslts[2] = dmax(reslts[2],tmp);
00306 }
00307
00308 }
00309
00310 return 0;
00311
00312
00313
00314 }