ddrvrf3.c
Go to the documentation of this file.
00001 /* ddrvrf3.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     char srnamt[32];
00020 } srnamc_;
00021 
00022 #define srnamc_1 srnamc_
00023 
00024 /* Table of constant values */
00025 
00026 static integer c__2 = 2;
00027 static integer c__1 = 1;
00028 
00029 /* Subroutine */ int ddrvrf3_(integer *nout, integer *nn, integer *nval, 
00030         doublereal *thresh, doublereal *a, integer *lda, doublereal *arf, 
00031         doublereal *b1, doublereal *b2, doublereal *d_work_dlange__, 
00032         doublereal *d_work_dgeqrf__, doublereal *tau)
00033 {
00034     /* Initialized data */
00035 
00036     static integer iseedy[4] = { 1988,1989,1990,1991 };
00037     static char uplos[1*2] = "U" "L";
00038     static char forms[1*2] = "N" "T";
00039     static char sides[1*2] = "L" "R";
00040     static char transs[1*2] = "N" "T";
00041     static char diags[1*2] = "N" "U";
00042 
00043     /* Format strings */
00044     static char fmt_9999[] = "(1x,\002 *** Error(s) or Failure(s) while test"
00045             "ing DTFSM               ***\002)";
00046     static char fmt_9997[] = "(1x,\002     Failure in \002,a5,\002, CFORM="
00047             "'\002,a1,\002',\002,\002 SIDE='\002,a1,\002',\002,\002 UPLO='"
00048             "\002,a1,\002',\002,\002 TRANS='\002,a1,\002',\002,\002 DIAG='"
00049             "\002,a1,\002',\002,\002 M=\002,i3,\002, N =\002,i3,\002, test"
00050             "=\002,g12.5)";
00051     static char fmt_9996[] = "(1x,\002All tests for \002,a5,\002 auxiliary r"
00052             "outine passed the \002,\002threshold (\002,i5,\002 tests run)"
00053             "\002)";
00054     static char fmt_9995[] = "(1x,a6,\002 auxiliary routine:\002,i5,\002 out"
00055             " of \002,i5,\002 tests failed to pass the threshold\002)";
00056 
00057     /* System generated locals */
00058     integer a_dim1, a_offset, b1_dim1, b1_offset, b2_dim1, b2_offset, i__1, 
00059             i__2, i__3, i__4;
00060 
00061     /* Builtin functions */
00062     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00063     double sqrt(doublereal);
00064     integer s_wsle(cilist *), e_wsle(void), s_wsfe(cilist *), e_wsfe(void), 
00065             do_fio(integer *, char *, ftnlen);
00066 
00067     /* Local variables */
00068     integer i__, j, m, n, na, iim, iin;
00069     doublereal eps;
00070     char diag[1], side[1];
00071     integer info;
00072     char uplo[1];
00073     integer nrun, idiag;
00074     doublereal alpha;
00075     integer nfail, iseed[4], iside;
00076     char cform[1];
00077     integer iform;
00078     extern /* Subroutine */ int dtfsm_(char *, char *, char *, char *, char *, 
00079              integer *, integer *, doublereal *, doublereal *, doublereal *, 
00080             integer *);
00081     char trans[1];
00082     integer iuplo;
00083     extern /* Subroutine */ int dtrsm_(char *, char *, char *, char *, 
00084             integer *, integer *, doublereal *, doublereal *, integer *, 
00085             doublereal *, integer *);
00086     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00087             integer *, doublereal *, integer *, doublereal *);
00088     integer ialpha;
00089     extern /* Subroutine */ int dgelqf_(integer *, integer *, doublereal *, 
00090             integer *, doublereal *, doublereal *, integer *, integer *);
00091     extern doublereal dlarnd_(integer *, integer *);
00092     extern /* Subroutine */ int dgeqrf_(integer *, integer *, doublereal *, 
00093             integer *, doublereal *, doublereal *, integer *, integer *);
00094     integer itrans;
00095     extern /* Subroutine */ int dtrttf_(char *, char *, integer *, doublereal 
00096             *, integer *, doublereal *, integer *);
00097     doublereal result[1];
00098 
00099     /* Fortran I/O blocks */
00100     static cilist io___32 = { 0, 0, 0, 0, 0 };
00101     static cilist io___33 = { 0, 0, 0, fmt_9999, 0 };
00102     static cilist io___34 = { 0, 0, 0, fmt_9997, 0 };
00103     static cilist io___35 = { 0, 0, 0, fmt_9996, 0 };
00104     static cilist io___36 = { 0, 0, 0, fmt_9995, 0 };
00105 
00106 
00107 
00108 /*  -- LAPACK test routine (version 3.2.0) -- */
00109 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00110 /*     November 2008 */
00111 
00112 /*     .. Scalar Arguments .. */
00113 /*     .. */
00114 /*     .. Array Arguments .. */
00115 /*     .. */
00116 
00117 /*  Purpose */
00118 /*  ======= */
00119 
00120 /*  DDRVRF3 tests the LAPACK RFP routines: */
00121 /*      DTFSM */
00122 
00123 /*  Arguments */
00124 /*  ========= */
00125 
00126 /*  NOUT          (input) INTEGER */
00127 /*                The unit number for output. */
00128 
00129 /*  NN            (input) INTEGER */
00130 /*                The number of values of N contained in the vector NVAL. */
00131 
00132 /*  NVAL          (input) INTEGER array, dimension (NN) */
00133 /*                The values of the matrix dimension N. */
00134 
00135 /*  THRESH        (input) DOUBLE PRECISION */
00136 /*                The threshold value for the test ratios.  A result is */
00137 /*                included in the output file if RESULT >= THRESH.  To have */
00138 /*                every test ratio printed, use THRESH = 0. */
00139 
00140 /*  A             (workspace) DOUBLE PRECISION array, dimension (LDA,NMAX) */
00141 
00142 /*  LDA           (input) INTEGER */
00143 /*                The leading dimension of the array A.  LDA >= max(1,NMAX). */
00144 
00145 /*  ARF           (workspace) DOUBLE PRECISION array, dimension ((NMAX*(NMAX+1))/2). */
00146 
00147 /*  B1            (workspace) DOUBLE PRECISION array, dimension (LDA,NMAX) */
00148 
00149 /*  B2            (workspace) DOUBLE PRECISION array, dimension (LDA,NMAX) */
00150 
00151 /*  D_WORK_DLANGE (workspace) DOUBLE PRECISION array, dimension (NMAX) */
00152 
00153 /*  D_WORK_DGEQRF (workspace) DOUBLE PRECISION array, dimension (NMAX) */
00154 
00155 /*  TAU           (workspace) DOUBLE PRECISION array, dimension (NMAX) */
00156 
00157 /*  ===================================================================== */
00158 /*     .. */
00159 /*     .. Parameters .. */
00160 /*     .. */
00161 /*     .. Local Scalars .. */
00162 /*     .. */
00163 /*     .. Local Arrays .. */
00164 /*     .. */
00165 /*     .. External Functions .. */
00166 /*     .. */
00167 /*     .. External Subroutines .. */
00168 /*     .. */
00169 /*     .. Intrinsic Functions .. */
00170 /*     .. */
00171 /*     .. Scalars in Common .. */
00172 /*     .. */
00173 /*     .. Common blocks .. */
00174 /*     .. */
00175 /*     .. Data statements .. */
00176     /* Parameter adjustments */
00177     --nval;
00178     b2_dim1 = *lda;
00179     b2_offset = 1 + b2_dim1;
00180     b2 -= b2_offset;
00181     b1_dim1 = *lda;
00182     b1_offset = 1 + b1_dim1;
00183     b1 -= b1_offset;
00184     a_dim1 = *lda;
00185     a_offset = 1 + a_dim1;
00186     a -= a_offset;
00187     --arf;
00188     --d_work_dlange__;
00189     --d_work_dgeqrf__;
00190     --tau;
00191 
00192     /* Function Body */
00193 /*     .. */
00194 /*     .. Executable Statements .. */
00195 
00196 /*     Initialize constants and the random number seed. */
00197 
00198     nrun = 0;
00199     nfail = 0;
00200     info = 0;
00201     for (i__ = 1; i__ <= 4; ++i__) {
00202         iseed[i__ - 1] = iseedy[i__ - 1];
00203 /* L10: */
00204     }
00205     eps = dlamch_("Precision");
00206 
00207     i__1 = *nn;
00208     for (iim = 1; iim <= i__1; ++iim) {
00209 
00210         m = nval[iim];
00211 
00212         i__2 = *nn;
00213         for (iin = 1; iin <= i__2; ++iin) {
00214 
00215             n = nval[iin];
00216 
00217             for (iform = 1; iform <= 2; ++iform) {
00218 
00219                 *(unsigned char *)cform = *(unsigned char *)&forms[iform - 1];
00220 
00221                 for (iuplo = 1; iuplo <= 2; ++iuplo) {
00222 
00223                     *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 
00224                             1];
00225 
00226                     for (iside = 1; iside <= 2; ++iside) {
00227 
00228                         *(unsigned char *)side = *(unsigned char *)&sides[
00229                                 iside - 1];
00230 
00231                         for (itrans = 1; itrans <= 2; ++itrans) {
00232 
00233                             *(unsigned char *)trans = *(unsigned char *)&
00234                                     transs[itrans - 1];
00235 
00236                             for (idiag = 1; idiag <= 2; ++idiag) {
00237 
00238                                 *(unsigned char *)diag = *(unsigned char *)&
00239                                         diags[idiag - 1];
00240 
00241                                 for (ialpha = 1; ialpha <= 3; ++ialpha) {
00242 
00243                                     if (ialpha == 1) {
00244                                         alpha = 0.;
00245                                     } else if (ialpha == 1) {
00246                                         alpha = 1.;
00247                                     } else {
00248                                         alpha = dlarnd_(&c__2, iseed);
00249                                     }
00250 
00251 /*                             All the parameters are set: */
00252 /*                                CFORM, SIDE, UPLO, TRANS, DIAG, M, N, */
00253 /*                                and ALPHA */
00254 /*                             READY TO TEST! */
00255 
00256                                     ++nrun;
00257 
00258                                     if (iside == 1) {
00259 
00260 /*                                The case ISIDE.EQ.1 is when SIDE.EQ.'L' */
00261 /*                                -> A is M-by-M ( B is M-by-N ) */
00262 
00263                                         na = m;
00264 
00265                                     } else {
00266 
00267 /*                                The case ISIDE.EQ.2 is when SIDE.EQ.'R' */
00268 /*                                -> A is N-by-N ( B is M-by-N ) */
00269 
00270                                         na = n;
00271 
00272                                     }
00273 
00274 /*                             Generate A our NA--by--NA triangular */
00275 /*                             matrix. */
00276 /*                             Our test is based on forward error so we */
00277 /*                             do want A to be well conditionned! To get */
00278 /*                             a well-conditionned triangular matrix, we */
00279 /*                             take the R factor of the QR/LQ factorization */
00280 /*                             of a random matrix. */
00281 
00282                                     i__3 = na;
00283                                     for (j = 1; j <= i__3; ++j) {
00284                                         i__4 = na;
00285                                         for (i__ = 1; i__ <= i__4; ++i__) {
00286                                             a[i__ + j * a_dim1] = dlarnd_(&
00287                                                     c__2, iseed);
00288                                         }
00289                                     }
00290 
00291                                     if (iuplo == 1) {
00292 
00293 /*                                The case IUPLO.EQ.1 is when SIDE.EQ.'U' */
00294 /*                                -> QR factorization. */
00295 
00296                                         s_copy(srnamc_1.srnamt, "DGEQRF", (
00297                                                 ftnlen)32, (ftnlen)6);
00298                                         dgeqrf_(&na, &na, &a[a_offset], lda, &
00299                                                 tau[1], &d_work_dgeqrf__[1], 
00300                                                 lda, &info);
00301                                     } else {
00302 
00303 /*                                The case IUPLO.EQ.2 is when SIDE.EQ.'L' */
00304 /*                                -> QL factorization. */
00305 
00306                                         s_copy(srnamc_1.srnamt, "DGELQF", (
00307                                                 ftnlen)32, (ftnlen)6);
00308                                         dgelqf_(&na, &na, &a[a_offset], lda, &
00309                                                 tau[1], &d_work_dgeqrf__[1], 
00310                                                 lda, &info);
00311                                     }
00312 
00313 /*                             Store a copy of A in RFP format (in ARF). */
00314 
00315                                     s_copy(srnamc_1.srnamt, "DTRTTF", (ftnlen)
00316                                             32, (ftnlen)6);
00317                                     dtrttf_(cform, uplo, &na, &a[a_offset], 
00318                                             lda, &arf[1], &info);
00319 
00320 /*                             Generate B1 our M--by--N right-hand side */
00321 /*                             and store a copy in B2. */
00322 
00323                                     i__3 = n;
00324                                     for (j = 1; j <= i__3; ++j) {
00325                                         i__4 = m;
00326                                         for (i__ = 1; i__ <= i__4; ++i__) {
00327                                             b1[i__ + j * b1_dim1] = dlarnd_(&
00328                                                     c__2, iseed);
00329                                             b2[i__ + j * b2_dim1] = b1[i__ + 
00330                                                     j * b1_dim1];
00331                                         }
00332                                     }
00333 
00334 /*                             Solve op( A ) X = B or X op( A ) = B */
00335 /*                             with DTRSM */
00336 
00337                                     s_copy(srnamc_1.srnamt, "DTRSM", (ftnlen)
00338                                             32, (ftnlen)5);
00339                                     dtrsm_(side, uplo, trans, diag, &m, &n, &
00340                                             alpha, &a[a_offset], lda, &b1[
00341                                             b1_offset], lda);
00342 
00343 /*                             Solve op( A ) X = B or X op( A ) = B */
00344 /*                             with DTFSM */
00345 
00346                                     s_copy(srnamc_1.srnamt, "DTFSM", (ftnlen)
00347                                             32, (ftnlen)5);
00348                                     dtfsm_(cform, side, uplo, trans, diag, &m, 
00349                                              &n, &alpha, &arf[1], &b2[
00350                                             b2_offset], lda);
00351 
00352 /*                             Check that the result agrees. */
00353 
00354                                     i__3 = n;
00355                                     for (j = 1; j <= i__3; ++j) {
00356                                         i__4 = m;
00357                                         for (i__ = 1; i__ <= i__4; ++i__) {
00358                                             b1[i__ + j * b1_dim1] = b2[i__ + 
00359                                                     j * b2_dim1] - b1[i__ + j 
00360                                                     * b1_dim1];
00361                                         }
00362                                     }
00363 
00364                                     result[0] = dlange_("I", &m, &n, &b1[
00365                                             b1_offset], lda, &d_work_dlange__[
00366                                             1]);
00367 
00368 /* Computing MAX */
00369                                     i__3 = max(m,n);
00370                                     result[0] = result[0] / sqrt(eps) / max(
00371                                             i__3,1);
00372 
00373                                     if (result[0] >= *thresh) {
00374                                         if (nfail == 0) {
00375                                             io___32.ciunit = *nout;
00376                                             s_wsle(&io___32);
00377                                             e_wsle();
00378                                             io___33.ciunit = *nout;
00379                                             s_wsfe(&io___33);
00380                                             e_wsfe();
00381                                         }
00382                                         io___34.ciunit = *nout;
00383                                         s_wsfe(&io___34);
00384                                         do_fio(&c__1, "DTFSM", (ftnlen)5);
00385                                         do_fio(&c__1, cform, (ftnlen)1);
00386                                         do_fio(&c__1, side, (ftnlen)1);
00387                                         do_fio(&c__1, uplo, (ftnlen)1);
00388                                         do_fio(&c__1, trans, (ftnlen)1);
00389                                         do_fio(&c__1, diag, (ftnlen)1);
00390                                         do_fio(&c__1, (char *)&m, (ftnlen)
00391                                                 sizeof(integer));
00392                                         do_fio(&c__1, (char *)&n, (ftnlen)
00393                                                 sizeof(integer));
00394                                         do_fio(&c__1, (char *)&result[0], (
00395                                                 ftnlen)sizeof(doublereal));
00396                                         e_wsfe();
00397                                         ++nfail;
00398                                     }
00399 
00400 /* L100: */
00401                                 }
00402 /* L110: */
00403                             }
00404 /* L120: */
00405                         }
00406 /* L130: */
00407                     }
00408 /* L140: */
00409                 }
00410 /* L150: */
00411             }
00412 /* L160: */
00413         }
00414 /* L170: */
00415     }
00416 
00417 /*     Print a summary of the results. */
00418 
00419     if (nfail == 0) {
00420         io___35.ciunit = *nout;
00421         s_wsfe(&io___35);
00422         do_fio(&c__1, "DTFSM", (ftnlen)5);
00423         do_fio(&c__1, (char *)&nrun, (ftnlen)sizeof(integer));
00424         e_wsfe();
00425     } else {
00426         io___36.ciunit = *nout;
00427         s_wsfe(&io___36);
00428         do_fio(&c__1, "DTFSM", (ftnlen)5);
00429         do_fio(&c__1, (char *)&nfail, (ftnlen)sizeof(integer));
00430         do_fio(&c__1, (char *)&nrun, (ftnlen)sizeof(integer));
00431         e_wsfe();
00432     }
00433 
00434 
00435     return 0;
00436 
00437 /*     End of DDRVRF3 */
00438 
00439 } /* ddrvrf3_ */


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