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