schkq3.c
Go to the documentation of this file.
00001 /* schkq3.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 real c_b11 = 0.f;
00034 static real c_b16 = 1.f;
00035 static integer c__1 = 1;
00036 static integer c__3 = 3;
00037 
00038 /* Subroutine */ int schkq3_(logical *dotype, integer *nm, integer *mval, 
00039         integer *nn, integer *nval, integer *nnb, integer *nbval, integer *
00040         nxval, real *thresh, real *a, real *copya, real *s, real *copys, real 
00041         *tau, real *work, integer *iwork, integer *nout)
00042 {
00043     /* Initialized data */
00044 
00045     static integer iseedy[4] = { 1988,1989,1990,1991 };
00046 
00047     /* Format strings */
00048     static char fmt_9999[] = "(1x,a,\002 M =\002,i5,\002, N =\002,i5,\002, N"
00049             "B =\002,i4,\002, type \002,i2,\002, test \002,i2,\002, ratio "
00050             "=\002,g12.5)";
00051 
00052     /* System generated locals */
00053     integer i__1, i__2, i__3, i__4, i__5;
00054     real r__1;
00055 
00056     /* Builtin functions */
00057     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00058     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00059 
00060     /* Local variables */
00061     integer i__, k, m, n, nb, im, in, lw, nx, lda, inb;
00062     real eps;
00063     integer mode, info;
00064     char path[3];
00065     integer ilow, nrun;
00066     extern /* Subroutine */ int alahd_(integer *, char *);
00067     integer ihigh, nfail, iseed[4], imode, mnmin;
00068     extern /* Subroutine */ int icopy_(integer *, integer *, integer *, 
00069             integer *, integer *);
00070     integer istep, nerrs;
00071     extern doublereal sqpt01_(integer *, integer *, integer *, real *, real *, 
00072              integer *, real *, integer *, real *, integer *), sqrt11_(
00073             integer *, integer *, real *, integer *, real *, real *, integer *
00074 );
00075     integer lwork;
00076     extern doublereal sqrt12_(integer *, integer *, real *, integer *, real *, 
00077              real *, integer *);
00078     extern /* Subroutine */ int sgeqp3_(integer *, integer *, real *, integer 
00079             *, integer *, real *, real *, integer *, integer *);
00080     extern doublereal slamch_(char *);
00081     extern /* Subroutine */ int alasum_(char *, integer *, integer *, integer 
00082             *, integer *), slaord_(char *, integer *, real *, integer 
00083             *), slacpy_(char *, integer *, integer *, real *, integer 
00084             *, real *, integer *), slaset_(char *, integer *, integer 
00085             *, real *, real *, real *, integer *), xlaenv_(integer *, 
00086             integer *), slatms_(integer *, integer *, char *, integer *, char 
00087             *, real *, integer *, real *, real *, integer *, integer *, char *
00088 , real *, integer *, real *, 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.1) -- */
00097 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00098 /*     January 2007 */
00099 
00100 /*     .. Scalar Arguments .. */
00101 /*     .. */
00102 /*     .. Array Arguments .. */
00103 /*     .. */
00104 
00105 /*  Purpose */
00106 /*  ======= */
00107 
00108 /*  SCHKQ3 tests SGEQP3. */
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) REAL 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) REAL 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) REAL array, dimension (MMAX) */
00159 
00160 /*  WORK    (workspace) REAL array, dimension */
00161 /*                      (MMAX*NMAX + 4*NMAX + MMAX) */
00162 
00163 /*  IWORK   (workspace) INTEGER array, dimension (2*NMAX) */
00164 
00165 /*  NOUT    (input) INTEGER */
00166 /*          The unit number for output. */
00167 
00168 /*  ===================================================================== */
00169 
00170 /*     .. Parameters .. */
00171 /*     .. */
00172 /*     .. Local Scalars .. */
00173 /*     .. */
00174 /*     .. Local Arrays .. */
00175 /*     .. */
00176 /*     .. External Functions .. */
00177 /*     .. */
00178 /*     .. External Subroutines .. */
00179 /*     .. */
00180 /*     .. Intrinsic Functions .. */
00181 /*     .. */
00182 /*     .. Scalars in Common .. */
00183 /*     .. */
00184 /*     .. Common blocks .. */
00185 /*     .. */
00186 /*     .. Data statements .. */
00187     /* Parameter adjustments */
00188     --iwork;
00189     --work;
00190     --tau;
00191     --copys;
00192     --s;
00193     --copya;
00194     --a;
00195     --nxval;
00196     --nbval;
00197     --nval;
00198     --mval;
00199     --dotype;
00200 
00201     /* Function Body */
00202 /*     .. */
00203 /*     .. Executable Statements .. */
00204 
00205 /*     Initialize constants and the random number seed. */
00206 
00207     s_copy(path, "Single precision", (ftnlen)1, (ftnlen)16);
00208     s_copy(path + 1, "Q3", (ftnlen)2, (ftnlen)2);
00209     nrun = 0;
00210     nfail = 0;
00211     nerrs = 0;
00212     for (i__ = 1; i__ <= 4; ++i__) {
00213         iseed[i__ - 1] = iseedy[i__ - 1];
00214 /* L10: */
00215     }
00216     eps = slamch_("Epsilon");
00217     infoc_1.infot = 0;
00218 
00219     i__1 = *nm;
00220     for (im = 1; im <= i__1; ++im) {
00221 
00222 /*        Do for each value of M in MVAL. */
00223 
00224         m = mval[im];
00225         lda = max(1,m);
00226 
00227         i__2 = *nn;
00228         for (in = 1; in <= i__2; ++in) {
00229 
00230 /*           Do for each value of N in NVAL. */
00231 
00232             n = nval[in];
00233             mnmin = min(m,n);
00234 /* Computing MAX */
00235             i__3 = 1, i__4 = m * max(m,n) + (mnmin << 2) + max(m,n), i__3 = 
00236                     max(i__3,i__4), i__4 = m * n + (mnmin << 1) + (n << 2);
00237             lwork = max(i__3,i__4);
00238 
00239             for (imode = 1; imode <= 6; ++imode) {
00240                 if (! dotype[imode]) {
00241                     goto L70;
00242                 }
00243 
00244 /*              Do for each type of matrix */
00245 /*                 1:  zero matrix */
00246 /*                 2:  one small singular value */
00247 /*                 3:  geometric distribution of singular values */
00248 /*                 4:  first n/2 columns fixed */
00249 /*                 5:  last n/2 columns fixed */
00250 /*                 6:  every second column fixed */
00251 
00252                 mode = imode;
00253                 if (imode > 3) {
00254                     mode = 1;
00255                 }
00256 
00257 /*              Generate test matrix of size m by n using */
00258 /*              singular value distribution indicated by `mode'. */
00259 
00260                 i__3 = n;
00261                 for (i__ = 1; i__ <= i__3; ++i__) {
00262                     iwork[i__] = 0;
00263 /* L20: */
00264                 }
00265                 if (imode == 1) {
00266                     slaset_("Full", &m, &n, &c_b11, &c_b11, &copya[1], &lda);
00267                     i__3 = mnmin;
00268                     for (i__ = 1; i__ <= i__3; ++i__) {
00269                         copys[i__] = 0.f;
00270 /* L30: */
00271                     }
00272                 } else {
00273                     r__1 = 1.f / eps;
00274                     slatms_(&m, &n, "Uniform", iseed, "Nonsymm", &copys[1], &
00275                             mode, &r__1, &c_b16, &m, &n, "No packing", &copya[
00276                             1], &lda, &work[1], &info);
00277                     if (imode >= 4) {
00278                         if (imode == 4) {
00279                             ilow = 1;
00280                             istep = 1;
00281 /* Computing MAX */
00282                             i__3 = 1, i__4 = n / 2;
00283                             ihigh = max(i__3,i__4);
00284                         } else if (imode == 5) {
00285 /* Computing MAX */
00286                             i__3 = 1, i__4 = n / 2;
00287                             ilow = max(i__3,i__4);
00288                             istep = 1;
00289                             ihigh = n;
00290                         } else if (imode == 6) {
00291                             ilow = 1;
00292                             istep = 2;
00293                             ihigh = n;
00294                         }
00295                         i__3 = ihigh;
00296                         i__4 = istep;
00297                         for (i__ = ilow; i__4 < 0 ? i__ >= i__3 : i__ <= i__3;
00298                                  i__ += i__4) {
00299                             iwork[i__] = 1;
00300 /* L40: */
00301                         }
00302                     }
00303                     slaord_("Decreasing", &mnmin, &copys[1], &c__1);
00304                 }
00305 
00306                 i__4 = *nnb;
00307                 for (inb = 1; inb <= i__4; ++inb) {
00308 
00309 /*                 Do for each pair of values (NB,NX) in NBVAL and NXVAL. */
00310 
00311                     nb = nbval[inb];
00312                     xlaenv_(&c__1, &nb);
00313                     nx = nxval[inb];
00314                     xlaenv_(&c__3, &nx);
00315 
00316 /*                 Get a working copy of COPYA into A and a copy of */
00317 /*                 vector IWORK. */
00318 
00319                     slacpy_("All", &m, &n, &copya[1], &lda, &a[1], &lda);
00320                     icopy_(&n, &iwork[1], &c__1, &iwork[n + 1], &c__1);
00321 
00322 /*                 Compute the QR factorization with pivoting of A */
00323 
00324 /* Computing MAX */
00325                     i__3 = 1, i__5 = (n << 1) + nb * (n + 1);
00326                     lw = max(i__3,i__5);
00327 
00328 /*                 Compute the QP3 factorization of A */
00329 
00330                     s_copy(srnamc_1.srnamt, "SGEQP3", (ftnlen)32, (ftnlen)6);
00331                     sgeqp3_(&m, &n, &a[1], &lda, &iwork[n + 1], &tau[1], &
00332                             work[1], &lw, &info);
00333 
00334 /*                 Compute norm(svd(a) - svd(r)) */
00335 
00336                     result[0] = sqrt12_(&m, &n, &a[1], &lda, &copys[1], &work[
00337                             1], &lwork);
00338 
00339 /*                 Compute norm( A*P - Q*R ) */
00340 
00341                     result[1] = sqpt01_(&m, &n, &mnmin, &copya[1], &a[1], &
00342                             lda, &tau[1], &iwork[n + 1], &work[1], &lwork);
00343 
00344 /*                 Compute Q'*Q */
00345 
00346                     result[2] = sqrt11_(&m, &mnmin, &a[1], &lda, &tau[1], &
00347                             work[1], &lwork);
00348 
00349 /*                 Print information about the tests that did not pass */
00350 /*                 the threshold. */
00351 
00352                     for (k = 1; k <= 3; ++k) {
00353                         if (result[k - 1] >= *thresh) {
00354                             if (nfail == 0 && nerrs == 0) {
00355                                 alahd_(nout, path);
00356                             }
00357                             io___28.ciunit = *nout;
00358                             s_wsfe(&io___28);
00359                             do_fio(&c__1, "SGEQP3", (ftnlen)6);
00360                             do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer))
00361                                     ;
00362                             do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
00363                                     ;
00364                             do_fio(&c__1, (char *)&nb, (ftnlen)sizeof(integer)
00365                                     );
00366                             do_fio(&c__1, (char *)&imode, (ftnlen)sizeof(
00367                                     integer));
00368                             do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer))
00369                                     ;
00370                             do_fio(&c__1, (char *)&result[k - 1], (ftnlen)
00371                                     sizeof(real));
00372                             e_wsfe();
00373                             ++nfail;
00374                         }
00375 /* L50: */
00376                     }
00377                     nrun += 3;
00378 
00379 /* L60: */
00380                 }
00381 L70:
00382                 ;
00383             }
00384 /* L80: */
00385         }
00386 /* L90: */
00387     }
00388 
00389 /*     Print a summary of the results. */
00390 
00391     alasum_(path, nout, &nfail, &nrun, &nerrs);
00392 
00393 
00394 /*     End of SCHKQ3 */
00395 
00396     return 0;
00397 } /* schkq3_ */


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