cchkqp.c
Go to the documentation of this file.
00001 /* cchkqp.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_b11 = {0.f,0.f};
00034 static real c_b16 = 1.f;
00035 static integer c__1 = 1;
00036 
00037 /* Subroutine */ int cchkqp_(logical *dotype, integer *nm, integer *mval, 
00038         integer *nn, integer *nval, real *thresh, logical *tsterr, complex *a, 
00039          complex *copya, real *s, real *copys, complex *tau, complex *work, 
00040         real *rwork, 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     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;
00066     extern doublereal cqpt01_(integer *, integer *, integer *, complex *, 
00067             complex *, integer *, complex *, integer *, complex *, integer *),
00068              cqrt11_(integer *, integer *, complex *, integer *, complex *, 
00069             complex *, integer *), cqrt12_(integer *, integer *, complex *, 
00070             integer *, real *, complex *, integer *, real *);
00071     integer mnmin, istep, nerrs, lwork;
00072     extern /* Subroutine */ int cgeqpf_(integer *, integer *, complex *, 
00073             integer *, integer *, complex *, complex *, real *, integer *);
00074     extern doublereal slamch_(char *);
00075     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00076             *, integer *, complex *, integer *), claset_(char *, 
00077             integer *, integer *, complex *, complex *, complex *, integer *), alasum_(char *, integer *, integer *, integer *, integer 
00078             *), clatms_(integer *, integer *, char *, integer *, char 
00079             *, real *, integer *, real *, real *, integer *, integer *, char *
00080 , complex *, integer *, complex *, integer *), slaord_(char *, integer *, real *, integer *), 
00081             cerrqp_(char *, integer *);
00082     real result[3];
00083 
00084     /* Fortran I/O blocks */
00085     static cilist io___24 = { 0, 0, 0, fmt_9999, 0 };
00086 
00087 
00088 
00089 /*  -- LAPACK test routine (version 3.1) -- */
00090 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00091 /*     November 2006 */
00092 
00093 /*     .. Scalar Arguments .. */
00094 /*     .. */
00095 /*     .. Array Arguments .. */
00096 /*     .. */
00097 
00098 /*  Purpose */
00099 /*  ======= */
00100 
00101 /*  CCHKQP tests CGEQPF. */
00102 
00103 /*  Arguments */
00104 /*  ========= */
00105 
00106 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00107 /*          The matrix types to be used for testing.  Matrices of type j */
00108 /*          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */
00109 /*          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */
00110 
00111 /*  NM      (input) INTEGER */
00112 /*          The number of values of M contained in the vector MVAL. */
00113 
00114 /*  MVAL    (input) INTEGER array, dimension (NM) */
00115 /*          The values of the matrix row dimension M. */
00116 
00117 /*  NN      (input) INTEGER */
00118 /*          The number of values of N contained in the vector NVAL. */
00119 
00120 /*  NVAL    (input) INTEGER array, dimension (NN) */
00121 /*          The values of the matrix column dimension N. */
00122 
00123 /*  THRESH  (input) REAL */
00124 /*          The threshold value for the test ratios.  A result is */
00125 /*          included in the output file if RESULT >= THRESH.  To have */
00126 /*          every test ratio printed, use THRESH = 0. */
00127 
00128 /*  TSTERR  (input) LOGICAL */
00129 /*          Flag that indicates whether error exits are to be tested. */
00130 
00131 /*  A       (workspace) COMPLEX array, dimension (MMAX*NMAX) */
00132 /*          where MMAX is the maximum value of M in MVAL and NMAX is the */
00133 /*          maximum value of N in NVAL. */
00134 
00135 /*  COPYA   (workspace) COMPLEX array, dimension (MMAX*NMAX) */
00136 
00137 /*  S       (workspace) REAL array, dimension */
00138 /*                      (min(MMAX,NMAX)) */
00139 
00140 /*  COPYS   (workspace) REAL array, dimension */
00141 /*                      (min(MMAX,NMAX)) */
00142 
00143 /*  TAU     (workspace) COMPLEX array, dimension (MMAX) */
00144 
00145 /*  WORK    (workspace) COMPLEX array, dimension */
00146 /*                      (max(M*max(M,N) + 4*min(M,N) + max(M,N))) */
00147 
00148 /*  RWORK   (workspace) REAL array, dimension (4*NMAX) */
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     --rwork;
00177     --work;
00178     --tau;
00179     --copys;
00180     --s;
00181     --copya;
00182     --a;
00183     --nval;
00184     --mval;
00185     --dotype;
00186 
00187     /* Function Body */
00188 /*     .. */
00189 /*     .. Executable Statements .. */
00190 
00191 /*     Initialize constants and the random number seed. */
00192 
00193     s_copy(path, "Complex precision", (ftnlen)1, (ftnlen)17);
00194     s_copy(path + 1, "QP", (ftnlen)2, (ftnlen)2);
00195     nrun = 0;
00196     nfail = 0;
00197     nerrs = 0;
00198     for (i__ = 1; i__ <= 4; ++i__) {
00199         iseed[i__ - 1] = iseedy[i__ - 1];
00200 /* L10: */
00201     }
00202     eps = slamch_("Epsilon");
00203 
00204 /*     Test the error exits */
00205 
00206     if (*tsterr) {
00207         cerrqp_(path, nout);
00208     }
00209     infoc_1.infot = 0;
00210 
00211     i__1 = *nm;
00212     for (im = 1; im <= i__1; ++im) {
00213 
00214 /*        Do for each value of M in MVAL. */
00215 
00216         m = mval[im];
00217         lda = max(1,m);
00218 
00219         i__2 = *nn;
00220         for (in = 1; in <= i__2; ++in) {
00221 
00222 /*           Do for each value of N in NVAL. */
00223 
00224             n = nval[in];
00225             mnmin = min(m,n);
00226 /* Computing MAX */
00227             i__3 = 1, i__4 = m * max(m,n) + (mnmin << 2) + max(m,n);
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                     claset_("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.f;
00261 /* L30: */
00262                     }
00263                 } else {
00264                     r__1 = 1.f / eps;
00265                     clatms_(&m, &n, "Uniform", iseed, "Nonsymm", &copys[1], &
00266                             mode, &r__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                     slaord_("Decreasing", &mnmin, &copys[1], &c__1);
00295                 }
00296 
00297 /*              Save A and its singular values */
00298 
00299                 clacpy_("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, "CGEQPF", (ftnlen)32, (ftnlen)6);
00304                 cgeqpf_(&m, &n, &a[1], &lda, &iwork[1], &tau[1], &work[1], &
00305                         rwork[1], &info);
00306 
00307 /*              Compute norm(svd(a) - svd(r)) */
00308 
00309                 result[0] = cqrt12_(&m, &n, &a[1], &lda, &copys[1], &work[1], 
00310                         &lwork, &rwork[1]);
00311 
00312 /*              Compute norm( A*P - Q*R ) */
00313 
00314                 result[1] = cqpt01_(&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] = cqrt11_(&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                                 real));
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 CCHKQP */
00359 
00360     return 0;
00361 } /* cchkqp_ */


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