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 zppt05_(char *uplo, integer *n, integer *nrhs,
00021 doublecomplex *ap, doublecomplex *b, integer *ldb, doublecomplex *x,
00022 integer *ldx, doublecomplex *xact, integer *ldxact, doublereal *ferr,
00023 doublereal *berr, doublereal *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 doublereal d__1, d__2, d__3, d__4;
00029 doublecomplex z__1, z__2;
00030
00031
00032 double d_imag(doublecomplex *);
00033
00034
00035 integer i__, j, k, jc;
00036 doublereal eps, tmp, diff, axbi;
00037 integer imax;
00038 doublereal unfl, ovfl;
00039 extern logical lsame_(char *, char *);
00040 logical upper;
00041 doublereal xnorm;
00042 extern doublereal dlamch_(char *);
00043 doublereal errbnd;
00044 extern integer izamax_(integer *, doublecomplex *, integer *);
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 --ap;
00153 b_dim1 = *ldb;
00154 b_offset = 1 + b_dim1;
00155 b -= b_offset;
00156 x_dim1 = *ldx;
00157 x_offset = 1 + x_dim1;
00158 x -= x_offset;
00159 xact_dim1 = *ldxact;
00160 xact_offset = 1 + xact_dim1;
00161 xact -= xact_offset;
00162 --ferr;
00163 --berr;
00164 --reslts;
00165
00166
00167 if (*n <= 0 || *nrhs <= 0) {
00168 reslts[1] = 0.;
00169 reslts[2] = 0.;
00170 return 0;
00171 }
00172
00173 eps = dlamch_("Epsilon");
00174 unfl = dlamch_("Safe minimum");
00175 ovfl = 1. / unfl;
00176 upper = lsame_(uplo, "U");
00177
00178
00179
00180
00181
00182 errbnd = 0.;
00183 i__1 = *nrhs;
00184 for (j = 1; j <= i__1; ++j) {
00185 imax = izamax_(n, &x[j * x_dim1 + 1], &c__1);
00186
00187 i__2 = imax + j * x_dim1;
00188 d__3 = (d__1 = x[i__2].r, abs(d__1)) + (d__2 = d_imag(&x[imax + j *
00189 x_dim1]), abs(d__2));
00190 xnorm = max(d__3,unfl);
00191 diff = 0.;
00192 i__2 = *n;
00193 for (i__ = 1; i__ <= i__2; ++i__) {
00194 i__3 = i__ + j * x_dim1;
00195 i__4 = i__ + j * xact_dim1;
00196 z__2.r = x[i__3].r - xact[i__4].r, z__2.i = x[i__3].i - xact[i__4]
00197 .i;
00198 z__1.r = z__2.r, z__1.i = z__2.i;
00199
00200 d__3 = diff, d__4 = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&
00201 z__1), abs(d__2));
00202 diff = max(d__3,d__4);
00203
00204 }
00205
00206 if (xnorm > 1.) {
00207 goto L20;
00208 } else if (diff <= ovfl * xnorm) {
00209 goto L20;
00210 } else {
00211 errbnd = 1. / eps;
00212 goto L30;
00213 }
00214
00215 L20:
00216 if (diff / xnorm <= ferr[j]) {
00217
00218 d__1 = errbnd, d__2 = diff / xnorm / ferr[j];
00219 errbnd = max(d__1,d__2);
00220 } else {
00221 errbnd = 1. / eps;
00222 }
00223 L30:
00224 ;
00225 }
00226 reslts[1] = errbnd;
00227
00228
00229
00230
00231 i__1 = *nrhs;
00232 for (k = 1; k <= i__1; ++k) {
00233 i__2 = *n;
00234 for (i__ = 1; i__ <= i__2; ++i__) {
00235 i__3 = i__ + k * b_dim1;
00236 tmp = (d__1 = b[i__3].r, abs(d__1)) + (d__2 = d_imag(&b[i__ + k *
00237 b_dim1]), abs(d__2));
00238 if (upper) {
00239 jc = (i__ - 1) * i__ / 2;
00240 i__3 = i__ - 1;
00241 for (j = 1; j <= i__3; ++j) {
00242 i__4 = jc + j;
00243 i__5 = j + k * x_dim1;
00244 tmp += ((d__1 = ap[i__4].r, abs(d__1)) + (d__2 = d_imag(&
00245 ap[jc + j]), abs(d__2))) * ((d__3 = x[i__5].r,
00246 abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]),
00247 abs(d__4)));
00248
00249 }
00250 i__3 = jc + i__;
00251 i__4 = i__ + k * x_dim1;
00252 tmp += (d__1 = ap[i__3].r, abs(d__1)) * ((d__2 = x[i__4].r,
00253 abs(d__2)) + (d__3 = d_imag(&x[i__ + k * x_dim1]),
00254 abs(d__3)));
00255 jc = jc + i__ + i__;
00256 i__3 = *n;
00257 for (j = i__ + 1; j <= i__3; ++j) {
00258 i__4 = jc;
00259 i__5 = j + k * x_dim1;
00260 tmp += ((d__1 = ap[i__4].r, abs(d__1)) + (d__2 = d_imag(&
00261 ap[jc]), abs(d__2))) * ((d__3 = x[i__5].r, abs(
00262 d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]), abs(
00263 d__4)));
00264 jc += j;
00265
00266 }
00267 } else {
00268 jc = i__;
00269 i__3 = i__ - 1;
00270 for (j = 1; j <= i__3; ++j) {
00271 i__4 = jc;
00272 i__5 = j + k * x_dim1;
00273 tmp += ((d__1 = ap[i__4].r, abs(d__1)) + (d__2 = d_imag(&
00274 ap[jc]), abs(d__2))) * ((d__3 = x[i__5].r, abs(
00275 d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]), abs(
00276 d__4)));
00277 jc = jc + *n - j;
00278
00279 }
00280 i__3 = jc;
00281 i__4 = i__ + k * x_dim1;
00282 tmp += (d__1 = ap[i__3].r, abs(d__1)) * ((d__2 = x[i__4].r,
00283 abs(d__2)) + (d__3 = d_imag(&x[i__ + k * x_dim1]),
00284 abs(d__3)));
00285 i__3 = *n;
00286 for (j = i__ + 1; j <= i__3; ++j) {
00287 i__4 = jc + j - i__;
00288 i__5 = j + k * x_dim1;
00289 tmp += ((d__1 = ap[i__4].r, abs(d__1)) + (d__2 = d_imag(&
00290 ap[jc + j - i__]), abs(d__2))) * ((d__3 = x[i__5]
00291 .r, abs(d__3)) + (d__4 = d_imag(&x[j + k * x_dim1]
00292 ), abs(d__4)));
00293
00294 }
00295 }
00296 if (i__ == 1) {
00297 axbi = tmp;
00298 } else {
00299 axbi = min(axbi,tmp);
00300 }
00301
00302 }
00303
00304 d__1 = axbi, d__2 = (*n + 1) * unfl;
00305 tmp = berr[k] / ((*n + 1) * eps + (*n + 1) * unfl / max(d__1,d__2));
00306 if (k == 1) {
00307 reslts[2] = tmp;
00308 } else {
00309 reslts[2] = max(reslts[2],tmp);
00310 }
00311
00312 }
00313
00314 return 0;
00315
00316
00317
00318 }