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__10 = 10;
00019 static integer c__2 = 2;
00020 static integer c__3 = 3;
00021 static integer c__1 = 1;
00022 static integer c__4 = 4;
00023 static integer c__5 = 5;
00024 static integer c__6 = 6;
00025 static integer c__7 = 7;
00026 static integer c__8 = 8;
00027
00028 int debchvxx_(doublereal *thresh, char *path)
00029 {
00030
00031 static char fmt_8000[] = "(\002 D\002,a2,\002SVXX: N =\002,i2,\002, INFO"
00032 " = \002,i3,\002, ORCOND = \002,g12.5,\002, real RCOND = \002,g12"
00033 ".5)";
00034 static char fmt_9996[] = "(3x,i2,\002: Normwise guaranteed forward erro"
00035 "r\002,/5x,\002Guaranteed case: if norm ( abs( Xc - Xt )\002,\002"
00036 " / norm ( Xt ) .LE. ERRBND( *, nwise_i, bnd_i ), then\002,/5x"
00037 ",\002ERRBND( *, nwise_i, bnd_i ) .LE. MAX(SQRT(N), 10) * EPS\002)"
00038 ;
00039 static char fmt_9995[] = "(3x,i2,\002: Componentwise guaranteed forward "
00040 "error\002)";
00041 static char fmt_9994[] = "(3x,i2,\002: Backwards error\002)";
00042 static char fmt_9993[] = "(3x,i2,\002: Reciprocal condition number\002)";
00043 static char fmt_9992[] = "(3x,i2,\002: Reciprocal normwise condition num"
00044 "ber\002)";
00045 static char fmt_9991[] = "(3x,i2,\002: Raw normwise error estimate\002)";
00046 static char fmt_9990[] = "(3x,i2,\002: Reciprocal componentwise conditio"
00047 "n number\002)";
00048 static char fmt_9989[] = "(3x,i2,\002: Raw componentwise error estimat"
00049 "e\002)";
00050 static char fmt_9999[] = "(\002 D\002,a2,\002SVXX: N =\002,i2,\002, RHS "
00051 "= \002,i2,\002, NWISE GUAR. = \002,a,\002, CWISE GUAR. = \002,a"
00052 ",\002 test(\002,i1,\002) =\002,g12.5)";
00053 static char fmt_9998[] = "(\002 D\002,a2,\002SVXX: \002,i6,\002 out of"
00054 " \002,i6,\002 tests failed to pass the threshold\002)";
00055 static char fmt_9997[] = "(\002 D\002,a2,\002SVXX passed the tests of er"
00056 "ror bounds\002)";
00057
00058
00059 integer i__1, i__2, i__3, i__4, i__5, i__6;
00060 doublereal d__1, d__2, d__3;
00061
00062
00063 int s_copy(char *, char *, ftnlen, ftnlen);
00064 double sqrt(doublereal);
00065 integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void),
00066 s_wsle(cilist *), e_wsle(void);
00067
00068
00069 extern int dsysvxx_(char *, char *, integer *, integer *,
00070 doublereal *, integer *, doublereal *, integer *, integer *,
00071 char *, doublereal *, doublereal *, integer *, doublereal *,
00072 integer *, doublereal *, doublereal *, doublereal *, integer *,
00073 doublereal *, doublereal *, integer *, doublereal *, doublereal *,
00074 integer *, integer *);
00075 doublereal errbnd_c__[30], errbnd_n__[30], a[100] , b[
00076 100] , c__[10];
00077 integer i__, j, k;
00078 doublereal m;
00079 integer n;
00080 doublereal r__[10], s[10], x[100] , cwise_bnd__;
00081 char c2[2];
00082 doublereal nwise_bnd__, cwise_err__, nwise_err__, errthresh, ab[190]
00083 , af[100] ;
00084 integer kl, ku;
00085 doublereal condthresh, afb[280] ;
00086 integer lda;
00087 doublereal eps, cwise_rcond__, nwise_rcond__;
00088 integer n_aux_tests__, ldab;
00089 doublereal diff[100] ;
00090 char fact[1];
00091 doublereal berr[10];
00092 integer info, ipiv[10], nrhs;
00093 doublereal rinv[10];
00094 char uplo[1];
00095 doublereal work[150], sumr;
00096 integer ldafb;
00097 doublereal ccond;
00098 integer nfail;
00099 char cguar[3];
00100 doublereal ncond;
00101 char equed[1];
00102 doublereal rcond, acopy[100] ;
00103 char nguar[3], trans[1];
00104 integer iwork[30];
00105 doublereal rnorm, normt, sumri;
00106 logical printed_guide__;
00107 extern doublereal dlamch_(char *);
00108 extern int dlacpy_(char *, integer *, integer *,
00109 doublereal *, integer *, doublereal *, integer *);
00110 doublereal abcopy[190] ;
00111 extern logical lsamen_(integer *, char *, char *);
00112 doublereal params[2], orcond, rinorm, tstrat[6], rpvgrw;
00113 extern int dlahilb_(integer *, integer *, doublereal *,
00114 integer *, doublereal *, integer *, doublereal *, integer *,
00115 doublereal *, integer *);
00116 doublereal invhilb[100] , normdif;
00117 extern int dgbsvxx_(char *, char *, integer *, integer *,
00118 integer *, integer *, doublereal *, integer *, doublereal *,
00119 integer *, integer *, char *, doublereal *, doublereal *,
00120 doublereal *, integer *, doublereal *, integer *, doublereal *,
00121 doublereal *, doublereal *, integer *, doublereal *, doublereal *,
00122 integer *, doublereal *, doublereal *, integer *, integer *), dgesvxx_(char *, char *, integer *,
00123 integer *, doublereal *, integer *, doublereal *, integer *,
00124 integer *, char *, doublereal *, doublereal *, doublereal *,
00125 integer *, doublereal *, integer *, doublereal *, doublereal *,
00126 doublereal *, integer *, doublereal *, doublereal *, integer *,
00127 doublereal *, doublereal *, integer *, integer *), dposvxx_(char *, char *, integer *, integer *,
00128 doublereal *, integer *, doublereal *, integer *, char *,
00129 doublereal *, doublereal *, integer *, doublereal *, integer *,
00130 doublereal *, doublereal *, doublereal *, integer *, doublereal *,
00131 doublereal *, integer *, doublereal *, doublereal *, integer *,
00132 integer *);
00133
00134
00135 static cilist io___42 = { 0, 6, 0, fmt_8000, 0 };
00136 static cilist io___66 = { 0, 6, 0, 0, 0 };
00137 static cilist io___67 = { 0, 6, 0, fmt_9996, 0 };
00138 static cilist io___68 = { 0, 6, 0, fmt_9995, 0 };
00139 static cilist io___69 = { 0, 6, 0, fmt_9994, 0 };
00140 static cilist io___70 = { 0, 6, 0, fmt_9993, 0 };
00141 static cilist io___71 = { 0, 6, 0, fmt_9992, 0 };
00142 static cilist io___72 = { 0, 6, 0, fmt_9991, 0 };
00143 static cilist io___73 = { 0, 6, 0, fmt_9990, 0 };
00144 static cilist io___74 = { 0, 6, 0, fmt_9989, 0 };
00145 static cilist io___75 = { 0, 6, 0, 0, 0 };
00146 static cilist io___76 = { 0, 6, 0, fmt_9999, 0 };
00147 static cilist io___77 = { 0, 6, 0, 0, 0 };
00148 static cilist io___78 = { 0, 6, 0, fmt_9998, 0 };
00149 static cilist io___79 = { 0, 6, 0, fmt_9997, 0 };
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221 *(unsigned char *)fact = 'E';
00222 *(unsigned char *)uplo = 'U';
00223 *(unsigned char *)trans = 'N';
00224 *(unsigned char *)equed = 'N';
00225 eps = dlamch_("Epsilon");
00226 nfail = 0;
00227 n_aux_tests__ = 0;
00228 lda = 10;
00229 ldab = 19;
00230 ldafb = 28;
00231 s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2);
00232
00233 printed_guide__ = FALSE_;
00234 for (n = 1; n <= 10; ++n) {
00235 params[0] = -1.;
00236 params[1] = -1.;
00237 kl = n - 1;
00238 ku = n - 1;
00239 nrhs = n;
00240
00241 d__1 = sqrt((doublereal) n);
00242 m = max(d__1,10.);
00243
00244
00245 dlahilb_(&n, &n, a, &lda, invhilb, &lda, b, &lda, work, &info);
00246
00247 dlacpy_("ALL", &n, &n, a, &c__10, acopy, &c__10);
00248
00249 i__1 = n;
00250 for (j = 1; j <= i__1; ++j) {
00251 i__2 = kl + ku + 1;
00252 for (i__ = 1; i__ <= i__2; ++i__) {
00253 ab[i__ + j * 19 - 20] = 0.;
00254 }
00255 }
00256 i__1 = n;
00257 for (j = 1; j <= i__1; ++j) {
00258
00259 i__2 = 1, i__3 = j - ku;
00260
00261 i__5 = n, i__6 = j + kl;
00262 i__4 = min(i__5,i__6);
00263 for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00264 ab[ku + 1 + i__ - j + j * 19 - 20] = a[i__ + j * 10 - 11];
00265 }
00266 }
00267
00268 i__1 = n;
00269 for (j = 1; j <= i__1; ++j) {
00270 i__4 = kl + ku + 1;
00271 for (i__ = 1; i__ <= i__4; ++i__) {
00272 abcopy[i__ + j * 19 - 20] = 0.;
00273 }
00274 }
00275 i__1 = kl + ku + 1;
00276 dlacpy_("ALL", &i__1, &n, ab, &ldab, abcopy, &ldab);
00277
00278 if (lsamen_(&c__2, c2, "SY")) {
00279 dsysvxx_(fact, uplo, &n, &nrhs, acopy, &lda, af, &lda, ipiv,
00280 equed, s, b, &lda, x, &lda, &orcond, &rpvgrw, berr, &c__3,
00281 errbnd_n__, errbnd_c__, &c__2, params, work, iwork, &
00282 info);
00283 } else if (lsamen_(&c__2, c2, "PO")) {
00284 dposvxx_(fact, uplo, &n, &nrhs, acopy, &lda, af, &lda, equed, s,
00285 b, &lda, x, &lda, &orcond, &rpvgrw, berr, &c__3,
00286 errbnd_n__, errbnd_c__, &c__2, params, work, iwork, &info);
00287 } else if (lsamen_(&c__2, c2, "GB")) {
00288 dgbsvxx_(fact, trans, &n, &kl, &ku, &nrhs, abcopy, &ldab, afb, &
00289 ldafb, ipiv, equed, r__, c__, b, &lda, x, &lda, &orcond, &
00290 rpvgrw, berr, &c__3, errbnd_n__, errbnd_c__, &c__2,
00291 params, work, iwork, &info);
00292 } else {
00293 dgesvxx_(fact, trans, &n, &nrhs, acopy, &lda, af, &lda, ipiv,
00294 equed, r__, c__, b, &lda, x, &lda, &orcond, &rpvgrw, berr,
00295 &c__3, errbnd_n__, errbnd_c__, &c__2, params, work,
00296 iwork, &info);
00297 }
00298 ++n_aux_tests__;
00299 if (orcond < eps) {
00300
00301
00302
00303
00304
00305
00306 } else {
00307
00308
00309 if (info > 0 && info <= n + 1) {
00310 ++nfail;
00311 s_wsfe(&io___42);
00312 do_fio(&c__1, c2, (ftnlen)2);
00313 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00314 do_fio(&c__1, (char *)&info, (ftnlen)sizeof(integer));
00315 do_fio(&c__1, (char *)&orcond, (ftnlen)sizeof(doublereal));
00316 do_fio(&c__1, (char *)&rcond, (ftnlen)sizeof(doublereal));
00317 e_wsfe();
00318 }
00319 }
00320
00321 i__1 = n;
00322 for (i__ = 1; i__ <= i__1; ++i__) {
00323 i__4 = nrhs;
00324 for (j = 1; j <= i__4; ++j) {
00325 diff[i__ + j * 10 - 11] = x[i__ + j * 10 - 11] - invhilb[i__
00326 + j * 10 - 11];
00327 }
00328 }
00329
00330 rnorm = 0.;
00331 rinorm = 0.;
00332 if (lsamen_(&c__2, c2, "PO") || lsamen_(&c__2,
00333 c2, "SY")) {
00334 i__1 = n;
00335 for (i__ = 1; i__ <= i__1; ++i__) {
00336 sumr = 0.;
00337 sumri = 0.;
00338 i__4 = n;
00339 for (j = 1; j <= i__4; ++j) {
00340 sumr += s[i__ - 1] * (d__1 = a[i__ + j * 10 - 11], abs(
00341 d__1)) * s[j - 1];
00342 sumri += (d__1 = invhilb[i__ + j * 10 - 11], abs(d__1)) /
00343 (s[j - 1] * s[i__ - 1]);
00344 }
00345 rnorm = max(rnorm,sumr);
00346 rinorm = max(rinorm,sumri);
00347 }
00348 } else if (lsamen_(&c__2, c2, "GE") || lsamen_(&
00349 c__2, c2, "GB")) {
00350 i__1 = n;
00351 for (i__ = 1; i__ <= i__1; ++i__) {
00352 sumr = 0.;
00353 sumri = 0.;
00354 i__4 = n;
00355 for (j = 1; j <= i__4; ++j) {
00356 sumr += r__[i__ - 1] * (d__1 = a[i__ + j * 10 - 11], abs(
00357 d__1)) * c__[j - 1];
00358 sumri += (d__1 = invhilb[i__ + j * 10 - 11], abs(d__1)) /
00359 (r__[j - 1] * c__[i__ - 1]);
00360 }
00361 rnorm = max(rnorm,sumr);
00362 rinorm = max(rinorm,sumri);
00363 }
00364 }
00365 rnorm /= abs(a[0]);
00366 rcond = 1. / (rnorm * rinorm);
00367
00368 i__1 = n;
00369 for (i__ = 1; i__ <= i__1; ++i__) {
00370 rinv[i__ - 1] = 0.;
00371 }
00372 i__1 = n;
00373 for (j = 1; j <= i__1; ++j) {
00374 i__4 = n;
00375 for (i__ = 1; i__ <= i__4; ++i__) {
00376 rinv[i__ - 1] += (d__1 = a[i__ + j * 10 - 11], abs(d__1));
00377 }
00378 }
00379
00380 rinorm = 0.;
00381 i__1 = n;
00382 for (i__ = 1; i__ <= i__1; ++i__) {
00383 sumri = 0.;
00384 i__4 = n;
00385 for (j = 1; j <= i__4; ++j) {
00386 sumri += (d__1 = invhilb[i__ + j * 10 - 11] * rinv[j - 1],
00387 abs(d__1));
00388 }
00389 rinorm = max(rinorm,sumri);
00390 }
00391
00392
00393 ncond = abs(a[0]) / rinorm;
00394 condthresh = m * eps;
00395 errthresh = m * eps;
00396 i__1 = nrhs;
00397 for (k = 1; k <= i__1; ++k) {
00398 normt = 0.;
00399 normdif = 0.;
00400 cwise_err__ = 0.;
00401 i__4 = n;
00402 for (i__ = 1; i__ <= i__4; ++i__) {
00403
00404 d__2 = (d__1 = invhilb[i__ + k * 10 - 11], abs(d__1));
00405 normt = max(d__2,normt);
00406
00407 d__2 = (d__1 = x[i__ + k * 10 - 11] - invhilb[i__ + k * 10 -
00408 11], abs(d__1));
00409 normdif = max(d__2,normdif);
00410 if (invhilb[i__ + k * 10 - 11] != 0.) {
00411
00412 d__3 = (d__1 = x[i__ + k * 10 - 11] - invhilb[i__ + k *
00413 10 - 11], abs(d__1)) / (d__2 = invhilb[i__ + k *
00414 10 - 11], abs(d__2));
00415 cwise_err__ = max(d__3,cwise_err__);
00416 } else if (x[i__ + k * 10 - 11] != 0.) {
00417 cwise_err__ = dlamch_("OVERFLOW");
00418 }
00419 }
00420 if (normt != 0.) {
00421 nwise_err__ = normdif / normt;
00422 } else if (normdif != 0.) {
00423 nwise_err__ = dlamch_("OVERFLOW");
00424 } else {
00425 nwise_err__ = 0.;
00426 }
00427 i__4 = n;
00428 for (i__ = 1; i__ <= i__4; ++i__) {
00429 rinv[i__ - 1] = 0.;
00430 }
00431 i__4 = n;
00432 for (j = 1; j <= i__4; ++j) {
00433 i__2 = n;
00434 for (i__ = 1; i__ <= i__2; ++i__) {
00435 rinv[i__ - 1] += (d__1 = a[i__ + j * 10 - 11] * invhilb[j
00436 + k * 10 - 11], abs(d__1));
00437 }
00438 }
00439 rinorm = 0.;
00440 i__4 = n;
00441 for (i__ = 1; i__ <= i__4; ++i__) {
00442 sumri = 0.;
00443 i__2 = n;
00444 for (j = 1; j <= i__2; ++j) {
00445 sumri += (d__1 = invhilb[i__ + j * 10 - 11] * rinv[j - 1]
00446 / invhilb[i__ + k * 10 - 11], abs(d__1));
00447 }
00448 rinorm = max(rinorm,sumri);
00449 }
00450
00451
00452 ccond = abs(a[0]) / rinorm;
00453
00454 nwise_bnd__ = errbnd_n__[k + nrhs - 1];
00455 cwise_bnd__ = errbnd_c__[k + nrhs - 1];
00456 nwise_rcond__ = errbnd_n__[k + (nrhs << 1) - 1];
00457 cwise_rcond__ = errbnd_c__[k + (nrhs << 1) - 1];
00458
00459
00460
00461 if (ncond >= condthresh) {
00462 s_copy(nguar, "YES", (ftnlen)3, (ftnlen)3);
00463 if (nwise_bnd__ > errthresh) {
00464 tstrat[0] = 1 / (eps * 2.);
00465 } else {
00466 if (nwise_bnd__ != 0.) {
00467 tstrat[0] = nwise_err__ / nwise_bnd__;
00468 } else if (nwise_err__ != 0.) {
00469 tstrat[0] = 1 / (eps * 16.f);
00470 } else {
00471 tstrat[0] = 0.;
00472 }
00473 if (tstrat[0] > 1.) {
00474 tstrat[0] = 1 / (eps * 4.);
00475 }
00476 }
00477 } else {
00478 s_copy(nguar, "NO", (ftnlen)3, (ftnlen)2);
00479 if (nwise_bnd__ < 1.) {
00480 tstrat[0] = 1 / (eps * 8.);
00481 } else {
00482 tstrat[0] = 1.;
00483 }
00484 }
00485
00486
00487
00488 if (ccond >= condthresh) {
00489 s_copy(cguar, "YES", (ftnlen)3, (ftnlen)3);
00490 if (cwise_bnd__ > errthresh) {
00491 tstrat[1] = 1 / (eps * 2.);
00492 } else {
00493 if (cwise_bnd__ != 0.) {
00494 tstrat[1] = cwise_err__ / cwise_bnd__;
00495 } else if (cwise_err__ != 0.) {
00496 tstrat[1] = 1 / (eps * 16.);
00497 } else {
00498 tstrat[1] = 0.;
00499 }
00500 if (tstrat[1] > 1.) {
00501 tstrat[1] = 1 / (eps * 4.);
00502 }
00503 }
00504 } else {
00505 s_copy(cguar, "NO", (ftnlen)3, (ftnlen)2);
00506 if (cwise_bnd__ < 1.) {
00507 tstrat[1] = 1 / (eps * 8.);
00508 } else {
00509 tstrat[1] = 1.;
00510 }
00511 }
00512
00513 tstrat[2] = berr[k - 1] / eps;
00514
00515 tstrat[3] = rcond / orcond;
00516 if (rcond >= condthresh && tstrat[3] < 1.) {
00517 tstrat[3] = 1. / tstrat[3];
00518 }
00519 tstrat[4] = ncond / nwise_rcond__;
00520 if (ncond >= condthresh && tstrat[4] < 1.) {
00521 tstrat[4] = 1. / tstrat[4];
00522 }
00523 tstrat[5] = ccond / nwise_rcond__;
00524 if (ccond >= condthresh && tstrat[5] < 1.) {
00525 tstrat[5] = 1. / tstrat[5];
00526 }
00527 for (i__ = 1; i__ <= 6; ++i__) {
00528 if (tstrat[i__ - 1] > *thresh) {
00529 if (! printed_guide__) {
00530 s_wsle(&io___66);
00531 e_wsle();
00532 s_wsfe(&io___67);
00533 do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
00534 e_wsfe();
00535 s_wsfe(&io___68);
00536 do_fio(&c__1, (char *)&c__2, (ftnlen)sizeof(integer));
00537 e_wsfe();
00538 s_wsfe(&io___69);
00539 do_fio(&c__1, (char *)&c__3, (ftnlen)sizeof(integer));
00540 e_wsfe();
00541 s_wsfe(&io___70);
00542 do_fio(&c__1, (char *)&c__4, (ftnlen)sizeof(integer));
00543 e_wsfe();
00544 s_wsfe(&io___71);
00545 do_fio(&c__1, (char *)&c__5, (ftnlen)sizeof(integer));
00546 e_wsfe();
00547 s_wsfe(&io___72);
00548 do_fio(&c__1, (char *)&c__6, (ftnlen)sizeof(integer));
00549 e_wsfe();
00550 s_wsfe(&io___73);
00551 do_fio(&c__1, (char *)&c__7, (ftnlen)sizeof(integer));
00552 e_wsfe();
00553 s_wsfe(&io___74);
00554 do_fio(&c__1, (char *)&c__8, (ftnlen)sizeof(integer));
00555 e_wsfe();
00556 s_wsle(&io___75);
00557 e_wsle();
00558 printed_guide__ = TRUE_;
00559 }
00560 s_wsfe(&io___76);
00561 do_fio(&c__1, c2, (ftnlen)2);
00562 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00563 do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
00564 do_fio(&c__1, nguar, (ftnlen)3);
00565 do_fio(&c__1, cguar, (ftnlen)3);
00566 do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
00567 do_fio(&c__1, (char *)&tstrat[i__ - 1], (ftnlen)sizeof(
00568 doublereal));
00569 e_wsfe();
00570 ++nfail;
00571 }
00572 }
00573 }
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 }
00588 s_wsle(&io___77);
00589 e_wsle();
00590 if (nfail > 0) {
00591 s_wsfe(&io___78);
00592 do_fio(&c__1, c2, (ftnlen)2);
00593 do_fio(&c__1, (char *)&nfail, (ftnlen)sizeof(integer));
00594 i__1 = n * 6 + n_aux_tests__;
00595 do_fio(&c__1, (char *)&i__1, (ftnlen)sizeof(integer));
00596 e_wsfe();
00597 } else {
00598 s_wsfe(&io___79);
00599 do_fio(&c__1, c2, (ftnlen)2);
00600 e_wsfe();
00601 }
00602
00603 return 0;
00604 }