zdrvbd.c
Go to the documentation of this file.
00001 /* zdrvbd.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 /* Table of constant values */
00017 
00018 static doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__4 = 4;
00021 static integer c__1 = 1;
00022 static integer c__0 = 0;
00023 
00024 /* Subroutine */ int zdrvbd_(integer *nsizes, integer *mm, integer *nn, 
00025         integer *ntypes, logical *dotype, integer *iseed, doublereal *thresh, 
00026         doublecomplex *a, integer *lda, doublecomplex *u, integer *ldu, 
00027         doublecomplex *vt, integer *ldvt, doublecomplex *asav, doublecomplex *
00028         usav, doublecomplex *vtsav, doublereal *s, doublereal *ssav, 
00029         doublereal *e, doublecomplex *work, integer *lwork, doublereal *rwork, 
00030          integer *iwork, integer *nounit, integer *info)
00031 {
00032     /* Initialized data */
00033 
00034     static char cjob[1*4] = "N" "O" "S" "A";
00035 
00036     /* Format strings */
00037     static char fmt_9996[] = "(\002 ZDRVBD: \002,a,\002 returned INFO=\002,i"
00038             "6,\002.\002,/9x,\002M=\002,i6,\002, N=\002,i6,\002, JTYPE=\002,i"
00039             "6,\002, ISEED=(\002,3(i5,\002,\002),i5,\002)\002)";
00040     static char fmt_9995[] = "(\002 ZDRVBD: \002,a,\002 returned INFO=\002,i"
00041             "6,\002.\002,/9x,\002M=\002,i6,\002, N=\002,i6,\002, JTYPE=\002,i"
00042             "6,\002, LSWORK=\002,i6,/9x,\002ISEED=(\002,3(i5,\002,\002),i5"
00043             ",\002)\002)";
00044     static char fmt_9999[] = "(\002 SVD -- Complex Singular Value Decomposit"
00045             "ion Driver \002,/\002 Matrix types (see ZDRVBD for details):\002"
00046             ",//\002 1 = Zero matrix\002,/\002 2 = Identity matrix\002,/\002 "
00047             "3 = Evenly spaced singular values near 1\002,/\002 4 = Evenly sp"
00048             "aced singular values near underflow\002,/\002 5 = Evenly spaced "
00049             "singular values near overflow\002,//\002 Tests performed: ( A is"
00050             " dense, U and V are unitary,\002,/19x,\002 S is an array, and Up"
00051             "artial, VTpartial, and\002,/19x,\002 Spartial are partially comp"
00052             "uted U, VT and S),\002,/)";
00053     static char fmt_9998[] = "(\002 Tests performed with Test Threshold ="
00054             " \002,f8.2,/\002 ZGESVD: \002,/\002 1 = | A - U diag(S) VT | / ("
00055             " |A| max(M,N) ulp ) \002,/\002 2 = | I - U**T U | / ( M ulp )"
00056             " \002,/\002 3 = | I - VT VT**T | / ( N ulp ) \002,/\002 4 = 0 if"
00057             " S contains min(M,N) nonnegative values in\002,\002 decreasing o"
00058             "rder, else 1/ulp\002,/\002 5 = | U - Upartial | / ( M ulp )\002,/"
00059             "\002 6 = | VT - VTpartial | / ( N ulp )\002,/\002 7 = | S - Spar"
00060             "tial | / ( min(M,N) ulp |S| )\002,/\002 ZGESDD: \002,/\002 8 = |"
00061             " A - U diag(S) VT | / ( |A| max(M,N) ulp ) \002,/\002 9 = | I - "
00062             "U**T U | / ( M ulp ) \002,/\00210 = | I - VT VT**T | / ( N ulp ) "
00063             "\002,/\00211 = 0 if S contains min(M,N) nonnegative values in"
00064             "\002,\002 decreasing order, else 1/ulp\002,/\00212 = | U - Upart"
00065             "ial | / ( M ulp )\002,/\00213 = | VT - VTpartial | / ( N ulp "
00066             ")\002,/\00214 = | S - Spartial | / ( min(M,N) ulp |S| )\002,//)";
00067     static char fmt_9997[] = "(\002 M=\002,i5,\002, N=\002,i5,\002, type "
00068             "\002,i1,\002, IWS=\002,i1,\002, seed=\002,4(i4,\002,\002),\002 t"
00069             "est(\002,i1,\002)=\002,g11.4)";
00070 
00071     /* System generated locals */
00072     integer a_dim1, a_offset, asav_dim1, asav_offset, u_dim1, u_offset, 
00073             usav_dim1, usav_offset, vt_dim1, vt_offset, vtsav_dim1, 
00074             vtsav_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7, i__8, 
00075             i__9, i__10, i__11, i__12, i__13, i__14;
00076     doublereal d__1, d__2, d__3;
00077 
00078     /* Builtin functions */
00079     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00080 
00081     /* Local variables */
00082     integer i__, j, m, n;
00083     doublereal dif, div;
00084     integer ijq, iju;
00085     doublereal ulp;
00086     char jobq[1], jobu[1];
00087     integer mmax, nmax;
00088     doublereal unfl, ovfl;
00089     integer ijvt;
00090     logical badmm, badnn;
00091     integer nfail, iinfo;
00092     extern /* Subroutine */ int zbdt01_(integer *, integer *, integer *, 
00093             doublecomplex *, integer *, doublecomplex *, integer *, 
00094             doublereal *, doublereal *, doublecomplex *, integer *, 
00095             doublecomplex *, doublereal *, doublereal *);
00096     doublereal anorm;
00097     integer mnmin, mnmax;
00098     char jobvt[1];
00099     integer iwspc, jsize, nerrs, jtype, ntest, iwtmp;
00100     extern /* Subroutine */ int zunt01_(char *, integer *, integer *, 
00101             doublecomplex *, integer *, doublecomplex *, integer *, 
00102             doublereal *, doublereal *), zunt03_(char *, integer *, 
00103             integer *, integer *, integer *, doublecomplex *, integer *, 
00104             doublecomplex *, integer *, doublecomplex *, integer *, 
00105             doublereal *, doublereal *, integer *);
00106     extern doublereal dlamch_(char *);
00107     extern /* Subroutine */ int xerbla_(char *, integer *);
00108     integer ioldsd[4];
00109     extern /* Subroutine */ int zgesdd_(char *, integer *, integer *, 
00110             doublecomplex *, integer *, doublereal *, doublecomplex *, 
00111             integer *, doublecomplex *, integer *, doublecomplex *, integer *, 
00112              doublereal *, integer *, integer *), alasvm_(char *, 
00113             integer *, integer *, integer *, integer *), zgesvd_(char 
00114             *, char *, integer *, integer *, doublecomplex *, integer *, 
00115             doublereal *, doublecomplex *, integer *, doublecomplex *, 
00116             integer *, doublecomplex *, integer *, doublereal *, integer *);
00117     integer ntestf;
00118     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00119             doublecomplex *, integer *, doublecomplex *, integer *), 
00120             zlaset_(char *, integer *, integer *, doublecomplex *, 
00121             doublecomplex *, doublecomplex *, integer *);
00122     integer minwrk;
00123     extern /* Subroutine */ int zlatms_(integer *, integer *, char *, integer 
00124             *, char *, doublereal *, integer *, doublereal *, doublereal *, 
00125             integer *, integer *, char *, doublecomplex *, integer *, 
00126             doublecomplex *, integer *);
00127     doublereal ulpinv, result[14];
00128     integer lswork, mtypes, ntestt;
00129 
00130     /* Fortran I/O blocks */
00131     static cilist io___27 = { 0, 0, 0, fmt_9996, 0 };
00132     static cilist io___32 = { 0, 0, 0, fmt_9995, 0 };
00133     static cilist io___39 = { 0, 0, 0, fmt_9995, 0 };
00134     static cilist io___43 = { 0, 0, 0, fmt_9999, 0 };
00135     static cilist io___44 = { 0, 0, 0, fmt_9998, 0 };
00136     static cilist io___45 = { 0, 0, 0, fmt_9997, 0 };
00137 
00138 
00139 
00140 /*  -- LAPACK test routine (version 3.1) -- */
00141 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00142 /*     November 2006 */
00143 
00144 /*     .. Scalar Arguments .. */
00145 /*     .. */
00146 /*     .. Array Arguments .. */
00147 /*     .. */
00148 
00149 /*  Purpose */
00150 /*  ======= */
00151 
00152 /*  ZDRVBD checks the singular value decomposition (SVD) driver ZGESVD */
00153 /*  and ZGESDD. */
00154 /*  ZGESVD and CGESDD factors A = U diag(S) VT, where U and VT are */
00155 /*  unitary and diag(S) is diagonal with the entries of the array S on */
00156 /*  its diagonal. The entries of S are the singular values, nonnegative */
00157 /*  and stored in decreasing order.  U and VT can be optionally not */
00158 /*  computed, overwritten on A, or computed partially. */
00159 
00160 /*  A is M by N. Let MNMIN = min( M, N ). S has dimension MNMIN. */
00161 /*  U can be M by M or M by MNMIN. VT can be N by N or MNMIN by N. */
00162 
00163 /*  When ZDRVBD is called, a number of matrix "sizes" (M's and N's) */
00164 /*  and a number of matrix "types" are specified.  For each size (M,N) */
00165 /*  and each type of matrix, and for the minimal workspace as well as */
00166 /*  workspace adequate to permit blocking, an  M x N  matrix "A" will be */
00167 /*  generated and used to test the SVD routines.  For each matrix, A will */
00168 /*  be factored as A = U diag(S) VT and the following 12 tests computed: */
00169 
00170 /*  Test for ZGESVD: */
00171 
00172 /*  (1)   | A - U diag(S) VT | / ( |A| max(M,N) ulp ) */
00173 
00174 /*  (2)   | I - U'U | / ( M ulp ) */
00175 
00176 /*  (3)   | I - VT VT' | / ( N ulp ) */
00177 
00178 /*  (4)   S contains MNMIN nonnegative values in decreasing order. */
00179 /*        (Return 0 if true, 1/ULP if false.) */
00180 
00181 /*  (5)   | U - Upartial | / ( M ulp ) where Upartial is a partially */
00182 /*        computed U. */
00183 
00184 /*  (6)   | VT - VTpartial | / ( N ulp ) where VTpartial is a partially */
00185 /*        computed VT. */
00186 
00187 /*  (7)   | S - Spartial | / ( MNMIN ulp |S| ) where Spartial is the */
00188 /*        vector of singular values from the partial SVD */
00189 
00190 /*  Test for ZGESDD: */
00191 
00192 /*  (1)   | A - U diag(S) VT | / ( |A| max(M,N) ulp ) */
00193 
00194 /*  (2)   | I - U'U | / ( M ulp ) */
00195 
00196 /*  (3)   | I - VT VT' | / ( N ulp ) */
00197 
00198 /*  (4)   S contains MNMIN nonnegative values in decreasing order. */
00199 /*        (Return 0 if true, 1/ULP if false.) */
00200 
00201 /*  (5)   | U - Upartial | / ( M ulp ) where Upartial is a partially */
00202 /*        computed U. */
00203 
00204 /*  (6)   | VT - VTpartial | / ( N ulp ) where VTpartial is a partially */
00205 /*        computed VT. */
00206 
00207 /*  (7)   | S - Spartial | / ( MNMIN ulp |S| ) where Spartial is the */
00208 /*        vector of singular values from the partial SVD */
00209 
00210 /*  The "sizes" are specified by the arrays MM(1:NSIZES) and */
00211 /*  NN(1:NSIZES); the value of each element pair (MM(j),NN(j)) */
00212 /*  specifies one size.  The "types" are specified by a logical array */
00213 /*  DOTYPE( 1:NTYPES ); if DOTYPE(j) is .TRUE., then matrix type "j" */
00214 /*  will be generated. */
00215 /*  Currently, the list of possible types is: */
00216 
00217 /*  (1)  The zero matrix. */
00218 /*  (2)  The identity matrix. */
00219 /*  (3)  A matrix of the form  U D V, where U and V are unitary and */
00220 /*       D has evenly spaced entries 1, ..., ULP with random signs */
00221 /*       on the diagonal. */
00222 /*  (4)  Same as (3), but multiplied by the underflow-threshold / ULP. */
00223 /*  (5)  Same as (3), but multiplied by the overflow-threshold * ULP. */
00224 
00225 /*  Arguments */
00226 /*  ========== */
00227 
00228 /*  NSIZES  (input) INTEGER */
00229 /*          The number of sizes of matrices to use.  If it is zero, */
00230 /*          ZDRVBD does nothing.  It must be at least zero. */
00231 
00232 /*  MM      (input) INTEGER array, dimension (NSIZES) */
00233 /*          An array containing the matrix "heights" to be used.  For */
00234 /*          each j=1,...,NSIZES, if MM(j) is zero, then MM(j) and NN(j) */
00235 /*          will be ignored.  The MM(j) values must be at least zero. */
00236 
00237 /*  NN      (input) INTEGER array, dimension (NSIZES) */
00238 /*          An array containing the matrix "widths" to be used.  For */
00239 /*          each j=1,...,NSIZES, if NN(j) is zero, then MM(j) and NN(j) */
00240 /*          will be ignored.  The NN(j) values must be at least zero. */
00241 
00242 /*  NTYPES  (input) INTEGER */
00243 /*          The number of elements in DOTYPE.   If it is zero, ZDRVBD */
00244 /*          does nothing.  It must be at least zero.  If it is MAXTYP+1 */
00245 /*          and NSIZES is 1, then an additional type, MAXTYP+1 is */
00246 /*          defined, which is to use whatever matrices are in A and B. */
00247 /*          This is only useful if DOTYPE(1:MAXTYP) is .FALSE. and */
00248 /*          DOTYPE(MAXTYP+1) is .TRUE. . */
00249 
00250 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00251 /*          If DOTYPE(j) is .TRUE., then for each size (m,n), a matrix */
00252 /*          of type j will be generated.  If NTYPES is smaller than the */
00253 /*          maximum number of types defined (PARAMETER MAXTYP), then */
00254 /*          types NTYPES+1 through MAXTYP will not be generated.  If */
00255 /*          NTYPES is larger than MAXTYP, DOTYPE(MAXTYP+1) through */
00256 /*          DOTYPE(NTYPES) will be ignored. */
00257 
00258 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00259 /*          On entry ISEED specifies the seed of the random number */
00260 /*          generator. The array elements should be between 0 and 4095; */
00261 /*          if not they will be reduced mod 4096.  Also, ISEED(4) must */
00262 /*          be odd.  The random number generator uses a linear */
00263 /*          congruential sequence limited to small integers, and so */
00264 /*          should produce machine independent random numbers. The */
00265 /*          values of ISEED are changed on exit, and can be used in the */
00266 /*          next call to ZDRVBD to continue the same random number */
00267 /*          sequence. */
00268 
00269 /*  THRESH  (input) DOUBLE PRECISION */
00270 /*          A test will count as "failed" if the "error", computed as */
00271 /*          described above, exceeds THRESH.  Note that the error */
00272 /*          is scaled to be O(1), so THRESH should be a reasonably */
00273 /*          small multiple of 1, e.g., 10 or 100.  In particular, */
00274 /*          it should not depend on the precision (single vs. double) */
00275 /*          or the size of the matrix.  It must be at least zero. */
00276 
00277 /*  NOUNIT  (input) INTEGER */
00278 /*          The FORTRAN unit number for printing out error messages */
00279 /*          (e.g., if a routine returns IINFO not equal to 0.) */
00280 
00281 /*  A       (output) COMPLEX*16 array, dimension (LDA,max(NN)) */
00282 /*          Used to hold the matrix whose singular values are to be */
00283 /*          computed.  On exit, A contains the last matrix actually */
00284 /*          used. */
00285 
00286 /*  LDA     (input) INTEGER */
00287 /*          The leading dimension of A.  It must be at */
00288 /*          least 1 and at least max( MM ). */
00289 
00290 /*  U       (output) COMPLEX*16 array, dimension (LDU,max(MM)) */
00291 /*          Used to hold the computed matrix of right singular vectors. */
00292 /*          On exit, U contains the last such vectors actually computed. */
00293 
00294 /*  LDU     (input) INTEGER */
00295 /*          The leading dimension of U.  It must be at */
00296 /*          least 1 and at least max( MM ). */
00297 
00298 /*  VT      (output) COMPLEX*16 array, dimension (LDVT,max(NN)) */
00299 /*          Used to hold the computed matrix of left singular vectors. */
00300 /*          On exit, VT contains the last such vectors actually computed. */
00301 
00302 /*  LDVT    (input) INTEGER */
00303 /*          The leading dimension of VT.  It must be at */
00304 /*          least 1 and at least max( NN ). */
00305 
00306 /*  ASAV    (output) COMPLEX*16 array, dimension (LDA,max(NN)) */
00307 /*          Used to hold a different copy of the matrix whose singular */
00308 /*          values are to be computed.  On exit, A contains the last */
00309 /*          matrix actually used. */
00310 
00311 /*  USAV    (output) COMPLEX*16 array, dimension (LDU,max(MM)) */
00312 /*          Used to hold a different copy of the computed matrix of */
00313 /*          right singular vectors. On exit, USAV contains the last such */
00314 /*          vectors actually computed. */
00315 
00316 /*  VTSAV   (output) COMPLEX*16 array, dimension (LDVT,max(NN)) */
00317 /*          Used to hold a different copy of the computed matrix of */
00318 /*          left singular vectors. On exit, VTSAV contains the last such */
00319 /*          vectors actually computed. */
00320 
00321 /*  S       (output) DOUBLE PRECISION array, dimension (max(min(MM,NN))) */
00322 /*          Contains the computed singular values. */
00323 
00324 /*  SSAV    (output) DOUBLE PRECISION array, dimension (max(min(MM,NN))) */
00325 /*          Contains another copy of the computed singular values. */
00326 
00327 /*  E       (output) DOUBLE PRECISION array, dimension (max(min(MM,NN))) */
00328 /*          Workspace for ZGESVD. */
00329 
00330 /*  WORK    (workspace) COMPLEX*16 array, dimension (LWORK) */
00331 
00332 /*  LWORK   (input) INTEGER */
00333 /*          The number of entries in WORK.  This must be at least */
00334 /*          MAX(3*MIN(M,N)+MAX(M,N)**2,5*MIN(M,N),3*MAX(M,N)) for all */
00335 /*          pairs  (M,N)=(MM(j),NN(j)) */
00336 
00337 /*  RWORK   (workspace) DOUBLE PRECISION array, */
00338 /*                      dimension ( 5*max(max(MM,NN)) ) */
00339 
00340 /*  IWORK   (workspace) INTEGER array, dimension at least 8*min(M,N) */
00341 
00342 /*  RESULT  (output) DOUBLE PRECISION array, dimension (7) */
00343 /*          The values computed by the 7 tests described above. */
00344 /*          The values are currently limited to 1/ULP, to avoid */
00345 /*          overflow. */
00346 
00347 /*  INFO    (output) INTEGER */
00348 /*          If 0, then everything ran OK. */
00349 /*           -1: NSIZES < 0 */
00350 /*           -2: Some MM(j) < 0 */
00351 /*           -3: Some NN(j) < 0 */
00352 /*           -4: NTYPES < 0 */
00353 /*           -7: THRESH < 0 */
00354 /*          -10: LDA < 1 or LDA < MMAX, where MMAX is max( MM(j) ). */
00355 /*          -12: LDU < 1 or LDU < MMAX. */
00356 /*          -14: LDVT < 1 or LDVT < NMAX, where NMAX is max( NN(j) ). */
00357 /*          -21: LWORK too small. */
00358 /*          If  ZLATMS, or ZGESVD returns an error code, the */
00359 /*              absolute value of it is returned. */
00360 
00361 /*  ===================================================================== */
00362 
00363 /*     .. Parameters .. */
00364 /*     .. */
00365 /*     .. Local Scalars .. */
00366 /*     .. */
00367 /*     .. Local Arrays .. */
00368 /*     .. */
00369 /*     .. External Functions .. */
00370 /*     .. */
00371 /*     .. External Subroutines .. */
00372 /*     .. */
00373 /*     .. Intrinsic Functions .. */
00374 /*     .. */
00375 /*     .. Data statements .. */
00376     /* Parameter adjustments */
00377     --mm;
00378     --nn;
00379     --dotype;
00380     --iseed;
00381     asav_dim1 = *lda;
00382     asav_offset = 1 + asav_dim1;
00383     asav -= asav_offset;
00384     a_dim1 = *lda;
00385     a_offset = 1 + a_dim1;
00386     a -= a_offset;
00387     usav_dim1 = *ldu;
00388     usav_offset = 1 + usav_dim1;
00389     usav -= usav_offset;
00390     u_dim1 = *ldu;
00391     u_offset = 1 + u_dim1;
00392     u -= u_offset;
00393     vtsav_dim1 = *ldvt;
00394     vtsav_offset = 1 + vtsav_dim1;
00395     vtsav -= vtsav_offset;
00396     vt_dim1 = *ldvt;
00397     vt_offset = 1 + vt_dim1;
00398     vt -= vt_offset;
00399     --s;
00400     --ssav;
00401     --e;
00402     --work;
00403     --rwork;
00404     --iwork;
00405 
00406     /* Function Body */
00407 /*     .. */
00408 /*     .. Executable Statements .. */
00409 
00410 /*     Check for errors */
00411 
00412     *info = 0;
00413 
00414 /*     Important constants */
00415 
00416     nerrs = 0;
00417     ntestt = 0;
00418     ntestf = 0;
00419     badmm = FALSE_;
00420     badnn = FALSE_;
00421     mmax = 1;
00422     nmax = 1;
00423     mnmax = 1;
00424     minwrk = 1;
00425     i__1 = *nsizes;
00426     for (j = 1; j <= i__1; ++j) {
00427 /* Computing MAX */
00428         i__2 = mmax, i__3 = mm[j];
00429         mmax = max(i__2,i__3);
00430         if (mm[j] < 0) {
00431             badmm = TRUE_;
00432         }
00433 /* Computing MAX */
00434         i__2 = nmax, i__3 = nn[j];
00435         nmax = max(i__2,i__3);
00436         if (nn[j] < 0) {
00437             badnn = TRUE_;
00438         }
00439 /* Computing MAX */
00440 /* Computing MIN */
00441         i__4 = mm[j], i__5 = nn[j];
00442         i__2 = mnmax, i__3 = min(i__4,i__5);
00443         mnmax = max(i__2,i__3);
00444 /* Computing MAX */
00445 /* Computing MAX */
00446 /* Computing MIN */
00447         i__6 = mm[j], i__7 = nn[j];
00448 /* Computing MAX */
00449         i__9 = mm[j], i__10 = nn[j];
00450 /* Computing 2nd power */
00451         i__8 = max(i__9,i__10);
00452 /* Computing MIN */
00453         i__11 = mm[j], i__12 = nn[j];
00454 /* Computing MAX */
00455         i__13 = mm[j], i__14 = nn[j];
00456         i__4 = min(i__6,i__7) * 3 + i__8 * i__8, i__5 = min(i__11,i__12) * 5, 
00457                 i__4 = max(i__4,i__5), i__5 = max(i__13,i__14) * 3;
00458         i__2 = minwrk, i__3 = max(i__4,i__5);
00459         minwrk = max(i__2,i__3);
00460 /* L10: */
00461     }
00462 
00463 /*     Check for errors */
00464 
00465     if (*nsizes < 0) {
00466         *info = -1;
00467     } else if (badmm) {
00468         *info = -2;
00469     } else if (badnn) {
00470         *info = -3;
00471     } else if (*ntypes < 0) {
00472         *info = -4;
00473     } else if (*lda < max(1,mmax)) {
00474         *info = -10;
00475     } else if (*ldu < max(1,mmax)) {
00476         *info = -12;
00477     } else if (*ldvt < max(1,nmax)) {
00478         *info = -14;
00479     } else if (minwrk > *lwork) {
00480         *info = -21;
00481     }
00482 
00483     if (*info != 0) {
00484         i__1 = -(*info);
00485         xerbla_("ZDRVBD", &i__1);
00486         return 0;
00487     }
00488 
00489 /*     Quick return if nothing to do */
00490 
00491     if (*nsizes == 0 || *ntypes == 0) {
00492         return 0;
00493     }
00494 
00495 /*     More Important constants */
00496 
00497     unfl = dlamch_("S");
00498     ovfl = 1. / unfl;
00499     ulp = dlamch_("E");
00500     ulpinv = 1. / ulp;
00501 
00502 /*     Loop over sizes, types */
00503 
00504     nerrs = 0;
00505 
00506     i__1 = *nsizes;
00507     for (jsize = 1; jsize <= i__1; ++jsize) {
00508         m = mm[jsize];
00509         n = nn[jsize];
00510         mnmin = min(m,n);
00511 
00512         if (*nsizes != 1) {
00513             mtypes = min(5,*ntypes);
00514         } else {
00515             mtypes = min(6,*ntypes);
00516         }
00517 
00518         i__2 = mtypes;
00519         for (jtype = 1; jtype <= i__2; ++jtype) {
00520             if (! dotype[jtype]) {
00521                 goto L170;
00522             }
00523             ntest = 0;
00524 
00525             for (j = 1; j <= 4; ++j) {
00526                 ioldsd[j - 1] = iseed[j];
00527 /* L20: */
00528             }
00529 
00530 /*           Compute "A" */
00531 
00532             if (mtypes > 5) {
00533                 goto L50;
00534             }
00535 
00536             if (jtype == 1) {
00537 
00538 /*              Zero matrix */
00539 
00540                 zlaset_("Full", &m, &n, &c_b1, &c_b1, &a[a_offset], lda);
00541                 i__3 = min(m,n);
00542                 for (i__ = 1; i__ <= i__3; ++i__) {
00543                     s[i__] = 0.;
00544 /* L30: */
00545                 }
00546 
00547             } else if (jtype == 2) {
00548 
00549 /*              Identity matrix */
00550 
00551                 zlaset_("Full", &m, &n, &c_b1, &c_b2, &a[a_offset], lda);
00552                 i__3 = min(m,n);
00553                 for (i__ = 1; i__ <= i__3; ++i__) {
00554                     s[i__] = 1.;
00555 /* L40: */
00556                 }
00557 
00558             } else {
00559 
00560 /*              (Scaled) random matrix */
00561 
00562                 if (jtype == 3) {
00563                     anorm = 1.;
00564                 }
00565                 if (jtype == 4) {
00566                     anorm = unfl / ulp;
00567                 }
00568                 if (jtype == 5) {
00569                     anorm = ovfl * ulp;
00570                 }
00571                 d__1 = (doublereal) mnmin;
00572                 i__3 = m - 1;
00573                 i__4 = n - 1;
00574                 zlatms_(&m, &n, "U", &iseed[1], "N", &s[1], &c__4, &d__1, &
00575                         anorm, &i__3, &i__4, "N", &a[a_offset], lda, &work[1], 
00576                          &iinfo);
00577                 if (iinfo != 0) {
00578                     io___27.ciunit = *nounit;
00579                     s_wsfe(&io___27);
00580                     do_fio(&c__1, "Generator", (ftnlen)9);
00581                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00582                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00583                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00584                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00585                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00586                             ;
00587                     e_wsfe();
00588                     *info = abs(iinfo);
00589                     return 0;
00590                 }
00591             }
00592 
00593 L50:
00594             zlacpy_("F", &m, &n, &a[a_offset], lda, &asav[asav_offset], lda);
00595 
00596 /*           Do for minimal and adequate (for blocking) workspace */
00597 
00598             for (iwspc = 1; iwspc <= 4; ++iwspc) {
00599 
00600 /*              Test for ZGESVD */
00601 
00602                 iwtmp = (min(m,n) << 1) + max(m,n);
00603                 lswork = iwtmp + (iwspc - 1) * (*lwork - iwtmp) / 3;
00604                 lswork = min(lswork,*lwork);
00605                 lswork = max(lswork,1);
00606                 if (iwspc == 4) {
00607                     lswork = *lwork;
00608                 }
00609 
00610                 for (j = 1; j <= 14; ++j) {
00611                     result[j - 1] = -1.;
00612 /* L60: */
00613                 }
00614 
00615 /*              Factorize A */
00616 
00617                 if (iwspc > 1) {
00618                     zlacpy_("F", &m, &n, &asav[asav_offset], lda, &a[a_offset]
00619 , lda);
00620                 }
00621                 zgesvd_("A", "A", &m, &n, &a[a_offset], lda, &ssav[1], &usav[
00622                         usav_offset], ldu, &vtsav[vtsav_offset], ldvt, &work[
00623                         1], &lswork, &rwork[1], &iinfo);
00624                 if (iinfo != 0) {
00625                     io___32.ciunit = *nounit;
00626                     s_wsfe(&io___32);
00627                     do_fio(&c__1, "GESVD", (ftnlen)5);
00628                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00629                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00630                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00631                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00632                     do_fio(&c__1, (char *)&lswork, (ftnlen)sizeof(integer));
00633                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00634                             ;
00635                     e_wsfe();
00636                     *info = abs(iinfo);
00637                     return 0;
00638                 }
00639 
00640 /*              Do tests 1--4 */
00641 
00642                 zbdt01_(&m, &n, &c__0, &asav[asav_offset], lda, &usav[
00643                         usav_offset], ldu, &ssav[1], &e[1], &vtsav[
00644                         vtsav_offset], ldvt, &work[1], &rwork[1], result);
00645                 if (m != 0 && n != 0) {
00646                     zunt01_("Columns", &mnmin, &m, &usav[usav_offset], ldu, &
00647                             work[1], lwork, &rwork[1], &result[1]);
00648                     zunt01_("Rows", &mnmin, &n, &vtsav[vtsav_offset], ldvt, &
00649                             work[1], lwork, &rwork[1], &result[2]);
00650                 }
00651                 result[3] = 0.;
00652                 i__3 = mnmin - 1;
00653                 for (i__ = 1; i__ <= i__3; ++i__) {
00654                     if (ssav[i__] < ssav[i__ + 1]) {
00655                         result[3] = ulpinv;
00656                     }
00657                     if (ssav[i__] < 0.) {
00658                         result[3] = ulpinv;
00659                     }
00660 /* L70: */
00661                 }
00662                 if (mnmin >= 1) {
00663                     if (ssav[mnmin] < 0.) {
00664                         result[3] = ulpinv;
00665                     }
00666                 }
00667 
00668 /*              Do partial SVDs, comparing to SSAV, USAV, and VTSAV */
00669 
00670                 result[4] = 0.;
00671                 result[5] = 0.;
00672                 result[6] = 0.;
00673                 for (iju = 0; iju <= 3; ++iju) {
00674                     for (ijvt = 0; ijvt <= 3; ++ijvt) {
00675                         if (iju == 3 && ijvt == 3 || iju == 1 && ijvt == 1) {
00676                             goto L90;
00677                         }
00678                         *(unsigned char *)jobu = *(unsigned char *)&cjob[iju];
00679                         *(unsigned char *)jobvt = *(unsigned char *)&cjob[
00680                                 ijvt];
00681                         zlacpy_("F", &m, &n, &asav[asav_offset], lda, &a[
00682                                 a_offset], lda);
00683                         zgesvd_(jobu, jobvt, &m, &n, &a[a_offset], lda, &s[1], 
00684                                  &u[u_offset], ldu, &vt[vt_offset], ldvt, &
00685                                 work[1], &lswork, &rwork[1], &iinfo);
00686 
00687 /*                    Compare U */
00688 
00689                         dif = 0.;
00690                         if (m > 0 && n > 0) {
00691                             if (iju == 1) {
00692                                 zunt03_("C", &m, &mnmin, &m, &mnmin, &usav[
00693                                         usav_offset], ldu, &a[a_offset], lda, 
00694                                         &work[1], lwork, &rwork[1], &dif, &
00695                                         iinfo);
00696                             } else if (iju == 2) {
00697                                 zunt03_("C", &m, &mnmin, &m, &mnmin, &usav[
00698                                         usav_offset], ldu, &u[u_offset], ldu, 
00699                                         &work[1], lwork, &rwork[1], &dif, &
00700                                         iinfo);
00701                             } else if (iju == 3) {
00702                                 zunt03_("C", &m, &m, &m, &mnmin, &usav[
00703                                         usav_offset], ldu, &u[u_offset], ldu, 
00704                                         &work[1], lwork, &rwork[1], &dif, &
00705                                         iinfo);
00706                             }
00707                         }
00708                         result[4] = max(result[4],dif);
00709 
00710 /*                    Compare VT */
00711 
00712                         dif = 0.;
00713                         if (m > 0 && n > 0) {
00714                             if (ijvt == 1) {
00715                                 zunt03_("R", &n, &mnmin, &n, &mnmin, &vtsav[
00716                                         vtsav_offset], ldvt, &a[a_offset], 
00717                                         lda, &work[1], lwork, &rwork[1], &dif, 
00718                                          &iinfo);
00719                             } else if (ijvt == 2) {
00720                                 zunt03_("R", &n, &mnmin, &n, &mnmin, &vtsav[
00721                                         vtsav_offset], ldvt, &vt[vt_offset], 
00722                                         ldvt, &work[1], lwork, &rwork[1], &
00723                                         dif, &iinfo);
00724                             } else if (ijvt == 3) {
00725                                 zunt03_("R", &n, &n, &n, &mnmin, &vtsav[
00726                                         vtsav_offset], ldvt, &vt[vt_offset], 
00727                                         ldvt, &work[1], lwork, &rwork[1], &
00728                                         dif, &iinfo);
00729                             }
00730                         }
00731                         result[5] = max(result[5],dif);
00732 
00733 /*                    Compare S */
00734 
00735                         dif = 0.;
00736 /* Computing MAX */
00737                         d__1 = (doublereal) mnmin * ulp * s[1], d__2 = 
00738                                 dlamch_("Safe minimum");
00739                         div = max(d__1,d__2);
00740                         i__3 = mnmin - 1;
00741                         for (i__ = 1; i__ <= i__3; ++i__) {
00742                             if (ssav[i__] < ssav[i__ + 1]) {
00743                                 dif = ulpinv;
00744                             }
00745                             if (ssav[i__] < 0.) {
00746                                 dif = ulpinv;
00747                             }
00748 /* Computing MAX */
00749                             d__2 = dif, d__3 = (d__1 = ssav[i__] - s[i__], 
00750                                     abs(d__1)) / div;
00751                             dif = max(d__2,d__3);
00752 /* L80: */
00753                         }
00754                         result[6] = max(result[6],dif);
00755 L90:
00756                         ;
00757                     }
00758 /* L100: */
00759                 }
00760 
00761 /*              Test for ZGESDD */
00762 
00763                 iwtmp = (mnmin << 1) * mnmin + (mnmin << 1) + max(m,n);
00764                 lswork = iwtmp + (iwspc - 1) * (*lwork - iwtmp) / 3;
00765                 lswork = min(lswork,*lwork);
00766                 lswork = max(lswork,1);
00767                 if (iwspc == 4) {
00768                     lswork = *lwork;
00769                 }
00770 
00771 /*              Factorize A */
00772 
00773                 zlacpy_("F", &m, &n, &asav[asav_offset], lda, &a[a_offset], 
00774                         lda);
00775                 zgesdd_("A", &m, &n, &a[a_offset], lda, &ssav[1], &usav[
00776                         usav_offset], ldu, &vtsav[vtsav_offset], ldvt, &work[
00777                         1], &lswork, &rwork[1], &iwork[1], &iinfo);
00778                 if (iinfo != 0) {
00779                     io___39.ciunit = *nounit;
00780                     s_wsfe(&io___39);
00781                     do_fio(&c__1, "GESDD", (ftnlen)5);
00782                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00783                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00784                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00785                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00786                     do_fio(&c__1, (char *)&lswork, (ftnlen)sizeof(integer));
00787                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00788                             ;
00789                     e_wsfe();
00790                     *info = abs(iinfo);
00791                     return 0;
00792                 }
00793 
00794 /*              Do tests 1--4 */
00795 
00796                 zbdt01_(&m, &n, &c__0, &asav[asav_offset], lda, &usav[
00797                         usav_offset], ldu, &ssav[1], &e[1], &vtsav[
00798                         vtsav_offset], ldvt, &work[1], &rwork[1], &result[7]);
00799                 if (m != 0 && n != 0) {
00800                     zunt01_("Columns", &mnmin, &m, &usav[usav_offset], ldu, &
00801                             work[1], lwork, &rwork[1], &result[8]);
00802                     zunt01_("Rows", &mnmin, &n, &vtsav[vtsav_offset], ldvt, &
00803                             work[1], lwork, &rwork[1], &result[9]);
00804                 }
00805                 result[10] = 0.;
00806                 i__3 = mnmin - 1;
00807                 for (i__ = 1; i__ <= i__3; ++i__) {
00808                     if (ssav[i__] < ssav[i__ + 1]) {
00809                         result[10] = ulpinv;
00810                     }
00811                     if (ssav[i__] < 0.) {
00812                         result[10] = ulpinv;
00813                     }
00814 /* L110: */
00815                 }
00816                 if (mnmin >= 1) {
00817                     if (ssav[mnmin] < 0.) {
00818                         result[10] = ulpinv;
00819                     }
00820                 }
00821 
00822 /*              Do partial SVDs, comparing to SSAV, USAV, and VTSAV */
00823 
00824                 result[11] = 0.;
00825                 result[12] = 0.;
00826                 result[13] = 0.;
00827                 for (ijq = 0; ijq <= 2; ++ijq) {
00828                     *(unsigned char *)jobq = *(unsigned char *)&cjob[ijq];
00829                     zlacpy_("F", &m, &n, &asav[asav_offset], lda, &a[a_offset]
00830 , lda);
00831                     zgesdd_(jobq, &m, &n, &a[a_offset], lda, &s[1], &u[
00832                             u_offset], ldu, &vt[vt_offset], ldvt, &work[1], &
00833                             lswork, &rwork[1], &iwork[1], &iinfo);
00834 
00835 /*                 Compare U */
00836 
00837                     dif = 0.;
00838                     if (m > 0 && n > 0) {
00839                         if (ijq == 1) {
00840                             if (m >= n) {
00841                                 zunt03_("C", &m, &mnmin, &m, &mnmin, &usav[
00842                                         usav_offset], ldu, &a[a_offset], lda, 
00843                                         &work[1], lwork, &rwork[1], &dif, &
00844                                         iinfo);
00845                             } else {
00846                                 zunt03_("C", &m, &mnmin, &m, &mnmin, &usav[
00847                                         usav_offset], ldu, &u[u_offset], ldu, 
00848                                         &work[1], lwork, &rwork[1], &dif, &
00849                                         iinfo);
00850                             }
00851                         } else if (ijq == 2) {
00852                             zunt03_("C", &m, &mnmin, &m, &mnmin, &usav[
00853                                     usav_offset], ldu, &u[u_offset], ldu, &
00854                                     work[1], lwork, &rwork[1], &dif, &iinfo);
00855                         }
00856                     }
00857                     result[11] = max(result[11],dif);
00858 
00859 /*                 Compare VT */
00860 
00861                     dif = 0.;
00862                     if (m > 0 && n > 0) {
00863                         if (ijq == 1) {
00864                             if (m >= n) {
00865                                 zunt03_("R", &n, &mnmin, &n, &mnmin, &vtsav[
00866                                         vtsav_offset], ldvt, &vt[vt_offset], 
00867                                         ldvt, &work[1], lwork, &rwork[1], &
00868                                         dif, &iinfo);
00869                             } else {
00870                                 zunt03_("R", &n, &mnmin, &n, &mnmin, &vtsav[
00871                                         vtsav_offset], ldvt, &a[a_offset], 
00872                                         lda, &work[1], lwork, &rwork[1], &dif, 
00873                                          &iinfo);
00874                             }
00875                         } else if (ijq == 2) {
00876                             zunt03_("R", &n, &mnmin, &n, &mnmin, &vtsav[
00877                                     vtsav_offset], ldvt, &vt[vt_offset], ldvt, 
00878                                      &work[1], lwork, &rwork[1], &dif, &iinfo);
00879                         }
00880                     }
00881                     result[12] = max(result[12],dif);
00882 
00883 /*                 Compare S */
00884 
00885                     dif = 0.;
00886 /* Computing MAX */
00887                     d__1 = (doublereal) mnmin * ulp * s[1], d__2 = dlamch_(
00888                             "Safe minimum");
00889                     div = max(d__1,d__2);
00890                     i__3 = mnmin - 1;
00891                     for (i__ = 1; i__ <= i__3; ++i__) {
00892                         if (ssav[i__] < ssav[i__ + 1]) {
00893                             dif = ulpinv;
00894                         }
00895                         if (ssav[i__] < 0.) {
00896                             dif = ulpinv;
00897                         }
00898 /* Computing MAX */
00899                         d__2 = dif, d__3 = (d__1 = ssav[i__] - s[i__], abs(
00900                                 d__1)) / div;
00901                         dif = max(d__2,d__3);
00902 /* L120: */
00903                     }
00904                     result[13] = max(result[13],dif);
00905 /* L130: */
00906                 }
00907 
00908 /*              End of Loop -- Check for RESULT(j) > THRESH */
00909 
00910                 ntest = 0;
00911                 nfail = 0;
00912                 for (j = 1; j <= 14; ++j) {
00913                     if (result[j - 1] >= 0.) {
00914                         ++ntest;
00915                     }
00916                     if (result[j - 1] >= *thresh) {
00917                         ++nfail;
00918                     }
00919 /* L140: */
00920                 }
00921 
00922                 if (nfail > 0) {
00923                     ++ntestf;
00924                 }
00925                 if (ntestf == 1) {
00926                     io___43.ciunit = *nounit;
00927                     s_wsfe(&io___43);
00928                     e_wsfe();
00929                     io___44.ciunit = *nounit;
00930                     s_wsfe(&io___44);
00931                     do_fio(&c__1, (char *)&(*thresh), (ftnlen)sizeof(
00932                             doublereal));
00933                     e_wsfe();
00934                     ntestf = 2;
00935                 }
00936 
00937                 for (j = 1; j <= 14; ++j) {
00938                     if (result[j - 1] >= *thresh) {
00939                         io___45.ciunit = *nounit;
00940                         s_wsfe(&io___45);
00941                         do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00942                         do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00943                         do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer))
00944                                 ;
00945                         do_fio(&c__1, (char *)&iwspc, (ftnlen)sizeof(integer))
00946                                 ;
00947                         do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(
00948                                 integer));
00949                         do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
00950                         do_fio(&c__1, (char *)&result[j - 1], (ftnlen)sizeof(
00951                                 doublereal));
00952                         e_wsfe();
00953                     }
00954 /* L150: */
00955                 }
00956 
00957                 nerrs += nfail;
00958                 ntestt += ntest;
00959 
00960 /* L160: */
00961             }
00962 
00963 L170:
00964             ;
00965         }
00966 /* L180: */
00967     }
00968 
00969 /*     Summary */
00970 
00971     alasvm_("ZBD", nounit, &nerrs, &ntestt, &c__0);
00972 
00973 
00974     return 0;
00975 
00976 /*     End of ZDRVBD */
00977 
00978 } /* zdrvbd_ */


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