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