zchkq3.c
Go to the documentation of this file.
00001 /* zchkq3.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     integer infot, iounit;
00020     logical ok, lerr;
00021 } infoc_;
00022 
00023 #define infoc_1 infoc_
00024 
00025 struct {
00026     char srnamt[32];
00027 } srnamc_;
00028 
00029 #define srnamc_1 srnamc_
00030 
00031 /* Table of constant values */
00032 
00033 static doublecomplex c_b1 = {0.,0.};
00034 static doublereal c_b15 = 1.;
00035 static integer c__1 = 1;
00036 static integer c__3 = 3;
00037 
00038 /* Subroutine */ int zchkq3_(logical *dotype, integer *nm, integer *mval, 
00039         integer *nn, integer *nval, integer *nnb, integer *nbval, integer *
00040         nxval, doublereal *thresh, doublecomplex *a, doublecomplex *copya, 
00041         doublereal *s, doublereal *copys, doublecomplex *tau, doublecomplex *
00042         work, doublereal *rwork, integer *iwork, integer *nout)
00043 {
00044     /* Initialized data */
00045 
00046     static integer iseedy[4] = { 1988,1989,1990,1991 };
00047 
00048     /* Format strings */
00049     static char fmt_9999[] = "(1x,a,\002 M =\002,i5,\002, N =\002,i5,\002, N"
00050             "B =\002,i4,\002, type \002,i2,\002, test \002,i2,\002, ratio "
00051             "=\002,g12.5)";
00052 
00053     /* System generated locals */
00054     integer i__1, i__2, i__3, i__4;
00055     doublereal d__1;
00056 
00057     /* Builtin functions */
00058     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00059     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00060 
00061     /* Local variables */
00062     integer i__, k, m, n, nb, im, in, lw, nx, lda, inb;
00063     doublereal eps;
00064     integer mode, info;
00065     char path[3];
00066     integer ilow, nrun;
00067     extern /* Subroutine */ int alahd_(integer *, char *);
00068     integer ihigh, nfail, iseed[4], imode, mnmin;
00069     extern /* Subroutine */ int icopy_(integer *, integer *, integer *, 
00070             integer *, integer *);
00071     integer istep, nerrs, lwork;
00072     extern doublereal zqpt01_(integer *, integer *, integer *, doublecomplex *
00073 , doublecomplex *, integer *, doublecomplex *, integer *, 
00074             doublecomplex *, integer *), zqrt11_(integer *, integer *, 
00075             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00076             integer *), zqrt12_(integer *, integer *, doublecomplex *, 
00077             integer *, doublereal *, doublecomplex *, integer *, doublereal *)
00078             ;
00079     extern /* Subroutine */ int zgeqp3_(integer *, integer *, doublecomplex *, 
00080              integer *, integer *, doublecomplex *, doublecomplex *, integer *
00081 , doublereal *, integer *);
00082     extern doublereal dlamch_(char *);
00083     extern /* Subroutine */ int dlaord_(char *, integer *, doublereal *, 
00084             integer *), alasum_(char *, integer *, integer *, integer 
00085             *, integer *), xlaenv_(integer *, integer *), zlacpy_(
00086             char *, integer *, integer *, doublecomplex *, integer *, 
00087             doublecomplex *, integer *), zlaset_(char *, integer *, 
00088             integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
00089             integer *), zlatms_(integer *, integer *, char *, integer 
00090             *, char *, doublereal *, integer *, doublereal *, doublereal *, 
00091             integer *, integer *, char *, doublecomplex *, integer *, 
00092             doublecomplex *, integer *);
00093     doublereal result[3];
00094 
00095     /* Fortran I/O blocks */
00096     static cilist io___28 = { 0, 0, 0, fmt_9999, 0 };
00097 
00098 
00099 
00100 /*  -- LAPACK test routine (version 3.1) -- */
00101 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00102 /*     November 2006 */
00103 
00104 /*     .. Scalar Arguments .. */
00105 /*     .. */
00106 /*     .. Array Arguments .. */
00107 /*     .. */
00108 
00109 /*  Purpose */
00110 /*  ======= */
00111 
00112 /*  ZCHKQ3 tests ZGEQP3. */
00113 
00114 /*  Arguments */
00115 /*  ========= */
00116 
00117 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00118 /*          The matrix types to be used for testing.  Matrices of type j */
00119 /*          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */
00120 /*          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */
00121 
00122 /*  NM      (input) INTEGER */
00123 /*          The number of values of M contained in the vector MVAL. */
00124 
00125 /*  MVAL    (input) INTEGER array, dimension (NM) */
00126 /*          The values of the matrix row dimension M. */
00127 
00128 /*  NN      (input) INTEGER */
00129 /*          The number of values of N contained in the vector NVAL. */
00130 
00131 /*  NVAL    (input) INTEGER array, dimension (NN) */
00132 /*          The values of the matrix column dimension N. */
00133 
00134 /*  NNB     (input) INTEGER */
00135 /*          The number of values of NB and NX contained in the */
00136 /*          vectors NBVAL and NXVAL.  The blocking parameters are used */
00137 /*          in pairs (NB,NX). */
00138 
00139 /*  NBVAL   (input) INTEGER array, dimension (NNB) */
00140 /*          The values of the blocksize NB. */
00141 
00142 /*  NXVAL   (input) INTEGER array, dimension (NNB) */
00143 /*          The values of the crossover point NX. */
00144 
00145 /*  THRESH  (input) DOUBLE PRECISION */
00146 /*          The threshold value for the test ratios.  A result is */
00147 /*          included in the output file if RESULT >= THRESH.  To have */
00148 /*          every test ratio printed, use THRESH = 0. */
00149 
00150 /*  A       (workspace) COMPLEX*16 array, dimension (MMAX*NMAX) */
00151 /*          where MMAX is the maximum value of M in MVAL and NMAX is the */
00152 /*          maximum value of N in NVAL. */
00153 
00154 /*  COPYA   (workspace) COMPLEX*16 array, dimension (MMAX*NMAX) */
00155 
00156 /*  S       (workspace) DOUBLE PRECISION array, dimension */
00157 /*                      (min(MMAX,NMAX)) */
00158 
00159 /*  COPYS   (workspace) DOUBLE PRECISION array, dimension */
00160 /*                      (min(MMAX,NMAX)) */
00161 
00162 /*  TAU     (workspace) COMPLEX*16 array, dimension (MMAX) */
00163 
00164 /*  WORK    (workspace) COMPLEX*16 array, dimension */
00165 /*                      (max(M*max(M,N) + 4*min(M,N) + max(M,N))) */
00166 
00167 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (4*NMAX) */
00168 
00169 /*  IWORK   (workspace) INTEGER array, dimension (2*NMAX) */
00170 
00171 /*  NOUT    (input) INTEGER */
00172 /*          The unit number for output. */
00173 
00174 /*  ===================================================================== */
00175 
00176 /*     .. Parameters .. */
00177 /*     .. */
00178 /*     .. Local Scalars .. */
00179 /*     .. */
00180 /*     .. Local Arrays .. */
00181 /*     .. */
00182 /*     .. External Functions .. */
00183 /*     .. */
00184 /*     .. External Subroutines .. */
00185 /*     .. */
00186 /*     .. Intrinsic Functions .. */
00187 /*     .. */
00188 /*     .. Scalars in Common .. */
00189 /*     .. */
00190 /*     .. Common blocks .. */
00191 /*     .. */
00192 /*     .. Data statements .. */
00193     /* Parameter adjustments */
00194     --iwork;
00195     --rwork;
00196     --work;
00197     --tau;
00198     --copys;
00199     --s;
00200     --copya;
00201     --a;
00202     --nxval;
00203     --nbval;
00204     --nval;
00205     --mval;
00206     --dotype;
00207 
00208     /* Function Body */
00209 /*     .. */
00210 /*     .. Executable Statements .. */
00211 
00212 /*     Initialize constants and the random number seed. */
00213 
00214     s_copy(path, "Zomplex precision", (ftnlen)1, (ftnlen)17);
00215     s_copy(path + 1, "Q3", (ftnlen)2, (ftnlen)2);
00216     nrun = 0;
00217     nfail = 0;
00218     nerrs = 0;
00219     for (i__ = 1; i__ <= 4; ++i__) {
00220         iseed[i__ - 1] = iseedy[i__ - 1];
00221 /* L10: */
00222     }
00223     eps = dlamch_("Epsilon");
00224     infoc_1.infot = 0;
00225 
00226     i__1 = *nm;
00227     for (im = 1; im <= i__1; ++im) {
00228 
00229 /*        Do for each value of M in MVAL. */
00230 
00231         m = mval[im];
00232         lda = max(1,m);
00233 
00234         i__2 = *nn;
00235         for (in = 1; in <= i__2; ++in) {
00236 
00237 /*           Do for each value of N in NVAL. */
00238 
00239             n = nval[in];
00240             mnmin = min(m,n);
00241 /* Computing MAX */
00242             i__3 = 1, i__4 = m * max(m,n) + (mnmin << 2) + max(m,n);
00243             lwork = max(i__3,i__4);
00244 
00245             for (imode = 1; imode <= 6; ++imode) {
00246                 if (! dotype[imode]) {
00247                     goto L70;
00248                 }
00249 
00250 /*              Do for each type of matrix */
00251 /*                 1:  zero matrix */
00252 /*                 2:  one small singular value */
00253 /*                 3:  geometric distribution of singular values */
00254 /*                 4:  first n/2 columns fixed */
00255 /*                 5:  last n/2 columns fixed */
00256 /*                 6:  every second column fixed */
00257 
00258                 mode = imode;
00259                 if (imode > 3) {
00260                     mode = 1;
00261                 }
00262 
00263 /*              Generate test matrix of size m by n using */
00264 /*              singular value distribution indicated by `mode'. */
00265 
00266                 i__3 = n;
00267                 for (i__ = 1; i__ <= i__3; ++i__) {
00268                     iwork[i__] = 0;
00269 /* L20: */
00270                 }
00271                 if (imode == 1) {
00272                     zlaset_("Full", &m, &n, &c_b1, &c_b1, &copya[1], &lda);
00273                     i__3 = mnmin;
00274                     for (i__ = 1; i__ <= i__3; ++i__) {
00275                         copys[i__] = 0.;
00276 /* L30: */
00277                     }
00278                 } else {
00279                     d__1 = 1. / eps;
00280                     zlatms_(&m, &n, "Uniform", iseed, "Nonsymm", &copys[1], &
00281                             mode, &d__1, &c_b15, &m, &n, "No packing", &copya[
00282                             1], &lda, &work[1], &info);
00283                     if (imode >= 4) {
00284                         if (imode == 4) {
00285                             ilow = 1;
00286                             istep = 1;
00287 /* Computing MAX */
00288                             i__3 = 1, i__4 = n / 2;
00289                             ihigh = max(i__3,i__4);
00290                         } else if (imode == 5) {
00291 /* Computing MAX */
00292                             i__3 = 1, i__4 = n / 2;
00293                             ilow = max(i__3,i__4);
00294                             istep = 1;
00295                             ihigh = n;
00296                         } else if (imode == 6) {
00297                             ilow = 1;
00298                             istep = 2;
00299                             ihigh = n;
00300                         }
00301                         i__3 = ihigh;
00302                         i__4 = istep;
00303                         for (i__ = ilow; i__4 < 0 ? i__ >= i__3 : i__ <= i__3;
00304                                  i__ += i__4) {
00305                             iwork[i__] = 1;
00306 /* L40: */
00307                         }
00308                     }
00309                     dlaord_("Decreasing", &mnmin, &copys[1], &c__1);
00310                 }
00311 
00312                 i__4 = *nnb;
00313                 for (inb = 1; inb <= i__4; ++inb) {
00314 
00315 /*                 Do for each pair of values (NB,NX) in NBVAL and NXVAL. */
00316 
00317                     nb = nbval[inb];
00318                     xlaenv_(&c__1, &nb);
00319                     nx = nxval[inb];
00320                     xlaenv_(&c__3, &nx);
00321 
00322 /*                 Save A and its singular values and a copy of */
00323 /*                 vector IWORK. */
00324 
00325                     zlacpy_("All", &m, &n, &copya[1], &lda, &a[1], &lda);
00326                     icopy_(&n, &iwork[1], &c__1, &iwork[n + 1], &c__1);
00327 
00328 /*                 Workspace needed. */
00329 
00330                     lw = nb * (n + 1);
00331 
00332                     s_copy(srnamc_1.srnamt, "ZGEQP3", (ftnlen)32, (ftnlen)6);
00333                     zgeqp3_(&m, &n, &a[1], &lda, &iwork[n + 1], &tau[1], &
00334                             work[1], &lw, &rwork[1], &info);
00335 
00336 /*                 Compute norm(svd(a) - svd(r)) */
00337 
00338                     result[0] = zqrt12_(&m, &n, &a[1], &lda, &copys[1], &work[
00339                             1], &lwork, &rwork[1]);
00340 
00341 /*                 Compute norm( A*P - Q*R ) */
00342 
00343                     result[1] = zqpt01_(&m, &n, &mnmin, &copya[1], &a[1], &
00344                             lda, &tau[1], &iwork[n + 1], &work[1], &lwork);
00345 
00346 /*                 Compute Q'*Q */
00347 
00348                     result[2] = zqrt11_(&m, &mnmin, &a[1], &lda, &tau[1], &
00349                             work[1], &lwork);
00350 
00351 /*                 Print information about the tests that did not pass */
00352 /*                 the threshold. */
00353 
00354                     for (k = 1; k <= 3; ++k) {
00355                         if (result[k - 1] >= *thresh) {
00356                             if (nfail == 0 && nerrs == 0) {
00357                                 alahd_(nout, path);
00358                             }
00359                             io___28.ciunit = *nout;
00360                             s_wsfe(&io___28);
00361                             do_fio(&c__1, "ZGEQP3", (ftnlen)6);
00362                             do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer))
00363                                     ;
00364                             do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
00365                                     ;
00366                             do_fio(&c__1, (char *)&nb, (ftnlen)sizeof(integer)
00367                                     );
00368                             do_fio(&c__1, (char *)&imode, (ftnlen)sizeof(
00369                                     integer));
00370                             do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer))
00371                                     ;
00372                             do_fio(&c__1, (char *)&result[k - 1], (ftnlen)
00373                                     sizeof(doublereal));
00374                             e_wsfe();
00375                             ++nfail;
00376                         }
00377 /* L50: */
00378                     }
00379                     nrun += 3;
00380 
00381 /* L60: */
00382                 }
00383 L70:
00384                 ;
00385             }
00386 /* L80: */
00387         }
00388 /* L90: */
00389     }
00390 
00391 /*     Print a summary of the results. */
00392 
00393     alasum_(path, nout, &nfail, &nrun, &nerrs);
00394 
00395 
00396 /*     End of ZCHKQ3 */
00397 
00398     return 0;
00399 } /* zchkq3_ */


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