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