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


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