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 ctbt05_(char *uplo, char *trans, char *diag, integer *n,
00021 integer *kd, integer *nrhs, complex *ab, integer *ldab, complex *b,
00022 integer *ldb, complex *x, integer *ldx, complex *xact, integer *
00023 ldxact, real *ferr, real *berr, real *reslts)
00024 {
00025
00026 integer ab_dim1, ab_offset, b_dim1, b_offset, x_dim1, x_offset, xact_dim1,
00027 xact_offset, i__1, i__2, i__3, i__4, i__5;
00028 real r__1, r__2, r__3, r__4;
00029 complex q__1, q__2;
00030
00031
00032 double r_imag(complex *);
00033
00034
00035 integer i__, j, k, nz, ifu;
00036 real eps, tmp, diff, axbi;
00037 integer imax;
00038 real unfl, ovfl;
00039 logical unit;
00040 extern logical lsame_(char *, char *);
00041 logical upper;
00042 real xnorm;
00043 extern integer icamax_(integer *, complex *, integer *);
00044 extern doublereal slamch_(char *);
00045 real errbnd;
00046 logical notran;
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
00168
00169
00170
00171
00172
00173
00174 ab_dim1 = *ldab;
00175 ab_offset = 1 + ab_dim1;
00176 ab -= ab_offset;
00177 b_dim1 = *ldb;
00178 b_offset = 1 + b_dim1;
00179 b -= b_offset;
00180 x_dim1 = *ldx;
00181 x_offset = 1 + x_dim1;
00182 x -= x_offset;
00183 xact_dim1 = *ldxact;
00184 xact_offset = 1 + xact_dim1;
00185 xact -= xact_offset;
00186 --ferr;
00187 --berr;
00188 --reslts;
00189
00190
00191 if (*n <= 0 || *nrhs <= 0) {
00192 reslts[1] = 0.f;
00193 reslts[2] = 0.f;
00194 return 0;
00195 }
00196
00197 eps = slamch_("Epsilon");
00198 unfl = slamch_("Safe minimum");
00199 ovfl = 1.f / unfl;
00200 upper = lsame_(uplo, "U");
00201 notran = lsame_(trans, "N");
00202 unit = lsame_(diag, "U");
00203
00204 i__1 = *kd, i__2 = *n - 1;
00205 nz = min(i__1,i__2) + 1;
00206
00207
00208
00209
00210
00211 errbnd = 0.f;
00212 i__1 = *nrhs;
00213 for (j = 1; j <= i__1; ++j) {
00214 imax = icamax_(n, &x[j * x_dim1 + 1], &c__1);
00215
00216 i__2 = imax + j * x_dim1;
00217 r__3 = (r__1 = x[i__2].r, dabs(r__1)) + (r__2 = r_imag(&x[imax + j *
00218 x_dim1]), dabs(r__2));
00219 xnorm = dmax(r__3,unfl);
00220 diff = 0.f;
00221 i__2 = *n;
00222 for (i__ = 1; i__ <= i__2; ++i__) {
00223 i__3 = i__ + j * x_dim1;
00224 i__4 = i__ + j * xact_dim1;
00225 q__2.r = x[i__3].r - xact[i__4].r, q__2.i = x[i__3].i - xact[i__4]
00226 .i;
00227 q__1.r = q__2.r, q__1.i = q__2.i;
00228
00229 r__3 = diff, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00230 q__1), dabs(r__2));
00231 diff = dmax(r__3,r__4);
00232
00233 }
00234
00235 if (xnorm > 1.f) {
00236 goto L20;
00237 } else if (diff <= ovfl * xnorm) {
00238 goto L20;
00239 } else {
00240 errbnd = 1.f / eps;
00241 goto L30;
00242 }
00243
00244 L20:
00245 if (diff / xnorm <= ferr[j]) {
00246
00247 r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00248 errbnd = dmax(r__1,r__2);
00249 } else {
00250 errbnd = 1.f / eps;
00251 }
00252 L30:
00253 ;
00254 }
00255 reslts[1] = errbnd;
00256
00257
00258
00259
00260 ifu = 0;
00261 if (unit) {
00262 ifu = 1;
00263 }
00264 i__1 = *nrhs;
00265 for (k = 1; k <= i__1; ++k) {
00266 i__2 = *n;
00267 for (i__ = 1; i__ <= i__2; ++i__) {
00268 i__3 = i__ + k * b_dim1;
00269 tmp = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[i__ + k *
00270 b_dim1]), dabs(r__2));
00271 if (upper) {
00272 if (! notran) {
00273
00274 i__3 = i__ - *kd;
00275 i__4 = i__ - ifu;
00276 for (j = max(i__3,1); j <= i__4; ++j) {
00277 i__3 = *kd + 1 - i__ + j + i__ * ab_dim1;
00278 i__5 = j + k * x_dim1;
00279 tmp += ((r__1 = ab[i__3].r, dabs(r__1)) + (r__2 =
00280 r_imag(&ab[*kd + 1 - i__ + j + i__ * ab_dim1])
00281 , dabs(r__2))) * ((r__3 = x[i__5].r, dabs(
00282 r__3)) + (r__4 = r_imag(&x[j + k * x_dim1]),
00283 dabs(r__4)));
00284
00285 }
00286 if (unit) {
00287 i__4 = i__ + k * x_dim1;
00288 tmp += (r__1 = x[i__4].r, dabs(r__1)) + (r__2 =
00289 r_imag(&x[i__ + k * x_dim1]), dabs(r__2));
00290 }
00291 } else {
00292 if (unit) {
00293 i__4 = i__ + k * x_dim1;
00294 tmp += (r__1 = x[i__4].r, dabs(r__1)) + (r__2 =
00295 r_imag(&x[i__ + k * x_dim1]), dabs(r__2));
00296 }
00297
00298 i__3 = i__ + *kd;
00299 i__4 = min(i__3,*n);
00300 for (j = i__ + ifu; j <= i__4; ++j) {
00301 i__3 = *kd + 1 + i__ - j + j * ab_dim1;
00302 i__5 = j + k * x_dim1;
00303 tmp += ((r__1 = ab[i__3].r, dabs(r__1)) + (r__2 =
00304 r_imag(&ab[*kd + 1 + i__ - j + j * ab_dim1]),
00305 dabs(r__2))) * ((r__3 = x[i__5].r, dabs(r__3))
00306 + (r__4 = r_imag(&x[j + k * x_dim1]), dabs(
00307 r__4)));
00308
00309 }
00310 }
00311 } else {
00312 if (notran) {
00313
00314 i__4 = i__ - *kd;
00315 i__3 = i__ - ifu;
00316 for (j = max(i__4,1); j <= i__3; ++j) {
00317 i__4 = i__ + 1 - j + j * ab_dim1;
00318 i__5 = j + k * x_dim1;
00319 tmp += ((r__1 = ab[i__4].r, dabs(r__1)) + (r__2 =
00320 r_imag(&ab[i__ + 1 - j + j * ab_dim1]), dabs(
00321 r__2))) * ((r__3 = x[i__5].r, dabs(r__3)) + (
00322 r__4 = r_imag(&x[j + k * x_dim1]), dabs(r__4))
00323 );
00324
00325 }
00326 if (unit) {
00327 i__3 = i__ + k * x_dim1;
00328 tmp += (r__1 = x[i__3].r, dabs(r__1)) + (r__2 =
00329 r_imag(&x[i__ + k * x_dim1]), dabs(r__2));
00330 }
00331 } else {
00332 if (unit) {
00333 i__3 = i__ + k * x_dim1;
00334 tmp += (r__1 = x[i__3].r, dabs(r__1)) + (r__2 =
00335 r_imag(&x[i__ + k * x_dim1]), dabs(r__2));
00336 }
00337
00338 i__4 = i__ + *kd;
00339 i__3 = min(i__4,*n);
00340 for (j = i__ + ifu; j <= i__3; ++j) {
00341 i__4 = j + 1 - i__ + i__ * ab_dim1;
00342 i__5 = j + k * x_dim1;
00343 tmp += ((r__1 = ab[i__4].r, dabs(r__1)) + (r__2 =
00344 r_imag(&ab[j + 1 - i__ + i__ * ab_dim1]),
00345 dabs(r__2))) * ((r__3 = x[i__5].r, dabs(r__3))
00346 + (r__4 = r_imag(&x[j + k * x_dim1]), dabs(
00347 r__4)));
00348
00349 }
00350 }
00351 }
00352 if (i__ == 1) {
00353 axbi = tmp;
00354 } else {
00355 axbi = dmin(axbi,tmp);
00356 }
00357
00358 }
00359
00360 r__1 = axbi, r__2 = nz * unfl;
00361 tmp = berr[k] / (nz * eps + nz * unfl / dmax(r__1,r__2));
00362 if (k == 1) {
00363 reslts[2] = tmp;
00364 } else {
00365 reslts[2] = dmax(reslts[2],tmp);
00366 }
00367
00368 }
00369
00370 return 0;
00371
00372
00373
00374 }