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


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