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


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