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 zgtt05_(char *trans, integer *n, integer *nrhs,
00021 doublecomplex *dl, doublecomplex *d__, doublecomplex *du,
00022 doublecomplex *b, integer *ldb, doublecomplex *x, integer *ldx,
00023 doublecomplex *xact, integer *ldxact, doublereal *ferr, doublereal *
00024 berr, doublereal *reslts)
00025 {
00026
00027 integer b_dim1, b_offset, x_dim1, x_offset, xact_dim1, xact_offset, i__1,
00028 i__2, i__3, i__4, i__5, i__6, i__7, i__8, i__9;
00029 doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10,
00030 d__11, d__12, d__13, d__14;
00031 doublecomplex z__1, z__2;
00032
00033
00034 double d_imag(doublecomplex *);
00035
00036
00037 integer i__, j, k, nz;
00038 doublereal eps, tmp, diff, axbi;
00039 integer imax;
00040 doublereal unfl, ovfl;
00041 extern logical lsame_(char *, char *);
00042 doublereal xnorm;
00043 extern doublereal dlamch_(char *);
00044 doublereal errbnd;
00045 extern integer izamax_(integer *, doublecomplex *, integer *);
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 --dl;
00157 --d__;
00158 --du;
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 notran = lsame_(trans, "N");
00183 nz = 4;
00184
00185
00186
00187
00188
00189 errbnd = 0.;
00190 i__1 = *nrhs;
00191 for (j = 1; j <= i__1; ++j) {
00192 imax = izamax_(n, &x[j * x_dim1 + 1], &c__1);
00193
00194 i__2 = imax + j * x_dim1;
00195 d__3 = (d__1 = x[i__2].r, abs(d__1)) + (d__2 = d_imag(&x[imax + j *
00196 x_dim1]), abs(d__2));
00197 xnorm = max(d__3,unfl);
00198 diff = 0.;
00199 i__2 = *n;
00200 for (i__ = 1; i__ <= i__2; ++i__) {
00201 i__3 = i__ + j * x_dim1;
00202 i__4 = i__ + j * xact_dim1;
00203 z__2.r = x[i__3].r - xact[i__4].r, z__2.i = x[i__3].i - xact[i__4]
00204 .i;
00205 z__1.r = z__2.r, z__1.i = z__2.i;
00206
00207 d__3 = diff, d__4 = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&
00208 z__1), abs(d__2));
00209 diff = max(d__3,d__4);
00210
00211 }
00212
00213 if (xnorm > 1.) {
00214 goto L20;
00215 } else if (diff <= ovfl * xnorm) {
00216 goto L20;
00217 } else {
00218 errbnd = 1. / eps;
00219 goto L30;
00220 }
00221
00222 L20:
00223 if (diff / xnorm <= ferr[j]) {
00224
00225 d__1 = errbnd, d__2 = diff / xnorm / ferr[j];
00226 errbnd = max(d__1,d__2);
00227 } else {
00228 errbnd = 1. / eps;
00229 }
00230 L30:
00231 ;
00232 }
00233 reslts[1] = errbnd;
00234
00235
00236
00237
00238 i__1 = *nrhs;
00239 for (k = 1; k <= i__1; ++k) {
00240 if (notran) {
00241 if (*n == 1) {
00242 i__2 = k * b_dim1 + 1;
00243 i__3 = k * x_dim1 + 1;
00244 axbi = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[k *
00245 b_dim1 + 1]), abs(d__2)) + ((d__3 = d__[1].r, abs(
00246 d__3)) + (d__4 = d_imag(&d__[1]), abs(d__4))) * ((
00247 d__5 = x[i__3].r, abs(d__5)) + (d__6 = d_imag(&x[k *
00248 x_dim1 + 1]), abs(d__6)));
00249 } else {
00250 i__2 = k * b_dim1 + 1;
00251 i__3 = k * x_dim1 + 1;
00252 i__4 = k * x_dim1 + 2;
00253 axbi = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[k *
00254 b_dim1 + 1]), abs(d__2)) + ((d__3 = d__[1].r, abs(
00255 d__3)) + (d__4 = d_imag(&d__[1]), abs(d__4))) * ((
00256 d__5 = x[i__3].r, abs(d__5)) + (d__6 = d_imag(&x[k *
00257 x_dim1 + 1]), abs(d__6))) + ((d__7 = du[1].r, abs(
00258 d__7)) + (d__8 = d_imag(&du[1]), abs(d__8))) * ((d__9
00259 = x[i__4].r, abs(d__9)) + (d__10 = d_imag(&x[k *
00260 x_dim1 + 2]), abs(d__10)));
00261 i__2 = *n - 1;
00262 for (i__ = 2; i__ <= i__2; ++i__) {
00263 i__3 = i__ + k * b_dim1;
00264 i__4 = i__ - 1;
00265 i__5 = i__ - 1 + k * x_dim1;
00266 i__6 = i__;
00267 i__7 = i__ + k * x_dim1;
00268 i__8 = i__;
00269 i__9 = i__ + 1 + k * x_dim1;
00270 tmp = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[
00271 i__ + k * b_dim1]), abs(d__2)) + ((d__3 = dl[i__4]
00272 .r, abs(d__3)) + (d__4 = d_imag(&dl[i__ - 1]),
00273 abs(d__4))) * ((d__5 = x[i__5].r, abs(d__5)) + (
00274 d__6 = d_imag(&x[i__ - 1 + k * x_dim1]), abs(d__6)
00275 )) + ((d__7 = d__[i__6].r, abs(d__7)) + (d__8 =
00276 d_imag(&d__[i__]), abs(d__8))) * ((d__9 = x[i__7]
00277 .r, abs(d__9)) + (d__10 = d_imag(&x[i__ + k *
00278 x_dim1]), abs(d__10))) + ((d__11 = du[i__8].r,
00279 abs(d__11)) + (d__12 = d_imag(&du[i__]), abs(
00280 d__12))) * ((d__13 = x[i__9].r, abs(d__13)) + (
00281 d__14 = d_imag(&x[i__ + 1 + k * x_dim1]), abs(
00282 d__14)));
00283 axbi = min(axbi,tmp);
00284
00285 }
00286 i__2 = *n + k * b_dim1;
00287 i__3 = *n - 1;
00288 i__4 = *n - 1 + k * x_dim1;
00289 i__5 = *n;
00290 i__6 = *n + k * x_dim1;
00291 tmp = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[*n +
00292 k * b_dim1]), abs(d__2)) + ((d__3 = dl[i__3].r, abs(
00293 d__3)) + (d__4 = d_imag(&dl[*n - 1]), abs(d__4))) * ((
00294 d__5 = x[i__4].r, abs(d__5)) + (d__6 = d_imag(&x[*n -
00295 1 + k * x_dim1]), abs(d__6))) + ((d__7 = d__[i__5].r,
00296 abs(d__7)) + (d__8 = d_imag(&d__[*n]), abs(d__8))) * (
00297 (d__9 = x[i__6].r, abs(d__9)) + (d__10 = d_imag(&x[*n
00298 + k * x_dim1]), abs(d__10)));
00299 axbi = min(axbi,tmp);
00300 }
00301 } else {
00302 if (*n == 1) {
00303 i__2 = k * b_dim1 + 1;
00304 i__3 = k * x_dim1 + 1;
00305 axbi = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[k *
00306 b_dim1 + 1]), abs(d__2)) + ((d__3 = d__[1].r, abs(
00307 d__3)) + (d__4 = d_imag(&d__[1]), abs(d__4))) * ((
00308 d__5 = x[i__3].r, abs(d__5)) + (d__6 = d_imag(&x[k *
00309 x_dim1 + 1]), abs(d__6)));
00310 } else {
00311 i__2 = k * b_dim1 + 1;
00312 i__3 = k * x_dim1 + 1;
00313 i__4 = k * x_dim1 + 2;
00314 axbi = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[k *
00315 b_dim1 + 1]), abs(d__2)) + ((d__3 = d__[1].r, abs(
00316 d__3)) + (d__4 = d_imag(&d__[1]), abs(d__4))) * ((
00317 d__5 = x[i__3].r, abs(d__5)) + (d__6 = d_imag(&x[k *
00318 x_dim1 + 1]), abs(d__6))) + ((d__7 = dl[1].r, abs(
00319 d__7)) + (d__8 = d_imag(&dl[1]), abs(d__8))) * ((d__9
00320 = x[i__4].r, abs(d__9)) + (d__10 = d_imag(&x[k *
00321 x_dim1 + 2]), abs(d__10)));
00322 i__2 = *n - 1;
00323 for (i__ = 2; i__ <= i__2; ++i__) {
00324 i__3 = i__ + k * b_dim1;
00325 i__4 = i__ - 1;
00326 i__5 = i__ - 1 + k * x_dim1;
00327 i__6 = i__;
00328 i__7 = i__ + k * x_dim1;
00329 i__8 = i__;
00330 i__9 = i__ + 1 + k * x_dim1;
00331 tmp = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[
00332 i__ + k * b_dim1]), abs(d__2)) + ((d__3 = du[i__4]
00333 .r, abs(d__3)) + (d__4 = d_imag(&du[i__ - 1]),
00334 abs(d__4))) * ((d__5 = x[i__5].r, abs(d__5)) + (
00335 d__6 = d_imag(&x[i__ - 1 + k * x_dim1]), abs(d__6)
00336 )) + ((d__7 = d__[i__6].r, abs(d__7)) + (d__8 =
00337 d_imag(&d__[i__]), abs(d__8))) * ((d__9 = x[i__7]
00338 .r, abs(d__9)) + (d__10 = d_imag(&x[i__ + k *
00339 x_dim1]), abs(d__10))) + ((d__11 = dl[i__8].r,
00340 abs(d__11)) + (d__12 = d_imag(&dl[i__]), abs(
00341 d__12))) * ((d__13 = x[i__9].r, abs(d__13)) + (
00342 d__14 = d_imag(&x[i__ + 1 + k * x_dim1]), abs(
00343 d__14)));
00344 axbi = min(axbi,tmp);
00345
00346 }
00347 i__2 = *n + k * b_dim1;
00348 i__3 = *n - 1;
00349 i__4 = *n - 1 + k * x_dim1;
00350 i__5 = *n;
00351 i__6 = *n + k * x_dim1;
00352 tmp = (d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[*n +
00353 k * b_dim1]), abs(d__2)) + ((d__3 = du[i__3].r, abs(
00354 d__3)) + (d__4 = d_imag(&du[*n - 1]), abs(d__4))) * ((
00355 d__5 = x[i__4].r, abs(d__5)) + (d__6 = d_imag(&x[*n -
00356 1 + k * x_dim1]), abs(d__6))) + ((d__7 = d__[i__5].r,
00357 abs(d__7)) + (d__8 = d_imag(&d__[*n]), abs(d__8))) * (
00358 (d__9 = x[i__6].r, abs(d__9)) + (d__10 = d_imag(&x[*n
00359 + k * x_dim1]), abs(d__10)));
00360 axbi = min(axbi,tmp);
00361 }
00362 }
00363
00364 d__1 = axbi, d__2 = nz * unfl;
00365 tmp = berr[k] / (nz * eps + nz * unfl / max(d__1,d__2));
00366 if (k == 1) {
00367 reslts[2] = tmp;
00368 } else {
00369 reslts[2] = max(reslts[2],tmp);
00370 }
00371
00372 }
00373
00374 return 0;
00375
00376
00377
00378 }