zebchvxx.c
Go to the documentation of this file.
00001 /* zebchvxx.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
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 /* Subroutine */ int zebchvxx_(doublereal *thresh, char *path)
00029 {
00030     /* Format strings */
00031     static char fmt_8000[] = "(\002 Z\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 Z\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 Z\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 Z\002,a2,\002SVXX passed the tests of er"
00056             "ror bounds\002)";
00057 
00058     /* System generated locals */
00059     integer i__1, i__2, i__3, i__4, i__5, i__6;
00060     doublereal d__1, d__2, d__3, d__4, d__5;
00061     doublecomplex z__1, z__2, z__3;
00062 
00063     /* Builtin functions */
00064     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00065     double sqrt(doublereal);
00066     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00067     double d_imag(doublecomplex *);
00068     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00069     integer s_wsle(cilist *), e_wsle(void);
00070 
00071     /* Local variables */
00072     extern /* Subroutine */ int zposvxx_(char *, char *, integer *, integer *, 
00073              doublecomplex *, integer *, doublecomplex *, integer *, char *, 
00074             doublereal *, doublecomplex *, integer *, doublecomplex *, 
00075             integer *, doublereal *, doublereal *, doublereal *, integer *, 
00076             doublereal *, doublereal *, integer *, doublereal *, 
00077             doublecomplex *, doublereal *, integer *);
00078     doublereal errbnd_c__[30];
00079     extern /* Subroutine */ int zsysvxx_(char *, char *, integer *, integer *, 
00080              doublecomplex *, integer *, doublecomplex *, integer *, integer *
00081 , char *, doublereal *, doublecomplex *, integer *, doublecomplex 
00082             *, integer *, doublereal *, doublereal *, doublereal *, integer *, 
00083              doublereal *, doublereal *, integer *, doublereal *, 
00084             doublecomplex *, doublereal *, integer *);
00085     doublereal errbnd_n__[30];
00086     doublecomplex a[100]        /* was [10][10] */, b[100]      /* was [10][
00087             10] */;
00088     doublereal c__[10];
00089     integer i__, j, k;
00090     doublereal m;
00091     integer n;
00092     doublereal r__[10], s[10];
00093     doublecomplex x[100]        /* was [10][10] */;
00094     doublereal cwise_bnd__;
00095     char c2[2];
00096     doublereal nwise_bnd__, cwise_err__, nwise_err__, errthresh;
00097     doublecomplex ab[190]       /* was [19][10] */, af[100]     /* was [10][
00098             10] */;
00099     integer kl, ku;
00100     doublereal condthresh;
00101     doublecomplex afb[280]      /* was [28][10] */;
00102     integer lda;
00103     doublereal eps, cwise_rcond__, nwise_rcond__;
00104     integer n_aux_tests__, ldab;
00105     doublereal diff[100]        /* was [10][10] */;
00106     char fact[1];
00107     doublereal berr[10];
00108     integer info, ipiv[10], nrhs;
00109     doublereal rinv[10];
00110     char uplo[1];
00111     doublecomplex work[150];
00112     doublereal sumr;
00113     integer ldafb;
00114     doublereal ccond;
00115     integer nfail;
00116     char cguar[3];
00117     doublereal ncond;
00118     char equed[1];
00119     doublereal rcond;
00120     doublecomplex acopy[100]    /* was [10][10] */;
00121     char nguar[3], trans[1];
00122     doublereal rnorm, normt, sumri, rwork[30];
00123     logical printed_guide__;
00124     extern doublereal dlamch_(char *);
00125     doublecomplex abcopy[190]   /* was [19][10] */;
00126     extern logical lsamen_(integer *, char *, char *);
00127     doublereal params[2], orcond;
00128     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00129             doublecomplex *, integer *, doublecomplex *, integer *);
00130     doublereal rinorm, tstrat[6], rpvgrw;
00131     extern /* Subroutine */ int zlahilb_(integer *, integer *, doublecomplex *
00132 , integer *, doublecomplex *, integer *, doublecomplex *, integer 
00133             *, doublecomplex *, integer *, char *);
00134     doublecomplex invhilb[100]  /* was [10][10] */;
00135     doublereal normdif;
00136     extern /* Subroutine */ int zgbsvxx_(char *, char *, integer *, integer *, 
00137              integer *, integer *, doublecomplex *, integer *, doublecomplex *
00138 , integer *, integer *, char *, doublereal *, doublereal *, 
00139             doublecomplex *, integer *, doublecomplex *, integer *, 
00140             doublereal *, doublereal *, doublereal *, integer *, doublereal *, 
00141              doublereal *, integer *, doublereal *, doublecomplex *, 
00142             doublereal *, integer *), zgesvxx_(char *, 
00143              char *, integer *, integer *, doublecomplex *, integer *, 
00144             doublecomplex *, integer *, integer *, char *, doublereal *, 
00145             doublereal *, doublecomplex *, integer *, doublecomplex *, 
00146             integer *, doublereal *, doublereal *, doublereal *, integer *, 
00147             doublereal *, doublereal *, integer *, doublereal *, 
00148             doublecomplex *, doublereal *, integer *),
00149              zhesvxx_(char *, char *, integer *, integer *, doublecomplex *, 
00150             integer *, doublecomplex *, integer *, integer *, char *, 
00151             doublereal *, doublecomplex *, integer *, doublecomplex *, 
00152             integer *, doublereal *, doublereal *, doublereal *, integer *, 
00153             doublereal *, doublereal *, integer *, doublereal *, 
00154             doublecomplex *, doublereal *, integer *);
00155 
00156     /* Fortran I/O blocks */
00157     static cilist io___42 = { 0, 6, 0, fmt_8000, 0 };
00158     static cilist io___66 = { 0, 6, 0, 0, 0 };
00159     static cilist io___67 = { 0, 6, 0, fmt_9996, 0 };
00160     static cilist io___68 = { 0, 6, 0, fmt_9995, 0 };
00161     static cilist io___69 = { 0, 6, 0, fmt_9994, 0 };
00162     static cilist io___70 = { 0, 6, 0, fmt_9993, 0 };
00163     static cilist io___71 = { 0, 6, 0, fmt_9992, 0 };
00164     static cilist io___72 = { 0, 6, 0, fmt_9991, 0 };
00165     static cilist io___73 = { 0, 6, 0, fmt_9990, 0 };
00166     static cilist io___74 = { 0, 6, 0, fmt_9989, 0 };
00167     static cilist io___75 = { 0, 6, 0, 0, 0 };
00168     static cilist io___76 = { 0, 6, 0, fmt_9999, 0 };
00169     static cilist io___77 = { 0, 6, 0, 0, 0 };
00170     static cilist io___78 = { 0, 6, 0, fmt_9998, 0 };
00171     static cilist io___79 = { 0, 6, 0, fmt_9997, 0 };
00172 
00173 
00174 /*     .. Scalar Arguments .. */
00175 
00176 /*  Purpose */
00177 /*  ====== */
00178 
00179 /*  ZEBCHVXX will run Z**SVXX on a series of Hilbert matrices and then */
00180 /*  compare the error bounds returned by Z**SVXX to see if the returned */
00181 /*  answer indeed falls within those bounds. */
00182 
00183 /*  Eight test ratios will be computed.  The tests will pass if they are .LT. */
00184 /*  THRESH.  There are two cases that are determined by 1 / (SQRT( N ) * EPS). */
00185 /*  If that value is .LE. to the component wise reciprocal condition number, */
00186 /*  it uses the guaranteed case, other wise it uses the unguaranteed case. */
00187 
00188 /*  Test ratios: */
00189 /*     Let Xc be X_computed and Xt be X_truth. */
00190 /*     The norm used is the infinity norm. */
00191 /*     Let A be the guaranteed case and B be the unguaranteed case. */
00192 
00193 /*       1. Normwise guaranteed forward error bound. */
00194 /*       A: norm ( abs( Xc - Xt ) / norm ( Xt ) .LE. ERRBND( *, nwise_i, bnd_i ) and */
00195 /*          ERRBND( *, nwise_i, bnd_i ) .LE. MAX(SQRT(N),10) * EPS. */
00196 /*          If these conditions are met, the test ratio is set to be */
00197 /*          ERRBND( *, nwise_i, bnd_i ) / MAX(SQRT(N), 10).  Otherwise it is 1/EPS. */
00198 /*       B: For this case, CGESVXX should just return 1.  If it is less than */
00199 /*          one, treat it the same as in 1A.  Otherwise it fails. (Set test */
00200 /*          ratio to ERRBND( *, nwise_i, bnd_i ) * THRESH?) */
00201 
00202 /*       2. Componentwise guaranteed forward error bound. */
00203 /*       A: norm ( abs( Xc(j) - Xt(j) ) ) / norm (Xt(j)) .LE. ERRBND( *, cwise_i, bnd_i ) */
00204 /*          for all j .AND. ERRBND( *, cwise_i, bnd_i ) .LE. MAX(SQRT(N), 10) * EPS. */
00205 /*          If these conditions are met, the test ratio is set to be */
00206 /*          ERRBND( *, cwise_i, bnd_i ) / MAX(SQRT(N), 10).  Otherwise it is 1/EPS. */
00207 /*       B: Same as normwise test ratio. */
00208 
00209 /*       3. Backwards error. */
00210 /*       A: The test ratio is set to BERR/EPS. */
00211 /*       B: Same test ratio. */
00212 
00213 /*       4. Reciprocal condition number. */
00214 /*       A: A condition number is computed with Xt and compared with the one */
00215 /*          returned from CGESVXX.  Let RCONDc be the RCOND returned by CGESVXX */
00216 /*          and RCONDt be the RCOND from the truth value.  Test ratio is set to */
00217 /*          MAX(RCONDc/RCONDt, RCONDt/RCONDc). */
00218 /*       B: Test ratio is set to 1 / (EPS * RCONDc). */
00219 
00220 /*       5. Reciprocal normwise condition number. */
00221 /*       A: The test ratio is set to */
00222 /*          MAX(ERRBND( *, nwise_i, cond_i ) / NCOND, NCOND / ERRBND( *, nwise_i, cond_i )). */
00223 /*       B: Test ratio is set to 1 / (EPS * ERRBND( *, nwise_i, cond_i )). */
00224 
00225 /*       6. Reciprocal componentwise condition number. */
00226 /*       A: Test ratio is set to */
00227 /*          MAX(ERRBND( *, cwise_i, cond_i ) / CCOND, CCOND / ERRBND( *, cwise_i, cond_i )). */
00228 /*       B: Test ratio is set to 1 / (EPS * ERRBND( *, cwise_i, cond_i )). */
00229 
00230 /*     .. Parameters .. */
00231 /*     NMAX is determined by the largest number in the inverse of the hilbert */
00232 /*     matrix.  Precision is exhausted when the largest entry in it is greater */
00233 /*     than 2 to the power of the number of bits in the fraction of the data */
00234 /*     type used plus one, which is 24 for single precision. */
00235 /*     NMAX should be 6 for single and 11 for double. */
00236 /*     .. Local Scalars .. */
00237 /*     .. Local Arrays .. */
00238 /*     .. External Functions .. */
00239 /*     .. External Subroutines .. */
00240 /*     .. Intrinsic Functions .. */
00241 /*     .. Statement Functions .. */
00242 /*     .. Statement Function Definitions .. */
00243 /*     .. Parameters .. */
00244 /*  Create the loop to test out the Hilbert matrices */
00245     *(unsigned char *)fact = 'E';
00246     *(unsigned char *)uplo = 'U';
00247     *(unsigned char *)trans = 'N';
00248     *(unsigned char *)equed = 'N';
00249     eps = dlamch_("Epsilon");
00250     nfail = 0;
00251     n_aux_tests__ = 0;
00252     lda = 10;
00253     ldab = 19;
00254     ldafb = 28;
00255     s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2);
00256 /*     Main loop to test the different Hilbert Matrices. */
00257     printed_guide__ = FALSE_;
00258     for (n = 1; n <= 10; ++n) {
00259         params[0] = -1.;
00260         params[1] = -1.;
00261         kl = n - 1;
00262         ku = n - 1;
00263         nrhs = n;
00264 /* Computing MAX */
00265         d__1 = sqrt((doublereal) n);
00266         m = max(d__1,10.);
00267 /*        Generate the Hilbert matrix, its inverse, and the */
00268 /*        right hand side, all scaled by the LCM(1,..,2N-1). */
00269         zlahilb_(&n, &n, a, &lda, invhilb, &lda, b, &lda, work, &info, path);
00270 /*        Copy A into ACOPY. */
00271         zlacpy_("ALL", &n, &n, a, &c__10, acopy, &c__10);
00272 /*        Store A in band format for GB tests */
00273         i__1 = n;
00274         for (j = 1; j <= i__1; ++j) {
00275             i__2 = kl + ku + 1;
00276             for (i__ = 1; i__ <= i__2; ++i__) {
00277                 i__3 = i__ + j * 19 - 20;
00278                 ab[i__3].r = 0., ab[i__3].i = 0.;
00279             }
00280         }
00281         i__1 = n;
00282         for (j = 1; j <= i__1; ++j) {
00283 /* Computing MAX */
00284             i__2 = 1, i__3 = j - ku;
00285 /* Computing MIN */
00286             i__5 = n, i__6 = j + kl;
00287             i__4 = min(i__5,i__6);
00288             for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00289                 i__2 = ku + 1 + i__ - j + j * 19 - 20;
00290                 i__3 = i__ + j * 10 - 11;
00291                 ab[i__2].r = a[i__3].r, ab[i__2].i = a[i__3].i;
00292             }
00293         }
00294 /*        Copy AB into ABCOPY. */
00295         i__1 = n;
00296         for (j = 1; j <= i__1; ++j) {
00297             i__4 = kl + ku + 1;
00298             for (i__ = 1; i__ <= i__4; ++i__) {
00299                 i__2 = i__ + j * 19 - 20;
00300                 abcopy[i__2].r = 0., abcopy[i__2].i = 0.;
00301             }
00302         }
00303         i__1 = kl + ku + 1;
00304         zlacpy_("ALL", &i__1, &n, ab, &ldab, abcopy, &ldab);
00305 /*        Call Z**SVXX with default PARAMS and N_ERR_BND = 3. */
00306         if (lsamen_(&c__2, c2, "SY")) {
00307             zsysvxx_(fact, uplo, &n, &nrhs, acopy, &lda, af, &lda, ipiv, 
00308                     equed, s, b, &lda, x, &lda, &orcond, &rpvgrw, berr, &c__3, 
00309                      errbnd_n__, errbnd_c__, &c__2, params, work, rwork, &
00310                     info);
00311         } else if (lsamen_(&c__2, c2, "PO")) {
00312             zposvxx_(fact, uplo, &n, &nrhs, acopy, &lda, af, &lda, equed, s, 
00313                     b, &lda, x, &lda, &orcond, &rpvgrw, berr, &c__3, 
00314                     errbnd_n__, errbnd_c__, &c__2, params, work, rwork, &info);
00315         } else if (lsamen_(&c__2, c2, "HE")) {
00316             zhesvxx_(fact, uplo, &n, &nrhs, acopy, &lda, af, &lda, ipiv, 
00317                     equed, s, b, &lda, x, &lda, &orcond, &rpvgrw, berr, &c__3, 
00318                      errbnd_n__, errbnd_c__, &c__2, params, work, rwork, &
00319                     info);
00320         } else if (lsamen_(&c__2, c2, "GB")) {
00321             zgbsvxx_(fact, trans, &n, &kl, &ku, &nrhs, abcopy, &ldab, afb, &
00322                     ldafb, ipiv, equed, r__, c__, b, &lda, x, &lda, &orcond, &
00323                     rpvgrw, berr, &c__3, errbnd_n__, errbnd_c__, &c__2, 
00324                     params, work, rwork, &info);
00325         } else {
00326             zgesvxx_(fact, trans, &n, &nrhs, acopy, &lda, af, &lda, ipiv, 
00327                     equed, r__, c__, b, &lda, x, &lda, &orcond, &rpvgrw, berr, 
00328                      &c__3, errbnd_n__, errbnd_c__, &c__2, params, work, 
00329                     rwork, &info);
00330         }
00331         ++n_aux_tests__;
00332         if (orcond < eps) {
00333 /*        Either factorization failed or the matrix is flagged, and 1 <= */
00334 /*        INFO <= N+1. We don't decide based on rcond anymore. */
00335 /*            IF (INFO .EQ. 0 .OR. INFO .GT. N+1) THEN */
00336 /*               NFAIL = NFAIL + 1 */
00337 /*               WRITE (*, FMT=8000) N, INFO, ORCOND, RCOND */
00338 /*            END IF */
00339         } else {
00340 /*        Either everything succeeded (INFO == 0) or some solution failed */
00341 /*        to converge (INFO > N+1). */
00342             if (info > 0 && info <= n + 1) {
00343                 ++nfail;
00344                 s_wsfe(&io___42);
00345                 do_fio(&c__1, c2, (ftnlen)2);
00346                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00347                 do_fio(&c__1, (char *)&info, (ftnlen)sizeof(integer));
00348                 do_fio(&c__1, (char *)&orcond, (ftnlen)sizeof(doublereal));
00349                 do_fio(&c__1, (char *)&rcond, (ftnlen)sizeof(doublereal));
00350                 e_wsfe();
00351             }
00352         }
00353 /*        Calculating the difference between Z**SVXX's X and the true X. */
00354         i__1 = n;
00355         for (i__ = 1; i__ <= i__1; ++i__) {
00356             i__4 = nrhs;
00357             for (j = 1; j <= i__4; ++j) {
00358                 i__2 = i__ + j * 10 - 11;
00359                 i__3 = i__ + j * 10 - 11;
00360                 i__5 = i__ + j * 10 - 11;
00361                 z__1.r = x[i__3].r - invhilb[i__5].r, z__1.i = x[i__3].i - 
00362                         invhilb[i__5].i;
00363                 diff[i__2] = z__1.r;
00364             }
00365         }
00366 /*        Calculating the RCOND */
00367         rnorm = 0.;
00368         rinorm = 0.;
00369         if (lsamen_(&c__2, c2, "PO") || lsamen_(&c__2, 
00370                 c2, "SY") || lsamen_(&c__2, c2, "HE")) {
00371             i__1 = n;
00372             for (i__ = 1; i__ <= i__1; ++i__) {
00373                 sumr = 0.;
00374                 sumri = 0.;
00375                 i__4 = n;
00376                 for (j = 1; j <= i__4; ++j) {
00377                     i__2 = i__ + j * 10 - 11;
00378                     sumr += s[i__ - 1] * ((d__1 = a[i__2].r, abs(d__1)) + (
00379                             d__2 = d_imag(&a[i__ + j * 10 - 11]), abs(d__2))) 
00380                             * s[j - 1];
00381                     i__2 = i__ + j * 10 - 11;
00382                     sumri += ((d__1 = invhilb[i__2].r, abs(d__1)) + (d__2 = 
00383                             d_imag(&invhilb[i__ + j * 10 - 11]), abs(d__2))) /
00384                              (s[j - 1] * s[i__ - 1]);
00385                 }
00386                 rnorm = max(rnorm,sumr);
00387                 rinorm = max(rinorm,sumri);
00388             }
00389         } else if (lsamen_(&c__2, c2, "GE") || lsamen_(&
00390                 c__2, c2, "GB")) {
00391             i__1 = n;
00392             for (i__ = 1; i__ <= i__1; ++i__) {
00393                 sumr = 0.;
00394                 sumri = 0.;
00395                 i__4 = n;
00396                 for (j = 1; j <= i__4; ++j) {
00397                     i__2 = i__ + j * 10 - 11;
00398                     sumr += r__[i__ - 1] * ((d__1 = a[i__2].r, abs(d__1)) + (
00399                             d__2 = d_imag(&a[i__ + j * 10 - 11]), abs(d__2))) 
00400                             * c__[j - 1];
00401                     i__2 = i__ + j * 10 - 11;
00402                     sumri += ((d__1 = invhilb[i__2].r, abs(d__1)) + (d__2 = 
00403                             d_imag(&invhilb[i__ + j * 10 - 11]), abs(d__2))) /
00404                              (r__[j - 1] * c__[i__ - 1]);
00405                 }
00406                 rnorm = max(rnorm,sumr);
00407                 rinorm = max(rinorm,sumri);
00408             }
00409         }
00410         rnorm /= (d__1 = a[0].r, abs(d__1)) + (d__2 = d_imag(a), abs(d__2));
00411         rcond = 1. / (rnorm * rinorm);
00412 /*        Calculating the R for normwise rcond. */
00413         i__1 = n;
00414         for (i__ = 1; i__ <= i__1; ++i__) {
00415             rinv[i__ - 1] = 0.;
00416         }
00417         i__1 = n;
00418         for (j = 1; j <= i__1; ++j) {
00419             i__4 = n;
00420             for (i__ = 1; i__ <= i__4; ++i__) {
00421                 i__2 = i__ + j * 10 - 11;
00422                 rinv[i__ - 1] += (d__1 = a[i__2].r, abs(d__1)) + (d__2 = 
00423                         d_imag(&a[i__ + j * 10 - 11]), abs(d__2));
00424             }
00425         }
00426 /*        Calculating the Normwise rcond. */
00427         rinorm = 0.;
00428         i__1 = n;
00429         for (i__ = 1; i__ <= i__1; ++i__) {
00430             sumri = 0.;
00431             i__4 = n;
00432             for (j = 1; j <= i__4; ++j) {
00433                 i__2 = i__ + j * 10 - 11;
00434                 i__3 = j - 1;
00435                 z__2.r = rinv[i__3] * invhilb[i__2].r, z__2.i = rinv[i__3] * 
00436                         invhilb[i__2].i;
00437                 z__1.r = z__2.r, z__1.i = z__2.i;
00438                 sumri += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00439                         abs(d__2));
00440             }
00441             rinorm = max(rinorm,sumri);
00442         }
00443 /*        invhilb is the inverse *unscaled* Hilbert matrix, so scale its norm */
00444 /*        by 1/A(1,1) to make the scaling match A (the scaled Hilbert matrix) */
00445         ncond = ((d__1 = a[0].r, abs(d__1)) + (d__2 = d_imag(a), abs(d__2))) /
00446                  rinorm;
00447         condthresh = m * eps;
00448         errthresh = m * eps;
00449         i__1 = nrhs;
00450         for (k = 1; k <= i__1; ++k) {
00451             normt = 0.;
00452             normdif = 0.;
00453             cwise_err__ = 0.;
00454             i__4 = n;
00455             for (i__ = 1; i__ <= i__4; ++i__) {
00456 /* Computing MAX */
00457                 i__2 = i__ + k * 10 - 11;
00458                 d__3 = (d__1 = invhilb[i__2].r, abs(d__1)) + (d__2 = d_imag(&
00459                         invhilb[i__ + k * 10 - 11]), abs(d__2));
00460                 normt = max(d__3,normt);
00461                 i__2 = i__ + k * 10 - 11;
00462                 i__3 = i__ + k * 10 - 11;
00463                 z__2.r = x[i__2].r - invhilb[i__3].r, z__2.i = x[i__2].i - 
00464                         invhilb[i__3].i;
00465                 z__1.r = z__2.r, z__1.i = z__2.i;
00466 /* Computing MAX */
00467                 d__3 = (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1), 
00468                         abs(d__2));
00469                 normdif = max(d__3,normdif);
00470                 i__2 = i__ + k * 10 - 11;
00471                 if (invhilb[i__2].r != 0. || invhilb[i__2].i != 0.) {
00472                     i__2 = i__ + k * 10 - 11;
00473                     i__3 = i__ + k * 10 - 11;
00474                     z__2.r = x[i__2].r - invhilb[i__3].r, z__2.i = x[i__2].i 
00475                             - invhilb[i__3].i;
00476                     z__1.r = z__2.r, z__1.i = z__2.i;
00477 /* Computing MAX */
00478                     i__5 = i__ + k * 10 - 11;
00479                     d__5 = ((d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&z__1)
00480                             , abs(d__2))) / ((d__3 = invhilb[i__5].r, abs(
00481                             d__3)) + (d__4 = d_imag(&invhilb[i__ + k * 10 - 
00482                             11]), abs(d__4)));
00483                     cwise_err__ = max(d__5,cwise_err__);
00484                 } else /* if(complicated condition) */ {
00485                     i__2 = i__ + k * 10 - 11;
00486                     if (x[i__2].r != 0. || x[i__2].i != 0.) {
00487                         cwise_err__ = dlamch_("OVERFLOW");
00488                     }
00489                 }
00490             }
00491             if (normt != 0.) {
00492                 nwise_err__ = normdif / normt;
00493             } else if (normdif != 0.) {
00494                 nwise_err__ = dlamch_("OVERFLOW");
00495             } else {
00496                 nwise_err__ = 0.;
00497             }
00498             i__4 = n;
00499             for (i__ = 1; i__ <= i__4; ++i__) {
00500                 rinv[i__ - 1] = 0.;
00501             }
00502             i__4 = n;
00503             for (j = 1; j <= i__4; ++j) {
00504                 i__2 = n;
00505                 for (i__ = 1; i__ <= i__2; ++i__) {
00506                     i__3 = i__ + j * 10 - 11;
00507                     i__5 = j + k * 10 - 11;
00508                     z__2.r = a[i__3].r * invhilb[i__5].r - a[i__3].i * 
00509                             invhilb[i__5].i, z__2.i = a[i__3].r * invhilb[
00510                             i__5].i + a[i__3].i * invhilb[i__5].r;
00511                     z__1.r = z__2.r, z__1.i = z__2.i;
00512                     rinv[i__ - 1] += (d__1 = z__1.r, abs(d__1)) + (d__2 = 
00513                             d_imag(&z__1), abs(d__2));
00514                 }
00515             }
00516             rinorm = 0.;
00517             i__4 = n;
00518             for (i__ = 1; i__ <= i__4; ++i__) {
00519                 sumri = 0.;
00520                 i__2 = n;
00521                 for (j = 1; j <= i__2; ++j) {
00522                     i__3 = i__ + j * 10 - 11;
00523                     i__5 = j - 1;
00524                     z__3.r = rinv[i__5] * invhilb[i__3].r, z__3.i = rinv[i__5]
00525                              * invhilb[i__3].i;
00526                     z_div(&z__2, &z__3, &invhilb[i__ + k * 10 - 11]);
00527                     z__1.r = z__2.r, z__1.i = z__2.i;
00528                     sumri += (d__1 = z__1.r, abs(d__1)) + (d__2 = d_imag(&
00529                             z__1), abs(d__2));
00530                 }
00531                 rinorm = max(rinorm,sumri);
00532             }
00533 /*        invhilb is the inverse *unscaled* Hilbert matrix, so scale its norm */
00534 /*        by 1/A(1,1) to make the scaling match A (the scaled Hilbert matrix) */
00535             ccond = ((d__1 = a[0].r, abs(d__1)) + (d__2 = d_imag(a), abs(d__2)
00536                     )) / rinorm;
00537 /*        Forward error bound tests */
00538             nwise_bnd__ = errbnd_n__[k + nrhs - 1];
00539             cwise_bnd__ = errbnd_c__[k + nrhs - 1];
00540             nwise_rcond__ = errbnd_n__[k + (nrhs << 1) - 1];
00541             cwise_rcond__ = errbnd_c__[k + (nrhs << 1) - 1];
00542 /*            write (*,*) 'nwise : ', n, k, ncond, nwise_rcond, */
00543 /*     $           condthresh, ncond.ge.condthresh */
00544 /*            write (*,*) 'nwise2: ', k, nwise_bnd, nwise_err, errthresh */
00545             if (ncond >= condthresh) {
00546                 s_copy(nguar, "YES", (ftnlen)3, (ftnlen)3);
00547                 if (nwise_bnd__ > errthresh) {
00548                     tstrat[0] = 1 / (eps * 2.);
00549                 } else {
00550                     if (nwise_bnd__ != 0.) {
00551                         tstrat[0] = nwise_err__ / nwise_bnd__;
00552                     } else if (nwise_err__ != 0.) {
00553                         tstrat[0] = 1 / (eps * 16.f);
00554                     } else {
00555                         tstrat[0] = 0.;
00556                     }
00557                     if (tstrat[0] > 1.) {
00558                         tstrat[0] = 1 / (eps * 4.);
00559                     }
00560                 }
00561             } else {
00562                 s_copy(nguar, "NO", (ftnlen)3, (ftnlen)2);
00563                 if (nwise_bnd__ < 1.) {
00564                     tstrat[0] = 1 / (eps * 8.);
00565                 } else {
00566                     tstrat[0] = 1.;
00567                 }
00568             }
00569 /*            write (*,*) 'cwise : ', n, k, ccond, cwise_rcond, */
00570 /*     $           condthresh, ccond.ge.condthresh */
00571 /*            write (*,*) 'cwise2: ', k, cwise_bnd, cwise_err, errthresh */
00572             if (ccond >= condthresh) {
00573                 s_copy(cguar, "YES", (ftnlen)3, (ftnlen)3);
00574                 if (cwise_bnd__ > errthresh) {
00575                     tstrat[1] = 1 / (eps * 2.);
00576                 } else {
00577                     if (cwise_bnd__ != 0.) {
00578                         tstrat[1] = cwise_err__ / cwise_bnd__;
00579                     } else if (cwise_err__ != 0.) {
00580                         tstrat[1] = 1 / (eps * 16.);
00581                     } else {
00582                         tstrat[1] = 0.;
00583                     }
00584                     if (tstrat[1] > 1.) {
00585                         tstrat[1] = 1 / (eps * 4.);
00586                     }
00587                 }
00588             } else {
00589                 s_copy(cguar, "NO", (ftnlen)3, (ftnlen)2);
00590                 if (cwise_bnd__ < 1.) {
00591                     tstrat[1] = 1 / (eps * 8.);
00592                 } else {
00593                     tstrat[1] = 1.;
00594                 }
00595             }
00596 /*     Backwards error test */
00597             tstrat[2] = berr[k - 1] / eps;
00598 /*     Condition number tests */
00599             tstrat[3] = rcond / orcond;
00600             if (rcond >= condthresh && tstrat[3] < 1.) {
00601                 tstrat[3] = 1. / tstrat[3];
00602             }
00603             tstrat[4] = ncond / nwise_rcond__;
00604             if (ncond >= condthresh && tstrat[4] < 1.) {
00605                 tstrat[4] = 1. / tstrat[4];
00606             }
00607             tstrat[5] = ccond / nwise_rcond__;
00608             if (ccond >= condthresh && tstrat[5] < 1.) {
00609                 tstrat[5] = 1. / tstrat[5];
00610             }
00611             for (i__ = 1; i__ <= 6; ++i__) {
00612                 if (tstrat[i__ - 1] > *thresh) {
00613                     if (! printed_guide__) {
00614                         s_wsle(&io___66);
00615                         e_wsle();
00616                         s_wsfe(&io___67);
00617                         do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
00618                         e_wsfe();
00619                         s_wsfe(&io___68);
00620                         do_fio(&c__1, (char *)&c__2, (ftnlen)sizeof(integer));
00621                         e_wsfe();
00622                         s_wsfe(&io___69);
00623                         do_fio(&c__1, (char *)&c__3, (ftnlen)sizeof(integer));
00624                         e_wsfe();
00625                         s_wsfe(&io___70);
00626                         do_fio(&c__1, (char *)&c__4, (ftnlen)sizeof(integer));
00627                         e_wsfe();
00628                         s_wsfe(&io___71);
00629                         do_fio(&c__1, (char *)&c__5, (ftnlen)sizeof(integer));
00630                         e_wsfe();
00631                         s_wsfe(&io___72);
00632                         do_fio(&c__1, (char *)&c__6, (ftnlen)sizeof(integer));
00633                         e_wsfe();
00634                         s_wsfe(&io___73);
00635                         do_fio(&c__1, (char *)&c__7, (ftnlen)sizeof(integer));
00636                         e_wsfe();
00637                         s_wsfe(&io___74);
00638                         do_fio(&c__1, (char *)&c__8, (ftnlen)sizeof(integer));
00639                         e_wsfe();
00640                         s_wsle(&io___75);
00641                         e_wsle();
00642                         printed_guide__ = TRUE_;
00643                     }
00644                     s_wsfe(&io___76);
00645                     do_fio(&c__1, c2, (ftnlen)2);
00646                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00647                     do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
00648                     do_fio(&c__1, nguar, (ftnlen)3);
00649                     do_fio(&c__1, cguar, (ftnlen)3);
00650                     do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
00651                     do_fio(&c__1, (char *)&tstrat[i__ - 1], (ftnlen)sizeof(
00652                             doublereal));
00653                     e_wsfe();
00654                     ++nfail;
00655                 }
00656             }
00657         }
00658 /* $$$         WRITE(*,*) */
00659 /* $$$         WRITE(*,*) 'Normwise Error Bounds' */
00660 /* $$$         WRITE(*,*) 'Guaranteed error bound: ',ERRBND(NRHS,nwise_i,bnd_i) */
00661 /* $$$         WRITE(*,*) 'Reciprocal condition number: ',ERRBND(NRHS,nwise_i,cond_i) */
00662 /* $$$         WRITE(*,*) 'Raw error estimate: ',ERRBND(NRHS,nwise_i,rawbnd_i) */
00663 /* $$$         WRITE(*,*) */
00664 /* $$$         WRITE(*,*) 'Componentwise Error Bounds' */
00665 /* $$$         WRITE(*,*) 'Guaranteed error bound: ',ERRBND(NRHS,cwise_i,bnd_i) */
00666 /* $$$         WRITE(*,*) 'Reciprocal condition number: ',ERRBND(NRHS,cwise_i,cond_i) */
00667 /* $$$         WRITE(*,*) 'Raw error estimate: ',ERRBND(NRHS,cwise_i,rawbnd_i) */
00668 /* $$$         print *, 'Info: ', info */
00669 /* $$$         WRITE(*,*) */
00670 /*         WRITE(*,*) 'TSTRAT: ',TSTRAT */
00671     }
00672     s_wsle(&io___77);
00673     e_wsle();
00674     if (nfail > 0) {
00675         s_wsfe(&io___78);
00676         do_fio(&c__1, c2, (ftnlen)2);
00677         do_fio(&c__1, (char *)&nfail, (ftnlen)sizeof(integer));
00678         i__1 = n * 6 + n_aux_tests__;
00679         do_fio(&c__1, (char *)&i__1, (ftnlen)sizeof(integer));
00680         e_wsfe();
00681     } else {
00682         s_wsfe(&io___79);
00683         do_fio(&c__1, c2, (ftnlen)2);
00684         e_wsfe();
00685     }
00686 /*     Test ratios. */
00687     return 0;
00688 } /* zebchvxx_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:23