cdrvrf4.c
Go to the documentation of this file.
00001 /* cdrvrf4.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__4 = 4;
00028 static integer c__1 = 1;
00029 
00030 /* Subroutine */ int cdrvrf4_(integer *nout, integer *nn, integer *nval, real 
00031         *thresh, complex *c1, complex *c2, integer *ldc, complex *crf, 
00032         complex *a, integer *lda, real *s_work_clange__)
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 transs[1*2] = "N" "C";
00040 
00041     /* Format strings */
00042     static char fmt_9999[] = "(1x,\002 *** Error(s) or Failure(s) while test"
00043             "ing CHFRK               ***\002)";
00044     static char fmt_9997[] = "(1x,\002     Failure in \002,a5,\002, CFORM="
00045             "'\002,a1,\002',\002,\002 UPLO='\002,a1,\002',\002,\002 TRANS="
00046             "'\002,a1,\002',\002,\002 N=\002,i3,\002, K =\002,i3,\002, test"
00047             "=\002,g12.5)";
00048     static char fmt_9996[] = "(1x,\002All tests for \002,a5,\002 auxiliary r"
00049             "outine passed the \002,\002threshold (\002,i5,\002 tests run)"
00050             "\002)";
00051     static char fmt_9995[] = "(1x,a6,\002 auxiliary routine:\002,i5,\002 out"
00052             " of \002,i5,\002 tests failed to pass the threshold\002)";
00053 
00054     /* System generated locals */
00055     integer a_dim1, a_offset, c1_dim1, c1_offset, c2_dim1, c2_offset, i__1, 
00056             i__2, i__3, i__4, i__5, i__6, i__7;
00057     real r__1;
00058     complex q__1;
00059 
00060     /* Builtin functions */
00061     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00062     integer s_wsle(cilist *), e_wsle(void), s_wsfe(cilist *), e_wsfe(void), 
00063             do_fio(integer *, char *, ftnlen);
00064 
00065     /* Local variables */
00066     integer i__, j, k, n, iik, iin;
00067     real eps, beta;
00068     integer info;
00069     char uplo[1];
00070     integer nrun;
00071     real alpha;
00072     integer nfail, iseed[4];
00073     extern /* Subroutine */ int cherk_(char *, char *, integer *, integer *, 
00074             real *, complex *, integer *, real *, complex *, integer *), chfrk_(char *, char *, char *, integer *, 
00075             integer *, real *, complex *, integer *, real *, complex *);
00076     char cform[1];
00077     integer iform;
00078     real norma, normc;
00079     char trans[1];
00080     integer iuplo;
00081     extern doublereal clange_(char *, integer *, integer *, complex *, 
00082             integer *, real *);
00083     integer ialpha;
00084     extern /* Complex */ VOID clarnd_(complex *, integer *, integer *);
00085     extern doublereal slamch_(char *), slarnd_(integer *, integer *);
00086     integer itrans;
00087     extern /* Subroutine */ int ctfttr_(char *, char *, integer *, complex *, 
00088             complex *, integer *, integer *), ctrttf_(char *, 
00089             char *, integer *, complex *, integer *, complex *, integer *);
00090     real result[1];
00091 
00092     /* Fortran I/O blocks */
00093     static cilist io___28 = { 0, 0, 0, 0, 0 };
00094     static cilist io___29 = { 0, 0, 0, fmt_9999, 0 };
00095     static cilist io___30 = { 0, 0, 0, fmt_9997, 0 };
00096     static cilist io___31 = { 0, 0, 0, fmt_9996, 0 };
00097     static cilist io___32 = { 0, 0, 0, fmt_9995, 0 };
00098 
00099 
00100 
00101 /*  -- LAPACK test routine (version 3.2.0) -- */
00102 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00103 /*     November 2008 */
00104 
00105 /*     .. Scalar Arguments .. */
00106 /*     .. */
00107 /*     .. Array Arguments .. */
00108 /*     .. */
00109 
00110 /*  Purpose */
00111 /*  ======= */
00112 
00113 /*  CDRVRF4 tests the LAPACK RFP routines: */
00114 /*      CHFRK */
00115 
00116 /*  Arguments */
00117 /*  ========= */
00118 
00119 /*  NOUT          (input) INTEGER */
00120 /*                The unit number for output. */
00121 
00122 /*  NN            (input) INTEGER */
00123 /*                The number of values of N contained in the vector NVAL. */
00124 
00125 /*  NVAL          (input) INTEGER array, dimension (NN) */
00126 /*                The values of the matrix dimension N. */
00127 
00128 /*  THRESH        (input) REAL */
00129 /*                The threshold value for the test ratios.  A result is */
00130 /*                included in the output file if RESULT >= THRESH.  To have */
00131 /*                every test ratio printed, use THRESH = 0. */
00132 
00133 /*  C1            (workspace) COMPLEX array, dimension (LDC,NMAX) */
00134 
00135 /*  C2            (workspace) COMPLEX array, dimension (LDC,NMAX) */
00136 
00137 /*  LDC           (input) INTEGER */
00138 /*                The leading dimension of the array A.  LDA >= max(1,NMAX). */
00139 
00140 /*  CRF           (workspace) COMPLEX array, dimension ((NMAX*(NMAX+1))/2). */
00141 
00142 /*  A             (workspace) COMPLEX array, dimension (LDA,NMAX) */
00143 
00144 /*  LDA           (input) INTEGER */
00145 /*                The leading dimension of the array A.  LDA >= max(1,NMAX). */
00146 
00147 /*  S_WORK_CLANGE (workspace) REAL array, dimension (NMAX) */
00148 
00149 /*  ===================================================================== */
00150 /*     .. */
00151 /*     .. Parameters .. */
00152 /*     .. */
00153 /*     .. Local Scalars .. */
00154 /*     .. */
00155 /*     .. Local Arrays .. */
00156 /*     .. */
00157 /*     .. External Functions .. */
00158 /*     .. */
00159 /*     .. External Subroutines .. */
00160 /*     .. */
00161 /*     .. Intrinsic Functions .. */
00162 /*     .. */
00163 /*     .. Scalars in Common .. */
00164 /*     .. */
00165 /*     .. Common blocks .. */
00166 /*     .. */
00167 /*     .. Data statements .. */
00168     /* Parameter adjustments */
00169     --nval;
00170     c2_dim1 = *ldc;
00171     c2_offset = 1 + c2_dim1;
00172     c2 -= c2_offset;
00173     c1_dim1 = *ldc;
00174     c1_offset = 1 + c1_dim1;
00175     c1 -= c1_offset;
00176     --crf;
00177     a_dim1 = *lda;
00178     a_offset = 1 + a_dim1;
00179     a -= a_offset;
00180     --s_work_clange__;
00181 
00182     /* Function Body */
00183 /*     .. */
00184 /*     .. Executable Statements .. */
00185 
00186 /*     Initialize constants and the random number seed. */
00187 
00188     nrun = 0;
00189     nfail = 0;
00190     info = 0;
00191     for (i__ = 1; i__ <= 4; ++i__) {
00192         iseed[i__ - 1] = iseedy[i__ - 1];
00193 /* L10: */
00194     }
00195     eps = slamch_("Precision");
00196 
00197     i__1 = *nn;
00198     for (iin = 1; iin <= i__1; ++iin) {
00199 
00200         n = nval[iin];
00201 
00202         i__2 = *nn;
00203         for (iik = 1; iik <= i__2; ++iik) {
00204 
00205             k = nval[iin];
00206 
00207             for (iform = 1; iform <= 2; ++iform) {
00208 
00209                 *(unsigned char *)cform = *(unsigned char *)&forms[iform - 1];
00210 
00211                 for (iuplo = 1; iuplo <= 2; ++iuplo) {
00212 
00213                     *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 
00214                             1];
00215 
00216                     for (itrans = 1; itrans <= 2; ++itrans) {
00217 
00218                         *(unsigned char *)trans = *(unsigned char *)&transs[
00219                                 itrans - 1];
00220 
00221                         for (ialpha = 1; ialpha <= 4; ++ialpha) {
00222 
00223                             if (ialpha == 1) {
00224                                 alpha = 0.f;
00225                                 beta = 0.f;
00226                             } else if (ialpha == 1) {
00227                                 alpha = 1.f;
00228                                 beta = 0.f;
00229                             } else if (ialpha == 1) {
00230                                 alpha = 0.f;
00231                                 beta = 1.f;
00232                             } else {
00233                                 alpha = slarnd_(&c__2, iseed);
00234                                 beta = slarnd_(&c__2, iseed);
00235                             }
00236 
00237 /*                       All the parameters are set: */
00238 /*                          CFORM, UPLO, TRANS, M, N, */
00239 /*                          ALPHA, and BETA */
00240 /*                       READY TO TEST! */
00241 
00242                             ++nrun;
00243 
00244                             if (itrans == 1) {
00245 
00246 /*                          In this case we are NOTRANS, so A is N-by-K */
00247 
00248                                 i__3 = k;
00249                                 for (j = 1; j <= i__3; ++j) {
00250                                     i__4 = n;
00251                                     for (i__ = 1; i__ <= i__4; ++i__) {
00252                                         i__5 = i__ + j * a_dim1;
00253                                         clarnd_(&q__1, &c__4, iseed);
00254                                         a[i__5].r = q__1.r, a[i__5].i = 
00255                                                 q__1.i;
00256                                     }
00257                                 }
00258 
00259                                 norma = clange_("I", &n, &k, &a[a_offset], 
00260                                         lda, &s_work_clange__[1]);
00261 
00262                             } else {
00263 
00264 /*                          In this case we are TRANS, so A is K-by-N */
00265 
00266                                 i__3 = n;
00267                                 for (j = 1; j <= i__3; ++j) {
00268                                     i__4 = k;
00269                                     for (i__ = 1; i__ <= i__4; ++i__) {
00270                                         i__5 = i__ + j * a_dim1;
00271                                         clarnd_(&q__1, &c__4, iseed);
00272                                         a[i__5].r = q__1.r, a[i__5].i = 
00273                                                 q__1.i;
00274                                     }
00275                                 }
00276 
00277                                 norma = clange_("I", &k, &n, &a[a_offset], 
00278                                         lda, &s_work_clange__[1]);
00279 
00280                             }
00281 
00282 
00283 /*                       Generate C1 our N--by--N Hermitian matrix. */
00284 /*                       Make sure C2 has the same upper/lower part, */
00285 /*                       (the one that we do not touch), so */
00286 /*                       copy the initial C1 in C2 in it. */
00287 
00288                             i__3 = n;
00289                             for (j = 1; j <= i__3; ++j) {
00290                                 i__4 = n;
00291                                 for (i__ = 1; i__ <= i__4; ++i__) {
00292                                     i__5 = i__ + j * c1_dim1;
00293                                     clarnd_(&q__1, &c__4, iseed);
00294                                     c1[i__5].r = q__1.r, c1[i__5].i = q__1.i;
00295                                     i__5 = i__ + j * c2_dim1;
00296                                     i__6 = i__ + j * c1_dim1;
00297                                     c2[i__5].r = c1[i__6].r, c2[i__5].i = c1[
00298                                             i__6].i;
00299                                 }
00300                             }
00301 
00302 /*                       (See comment later on for why we use CLANGE and */
00303 /*                       not CLANHE for C1.) */
00304 
00305                             normc = clange_("I", &n, &n, &c1[c1_offset], ldc, 
00306                                     &s_work_clange__[1]);
00307 
00308                             s_copy(srnamc_1.srnamt, "CTRTTF", (ftnlen)32, (
00309                                     ftnlen)6);
00310                             ctrttf_(cform, uplo, &n, &c1[c1_offset], ldc, &
00311                                     crf[1], &info);
00312 
00313 /*                       call zherk the BLAS routine -> gives C1 */
00314 
00315                             s_copy(srnamc_1.srnamt, "CHERK ", (ftnlen)32, (
00316                                     ftnlen)6);
00317                             cherk_(uplo, trans, &n, &k, &alpha, &a[a_offset], 
00318                                     lda, &beta, &c1[c1_offset], ldc);
00319 
00320 /*                       call zhfrk the RFP routine -> gives CRF */
00321 
00322                             s_copy(srnamc_1.srnamt, "CHFRK ", (ftnlen)32, (
00323                                     ftnlen)6);
00324                             chfrk_(cform, uplo, trans, &n, &k, &alpha, &a[
00325                                     a_offset], lda, &beta, &crf[1]);
00326 
00327 /*                       convert CRF in full format -> gives C2 */
00328 
00329                             s_copy(srnamc_1.srnamt, "CTFTTR", (ftnlen)32, (
00330                                     ftnlen)6);
00331                             ctfttr_(cform, uplo, &n, &crf[1], &c2[c2_offset], 
00332                                     ldc, &info);
00333 
00334 /*                       compare C1 and C2 */
00335 
00336                             i__3 = n;
00337                             for (j = 1; j <= i__3; ++j) {
00338                                 i__4 = n;
00339                                 for (i__ = 1; i__ <= i__4; ++i__) {
00340                                     i__5 = i__ + j * c1_dim1;
00341                                     i__6 = i__ + j * c1_dim1;
00342                                     i__7 = i__ + j * c2_dim1;
00343                                     q__1.r = c1[i__6].r - c2[i__7].r, q__1.i =
00344                                              c1[i__6].i - c2[i__7].i;
00345                                     c1[i__5].r = q__1.r, c1[i__5].i = q__1.i;
00346                                 }
00347                             }
00348 
00349 /*                       Yes, C1 is Hermitian so we could call CLANHE, */
00350 /*                       but we want to check the upper part that is */
00351 /*                       supposed to be unchanged and the diagonal that */
00352 /*                       is supposed to be real -> CLANGE */
00353 
00354                             result[0] = clange_("I", &n, &n, &c1[c1_offset], 
00355                                     ldc, &s_work_clange__[1]);
00356 /* Computing MAX */
00357                             r__1 = dabs(alpha) * norma * norma + dabs(beta) * 
00358                                     normc;
00359                             result[0] = result[0] / dmax(r__1,1.f) / max(n,1) 
00360                                     / eps;
00361 
00362                             if (result[0] >= *thresh) {
00363                                 if (nfail == 0) {
00364                                     io___28.ciunit = *nout;
00365                                     s_wsle(&io___28);
00366                                     e_wsle();
00367                                     io___29.ciunit = *nout;
00368                                     s_wsfe(&io___29);
00369                                     e_wsfe();
00370                                 }
00371                                 io___30.ciunit = *nout;
00372                                 s_wsfe(&io___30);
00373                                 do_fio(&c__1, "CHFRK", (ftnlen)5);
00374                                 do_fio(&c__1, cform, (ftnlen)1);
00375                                 do_fio(&c__1, uplo, (ftnlen)1);
00376                                 do_fio(&c__1, trans, (ftnlen)1);
00377                                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(
00378                                         integer));
00379                                 do_fio(&c__1, (char *)&k, (ftnlen)sizeof(
00380                                         integer));
00381                                 do_fio(&c__1, (char *)&result[0], (ftnlen)
00382                                         sizeof(real));
00383                                 e_wsfe();
00384                                 ++nfail;
00385                             }
00386 
00387 /* L100: */
00388                         }
00389 /* L110: */
00390                     }
00391 /* L120: */
00392                 }
00393 /* L130: */
00394             }
00395 /* L140: */
00396         }
00397 /* L150: */
00398     }
00399 
00400 /*     Print a summary of the results. */
00401 
00402     if (nfail == 0) {
00403         io___31.ciunit = *nout;
00404         s_wsfe(&io___31);
00405         do_fio(&c__1, "CHFRK", (ftnlen)5);
00406         do_fio(&c__1, (char *)&nrun, (ftnlen)sizeof(integer));
00407         e_wsfe();
00408     } else {
00409         io___32.ciunit = *nout;
00410         s_wsfe(&io___32);
00411         do_fio(&c__1, "CHFRK", (ftnlen)5);
00412         do_fio(&c__1, (char *)&nfail, (ftnlen)sizeof(integer));
00413         do_fio(&c__1, (char *)&nrun, (ftnlen)sizeof(integer));
00414         e_wsfe();
00415     }
00416 
00417 
00418     return 0;
00419 
00420 /*     End of CDRVRF4 */
00421 
00422 } /* cdrvrf4_ */


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