schktz.c
Go to the documentation of this file.
00001 /* schktz.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_b10 = 0.f;
00034 static real c_b15 = 1.f;
00035 static integer c__1 = 1;
00036 
00037 /* Subroutine */ int schktz_(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         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 nrun;
00064     extern /* Subroutine */ int alahd_(integer *, char *);
00065     integer nfail, iseed[4], imode, mnmin, nerrs;
00066     extern doublereal sqrt12_(integer *, integer *, real *, integer *, real *, 
00067              real *, integer *);
00068     integer lwork;
00069     extern doublereal srzt01_(integer *, integer *, real *, real *, integer *, 
00070              real *, real *, integer *), srzt02_(integer *, integer *, real *, 
00071              integer *, real *, real *, integer *), stzt01_(integer *, 
00072             integer *, real *, real *, integer *, real *, real *, integer *), 
00073             stzt02_(integer *, integer *, real *, integer *, real *, real *, 
00074             integer *);
00075     extern /* Subroutine */ int sgeqr2_(integer *, integer *, real *, integer 
00076             *, real *, real *, integer *);
00077     extern doublereal slamch_(char *);
00078     extern /* Subroutine */ int alasum_(char *, integer *, integer *, integer 
00079             *, integer *), slaord_(char *, integer *, real *, integer 
00080             *), slacpy_(char *, integer *, integer *, real *, integer 
00081             *, real *, integer *), slaset_(char *, integer *, integer 
00082             *, real *, real *, real *, integer *), slatms_(integer *, 
00083             integer *, char *, integer *, char *, real *, integer *, real *, 
00084             real *, integer *, integer *, char *, real *, integer *, real *, 
00085             integer *);
00086     real result[6];
00087     extern /* Subroutine */ int serrtz_(char *, integer *), stzrqf_(
00088             integer *, integer *, real *, integer *, real *, integer *), 
00089             stzrzf_(integer *, integer *, real *, integer *, real *, real *, 
00090             integer *, integer *);
00091 
00092     /* Fortran I/O blocks */
00093     static cilist io___21 = { 0, 0, 0, fmt_9999, 0 };
00094 
00095 
00096 
00097 /*  -- LAPACK test routine (version 3.1.1) -- */
00098 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00099 /*     January 2007 */
00100 
00101 /*     .. Scalar Arguments .. */
00102 /*     .. */
00103 /*     .. Array Arguments .. */
00104 /*     .. */
00105 
00106 /*  Purpose */
00107 /*  ======= */
00108 
00109 /*  SCHKTZ tests STZRQF and STZRZF. */
00110 
00111 /*  Arguments */
00112 /*  ========= */
00113 
00114 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00115 /*          The matrix types to be used for testing.  Matrices of type j */
00116 /*          (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */
00117 /*          .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */
00118 
00119 /*  NM      (input) INTEGER */
00120 /*          The number of values of M contained in the vector MVAL. */
00121 
00122 /*  MVAL    (input) INTEGER array, dimension (NM) */
00123 /*          The values of the matrix row dimension M. */
00124 
00125 /*  NN      (input) INTEGER */
00126 /*          The number of values of N contained in the vector NVAL. */
00127 
00128 /*  NVAL    (input) INTEGER array, dimension (NN) */
00129 /*          The values of the matrix column dimension N. */
00130 
00131 /*  THRESH  (input) REAL */
00132 /*          The threshold value for the test ratios.  A result is */
00133 /*          included in the output file if RESULT >= THRESH.  To have */
00134 /*          every test ratio printed, use THRESH = 0. */
00135 
00136 /*  TSTERR  (input) LOGICAL */
00137 /*          Flag that indicates whether error exits are to be tested. */
00138 
00139 /*  A       (workspace) REAL array, dimension (MMAX*NMAX) */
00140 /*          where MMAX is the maximum value of M in MVAL and NMAX is the */
00141 /*          maximum value of N in NVAL. */
00142 
00143 /*  COPYA   (workspace) REAL array, dimension (MMAX*NMAX) */
00144 
00145 /*  S       (workspace) REAL array, dimension */
00146 /*                      (min(MMAX,NMAX)) */
00147 
00148 /*  COPYS   (workspace) REAL array, dimension */
00149 /*                      (min(MMAX,NMAX)) */
00150 
00151 /*  TAU     (workspace) REAL array, dimension (MMAX) */
00152 
00153 /*  WORK    (workspace) REAL array, dimension */
00154 /*                      (MMAX*NMAX + 4*NMAX + MMAX) */
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     --work;
00180     --tau;
00181     --copys;
00182     --s;
00183     --copya;
00184     --a;
00185     --nval;
00186     --mval;
00187     --dotype;
00188 
00189     /* Function Body */
00190 /*     .. */
00191 /*     .. Executable Statements .. */
00192 
00193 /*     Initialize constants and the random number seed. */
00194 
00195     s_copy(path, "Single precision", (ftnlen)1, (ftnlen)16);
00196     s_copy(path + 1, "TZ", (ftnlen)2, (ftnlen)2);
00197     nrun = 0;
00198     nfail = 0;
00199     nerrs = 0;
00200     for (i__ = 1; i__ <= 4; ++i__) {
00201         iseed[i__ - 1] = iseedy[i__ - 1];
00202 /* L10: */
00203     }
00204     eps = slamch_("Epsilon");
00205 
00206 /*     Test the error exits */
00207 
00208     if (*tsterr) {
00209         serrtz_(path, nout);
00210     }
00211     infoc_1.infot = 0;
00212 
00213     i__1 = *nm;
00214     for (im = 1; im <= i__1; ++im) {
00215 
00216 /*        Do for each value of M in MVAL. */
00217 
00218         m = mval[im];
00219         lda = max(1,m);
00220 
00221         i__2 = *nn;
00222         for (in = 1; in <= i__2; ++in) {
00223 
00224 /*           Do for each value of N in NVAL for which M .LE. N. */
00225 
00226             n = nval[in];
00227             mnmin = min(m,n);
00228 /* Computing MAX */
00229             i__3 = 1, i__4 = n * n + (m << 2) + n, i__3 = max(i__3,i__4), 
00230                     i__4 = m * n + (mnmin << 1) + (n << 2);
00231             lwork = max(i__3,i__4);
00232 
00233             if (m <= n) {
00234                 for (imode = 1; imode <= 3; ++imode) {
00235                     if (! dotype[imode]) {
00236                         goto L50;
00237                     }
00238 
00239 /*                 Do for each type of singular value distribution. */
00240 /*                    0:  zero matrix */
00241 /*                    1:  one small singular value */
00242 /*                    2:  exponential distribution */
00243 
00244                     mode = imode - 1;
00245 
00246 /*                 Test STZRQF */
00247 
00248 /*                 Generate test matrix of size m by n using */
00249 /*                 singular value distribution indicated by `mode'. */
00250 
00251                     if (mode == 0) {
00252                         slaset_("Full", &m, &n, &c_b10, &c_b10, &a[1], &lda);
00253                         i__3 = mnmin;
00254                         for (i__ = 1; i__ <= i__3; ++i__) {
00255                             copys[i__] = 0.f;
00256 /* L20: */
00257                         }
00258                     } else {
00259                         r__1 = 1.f / eps;
00260                         slatms_(&m, &n, "Uniform", iseed, "Nonsymmetric", &
00261                                 copys[1], &imode, &r__1, &c_b15, &m, &n, 
00262                                 "No packing", &a[1], &lda, &work[1], &info);
00263                         sgeqr2_(&m, &n, &a[1], &lda, &work[1], &work[mnmin + 
00264                                 1], &info);
00265                         i__3 = m - 1;
00266                         slaset_("Lower", &i__3, &n, &c_b10, &c_b10, &a[2], &
00267                                 lda);
00268                         slaord_("Decreasing", &mnmin, &copys[1], &c__1);
00269                     }
00270 
00271 /*                 Save A and its singular values */
00272 
00273                     slacpy_("All", &m, &n, &a[1], &lda, &copya[1], &lda);
00274 
00275 /*                 Call STZRQF to reduce the upper trapezoidal matrix to */
00276 /*                 upper triangular form. */
00277 
00278                     s_copy(srnamc_1.srnamt, "STZRQF", (ftnlen)32, (ftnlen)6);
00279                     stzrqf_(&m, &n, &a[1], &lda, &tau[1], &info);
00280 
00281 /*                 Compute norm(svd(a) - svd(r)) */
00282 
00283                     result[0] = sqrt12_(&m, &m, &a[1], &lda, &copys[1], &work[
00284                             1], &lwork);
00285 
00286 /*                 Compute norm( A - R*Q ) */
00287 
00288                     result[1] = stzt01_(&m, &n, &copya[1], &a[1], &lda, &tau[
00289                             1], &work[1], &lwork);
00290 
00291 /*                 Compute norm(Q'*Q - I). */
00292 
00293                     result[2] = stzt02_(&m, &n, &a[1], &lda, &tau[1], &work[1]
00294 , &lwork);
00295 
00296 /*                 Test STZRZF */
00297 
00298 /*                 Generate test matrix of size m by n using */
00299 /*                 singular value distribution indicated by `mode'. */
00300 
00301                     if (mode == 0) {
00302                         slaset_("Full", &m, &n, &c_b10, &c_b10, &a[1], &lda);
00303                         i__3 = mnmin;
00304                         for (i__ = 1; i__ <= i__3; ++i__) {
00305                             copys[i__] = 0.f;
00306 /* L30: */
00307                         }
00308                     } else {
00309                         r__1 = 1.f / eps;
00310                         slatms_(&m, &n, "Uniform", iseed, "Nonsymmetric", &
00311                                 copys[1], &imode, &r__1, &c_b15, &m, &n, 
00312                                 "No packing", &a[1], &lda, &work[1], &info);
00313                         sgeqr2_(&m, &n, &a[1], &lda, &work[1], &work[mnmin + 
00314                                 1], &info);
00315                         i__3 = m - 1;
00316                         slaset_("Lower", &i__3, &n, &c_b10, &c_b10, &a[2], &
00317                                 lda);
00318                         slaord_("Decreasing", &mnmin, &copys[1], &c__1);
00319                     }
00320 
00321 /*                 Save A and its singular values */
00322 
00323                     slacpy_("All", &m, &n, &a[1], &lda, &copya[1], &lda);
00324 
00325 /*                 Call STZRZF to reduce the upper trapezoidal matrix to */
00326 /*                 upper triangular form. */
00327 
00328                     s_copy(srnamc_1.srnamt, "STZRZF", (ftnlen)32, (ftnlen)6);
00329                     stzrzf_(&m, &n, &a[1], &lda, &tau[1], &work[1], &lwork, &
00330                             info);
00331 
00332 /*                 Compute norm(svd(a) - svd(r)) */
00333 
00334                     result[3] = sqrt12_(&m, &m, &a[1], &lda, &copys[1], &work[
00335                             1], &lwork);
00336 
00337 /*                 Compute norm( A - R*Q ) */
00338 
00339                     result[4] = srzt01_(&m, &n, &copya[1], &a[1], &lda, &tau[
00340                             1], &work[1], &lwork);
00341 
00342 /*                 Compute norm(Q'*Q - I). */
00343 
00344                     result[5] = srzt02_(&m, &n, &a[1], &lda, &tau[1], &work[1]
00345 , &lwork);
00346 
00347 /*                 Print information about the tests that did not pass */
00348 /*                 the threshold. */
00349 
00350                     for (k = 1; k <= 6; ++k) {
00351                         if (result[k - 1] >= *thresh) {
00352                             if (nfail == 0 && nerrs == 0) {
00353                                 alahd_(nout, path);
00354                             }
00355                             io___21.ciunit = *nout;
00356                             s_wsfe(&io___21);
00357                             do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer))
00358                                     ;
00359                             do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
00360                                     ;
00361                             do_fio(&c__1, (char *)&imode, (ftnlen)sizeof(
00362                                     integer));
00363                             do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer))
00364                                     ;
00365                             do_fio(&c__1, (char *)&result[k - 1], (ftnlen)
00366                                     sizeof(real));
00367                             e_wsfe();
00368                             ++nfail;
00369                         }
00370 /* L40: */
00371                     }
00372                     nrun += 6;
00373 L50:
00374                     ;
00375                 }
00376             }
00377 /* L60: */
00378         }
00379 /* L70: */
00380     }
00381 
00382 /*     Print a summary of the results. */
00383 
00384     alasum_(path, nout, &nfail, &nrun, &nerrs);
00385 
00386 
00387 /*     End if SCHKTZ */
00388 
00389     return 0;
00390 } /* schktz_ */


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