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


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