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


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