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 cgbt05_(char *trans, integer *n, integer *kl, integer *
00021 ku, integer *nrhs, complex *ab, integer *ldab, complex *b, integer *
00022 ldb, complex *x, integer *ldx, complex *xact, integer *ldxact, real *
00023 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;
00036 real eps, tmp, diff, axbi;
00037 integer imax;
00038 real unfl, ovfl;
00039 extern logical lsame_(char *, char *);
00040 real xnorm;
00041 extern integer icamax_(integer *, complex *, integer *);
00042 extern doublereal slamch_(char *);
00043 real errbnd;
00044 logical notran;
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 ab_dim1 = *ldab;
00163 ab_offset = 1 + ab_dim1;
00164 ab -= ab_offset;
00165 b_dim1 = *ldb;
00166 b_offset = 1 + b_dim1;
00167 b -= b_offset;
00168 x_dim1 = *ldx;
00169 x_offset = 1 + x_dim1;
00170 x -= x_offset;
00171 xact_dim1 = *ldxact;
00172 xact_offset = 1 + xact_dim1;
00173 xact -= xact_offset;
00174 --ferr;
00175 --berr;
00176 --reslts;
00177
00178
00179 if (*n <= 0 || *nrhs <= 0) {
00180 reslts[1] = 0.f;
00181 reslts[2] = 0.f;
00182 return 0;
00183 }
00184
00185 eps = slamch_("Epsilon");
00186 unfl = slamch_("Safe minimum");
00187 ovfl = 1.f / unfl;
00188 notran = lsame_(trans, "N");
00189
00190 i__1 = *kl + *ku + 2, i__2 = *n + 1;
00191 nz = min(i__1,i__2);
00192
00193
00194
00195
00196
00197 errbnd = 0.f;
00198 i__1 = *nrhs;
00199 for (j = 1; j <= i__1; ++j) {
00200 imax = icamax_(n, &x[j * x_dim1 + 1], &c__1);
00201
00202 i__2 = imax + j * x_dim1;
00203 r__3 = (r__1 = x[i__2].r, dabs(r__1)) + (r__2 = r_imag(&x[imax + j *
00204 x_dim1]), dabs(r__2));
00205 xnorm = dmax(r__3,unfl);
00206 diff = 0.f;
00207 i__2 = *n;
00208 for (i__ = 1; i__ <= i__2; ++i__) {
00209 i__3 = i__ + j * x_dim1;
00210 i__4 = i__ + j * xact_dim1;
00211 q__2.r = x[i__3].r - xact[i__4].r, q__2.i = x[i__3].i - xact[i__4]
00212 .i;
00213 q__1.r = q__2.r, q__1.i = q__2.i;
00214
00215 r__3 = diff, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00216 q__1), dabs(r__2));
00217 diff = dmax(r__3,r__4);
00218
00219 }
00220
00221 if (xnorm > 1.f) {
00222 goto L20;
00223 } else if (diff <= ovfl * xnorm) {
00224 goto L20;
00225 } else {
00226 errbnd = 1.f / eps;
00227 goto L30;
00228 }
00229
00230 L20:
00231 if (diff / xnorm <= ferr[j]) {
00232
00233 r__1 = errbnd, r__2 = diff / xnorm / ferr[j];
00234 errbnd = dmax(r__1,r__2);
00235 } else {
00236 errbnd = 1.f / eps;
00237 }
00238 L30:
00239 ;
00240 }
00241 reslts[1] = errbnd;
00242
00243
00244
00245
00246 i__1 = *nrhs;
00247 for (k = 1; k <= i__1; ++k) {
00248 i__2 = *n;
00249 for (i__ = 1; i__ <= i__2; ++i__) {
00250 i__3 = i__ + k * b_dim1;
00251 tmp = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[i__ + k *
00252 b_dim1]), dabs(r__2));
00253 if (notran) {
00254
00255 i__3 = i__ - *kl;
00256
00257 i__5 = i__ + *ku;
00258 i__4 = min(i__5,*n);
00259 for (j = max(i__3,1); j <= i__4; ++j) {
00260 i__3 = *ku + 1 + i__ - j + j * ab_dim1;
00261 i__5 = j + k * x_dim1;
00262 tmp += ((r__1 = ab[i__3].r, dabs(r__1)) + (r__2 = r_imag(&
00263 ab[*ku + 1 + i__ - j + j * ab_dim1]), dabs(r__2)))
00264 * ((r__3 = x[i__5].r, dabs(r__3)) + (r__4 =
00265 r_imag(&x[j + k * x_dim1]), dabs(r__4)));
00266
00267 }
00268 } else {
00269
00270 i__4 = i__ - *ku;
00271
00272 i__5 = i__ + *kl;
00273 i__3 = min(i__5,*n);
00274 for (j = max(i__4,1); j <= i__3; ++j) {
00275 i__4 = *ku + 1 + j - i__ + i__ * ab_dim1;
00276 i__5 = j + k * x_dim1;
00277 tmp += ((r__1 = ab[i__4].r, dabs(r__1)) + (r__2 = r_imag(&
00278 ab[*ku + 1 + j - i__ + i__ * ab_dim1]), dabs(r__2)
00279 )) * ((r__3 = x[i__5].r, dabs(r__3)) + (r__4 =
00280 r_imag(&x[j + k * x_dim1]), dabs(r__4)));
00281
00282 }
00283 }
00284 if (i__ == 1) {
00285 axbi = tmp;
00286 } else {
00287 axbi = dmin(axbi,tmp);
00288 }
00289
00290 }
00291
00292 r__1 = axbi, r__2 = nz * unfl;
00293 tmp = berr[k] / (nz * eps + nz * unfl / dmax(r__1,r__2));
00294 if (k == 1) {
00295 reslts[2] = tmp;
00296 } else {
00297 reslts[2] = dmax(reslts[2],tmp);
00298 }
00299
00300 }
00301
00302 return 0;
00303
00304
00305
00306 }