schkqp.c
Go to the documentation of this file.
00001 /* schkqp.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 
00037 /* Subroutine */ int schkqp_(logical *dotype, integer *nm, integer *mval, 
00038         integer *nn, integer *nval, real *thresh, logical *tsterr, real *a, 
00039         real *copya, real *s, real *copys, real *tau, real *work, integer *
00040         iwork, integer *nout)
00041 {
00042     /* Initialized data */
00043 
00044     static integer iseedy[4] = { 1988,1989,1990,1991 };
00045 
00046     /* Format strings */
00047     static char fmt_9999[] = "(\002 M =\002,i5,\002, N =\002,i5,\002, type"
00048             " \002,i2,\002, test \002,i2,\002, ratio =\002,g12.5)";
00049 
00050     /* System generated locals */
00051     integer i__1, i__2, i__3, i__4;
00052     real r__1;
00053 
00054     /* Builtin functions */
00055     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00056     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00057 
00058     /* Local variables */
00059     integer i__, k, m, n, im, in, lda;
00060     real eps;
00061     integer mode, info;
00062     char path[3];
00063     integer ilow, nrun;
00064     extern /* Subroutine */ int alahd_(integer *, char *);
00065     integer ihigh, nfail, iseed[4], imode, mnmin, istep;
00066     extern doublereal sqpt01_(integer *, integer *, integer *, real *, real *, 
00067              integer *, real *, integer *, real *, integer *);
00068     integer nerrs;
00069     extern doublereal sqrt11_(integer *, integer *, real *, integer *, real *, 
00070              real *, integer *);
00071     integer lwork;
00072     extern doublereal sqrt12_(integer *, integer *, real *, integer *, real *, 
00073              real *, integer *), slamch_(char *);
00074     extern /* Subroutine */ int alasum_(char *, integer *, integer *, integer 
00075             *, integer *), slaord_(char *, integer *, real *, integer 
00076             *), sgeqpf_(integer *, integer *, real *, integer *, 
00077             integer *, real *, real *, integer *), slacpy_(char *, integer *, 
00078             integer *, real *, integer *, real *, integer *), slaset_(
00079             char *, integer *, integer *, real *, real *, real *, integer *), slatms_(integer *, integer *, char *, integer *, char *, 
00080             real *, integer *, real *, real *, integer *, integer *, char *, 
00081             real *, integer *, real *, integer *), 
00082             serrqp_(char *, integer *);
00083     real result[3];
00084 
00085     /* Fortran I/O blocks */
00086     static cilist io___24 = { 0, 0, 0, fmt_9999, 0 };
00087 
00088 
00089 
00090 /*  -- LAPACK test routine (version 3.1.1) -- */
00091 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00092 /*     January 2007 */
00093 
00094 /*     .. Scalar Arguments .. */
00095 /*     .. */
00096 /*     .. Array Arguments .. */
00097 /*     .. */
00098 
00099 /*  Purpose */
00100 /*  ======= */
00101 
00102 /*  SCHKQP tests SGEQPF. */
00103 
00104 /*  Arguments */
00105 /*  ========= */
00106 
00107 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00108 /*          The matrix types to be used for testing.  Matrices of type j */
00109 /*          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */
00110 /*          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */
00111 
00112 /*  NM      (input) INTEGER */
00113 /*          The number of values of M contained in the vector MVAL. */
00114 
00115 /*  MVAL    (input) INTEGER array, dimension (NM) */
00116 /*          The values of the matrix row dimension M. */
00117 
00118 /*  NN      (input) INTEGER */
00119 /*          The number of values of N contained in the vector NVAL. */
00120 
00121 /*  NVAL    (input) INTEGER array, dimension (NN) */
00122 /*          The values of the matrix column dimension N. */
00123 
00124 /*  THRESH  (input) REAL */
00125 /*          The threshold value for the test ratios.  A result is */
00126 /*          included in the output file if RESULT >= THRESH.  To have */
00127 /*          every test ratio printed, use THRESH = 0. */
00128 
00129 /*  TSTERR  (input) LOGICAL */
00130 /*          Flag that indicates whether error exits are to be tested. */
00131 
00132 /*  A       (workspace) REAL array, dimension (MMAX*NMAX) */
00133 /*          where MMAX is the maximum value of M in MVAL and NMAX is the */
00134 /*          maximum value of N in NVAL. */
00135 
00136 /*  COPYA   (workspace) REAL array, dimension (MMAX*NMAX) */
00137 
00138 /*  S       (workspace) REAL array, dimension */
00139 /*                      (min(MMAX,NMAX)) */
00140 
00141 /*  COPYS   (workspace) REAL array, dimension */
00142 /*                      (min(MMAX,NMAX)) */
00143 
00144 /*  TAU     (workspace) REAL array, dimension (MMAX) */
00145 
00146 /*  WORK    (workspace) REAL array, dimension */
00147 /*                      (MMAX*NMAX + 4*NMAX + MMAX) */
00148 
00149 /*  IWORK   (workspace) INTEGER array, dimension (NMAX) */
00150 
00151 /*  NOUT    (input) INTEGER */
00152 /*          The unit number for output. */
00153 
00154 /*  ===================================================================== */
00155 
00156 /*     .. Parameters .. */
00157 /*     .. */
00158 /*     .. Local Scalars .. */
00159 /*     .. */
00160 /*     .. Local Arrays .. */
00161 /*     .. */
00162 /*     .. External Functions .. */
00163 /*     .. */
00164 /*     .. External Subroutines .. */
00165 /*     .. */
00166 /*     .. Intrinsic Functions .. */
00167 /*     .. */
00168 /*     .. Scalars in Common .. */
00169 /*     .. */
00170 /*     .. Common blocks .. */
00171 /*     .. */
00172 /*     .. Data statements .. */
00173     /* Parameter adjustments */
00174     --iwork;
00175     --work;
00176     --tau;
00177     --copys;
00178     --s;
00179     --copya;
00180     --a;
00181     --nval;
00182     --mval;
00183     --dotype;
00184 
00185     /* Function Body */
00186 /*     .. */
00187 /*     .. Executable Statements .. */
00188 
00189 /*     Initialize constants and the random number seed. */
00190 
00191     s_copy(path, "Single precision", (ftnlen)1, (ftnlen)16);
00192     s_copy(path + 1, "QP", (ftnlen)2, (ftnlen)2);
00193     nrun = 0;
00194     nfail = 0;
00195     nerrs = 0;
00196     for (i__ = 1; i__ <= 4; ++i__) {
00197         iseed[i__ - 1] = iseedy[i__ - 1];
00198 /* L10: */
00199     }
00200     eps = slamch_("Epsilon");
00201 
00202 /*     Test the error exits */
00203 
00204     if (*tsterr) {
00205         serrqp_(path, nout);
00206     }
00207     infoc_1.infot = 0;
00208 
00209     i__1 = *nm;
00210     for (im = 1; im <= i__1; ++im) {
00211 
00212 /*        Do for each value of M in MVAL. */
00213 
00214         m = mval[im];
00215         lda = max(1,m);
00216 
00217         i__2 = *nn;
00218         for (in = 1; in <= i__2; ++in) {
00219 
00220 /*           Do for each value of N in NVAL. */
00221 
00222             n = nval[in];
00223             mnmin = min(m,n);
00224 /* Computing MAX */
00225             i__3 = 1, i__4 = m * max(m,n) + (mnmin << 2) + max(m,n), i__3 = 
00226                     max(i__3,i__4), i__4 = m * n + (mnmin << 1) + (n << 2);
00227             lwork = max(i__3,i__4);
00228 
00229             for (imode = 1; imode <= 6; ++imode) {
00230                 if (! dotype[imode]) {
00231                     goto L60;
00232                 }
00233 
00234 /*              Do for each type of matrix */
00235 /*                 1:  zero matrix */
00236 /*                 2:  one small singular value */
00237 /*                 3:  geometric distribution of singular values */
00238 /*                 4:  first n/2 columns fixed */
00239 /*                 5:  last n/2 columns fixed */
00240 /*                 6:  every second column fixed */
00241 
00242                 mode = imode;
00243                 if (imode > 3) {
00244                     mode = 1;
00245                 }
00246 
00247 /*              Generate test matrix of size m by n using */
00248 /*              singular value distribution indicated by `mode'. */
00249 
00250                 i__3 = n;
00251                 for (i__ = 1; i__ <= i__3; ++i__) {
00252                     iwork[i__] = 0;
00253 /* L20: */
00254                 }
00255                 if (imode == 1) {
00256                     slaset_("Full", &m, &n, &c_b11, &c_b11, &copya[1], &lda);
00257                     i__3 = mnmin;
00258                     for (i__ = 1; i__ <= i__3; ++i__) {
00259                         copys[i__] = 0.f;
00260 /* L30: */
00261                     }
00262                 } else {
00263                     r__1 = 1.f / eps;
00264                     slatms_(&m, &n, "Uniform", iseed, "Nonsymm", &copys[1], &
00265                             mode, &r__1, &c_b16, &m, &n, "No packing", &copya[
00266                             1], &lda, &work[1], &info);
00267                     if (imode >= 4) {
00268                         if (imode == 4) {
00269                             ilow = 1;
00270                             istep = 1;
00271 /* Computing MAX */
00272                             i__3 = 1, i__4 = n / 2;
00273                             ihigh = max(i__3,i__4);
00274                         } else if (imode == 5) {
00275 /* Computing MAX */
00276                             i__3 = 1, i__4 = n / 2;
00277                             ilow = max(i__3,i__4);
00278                             istep = 1;
00279                             ihigh = n;
00280                         } else if (imode == 6) {
00281                             ilow = 1;
00282                             istep = 2;
00283                             ihigh = n;
00284                         }
00285                         i__3 = ihigh;
00286                         i__4 = istep;
00287                         for (i__ = ilow; i__4 < 0 ? i__ >= i__3 : i__ <= i__3;
00288                                  i__ += i__4) {
00289                             iwork[i__] = 1;
00290 /* L40: */
00291                         }
00292                     }
00293                     slaord_("Decreasing", &mnmin, &copys[1], &c__1);
00294                 }
00295 
00296 /*              Save A and its singular values */
00297 
00298                 slacpy_("All", &m, &n, &copya[1], &lda, &a[1], &lda);
00299 
00300 /*              Compute the QR factorization with pivoting of A */
00301 
00302                 s_copy(srnamc_1.srnamt, "SGEQPF", (ftnlen)32, (ftnlen)6);
00303                 sgeqpf_(&m, &n, &a[1], &lda, &iwork[1], &tau[1], &work[1], &
00304                         info);
00305 
00306 /*              Compute norm(svd(a) - svd(r)) */
00307 
00308                 result[0] = sqrt12_(&m, &n, &a[1], &lda, &copys[1], &work[1], 
00309                         &lwork);
00310 
00311 /*              Compute norm( A*P - Q*R ) */
00312 
00313                 result[1] = sqpt01_(&m, &n, &mnmin, &copya[1], &a[1], &lda, &
00314                         tau[1], &iwork[1], &work[1], &lwork);
00315 
00316 /*              Compute Q'*Q */
00317 
00318                 result[2] = sqrt11_(&m, &mnmin, &a[1], &lda, &tau[1], &work[1]
00319 , &lwork);
00320 
00321 /*              Print information about the tests that did not pass */
00322 /*              the threshold. */
00323 
00324                 for (k = 1; k <= 3; ++k) {
00325                     if (result[k - 1] >= *thresh) {
00326                         if (nfail == 0 && nerrs == 0) {
00327                             alahd_(nout, path);
00328                         }
00329                         io___24.ciunit = *nout;
00330                         s_wsfe(&io___24);
00331                         do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00332                         do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00333                         do_fio(&c__1, (char *)&imode, (ftnlen)sizeof(integer))
00334                                 ;
00335                         do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
00336                         do_fio(&c__1, (char *)&result[k - 1], (ftnlen)sizeof(
00337                                 real));
00338                         e_wsfe();
00339                         ++nfail;
00340                     }
00341 /* L50: */
00342                 }
00343                 nrun += 3;
00344 L60:
00345                 ;
00346             }
00347 /* L70: */
00348         }
00349 /* L80: */
00350     }
00351 
00352 /*     Print a summary of the results. */
00353 
00354     alasum_(path, nout, &nfail, &nrun, &nerrs);
00355 
00356 
00357 /*     End of SCHKQP */
00358 
00359     return 0;
00360 } /* schkqp_ */


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