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


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