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