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


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