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


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