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