cchkpp.c
Go to the documentation of this file.
00001 /* cchkpp.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 /* Common Block Declarations */
00017 
00018 struct {
00019     integer infot, nunit;
00020     logical ok, lerr;
00021 } infoc_;
00022 
00023 #define infoc_1 infoc_
00024 
00025 struct {
00026     char srnamt[32];
00027 } srnamc_;
00028 
00029 #define srnamc_1 srnamc_
00030 
00031 /* Table of constant values */
00032 
00033 static integer c__0 = 0;
00034 static integer c_n1 = -1;
00035 static integer c__2 = 2;
00036 static integer c__1 = 1;
00037 static integer c__8 = 8;
00038 
00039 /* Subroutine */ int cchkpp_(logical *dotype, integer *nn, integer *nval, 
00040         integer *nns, integer *nsval, real *thresh, logical *tsterr, integer *
00041         nmax, complex *a, complex *afac, complex *ainv, complex *b, complex *
00042         x, complex *xact, complex *work, real *rwork, integer *nout)
00043 {
00044     /* Initialized data */
00045 
00046     static integer iseedy[4] = { 1988,1989,1990,1991 };
00047     static char uplos[1*2] = "U" "L";
00048     static char packs[1*2] = "C" "R";
00049 
00050     /* Format strings */
00051     static char fmt_9999[] = "(\002 UPLO = '\002,a1,\002', N =\002,i5,\002, "
00052             "type \002,i2,\002, test \002,i2,\002, ratio =\002,g12.5)";
00053     static char fmt_9998[] = "(\002 UPLO = '\002,a1,\002', N =\002,i5,\002, "
00054             "NRHS=\002,i3,\002, type \002,i2,\002, test(\002,i2,\002) =\002,g"
00055             "12.5)";
00056 
00057     /* System generated locals */
00058     integer i__1, i__2, i__3, i__4;
00059 
00060     /* Builtin functions */
00061     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00062     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00063 
00064     /* Local variables */
00065     integer i__, k, n, in, kl, ku, lda, npp, ioff, mode, imat, info;
00066     char path[3], dist[1];
00067     integer irhs, nrhs;
00068     char uplo[1], type__[1];
00069     integer nrun;
00070     extern /* Subroutine */ int alahd_(integer *, char *), cget04_(
00071             integer *, integer *, complex *, integer *, complex *, integer *, 
00072             real *, real *);
00073     integer nfail, iseed[4];
00074     real rcond;
00075     extern /* Subroutine */ int cppt01_(char *, integer *, complex *, complex 
00076             *, real *, real *);
00077     integer nimat;
00078     extern doublereal sget06_(real *, real *);
00079     extern /* Subroutine */ int cppt02_(char *, integer *, integer *, complex 
00080             *, complex *, integer *, complex *, integer *, real *, real *), cppt03_(char *, integer *, complex *, complex *, complex 
00081             *, integer *, real *, real *, real *);
00082     real anorm;
00083     extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, 
00084             complex *, integer *), cppt05_(char *, integer *, integer *, 
00085             complex *, complex *, integer *, complex *, integer *, complex *, 
00086             integer *, real *, real *, real *);
00087     integer iuplo, izero, nerrs;
00088     logical zerot;
00089     char xtype[1];
00090     extern /* Subroutine */ int clatb4_(char *, integer *, integer *, integer 
00091             *, char *, integer *, integer *, real *, integer *, real *, char *
00092 ), alaerh_(char *, char *, integer *, 
00093             integer *, char *, integer *, integer *, integer *, integer *, 
00094             integer *, integer *, integer *, integer *, integer *), claipd_(integer *, complex *, integer *, integer 
00095             *);
00096     extern doublereal clanhp_(char *, char *, integer *, complex *, real *);
00097     real rcondc;
00098     char packit[1];
00099     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00100             *, integer *, complex *, integer *), clarhs_(char *, char 
00101             *, char *, char *, integer *, integer *, integer *, integer *, 
00102             integer *, complex *, integer *, complex *, integer *, complex *, 
00103             integer *, integer *, integer *), 
00104             alasum_(char *, integer *, integer *, integer *, integer *);
00105     real cndnum;
00106     extern /* Subroutine */ int clatms_(integer *, integer *, char *, integer 
00107             *, char *, real *, integer *, real *, real *, integer *, integer *
00108 , char *, complex *, integer *, complex *, integer *), cppcon_(char *, integer *, complex *, real *, 
00109             real *, complex *, real *, integer *), cerrpo_(char *, 
00110             integer *), cpprfs_(char *, integer *, integer *, complex 
00111             *, complex *, complex *, integer *, complex *, integer *, real *, 
00112             real *, complex *, real *, integer *), cpptrf_(char *, 
00113             integer *, complex *, integer *), cpptri_(char *, integer 
00114             *, complex *, integer *), cpptrs_(char *, integer *, 
00115             integer *, complex *, complex *, integer *, integer *);
00116     real result[8];
00117 
00118     /* Fortran I/O blocks */
00119     static cilist io___34 = { 0, 0, 0, fmt_9999, 0 };
00120     static cilist io___37 = { 0, 0, 0, fmt_9998, 0 };
00121     static cilist io___39 = { 0, 0, 0, fmt_9999, 0 };
00122 
00123 
00124 
00125 /*  -- LAPACK test routine (version 3.1) -- */
00126 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00127 /*     November 2006 */
00128 
00129 /*     .. Scalar Arguments .. */
00130 /*     .. */
00131 /*     .. Array Arguments .. */
00132 /*     .. */
00133 
00134 /*  Purpose */
00135 /*  ======= */
00136 
00137 /*  CCHKPP tests CPPTRF, -TRI, -TRS, -RFS, and -CON */
00138 
00139 /*  Arguments */
00140 /*  ========= */
00141 
00142 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00143 /*          The matrix types to be used for testing.  Matrices of type j */
00144 /*          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */
00145 /*          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */
00146 
00147 /*  NN      (input) INTEGER */
00148 /*          The number of values of N contained in the vector NVAL. */
00149 
00150 /*  NVAL    (input) INTEGER array, dimension (NN) */
00151 /*          The values of the matrix dimension N. */
00152 
00153 /*  NNS     (input) INTEGER */
00154 /*          The number of values of NRHS contained in the vector NSVAL. */
00155 
00156 /*  NSVAL   (input) INTEGER array, dimension (NNS) */
00157 /*          The values of the number of right hand sides NRHS. */
00158 
00159 /*  THRESH  (input) REAL */
00160 /*          The threshold value for the test ratios.  A result is */
00161 /*          included in the output file if RESULT >= THRESH.  To have */
00162 /*          every test ratio printed, use THRESH = 0. */
00163 
00164 /*  TSTERR  (input) LOGICAL */
00165 /*          Flag that indicates whether error exits are to be tested. */
00166 
00167 /*  NMAX    (input) INTEGER */
00168 /*          The maximum value permitted for N, used in dimensioning the */
00169 /*          work arrays. */
00170 
00171 /*  A       (workspace) COMPLEX array, dimension */
00172 /*                      (NMAX*(NMAX+1)/2) */
00173 
00174 /*  AFAC    (workspace) COMPLEX array, dimension */
00175 /*                      (NMAX*(NMAX+1)/2) */
00176 
00177 /*  AINV    (workspace) COMPLEX array, dimension */
00178 /*                      (NMAX*(NMAX+1)/2) */
00179 
00180 /*  B       (workspace) COMPLEX array, dimension (NMAX*NSMAX) */
00181 /*          where NSMAX is the largest entry in NSVAL. */
00182 
00183 /*  X       (workspace) COMPLEX array, dimension (NMAX*NSMAX) */
00184 
00185 /*  XACT    (workspace) COMPLEX array, dimension (NMAX*NSMAX) */
00186 
00187 /*  WORK    (workspace) COMPLEX array, dimension */
00188 /*                      (NMAX*max(3,NSMAX)) */
00189 
00190 /*  RWORK   (workspace) REAL array, dimension */
00191 /*                      (max(NMAX,2*NSMAX)) */
00192 
00193 /*  NOUT    (input) INTEGER */
00194 /*          The unit number for output. */
00195 
00196 /*  ===================================================================== */
00197 
00198 /*     .. Parameters .. */
00199 /*     .. */
00200 /*     .. Local Scalars .. */
00201 /*     .. */
00202 /*     .. Local Arrays .. */
00203 /*     .. */
00204 /*     .. External Functions .. */
00205 /*     .. */
00206 /*     .. External Subroutines .. */
00207 /*     .. */
00208 /*     .. Scalars in Common .. */
00209 /*     .. */
00210 /*     .. Common blocks .. */
00211 /*     .. */
00212 /*     .. Intrinsic Functions .. */
00213 /*     .. */
00214 /*     .. Data statements .. */
00215     /* Parameter adjustments */
00216     --rwork;
00217     --work;
00218     --xact;
00219     --x;
00220     --b;
00221     --ainv;
00222     --afac;
00223     --a;
00224     --nsval;
00225     --nval;
00226     --dotype;
00227 
00228     /* Function Body */
00229 /*     .. */
00230 /*     .. Executable Statements .. */
00231 
00232 /*     Initialize constants and the random number seed. */
00233 
00234     s_copy(path, "Complex precision", (ftnlen)1, (ftnlen)17);
00235     s_copy(path + 1, "PP", (ftnlen)2, (ftnlen)2);
00236     nrun = 0;
00237     nfail = 0;
00238     nerrs = 0;
00239     for (i__ = 1; i__ <= 4; ++i__) {
00240         iseed[i__ - 1] = iseedy[i__ - 1];
00241 /* L10: */
00242     }
00243 
00244 /*     Test the error exits */
00245 
00246     if (*tsterr) {
00247         cerrpo_(path, nout);
00248     }
00249     infoc_1.infot = 0;
00250 
00251 /*     Do for each value of N in NVAL */
00252 
00253     i__1 = *nn;
00254     for (in = 1; in <= i__1; ++in) {
00255         n = nval[in];
00256         lda = max(n,1);
00257         *(unsigned char *)xtype = 'N';
00258         nimat = 9;
00259         if (n <= 0) {
00260             nimat = 1;
00261         }
00262 
00263         i__2 = nimat;
00264         for (imat = 1; imat <= i__2; ++imat) {
00265 
00266 /*           Do the tests only if DOTYPE( IMAT ) is true. */
00267 
00268             if (! dotype[imat]) {
00269                 goto L100;
00270             }
00271 
00272 /*           Skip types 3, 4, or 5 if the matrix size is too small. */
00273 
00274             zerot = imat >= 3 && imat <= 5;
00275             if (zerot && n < imat - 2) {
00276                 goto L100;
00277             }
00278 
00279 /*           Do first for UPLO = 'U', then for UPLO = 'L' */
00280 
00281             for (iuplo = 1; iuplo <= 2; ++iuplo) {
00282                 *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 1];
00283                 *(unsigned char *)packit = *(unsigned char *)&packs[iuplo - 1]
00284                         ;
00285 
00286 /*              Set up parameters with CLATB4 and generate a test matrix */
00287 /*              with CLATMS. */
00288 
00289                 clatb4_(path, &imat, &n, &n, type__, &kl, &ku, &anorm, &mode, 
00290                         &cndnum, dist);
00291 
00292                 s_copy(srnamc_1.srnamt, "CLATMS", (ftnlen)32, (ftnlen)6);
00293                 clatms_(&n, &n, dist, iseed, type__, &rwork[1], &mode, &
00294                         cndnum, &anorm, &kl, &ku, packit, &a[1], &lda, &work[
00295                         1], &info);
00296 
00297 /*              Check error code from CLATMS. */
00298 
00299                 if (info != 0) {
00300                     alaerh_(path, "CLATMS", &info, &c__0, uplo, &n, &n, &c_n1, 
00301                              &c_n1, &c_n1, &imat, &nfail, &nerrs, nout);
00302                     goto L90;
00303                 }
00304 
00305 /*              For types 3-5, zero one row and column of the matrix to */
00306 /*              test that INFO is returned correctly. */
00307 
00308                 if (zerot) {
00309                     if (imat == 3) {
00310                         izero = 1;
00311                     } else if (imat == 4) {
00312                         izero = n;
00313                     } else {
00314                         izero = n / 2 + 1;
00315                     }
00316 
00317 /*                 Set row and column IZERO of A to 0. */
00318 
00319                     if (iuplo == 1) {
00320                         ioff = (izero - 1) * izero / 2;
00321                         i__3 = izero - 1;
00322                         for (i__ = 1; i__ <= i__3; ++i__) {
00323                             i__4 = ioff + i__;
00324                             a[i__4].r = 0.f, a[i__4].i = 0.f;
00325 /* L20: */
00326                         }
00327                         ioff += izero;
00328                         i__3 = n;
00329                         for (i__ = izero; i__ <= i__3; ++i__) {
00330                             i__4 = ioff;
00331                             a[i__4].r = 0.f, a[i__4].i = 0.f;
00332                             ioff += i__;
00333 /* L30: */
00334                         }
00335                     } else {
00336                         ioff = izero;
00337                         i__3 = izero - 1;
00338                         for (i__ = 1; i__ <= i__3; ++i__) {
00339                             i__4 = ioff;
00340                             a[i__4].r = 0.f, a[i__4].i = 0.f;
00341                             ioff = ioff + n - i__;
00342 /* L40: */
00343                         }
00344                         ioff -= izero;
00345                         i__3 = n;
00346                         for (i__ = izero; i__ <= i__3; ++i__) {
00347                             i__4 = ioff + i__;
00348                             a[i__4].r = 0.f, a[i__4].i = 0.f;
00349 /* L50: */
00350                         }
00351                     }
00352                 } else {
00353                     izero = 0;
00354                 }
00355 
00356 /*              Set the imaginary part of the diagonals. */
00357 
00358                 if (iuplo == 1) {
00359                     claipd_(&n, &a[1], &c__2, &c__1);
00360                 } else {
00361                     claipd_(&n, &a[1], &n, &c_n1);
00362                 }
00363 
00364 /*              Compute the L*L' or U'*U factorization of the matrix. */
00365 
00366                 npp = n * (n + 1) / 2;
00367                 ccopy_(&npp, &a[1], &c__1, &afac[1], &c__1);
00368                 s_copy(srnamc_1.srnamt, "CPPTRF", (ftnlen)32, (ftnlen)6);
00369                 cpptrf_(uplo, &n, &afac[1], &info);
00370 
00371 /*              Check error code from CPPTRF. */
00372 
00373                 if (info != izero) {
00374                     alaerh_(path, "CPPTRF", &info, &izero, uplo, &n, &n, &
00375                             c_n1, &c_n1, &c_n1, &imat, &nfail, &nerrs, nout);
00376                     goto L90;
00377                 }
00378 
00379 /*              Skip the tests if INFO is not 0. */
00380 
00381                 if (info != 0) {
00382                     goto L90;
00383                 }
00384 
00385 /* +    TEST 1 */
00386 /*              Reconstruct matrix from factors and compute residual. */
00387 
00388                 ccopy_(&npp, &afac[1], &c__1, &ainv[1], &c__1);
00389                 cppt01_(uplo, &n, &a[1], &ainv[1], &rwork[1], result);
00390 
00391 /* +    TEST 2 */
00392 /*              Form the inverse and compute the residual. */
00393 
00394                 ccopy_(&npp, &afac[1], &c__1, &ainv[1], &c__1);
00395                 s_copy(srnamc_1.srnamt, "CPPTRI", (ftnlen)32, (ftnlen)6);
00396                 cpptri_(uplo, &n, &ainv[1], &info);
00397 
00398 /*              Check error code from CPPTRI. */
00399 
00400                 if (info != 0) {
00401                     alaerh_(path, "CPPTRI", &info, &c__0, uplo, &n, &n, &c_n1, 
00402                              &c_n1, &c_n1, &imat, &nfail, &nerrs, nout);
00403                 }
00404 
00405                 cppt03_(uplo, &n, &a[1], &ainv[1], &work[1], &lda, &rwork[1], 
00406                         &rcondc, &result[1]);
00407 
00408 /*              Print information about the tests that did not pass */
00409 /*              the threshold. */
00410 
00411                 for (k = 1; k <= 2; ++k) {
00412                     if (result[k - 1] >= *thresh) {
00413                         if (nfail == 0 && nerrs == 0) {
00414                             alahd_(nout, path);
00415                         }
00416                         io___34.ciunit = *nout;
00417                         s_wsfe(&io___34);
00418                         do_fio(&c__1, uplo, (ftnlen)1);
00419                         do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00420                         do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(integer));
00421                         do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
00422                         do_fio(&c__1, (char *)&result[k - 1], (ftnlen)sizeof(
00423                                 real));
00424                         e_wsfe();
00425                         ++nfail;
00426                     }
00427 /* L60: */
00428                 }
00429                 nrun += 2;
00430 
00431                 i__3 = *nns;
00432                 for (irhs = 1; irhs <= i__3; ++irhs) {
00433                     nrhs = nsval[irhs];
00434 
00435 /* +    TEST 3 */
00436 /*              Solve and compute residual for  A * X = B. */
00437 
00438                     s_copy(srnamc_1.srnamt, "CLARHS", (ftnlen)32, (ftnlen)6);
00439                     clarhs_(path, xtype, uplo, " ", &n, &n, &kl, &ku, &nrhs, &
00440                             a[1], &lda, &xact[1], &lda, &b[1], &lda, iseed, &
00441                             info);
00442                     clacpy_("Full", &n, &nrhs, &b[1], &lda, &x[1], &lda);
00443 
00444                     s_copy(srnamc_1.srnamt, "CPPTRS", (ftnlen)32, (ftnlen)6);
00445                     cpptrs_(uplo, &n, &nrhs, &afac[1], &x[1], &lda, &info);
00446 
00447 /*              Check error code from CPPTRS. */
00448 
00449                     if (info != 0) {
00450                         alaerh_(path, "CPPTRS", &info, &c__0, uplo, &n, &n, &
00451                                 c_n1, &c_n1, &nrhs, &imat, &nfail, &nerrs, 
00452                                 nout);
00453                     }
00454 
00455                     clacpy_("Full", &n, &nrhs, &b[1], &lda, &work[1], &lda);
00456                     cppt02_(uplo, &n, &nrhs, &a[1], &x[1], &lda, &work[1], &
00457                             lda, &rwork[1], &result[2]);
00458 
00459 /* +    TEST 4 */
00460 /*              Check solution from generated exact solution. */
00461 
00462                     cget04_(&n, &nrhs, &x[1], &lda, &xact[1], &lda, &rcondc, &
00463                             result[3]);
00464 
00465 /* +    TESTS 5, 6, and 7 */
00466 /*              Use iterative refinement to improve the solution. */
00467 
00468                     s_copy(srnamc_1.srnamt, "CPPRFS", (ftnlen)32, (ftnlen)6);
00469                     cpprfs_(uplo, &n, &nrhs, &a[1], &afac[1], &b[1], &lda, &x[
00470                             1], &lda, &rwork[1], &rwork[nrhs + 1], &work[1], &
00471                             rwork[(nrhs << 1) + 1], &info);
00472 
00473 /*              Check error code from CPPRFS. */
00474 
00475                     if (info != 0) {
00476                         alaerh_(path, "CPPRFS", &info, &c__0, uplo, &n, &n, &
00477                                 c_n1, &c_n1, &nrhs, &imat, &nfail, &nerrs, 
00478                                 nout);
00479                     }
00480 
00481                     cget04_(&n, &nrhs, &x[1], &lda, &xact[1], &lda, &rcondc, &
00482                             result[4]);
00483                     cppt05_(uplo, &n, &nrhs, &a[1], &b[1], &lda, &x[1], &lda, 
00484                             &xact[1], &lda, &rwork[1], &rwork[nrhs + 1], &
00485                             result[5]);
00486 
00487 /*                 Print information about the tests that did not pass */
00488 /*                 the threshold. */
00489 
00490                     for (k = 3; k <= 7; ++k) {
00491                         if (result[k - 1] >= *thresh) {
00492                             if (nfail == 0 && nerrs == 0) {
00493                                 alahd_(nout, path);
00494                             }
00495                             io___37.ciunit = *nout;
00496                             s_wsfe(&io___37);
00497                             do_fio(&c__1, uplo, (ftnlen)1);
00498                             do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
00499                                     ;
00500                             do_fio(&c__1, (char *)&nrhs, (ftnlen)sizeof(
00501                                     integer));
00502                             do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(
00503                                     integer));
00504                             do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer))
00505                                     ;
00506                             do_fio(&c__1, (char *)&result[k - 1], (ftnlen)
00507                                     sizeof(real));
00508                             e_wsfe();
00509                             ++nfail;
00510                         }
00511 /* L70: */
00512                     }
00513                     nrun += 5;
00514 /* L80: */
00515                 }
00516 
00517 /* +    TEST 8 */
00518 /*              Get an estimate of RCOND = 1/CNDNUM. */
00519 
00520                 anorm = clanhp_("1", uplo, &n, &a[1], &rwork[1]);
00521                 s_copy(srnamc_1.srnamt, "CPPCON", (ftnlen)32, (ftnlen)6);
00522                 cppcon_(uplo, &n, &afac[1], &anorm, &rcond, &work[1], &rwork[
00523                         1], &info);
00524 
00525 /*              Check error code from CPPCON. */
00526 
00527                 if (info != 0) {
00528                     alaerh_(path, "CPPCON", &info, &c__0, uplo, &n, &n, &c_n1, 
00529                              &c_n1, &c_n1, &imat, &nfail, &nerrs, nout);
00530                 }
00531 
00532                 result[7] = sget06_(&rcond, &rcondc);
00533 
00534 /*              Print the test ratio if greater than or equal to THRESH. */
00535 
00536                 if (result[7] >= *thresh) {
00537                     if (nfail == 0 && nerrs == 0) {
00538                         alahd_(nout, path);
00539                     }
00540                     io___39.ciunit = *nout;
00541                     s_wsfe(&io___39);
00542                     do_fio(&c__1, uplo, (ftnlen)1);
00543                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00544                     do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(integer));
00545                     do_fio(&c__1, (char *)&c__8, (ftnlen)sizeof(integer));
00546                     do_fio(&c__1, (char *)&result[7], (ftnlen)sizeof(real));
00547                     e_wsfe();
00548                     ++nfail;
00549                 }
00550                 ++nrun;
00551 
00552 L90:
00553                 ;
00554             }
00555 L100:
00556             ;
00557         }
00558 /* L110: */
00559     }
00560 
00561 /*     Print a summary of the results. */
00562 
00563     alasum_(path, nout, &nfail, &nrun, &nerrs);
00564 
00565     return 0;
00566 
00567 /*     End of CCHKPP */
00568 
00569 } /* cchkpp_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:19