dchkbd.c
Go to the documentation of this file.
00001 /* dchkbd.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, nunit;
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_b20 = 0.;
00034 static integer c__0 = 0;
00035 static integer c__6 = 6;
00036 static doublereal c_b37 = 1.;
00037 static integer c__1 = 1;
00038 static integer c__2 = 2;
00039 static integer c__4 = 4;
00040 
00041 /* Subroutine */ int dchkbd_(integer *nsizes, integer *mval, integer *nval, 
00042         integer *ntypes, logical *dotype, integer *nrhs, integer *iseed, 
00043         doublereal *thresh, doublereal *a, integer *lda, doublereal *bd, 
00044         doublereal *be, doublereal *s1, doublereal *s2, doublereal *x, 
00045         integer *ldx, doublereal *y, doublereal *z__, doublereal *q, integer *
00046         ldq, doublereal *pt, integer *ldpt, doublereal *u, doublereal *vt, 
00047         doublereal *work, integer *lwork, integer *iwork, integer *nout, 
00048         integer *info)
00049 {
00050     /* Initialized data */
00051 
00052     static integer ktype[16] = { 1,2,4,4,4,4,4,6,6,6,6,6,9,9,9,10 };
00053     static integer kmagn[16] = { 1,1,1,1,1,2,3,1,1,1,2,3,1,2,3,0 };
00054     static integer kmode[16] = { 0,0,4,3,1,4,4,4,3,1,4,4,0,0,0,0 };
00055 
00056     /* Format strings */
00057     static char fmt_9998[] = "(\002 DCHKBD: \002,a,\002 returned INFO=\002,i"
00058             "6,\002.\002,/9x,\002M=\002,i6,\002, N=\002,i6,\002, JTYPE=\002,i"
00059             "6,\002, ISEED=(\002,3(i5,\002,\002),i5,\002)\002)";
00060     static char fmt_9999[] = "(\002 M=\002,i5,\002, N=\002,i5,\002, type "
00061             "\002,i2,\002, seed=\002,4(i4,\002,\002),\002 test(\002,i2,\002)"
00062             "=\002,g11.4)";
00063 
00064     /* System generated locals */
00065     integer a_dim1, a_offset, pt_dim1, pt_offset, q_dim1, q_offset, u_dim1, 
00066             u_offset, vt_dim1, vt_offset, x_dim1, x_offset, y_dim1, y_offset, 
00067             z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7;
00068     doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7;
00069 
00070     /* Builtin functions */
00071     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00072     double log(doublereal), sqrt(doublereal), exp(doublereal);
00073     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00074 
00075     /* Local variables */
00076     integer i__, j, m, n, mq;
00077     doublereal dum[1], ulp, cond;
00078     integer jcol;
00079     char path[3];
00080     integer idum[1], mmax, nmax;
00081     doublereal unfl, ovfl;
00082     char uplo[1];
00083     doublereal temp1, temp2;
00084     extern /* Subroutine */ int dbdt01_(integer *, integer *, integer *, 
00085             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00086             doublereal *, doublereal *, integer *, doublereal *, doublereal *)
00087             , dbdt02_(integer *, integer *, doublereal *, integer *, 
00088             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00089             doublereal *);
00090     logical badmm;
00091     extern /* Subroutine */ int dbdt03_(char *, integer *, integer *, 
00092             doublereal *, doublereal *, doublereal *, integer *, doublereal *, 
00093              doublereal *, integer *, doublereal *, doublereal *);
00094     logical badnn;
00095     integer nfail;
00096     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
00097             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00098             integer *, doublereal *, doublereal *, integer *);
00099     integer imode;
00100     doublereal dumma[1];
00101     integer iinfo;
00102     extern /* Subroutine */ int dort01_(char *, integer *, integer *, 
00103             doublereal *, integer *, doublereal *, integer *, doublereal *);
00104     doublereal anorm;
00105     integer mnmin;
00106     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00107             doublereal *, integer *);
00108     integer mnmax, jsize, itype, jtype, ntest;
00109     extern /* Subroutine */ int dlahd2_(integer *, char *);
00110     integer log2ui;
00111     extern /* Subroutine */ int dlabad_(doublereal *, doublereal *);
00112     logical bidiag;
00113     extern /* Subroutine */ int dbdsdc_(char *, char *, integer *, doublereal 
00114             *, doublereal *, doublereal *, integer *, doublereal *, integer *, 
00115              doublereal *, integer *, doublereal *, integer *, integer *), dgebrd_(integer *, integer *, doublereal *, 
00116             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00117              doublereal *, integer *, integer *);
00118     extern doublereal dlamch_(char *), dlarnd_(integer *, integer *);
00119     extern /* Subroutine */ int dlacpy_(char *, integer *, integer *, 
00120             doublereal *, integer *, doublereal *, integer *), 
00121             dlaset_(char *, integer *, integer *, doublereal *, doublereal *, 
00122             doublereal *, integer *);
00123     integer ioldsd[4];
00124     extern /* Subroutine */ int dbdsqr_(char *, integer *, integer *, integer 
00125             *, integer *, doublereal *, doublereal *, doublereal *, integer *, 
00126              doublereal *, integer *, doublereal *, integer *, doublereal *, 
00127             integer *), dorgbr_(char *, integer *, integer *, integer 
00128             *, doublereal *, integer *, doublereal *, doublereal *, integer *, 
00129              integer *), xerbla_(char *, integer *), alasum_(
00130             char *, integer *, integer *, integer *, integer *), 
00131             dlatmr_(integer *, integer *, char *, integer *, char *, 
00132             doublereal *, integer *, doublereal *, doublereal *, char *, char 
00133             *, doublereal *, integer *, doublereal *, doublereal *, integer *, 
00134              doublereal *, char *, integer *, integer *, integer *, 
00135             doublereal *, doublereal *, char *, doublereal *, integer *, 
00136             integer *, integer *), dlatms_(integer *, integer *, char *, integer *, char *, 
00137             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00138             integer *, char *, doublereal *, integer *, doublereal *, integer 
00139             *);
00140     doublereal amninv;
00141     integer minwrk;
00142     doublereal rtunfl, rtovfl, ulpinv, result[19];
00143     integer mtypes;
00144 
00145     /* Fortran I/O blocks */
00146     static cilist io___39 = { 0, 0, 0, fmt_9998, 0 };
00147     static cilist io___40 = { 0, 0, 0, fmt_9998, 0 };
00148     static cilist io___42 = { 0, 0, 0, fmt_9998, 0 };
00149     static cilist io___43 = { 0, 0, 0, fmt_9998, 0 };
00150     static cilist io___44 = { 0, 0, 0, fmt_9998, 0 };
00151     static cilist io___45 = { 0, 0, 0, fmt_9998, 0 };
00152     static cilist io___51 = { 0, 0, 0, fmt_9998, 0 };
00153     static cilist io___52 = { 0, 0, 0, fmt_9998, 0 };
00154     static cilist io___53 = { 0, 0, 0, fmt_9999, 0 };
00155 
00156 
00157 
00158 /*  -- LAPACK test routine (version 3.1) -- */
00159 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00160 /*     November 2006 */
00161 
00162 /*     .. Scalar Arguments .. */
00163 /*     .. */
00164 /*     .. Array Arguments .. */
00165 /*     .. */
00166 
00167 /*  Purpose */
00168 /*  ======= */
00169 
00170 /*  DCHKBD checks the singular value decomposition (SVD) routines. */
00171 
00172 /*  DGEBRD reduces a real general m by n matrix A to upper or lower */
00173 /*  bidiagonal form B by an orthogonal transformation:  Q' * A * P = B */
00174 /*  (or A = Q * B * P').  The matrix B is upper bidiagonal if m >= n */
00175 /*  and lower bidiagonal if m < n. */
00176 
00177 /*  DORGBR generates the orthogonal matrices Q and P' from DGEBRD. */
00178 /*  Note that Q and P are not necessarily square. */
00179 
00180 /*  DBDSQR computes the singular value decomposition of the bidiagonal */
00181 /*  matrix B as B = U S V'.  It is called three times to compute */
00182 /*     1)  B = U S1 V', where S1 is the diagonal matrix of singular */
00183 /*         values and the columns of the matrices U and V are the left */
00184 /*         and right singular vectors, respectively, of B. */
00185 /*     2)  Same as 1), but the singular values are stored in S2 and the */
00186 /*         singular vectors are not computed. */
00187 /*     3)  A = (UQ) S (P'V'), the SVD of the original matrix A. */
00188 /*  In addition, DBDSQR has an option to apply the left orthogonal matrix */
00189 /*  U to a matrix X, useful in least squares applications. */
00190 
00191 /*  DBDSDC computes the singular value decomposition of the bidiagonal */
00192 /*  matrix B as B = U S V' using divide-and-conquer. It is called twice */
00193 /*  to compute */
00194 /*     1) B = U S1 V', where S1 is the diagonal matrix of singular */
00195 /*         values and the columns of the matrices U and V are the left */
00196 /*         and right singular vectors, respectively, of B. */
00197 /*     2) Same as 1), but the singular values are stored in S2 and the */
00198 /*         singular vectors are not computed. */
00199 
00200 /*  For each pair of matrix dimensions (M,N) and each selected matrix */
00201 /*  type, an M by N matrix A and an M by NRHS matrix X are generated. */
00202 /*  The problem dimensions are as follows */
00203 /*     A:          M x N */
00204 /*     Q:          M x min(M,N) (but M x M if NRHS > 0) */
00205 /*     P:          min(M,N) x N */
00206 /*     B:          min(M,N) x min(M,N) */
00207 /*     U, V:       min(M,N) x min(M,N) */
00208 /*     S1, S2      diagonal, order min(M,N) */
00209 /*     X:          M x NRHS */
00210 
00211 /*  For each generated matrix, 14 tests are performed: */
00212 
00213 /*  Test DGEBRD and DORGBR */
00214 
00215 /*  (1)   | A - Q B PT | / ( |A| max(M,N) ulp ), PT = P' */
00216 
00217 /*  (2)   | I - Q' Q | / ( M ulp ) */
00218 
00219 /*  (3)   | I - PT PT' | / ( N ulp ) */
00220 
00221 /*  Test DBDSQR on bidiagonal matrix B */
00222 
00223 /*  (4)   | B - U S1 VT | / ( |B| min(M,N) ulp ), VT = V' */
00224 
00225 /*  (5)   | Y - U Z | / ( |Y| max(min(M,N),k) ulp ), where Y = Q' X */
00226 /*                                                   and   Z = U' Y. */
00227 /*  (6)   | I - U' U | / ( min(M,N) ulp ) */
00228 
00229 /*  (7)   | I - VT VT' | / ( min(M,N) ulp ) */
00230 
00231 /*  (8)   S1 contains min(M,N) nonnegative values in decreasing order. */
00232 /*        (Return 0 if true, 1/ULP if false.) */
00233 
00234 /*  (9)   | S1 - S2 | / ( |S1| ulp ), where S2 is computed without */
00235 /*                                    computing U and V. */
00236 
00237 /*  (10)  0 if the true singular values of B are within THRESH of */
00238 /*        those in S1.  2*THRESH if they are not.  (Tested using */
00239 /*        DSVDCH) */
00240 
00241 /*  Test DBDSQR on matrix A */
00242 
00243 /*  (11)  | A - (QU) S (VT PT) | / ( |A| max(M,N) ulp ) */
00244 
00245 /*  (12)  | X - (QU) Z | / ( |X| max(M,k) ulp ) */
00246 
00247 /*  (13)  | I - (QU)'(QU) | / ( M ulp ) */
00248 
00249 /*  (14)  | I - (VT PT) (PT'VT') | / ( N ulp ) */
00250 
00251 /*  Test DBDSDC on bidiagonal matrix B */
00252 
00253 /*  (15)  | B - U S1 VT | / ( |B| min(M,N) ulp ), VT = V' */
00254 
00255 /*  (16)  | I - U' U | / ( min(M,N) ulp ) */
00256 
00257 /*  (17)  | I - VT VT' | / ( min(M,N) ulp ) */
00258 
00259 /*  (18)  S1 contains min(M,N) nonnegative values in decreasing order. */
00260 /*        (Return 0 if true, 1/ULP if false.) */
00261 
00262 /*  (19)  | S1 - S2 | / ( |S1| ulp ), where S2 is computed without */
00263 /*                                    computing U and V. */
00264 /*  The possible matrix types are */
00265 
00266 /*  (1)  The zero matrix. */
00267 /*  (2)  The identity matrix. */
00268 
00269 /*  (3)  A diagonal matrix with evenly spaced entries */
00270 /*       1, ..., ULP  and random signs. */
00271 /*       (ULP = (first number larger than 1) - 1 ) */
00272 /*  (4)  A diagonal matrix with geometrically spaced entries */
00273 /*       1, ..., ULP  and random signs. */
00274 /*  (5)  A diagonal matrix with "clustered" entries 1, ULP, ..., ULP */
00275 /*       and random signs. */
00276 
00277 /*  (6)  Same as (3), but multiplied by SQRT( overflow threshold ) */
00278 /*  (7)  Same as (3), but multiplied by SQRT( underflow threshold ) */
00279 
00280 /*  (8)  A matrix of the form  U D V, where U and V are orthogonal and */
00281 /*       D has evenly spaced entries 1, ..., ULP with random signs */
00282 /*       on the diagonal. */
00283 
00284 /*  (9)  A matrix of the form  U D V, where U and V are orthogonal and */
00285 /*       D has geometrically spaced entries 1, ..., ULP with random */
00286 /*       signs on the diagonal. */
00287 
00288 /*  (10) A matrix of the form  U D V, where U and V are orthogonal and */
00289 /*       D has "clustered" entries 1, ULP,..., ULP with random */
00290 /*       signs on the diagonal. */
00291 
00292 /*  (11) Same as (8), but multiplied by SQRT( overflow threshold ) */
00293 /*  (12) Same as (8), but multiplied by SQRT( underflow threshold ) */
00294 
00295 /*  (13) Rectangular matrix with random entries chosen from (-1,1). */
00296 /*  (14) Same as (13), but multiplied by SQRT( overflow threshold ) */
00297 /*  (15) Same as (13), but multiplied by SQRT( underflow threshold ) */
00298 
00299 /*  Special case: */
00300 /*  (16) A bidiagonal matrix with random entries chosen from a */
00301 /*       logarithmic distribution on [ulp^2,ulp^(-2)]  (I.e., each */
00302 /*       entry is  e^x, where x is chosen uniformly on */
00303 /*       [ 2 log(ulp), -2 log(ulp) ] .)  For *this* type: */
00304 /*       (a) DGEBRD is not called to reduce it to bidiagonal form. */
00305 /*       (b) the bidiagonal is  min(M,N) x min(M,N); if M<N, the */
00306 /*           matrix will be lower bidiagonal, otherwise upper. */
00307 /*       (c) only tests 5--8 and 14 are performed. */
00308 
00309 /*  A subset of the full set of matrix types may be selected through */
00310 /*  the logical array DOTYPE. */
00311 
00312 /*  Arguments */
00313 /*  ========== */
00314 
00315 /*  NSIZES  (input) INTEGER */
00316 /*          The number of values of M and N contained in the vectors */
00317 /*          MVAL and NVAL.  The matrix sizes are used in pairs (M,N). */
00318 
00319 /*  MVAL    (input) INTEGER array, dimension (NM) */
00320 /*          The values of the matrix row dimension M. */
00321 
00322 /*  NVAL    (input) INTEGER array, dimension (NM) */
00323 /*          The values of the matrix column dimension N. */
00324 
00325 /*  NTYPES  (input) INTEGER */
00326 /*          The number of elements in DOTYPE.   If it is zero, DCHKBD */
00327 /*          does nothing.  It must be at least zero.  If it is MAXTYP+1 */
00328 /*          and NSIZES is 1, then an additional type, MAXTYP+1 is */
00329 /*          defined, which is to use whatever matrices are in A and B. */
00330 /*          This is only useful if DOTYPE(1:MAXTYP) is .FALSE. and */
00331 /*          DOTYPE(MAXTYP+1) is .TRUE. . */
00332 
00333 /*  DOTYPE  (input) LOGICAL array, dimension (NTYPES) */
00334 /*          If DOTYPE(j) is .TRUE., then for each size (m,n), a matrix */
00335 /*          of type j will be generated.  If NTYPES is smaller than the */
00336 /*          maximum number of types defined (PARAMETER MAXTYP), then */
00337 /*          types NTYPES+1 through MAXTYP will not be generated.  If */
00338 /*          NTYPES is larger than MAXTYP, DOTYPE(MAXTYP+1) through */
00339 /*          DOTYPE(NTYPES) will be ignored. */
00340 
00341 /*  NRHS    (input) INTEGER */
00342 /*          The number of columns in the "right-hand side" matrices X, Y, */
00343 /*          and Z, used in testing DBDSQR.  If NRHS = 0, then the */
00344 /*          operations on the right-hand side will not be tested. */
00345 /*          NRHS must be at least 0. */
00346 
00347 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00348 /*          On entry ISEED specifies the seed of the random number */
00349 /*          generator. The array elements should be between 0 and 4095; */
00350 /*          if not they will be reduced mod 4096.  Also, ISEED(4) must */
00351 /*          be odd.  The values of ISEED are changed on exit, and can be */
00352 /*          used in the next call to DCHKBD to continue the same random */
00353 /*          number sequence. */
00354 
00355 /*  THRESH  (input) DOUBLE PRECISION */
00356 /*          The threshold value for the test ratios.  A result is */
00357 /*          included in the output file if RESULT >= THRESH.  To have */
00358 /*          every test ratio printed, use THRESH = 0.  Note that the */
00359 /*          expected value of the test ratios is O(1), so THRESH should */
00360 /*          be a reasonably small multiple of 1, e.g., 10 or 100. */
00361 
00362 /*  A       (workspace) DOUBLE PRECISION array, dimension (LDA,NMAX) */
00363 /*          where NMAX is the maximum value of N in NVAL. */
00364 
00365 /*  LDA     (input) INTEGER */
00366 /*          The leading dimension of the array A.  LDA >= max(1,MMAX), */
00367 /*          where MMAX is the maximum value of M in MVAL. */
00368 
00369 /*  BD      (workspace) DOUBLE PRECISION array, dimension */
00370 /*                      (max(min(MVAL(j),NVAL(j)))) */
00371 
00372 /*  BE      (workspace) DOUBLE PRECISION array, dimension */
00373 /*                      (max(min(MVAL(j),NVAL(j)))) */
00374 
00375 /*  S1      (workspace) DOUBLE PRECISION array, dimension */
00376 /*                      (max(min(MVAL(j),NVAL(j)))) */
00377 
00378 /*  S2      (workspace) DOUBLE PRECISION array, dimension */
00379 /*                      (max(min(MVAL(j),NVAL(j)))) */
00380 
00381 /*  X       (workspace) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00382 
00383 /*  LDX     (input) INTEGER */
00384 /*          The leading dimension of the arrays X, Y, and Z. */
00385 /*          LDX >= max(1,MMAX) */
00386 
00387 /*  Y       (workspace) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00388 
00389 /*  Z       (workspace) DOUBLE PRECISION array, dimension (LDX,NRHS) */
00390 
00391 /*  Q       (workspace) DOUBLE PRECISION array, dimension (LDQ,MMAX) */
00392 
00393 /*  LDQ     (input) INTEGER */
00394 /*          The leading dimension of the array Q.  LDQ >= max(1,MMAX). */
00395 
00396 /*  PT      (workspace) DOUBLE PRECISION array, dimension (LDPT,NMAX) */
00397 
00398 /*  LDPT    (input) INTEGER */
00399 /*          The leading dimension of the arrays PT, U, and V. */
00400 /*          LDPT >= max(1, max(min(MVAL(j),NVAL(j)))). */
00401 
00402 /*  U       (workspace) DOUBLE PRECISION array, dimension */
00403 /*                      (LDPT,max(min(MVAL(j),NVAL(j)))) */
00404 
00405 /*  V       (workspace) DOUBLE PRECISION array, dimension */
00406 /*                      (LDPT,max(min(MVAL(j),NVAL(j)))) */
00407 
00408 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00409 
00410 /*  LWORK   (input) INTEGER */
00411 /*          The number of entries in WORK.  This must be at least */
00412 /*          3(M+N) and  M(M + max(M,N,k) + 1) + N*min(M,N)  for all */
00413 /*          pairs  (M,N)=(MM(j),NN(j)) */
00414 
00415 /*  IWORK   (workspace) INTEGER array, dimension at least 8*min(M,N) */
00416 
00417 /*  NOUT    (input) INTEGER */
00418 /*          The FORTRAN unit number for printing out error messages */
00419 /*          (e.g., if a routine returns IINFO not equal to 0.) */
00420 
00421 /*  INFO    (output) INTEGER */
00422 /*          If 0, then everything ran OK. */
00423 /*           -1: NSIZES < 0 */
00424 /*           -2: Some MM(j) < 0 */
00425 /*           -3: Some NN(j) < 0 */
00426 /*           -4: NTYPES < 0 */
00427 /*           -6: NRHS  < 0 */
00428 /*           -8: THRESH < 0 */
00429 /*          -11: LDA < 1 or LDA < MMAX, where MMAX is max( MM(j) ). */
00430 /*          -17: LDB < 1 or LDB < MMAX. */
00431 /*          -21: LDQ < 1 or LDQ < MMAX. */
00432 /*          -23: LDPT< 1 or LDPT< MNMAX. */
00433 /*          -27: LWORK too small. */
00434 /*          If  DLATMR, SLATMS, DGEBRD, DORGBR, or DBDSQR, */
00435 /*              returns an error code, the */
00436 /*              absolute value of it is returned. */
00437 
00438 /* ----------------------------------------------------------------------- */
00439 
00440 /*     Some Local Variables and Parameters: */
00441 /*     ---- ----- --------- --- ---------- */
00442 
00443 /*     ZERO, ONE       Real 0 and 1. */
00444 /*     MAXTYP          The number of types defined. */
00445 /*     NTEST           The number of tests performed, or which can */
00446 /*                     be performed so far, for the current matrix. */
00447 /*     MMAX            Largest value in NN. */
00448 /*     NMAX            Largest value in NN. */
00449 /*     MNMIN           min(MM(j), NN(j)) (the dimension of the bidiagonal */
00450 /*                     matrix.) */
00451 /*     MNMAX           The maximum value of MNMIN for j=1,...,NSIZES. */
00452 /*     NFAIL           The number of tests which have exceeded THRESH */
00453 /*     COND, IMODE     Values to be passed to the matrix generators. */
00454 /*     ANORM           Norm of A; passed to matrix generators. */
00455 
00456 /*     OVFL, UNFL      Overflow and underflow thresholds. */
00457 /*     RTOVFL, RTUNFL  Square roots of the previous 2 values. */
00458 /*     ULP, ULPINV     Finest relative precision and its inverse. */
00459 
00460 /*             The following four arrays decode JTYPE: */
00461 /*     KTYPE(j)        The general type (1-10) for type "j". */
00462 /*     KMODE(j)        The MODE value to be passed to the matrix */
00463 /*                     generator for type "j". */
00464 /*     KMAGN(j)        The order of magnitude ( O(1), */
00465 /*                     O(overflow^(1/2) ), O(underflow^(1/2) ) */
00466 
00467 /* ====================================================================== */
00468 
00469 /*     .. Parameters .. */
00470 /*     .. */
00471 /*     .. Local Scalars .. */
00472 /*     .. */
00473 /*     .. Local Arrays .. */
00474 /*     .. */
00475 /*     .. External Functions .. */
00476 /*     .. */
00477 /*     .. External Subroutines .. */
00478 /*     .. */
00479 /*     .. Intrinsic Functions .. */
00480 /*     .. */
00481 /*     .. Scalars in Common .. */
00482 /*     .. */
00483 /*     .. Common blocks .. */
00484 /*     .. */
00485 /*     .. Data statements .. */
00486     /* Parameter adjustments */
00487     --mval;
00488     --nval;
00489     --dotype;
00490     --iseed;
00491     a_dim1 = *lda;
00492     a_offset = 1 + a_dim1;
00493     a -= a_offset;
00494     --bd;
00495     --be;
00496     --s1;
00497     --s2;
00498     z_dim1 = *ldx;
00499     z_offset = 1 + z_dim1;
00500     z__ -= z_offset;
00501     y_dim1 = *ldx;
00502     y_offset = 1 + y_dim1;
00503     y -= y_offset;
00504     x_dim1 = *ldx;
00505     x_offset = 1 + x_dim1;
00506     x -= x_offset;
00507     q_dim1 = *ldq;
00508     q_offset = 1 + q_dim1;
00509     q -= q_offset;
00510     vt_dim1 = *ldpt;
00511     vt_offset = 1 + vt_dim1;
00512     vt -= vt_offset;
00513     u_dim1 = *ldpt;
00514     u_offset = 1 + u_dim1;
00515     u -= u_offset;
00516     pt_dim1 = *ldpt;
00517     pt_offset = 1 + pt_dim1;
00518     pt -= pt_offset;
00519     --work;
00520     --iwork;
00521 
00522     /* Function Body */
00523 /*     .. */
00524 /*     .. Executable Statements .. */
00525 
00526 /*     Check for errors */
00527 
00528     *info = 0;
00529 
00530     badmm = FALSE_;
00531     badnn = FALSE_;
00532     mmax = 1;
00533     nmax = 1;
00534     mnmax = 1;
00535     minwrk = 1;
00536     i__1 = *nsizes;
00537     for (j = 1; j <= i__1; ++j) {
00538 /* Computing MAX */
00539         i__2 = mmax, i__3 = mval[j];
00540         mmax = max(i__2,i__3);
00541         if (mval[j] < 0) {
00542             badmm = TRUE_;
00543         }
00544 /* Computing MAX */
00545         i__2 = nmax, i__3 = nval[j];
00546         nmax = max(i__2,i__3);
00547         if (nval[j] < 0) {
00548             badnn = TRUE_;
00549         }
00550 /* Computing MAX */
00551 /* Computing MIN */
00552         i__4 = mval[j], i__5 = nval[j];
00553         i__2 = mnmax, i__3 = min(i__4,i__5);
00554         mnmax = max(i__2,i__3);
00555 /* Computing MAX */
00556 /* Computing MAX */
00557         i__4 = mval[j], i__5 = nval[j], i__4 = max(i__4,i__5);
00558 /* Computing MIN */
00559         i__6 = nval[j], i__7 = mval[j];
00560         i__2 = minwrk, i__3 = (mval[j] + nval[j]) * 3, i__2 = max(i__2,i__3), 
00561                 i__3 = mval[j] * (mval[j] + max(i__4,*nrhs) + 1) + nval[j] * 
00562                 min(i__6,i__7);
00563         minwrk = max(i__2,i__3);
00564 /* L10: */
00565     }
00566 
00567 /*     Check for errors */
00568 
00569     if (*nsizes < 0) {
00570         *info = -1;
00571     } else if (badmm) {
00572         *info = -2;
00573     } else if (badnn) {
00574         *info = -3;
00575     } else if (*ntypes < 0) {
00576         *info = -4;
00577     } else if (*nrhs < 0) {
00578         *info = -6;
00579     } else if (*lda < mmax) {
00580         *info = -11;
00581     } else if (*ldx < mmax) {
00582         *info = -17;
00583     } else if (*ldq < mmax) {
00584         *info = -21;
00585     } else if (*ldpt < mnmax) {
00586         *info = -23;
00587     } else if (minwrk > *lwork) {
00588         *info = -27;
00589     }
00590 
00591     if (*info != 0) {
00592         i__1 = -(*info);
00593         xerbla_("DCHKBD", &i__1);
00594         return 0;
00595     }
00596 
00597 /*     Initialize constants */
00598 
00599     s_copy(path, "Double precision", (ftnlen)1, (ftnlen)16);
00600     s_copy(path + 1, "BD", (ftnlen)2, (ftnlen)2);
00601     nfail = 0;
00602     ntest = 0;
00603     unfl = dlamch_("Safe minimum");
00604     ovfl = dlamch_("Overflow");
00605     dlabad_(&unfl, &ovfl);
00606     ulp = dlamch_("Precision");
00607     ulpinv = 1. / ulp;
00608     log2ui = (integer) (log(ulpinv) / log(2.));
00609     rtunfl = sqrt(unfl);
00610     rtovfl = sqrt(ovfl);
00611     infoc_1.infot = 0;
00612 
00613 /*     Loop over sizes, types */
00614 
00615     i__1 = *nsizes;
00616     for (jsize = 1; jsize <= i__1; ++jsize) {
00617         m = mval[jsize];
00618         n = nval[jsize];
00619         mnmin = min(m,n);
00620 /* Computing MAX */
00621         i__2 = max(m,n);
00622         amninv = 1. / max(i__2,1);
00623 
00624         if (*nsizes != 1) {
00625             mtypes = min(16,*ntypes);
00626         } else {
00627             mtypes = min(17,*ntypes);
00628         }
00629 
00630         i__2 = mtypes;
00631         for (jtype = 1; jtype <= i__2; ++jtype) {
00632             if (! dotype[jtype]) {
00633                 goto L190;
00634             }
00635 
00636             for (j = 1; j <= 4; ++j) {
00637                 ioldsd[j - 1] = iseed[j];
00638 /* L20: */
00639             }
00640 
00641             for (j = 1; j <= 14; ++j) {
00642                 result[j - 1] = -1.;
00643 /* L30: */
00644             }
00645 
00646             *(unsigned char *)uplo = ' ';
00647 
00648 /*           Compute "A" */
00649 
00650 /*           Control parameters: */
00651 
00652 /*           KMAGN  KMODE        KTYPE */
00653 /*       =1  O(1)   clustered 1  zero */
00654 /*       =2  large  clustered 2  identity */
00655 /*       =3  small  exponential  (none) */
00656 /*       =4         arithmetic   diagonal, (w/ eigenvalues) */
00657 /*       =5         random       symmetric, w/ eigenvalues */
00658 /*       =6                      nonsymmetric, w/ singular values */
00659 /*       =7                      random diagonal */
00660 /*       =8                      random symmetric */
00661 /*       =9                      random nonsymmetric */
00662 /*       =10                     random bidiagonal (log. distrib.) */
00663 
00664             if (mtypes > 16) {
00665                 goto L100;
00666             }
00667 
00668             itype = ktype[jtype - 1];
00669             imode = kmode[jtype - 1];
00670 
00671 /*           Compute norm */
00672 
00673             switch (kmagn[jtype - 1]) {
00674                 case 1:  goto L40;
00675                 case 2:  goto L50;
00676                 case 3:  goto L60;
00677             }
00678 
00679 L40:
00680             anorm = 1.;
00681             goto L70;
00682 
00683 L50:
00684             anorm = rtovfl * ulp * amninv;
00685             goto L70;
00686 
00687 L60:
00688             anorm = rtunfl * max(m,n) * ulpinv;
00689             goto L70;
00690 
00691 L70:
00692 
00693             dlaset_("Full", lda, &n, &c_b20, &c_b20, &a[a_offset], lda);
00694             iinfo = 0;
00695             cond = ulpinv;
00696 
00697             bidiag = FALSE_;
00698             if (itype == 1) {
00699 
00700 /*              Zero matrix */
00701 
00702                 iinfo = 0;
00703 
00704             } else if (itype == 2) {
00705 
00706 /*              Identity */
00707 
00708                 i__3 = mnmin;
00709                 for (jcol = 1; jcol <= i__3; ++jcol) {
00710                     a[jcol + jcol * a_dim1] = anorm;
00711 /* L80: */
00712                 }
00713 
00714             } else if (itype == 4) {
00715 
00716 /*              Diagonal Matrix, [Eigen]values Specified */
00717 
00718                 dlatms_(&mnmin, &mnmin, "S", &iseed[1], "N", &work[1], &imode, 
00719                          &cond, &anorm, &c__0, &c__0, "N", &a[a_offset], lda, 
00720                         &work[mnmin + 1], &iinfo);
00721 
00722             } else if (itype == 5) {
00723 
00724 /*              Symmetric, eigenvalues specified */
00725 
00726                 dlatms_(&mnmin, &mnmin, "S", &iseed[1], "S", &work[1], &imode, 
00727                          &cond, &anorm, &m, &n, "N", &a[a_offset], lda, &work[
00728                         mnmin + 1], &iinfo);
00729 
00730             } else if (itype == 6) {
00731 
00732 /*              Nonsymmetric, singular values specified */
00733 
00734                 dlatms_(&m, &n, "S", &iseed[1], "N", &work[1], &imode, &cond, 
00735                         &anorm, &m, &n, "N", &a[a_offset], lda, &work[mnmin + 
00736                         1], &iinfo);
00737 
00738             } else if (itype == 7) {
00739 
00740 /*              Diagonal, random entries */
00741 
00742                 dlatmr_(&mnmin, &mnmin, "S", &iseed[1], "N", &work[1], &c__6, 
00743                         &c_b37, &c_b37, "T", "N", &work[mnmin + 1], &c__1, &
00744                         c_b37, &work[(mnmin << 1) + 1], &c__1, &c_b37, "N", &
00745                         iwork[1], &c__0, &c__0, &c_b20, &anorm, "NO", &a[
00746                         a_offset], lda, &iwork[1], &iinfo);
00747 
00748             } else if (itype == 8) {
00749 
00750 /*              Symmetric, random entries */
00751 
00752                 dlatmr_(&mnmin, &mnmin, "S", &iseed[1], "S", &work[1], &c__6, 
00753                         &c_b37, &c_b37, "T", "N", &work[mnmin + 1], &c__1, &
00754                         c_b37, &work[m + mnmin + 1], &c__1, &c_b37, "N", &
00755                         iwork[1], &m, &n, &c_b20, &anorm, "NO", &a[a_offset], 
00756                         lda, &iwork[1], &iinfo);
00757 
00758             } else if (itype == 9) {
00759 
00760 /*              Nonsymmetric, random entries */
00761 
00762                 dlatmr_(&m, &n, "S", &iseed[1], "N", &work[1], &c__6, &c_b37, 
00763                         &c_b37, "T", "N", &work[mnmin + 1], &c__1, &c_b37, &
00764                         work[m + mnmin + 1], &c__1, &c_b37, "N", &iwork[1], &
00765                         m, &n, &c_b20, &anorm, "NO", &a[a_offset], lda, &
00766                         iwork[1], &iinfo);
00767 
00768             } else if (itype == 10) {
00769 
00770 /*              Bidiagonal, random entries */
00771 
00772                 temp1 = log(ulp) * -2.;
00773                 i__3 = mnmin;
00774                 for (j = 1; j <= i__3; ++j) {
00775                     bd[j] = exp(temp1 * dlarnd_(&c__2, &iseed[1]));
00776                     if (j < mnmin) {
00777                         be[j] = exp(temp1 * dlarnd_(&c__2, &iseed[1]));
00778                     }
00779 /* L90: */
00780                 }
00781 
00782                 iinfo = 0;
00783                 bidiag = TRUE_;
00784                 if (m >= n) {
00785                     *(unsigned char *)uplo = 'U';
00786                 } else {
00787                     *(unsigned char *)uplo = 'L';
00788                 }
00789             } else {
00790                 iinfo = 1;
00791             }
00792 
00793             if (iinfo == 0) {
00794 
00795 /*              Generate Right-Hand Side */
00796 
00797                 if (bidiag) {
00798                     dlatmr_(&mnmin, nrhs, "S", &iseed[1], "N", &work[1], &
00799                             c__6, &c_b37, &c_b37, "T", "N", &work[mnmin + 1], 
00800                             &c__1, &c_b37, &work[(mnmin << 1) + 1], &c__1, &
00801                             c_b37, "N", &iwork[1], &mnmin, nrhs, &c_b20, &
00802                             c_b37, "NO", &y[y_offset], ldx, &iwork[1], &iinfo);
00803                 } else {
00804                     dlatmr_(&m, nrhs, "S", &iseed[1], "N", &work[1], &c__6, &
00805                             c_b37, &c_b37, "T", "N", &work[m + 1], &c__1, &
00806                             c_b37, &work[(m << 1) + 1], &c__1, &c_b37, "N", &
00807                             iwork[1], &m, nrhs, &c_b20, &c_b37, "NO", &x[
00808                             x_offset], ldx, &iwork[1], &iinfo);
00809                 }
00810             }
00811 
00812 /*           Error Exit */
00813 
00814             if (iinfo != 0) {
00815                 io___39.ciunit = *nout;
00816                 s_wsfe(&io___39);
00817                 do_fio(&c__1, "Generator", (ftnlen)9);
00818                 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00819                 do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00820                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00821                 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00822                 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer));
00823                 e_wsfe();
00824                 *info = abs(iinfo);
00825                 return 0;
00826             }
00827 
00828 L100:
00829 
00830 /*           Call DGEBRD and DORGBR to compute B, Q, and P, do tests. */
00831 
00832             if (! bidiag) {
00833 
00834 /*              Compute transformations to reduce A to bidiagonal form: */
00835 /*              B := Q' * A * P. */
00836 
00837                 dlacpy_(" ", &m, &n, &a[a_offset], lda, &q[q_offset], ldq);
00838                 i__3 = *lwork - (mnmin << 1);
00839                 dgebrd_(&m, &n, &q[q_offset], ldq, &bd[1], &be[1], &work[1], &
00840                         work[mnmin + 1], &work[(mnmin << 1) + 1], &i__3, &
00841                         iinfo);
00842 
00843 /*              Check error code from DGEBRD. */
00844 
00845                 if (iinfo != 0) {
00846                     io___40.ciunit = *nout;
00847                     s_wsfe(&io___40);
00848                     do_fio(&c__1, "DGEBRD", (ftnlen)6);
00849                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00850                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00851                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00852                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00853                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00854                             ;
00855                     e_wsfe();
00856                     *info = abs(iinfo);
00857                     return 0;
00858                 }
00859 
00860                 dlacpy_(" ", &m, &n, &q[q_offset], ldq, &pt[pt_offset], ldpt);
00861                 if (m >= n) {
00862                     *(unsigned char *)uplo = 'U';
00863                 } else {
00864                     *(unsigned char *)uplo = 'L';
00865                 }
00866 
00867 /*              Generate Q */
00868 
00869                 mq = m;
00870                 if (*nrhs <= 0) {
00871                     mq = mnmin;
00872                 }
00873                 i__3 = *lwork - (mnmin << 1);
00874                 dorgbr_("Q", &m, &mq, &n, &q[q_offset], ldq, &work[1], &work[(
00875                         mnmin << 1) + 1], &i__3, &iinfo);
00876 
00877 /*              Check error code from DORGBR. */
00878 
00879                 if (iinfo != 0) {
00880                     io___42.ciunit = *nout;
00881                     s_wsfe(&io___42);
00882                     do_fio(&c__1, "DORGBR(Q)", (ftnlen)9);
00883                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00884                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00885                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00886                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00887                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00888                             ;
00889                     e_wsfe();
00890                     *info = abs(iinfo);
00891                     return 0;
00892                 }
00893 
00894 /*              Generate P' */
00895 
00896                 i__3 = *lwork - (mnmin << 1);
00897                 dorgbr_("P", &mnmin, &n, &m, &pt[pt_offset], ldpt, &work[
00898                         mnmin + 1], &work[(mnmin << 1) + 1], &i__3, &iinfo);
00899 
00900 /*              Check error code from DORGBR. */
00901 
00902                 if (iinfo != 0) {
00903                     io___43.ciunit = *nout;
00904                     s_wsfe(&io___43);
00905                     do_fio(&c__1, "DORGBR(P)", (ftnlen)9);
00906                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00907                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00908                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00909                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00910                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00911                             ;
00912                     e_wsfe();
00913                     *info = abs(iinfo);
00914                     return 0;
00915                 }
00916 
00917 /*              Apply Q' to an M by NRHS matrix X:  Y := Q' * X. */
00918 
00919                 dgemm_("Transpose", "No transpose", &m, nrhs, &m, &c_b37, &q[
00920                         q_offset], ldq, &x[x_offset], ldx, &c_b20, &y[
00921                         y_offset], ldx);
00922 
00923 /*              Test 1:  Check the decomposition A := Q * B * PT */
00924 /*                   2:  Check the orthogonality of Q */
00925 /*                   3:  Check the orthogonality of PT */
00926 
00927                 dbdt01_(&m, &n, &c__1, &a[a_offset], lda, &q[q_offset], ldq, &
00928                         bd[1], &be[1], &pt[pt_offset], ldpt, &work[1], result)
00929                         ;
00930                 dort01_("Columns", &m, &mq, &q[q_offset], ldq, &work[1], 
00931                         lwork, &result[1]);
00932                 dort01_("Rows", &mnmin, &n, &pt[pt_offset], ldpt, &work[1], 
00933                         lwork, &result[2]);
00934             }
00935 
00936 /*           Use DBDSQR to form the SVD of the bidiagonal matrix B: */
00937 /*           B := U * S1 * VT, and compute Z = U' * Y. */
00938 
00939             dcopy_(&mnmin, &bd[1], &c__1, &s1[1], &c__1);
00940             if (mnmin > 0) {
00941                 i__3 = mnmin - 1;
00942                 dcopy_(&i__3, &be[1], &c__1, &work[1], &c__1);
00943             }
00944             dlacpy_(" ", &m, nrhs, &y[y_offset], ldx, &z__[z_offset], ldx);
00945             dlaset_("Full", &mnmin, &mnmin, &c_b20, &c_b37, &u[u_offset], 
00946                     ldpt);
00947             dlaset_("Full", &mnmin, &mnmin, &c_b20, &c_b37, &vt[vt_offset], 
00948                     ldpt);
00949 
00950             dbdsqr_(uplo, &mnmin, &mnmin, &mnmin, nrhs, &s1[1], &work[1], &vt[
00951                     vt_offset], ldpt, &u[u_offset], ldpt, &z__[z_offset], ldx, 
00952                      &work[mnmin + 1], &iinfo);
00953 
00954 /*           Check error code from DBDSQR. */
00955 
00956             if (iinfo != 0) {
00957                 io___44.ciunit = *nout;
00958                 s_wsfe(&io___44);
00959                 do_fio(&c__1, "DBDSQR(vects)", (ftnlen)13);
00960                 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00961                 do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00962                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00963                 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00964                 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer));
00965                 e_wsfe();
00966                 *info = abs(iinfo);
00967                 if (iinfo < 0) {
00968                     return 0;
00969                 } else {
00970                     result[3] = ulpinv;
00971                     goto L170;
00972                 }
00973             }
00974 
00975 /*           Use DBDSQR to compute only the singular values of the */
00976 /*           bidiagonal matrix B;  U, VT, and Z should not be modified. */
00977 
00978             dcopy_(&mnmin, &bd[1], &c__1, &s2[1], &c__1);
00979             if (mnmin > 0) {
00980                 i__3 = mnmin - 1;
00981                 dcopy_(&i__3, &be[1], &c__1, &work[1], &c__1);
00982             }
00983 
00984             dbdsqr_(uplo, &mnmin, &c__0, &c__0, &c__0, &s2[1], &work[1], &vt[
00985                     vt_offset], ldpt, &u[u_offset], ldpt, &z__[z_offset], ldx, 
00986                      &work[mnmin + 1], &iinfo);
00987 
00988 /*           Check error code from DBDSQR. */
00989 
00990             if (iinfo != 0) {
00991                 io___45.ciunit = *nout;
00992                 s_wsfe(&io___45);
00993                 do_fio(&c__1, "DBDSQR(values)", (ftnlen)14);
00994                 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00995                 do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
00996                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00997                 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00998                 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer));
00999                 e_wsfe();
01000                 *info = abs(iinfo);
01001                 if (iinfo < 0) {
01002                     return 0;
01003                 } else {
01004                     result[8] = ulpinv;
01005                     goto L170;
01006                 }
01007             }
01008 
01009 /*           Test 4:  Check the decomposition B := U * S1 * VT */
01010 /*                5:  Check the computation Z := U' * Y */
01011 /*                6:  Check the orthogonality of U */
01012 /*                7:  Check the orthogonality of VT */
01013 
01014             dbdt03_(uplo, &mnmin, &c__1, &bd[1], &be[1], &u[u_offset], ldpt, &
01015                     s1[1], &vt[vt_offset], ldpt, &work[1], &result[3]);
01016             dbdt02_(&mnmin, nrhs, &y[y_offset], ldx, &z__[z_offset], ldx, &u[
01017                     u_offset], ldpt, &work[1], &result[4]);
01018             dort01_("Columns", &mnmin, &mnmin, &u[u_offset], ldpt, &work[1], 
01019                     lwork, &result[5]);
01020             dort01_("Rows", &mnmin, &mnmin, &vt[vt_offset], ldpt, &work[1], 
01021                     lwork, &result[6]);
01022 
01023 /*           Test 8:  Check that the singular values are sorted in */
01024 /*                    non-increasing order and are non-negative */
01025 
01026             result[7] = 0.;
01027             i__3 = mnmin - 1;
01028             for (i__ = 1; i__ <= i__3; ++i__) {
01029                 if (s1[i__] < s1[i__ + 1]) {
01030                     result[7] = ulpinv;
01031                 }
01032                 if (s1[i__] < 0.) {
01033                     result[7] = ulpinv;
01034                 }
01035 /* L110: */
01036             }
01037             if (mnmin >= 1) {
01038                 if (s1[mnmin] < 0.) {
01039                     result[7] = ulpinv;
01040                 }
01041             }
01042 
01043 /*           Test 9:  Compare DBDSQR with and without singular vectors */
01044 
01045             temp2 = 0.;
01046 
01047             i__3 = mnmin;
01048             for (j = 1; j <= i__3; ++j) {
01049 /* Computing MAX */
01050 /* Computing MAX */
01051                 d__6 = (d__1 = s1[j], abs(d__1)), d__7 = (d__2 = s2[j], abs(
01052                         d__2));
01053                 d__4 = sqrt(unfl) * max(s1[1],1.), d__5 = ulp * max(d__6,d__7)
01054                         ;
01055                 temp1 = (d__3 = s1[j] - s2[j], abs(d__3)) / max(d__4,d__5);
01056                 temp2 = max(temp1,temp2);
01057 /* L120: */
01058             }
01059 
01060             result[8] = temp2;
01061 
01062 /*           Test 10:  Sturm sequence test of singular values */
01063 /*                     Go up by factors of two until it succeeds */
01064 
01065             temp1 = *thresh * (.5 - ulp);
01066 
01067             i__3 = log2ui;
01068             for (j = 0; j <= i__3; ++j) {
01069 /*               CALL DSVDCH( MNMIN, BD, BE, S1, TEMP1, IINFO ) */
01070                 if (iinfo == 0) {
01071                     goto L140;
01072                 }
01073                 temp1 *= 2.;
01074 /* L130: */
01075             }
01076 
01077 L140:
01078             result[9] = temp1;
01079 
01080 /*           Use DBDSQR to form the decomposition A := (QU) S (VT PT) */
01081 /*           from the bidiagonal form A := Q B PT. */
01082 
01083             if (! bidiag) {
01084                 dcopy_(&mnmin, &bd[1], &c__1, &s2[1], &c__1);
01085                 if (mnmin > 0) {
01086                     i__3 = mnmin - 1;
01087                     dcopy_(&i__3, &be[1], &c__1, &work[1], &c__1);
01088                 }
01089 
01090                 dbdsqr_(uplo, &mnmin, &n, &m, nrhs, &s2[1], &work[1], &pt[
01091                         pt_offset], ldpt, &q[q_offset], ldq, &y[y_offset], 
01092                         ldx, &work[mnmin + 1], &iinfo);
01093 
01094 /*              Test 11:  Check the decomposition A := Q*U * S2 * VT*PT */
01095 /*                   12:  Check the computation Z := U' * Q' * X */
01096 /*                   13:  Check the orthogonality of Q*U */
01097 /*                   14:  Check the orthogonality of VT*PT */
01098 
01099                 dbdt01_(&m, &n, &c__0, &a[a_offset], lda, &q[q_offset], ldq, &
01100                         s2[1], dumma, &pt[pt_offset], ldpt, &work[1], &result[
01101                         10]);
01102                 dbdt02_(&m, nrhs, &x[x_offset], ldx, &y[y_offset], ldx, &q[
01103                         q_offset], ldq, &work[1], &result[11]);
01104                 dort01_("Columns", &m, &mq, &q[q_offset], ldq, &work[1], 
01105                         lwork, &result[12]);
01106                 dort01_("Rows", &mnmin, &n, &pt[pt_offset], ldpt, &work[1], 
01107                         lwork, &result[13]);
01108             }
01109 
01110 /*           Use DBDSDC to form the SVD of the bidiagonal matrix B: */
01111 /*           B := U * S1 * VT */
01112 
01113             dcopy_(&mnmin, &bd[1], &c__1, &s1[1], &c__1);
01114             if (mnmin > 0) {
01115                 i__3 = mnmin - 1;
01116                 dcopy_(&i__3, &be[1], &c__1, &work[1], &c__1);
01117             }
01118             dlaset_("Full", &mnmin, &mnmin, &c_b20, &c_b37, &u[u_offset], 
01119                     ldpt);
01120             dlaset_("Full", &mnmin, &mnmin, &c_b20, &c_b37, &vt[vt_offset], 
01121                     ldpt);
01122 
01123             dbdsdc_(uplo, "I", &mnmin, &s1[1], &work[1], &u[u_offset], ldpt, &
01124                     vt[vt_offset], ldpt, dum, idum, &work[mnmin + 1], &iwork[
01125                     1], &iinfo);
01126 
01127 /*           Check error code from DBDSDC. */
01128 
01129             if (iinfo != 0) {
01130                 io___51.ciunit = *nout;
01131                 s_wsfe(&io___51);
01132                 do_fio(&c__1, "DBDSDC(vects)", (ftnlen)13);
01133                 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
01134                 do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
01135                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
01136                 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
01137                 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer));
01138                 e_wsfe();
01139                 *info = abs(iinfo);
01140                 if (iinfo < 0) {
01141                     return 0;
01142                 } else {
01143                     result[14] = ulpinv;
01144                     goto L170;
01145                 }
01146             }
01147 
01148 /*           Use DBDSDC to compute only the singular values of the */
01149 /*           bidiagonal matrix B;  U and VT should not be modified. */
01150 
01151             dcopy_(&mnmin, &bd[1], &c__1, &s2[1], &c__1);
01152             if (mnmin > 0) {
01153                 i__3 = mnmin - 1;
01154                 dcopy_(&i__3, &be[1], &c__1, &work[1], &c__1);
01155             }
01156 
01157             dbdsdc_(uplo, "N", &mnmin, &s2[1], &work[1], dum, &c__1, dum, &
01158                     c__1, dum, idum, &work[mnmin + 1], &iwork[1], &iinfo);
01159 
01160 /*           Check error code from DBDSDC. */
01161 
01162             if (iinfo != 0) {
01163                 io___52.ciunit = *nout;
01164                 s_wsfe(&io___52);
01165                 do_fio(&c__1, "DBDSDC(values)", (ftnlen)14);
01166                 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
01167                 do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
01168                 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
01169                 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
01170                 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer));
01171                 e_wsfe();
01172                 *info = abs(iinfo);
01173                 if (iinfo < 0) {
01174                     return 0;
01175                 } else {
01176                     result[17] = ulpinv;
01177                     goto L170;
01178                 }
01179             }
01180 
01181 /*           Test 15:  Check the decomposition B := U * S1 * VT */
01182 /*                16:  Check the orthogonality of U */
01183 /*                17:  Check the orthogonality of VT */
01184 
01185             dbdt03_(uplo, &mnmin, &c__1, &bd[1], &be[1], &u[u_offset], ldpt, &
01186                     s1[1], &vt[vt_offset], ldpt, &work[1], &result[14]);
01187             dort01_("Columns", &mnmin, &mnmin, &u[u_offset], ldpt, &work[1], 
01188                     lwork, &result[15]);
01189             dort01_("Rows", &mnmin, &mnmin, &vt[vt_offset], ldpt, &work[1], 
01190                     lwork, &result[16]);
01191 
01192 /*           Test 18:  Check that the singular values are sorted in */
01193 /*                     non-increasing order and are non-negative */
01194 
01195             result[17] = 0.;
01196             i__3 = mnmin - 1;
01197             for (i__ = 1; i__ <= i__3; ++i__) {
01198                 if (s1[i__] < s1[i__ + 1]) {
01199                     result[17] = ulpinv;
01200                 }
01201                 if (s1[i__] < 0.) {
01202                     result[17] = ulpinv;
01203                 }
01204 /* L150: */
01205             }
01206             if (mnmin >= 1) {
01207                 if (s1[mnmin] < 0.) {
01208                     result[17] = ulpinv;
01209                 }
01210             }
01211 
01212 /*           Test 19:  Compare DBDSQR with and without singular vectors */
01213 
01214             temp2 = 0.;
01215 
01216             i__3 = mnmin;
01217             for (j = 1; j <= i__3; ++j) {
01218 /* Computing MAX */
01219 /* Computing MAX */
01220                 d__4 = abs(s1[1]), d__5 = abs(s2[1]);
01221                 d__2 = sqrt(unfl) * max(s1[1],1.), d__3 = ulp * max(d__4,d__5)
01222                         ;
01223                 temp1 = (d__1 = s1[j] - s2[j], abs(d__1)) / max(d__2,d__3);
01224                 temp2 = max(temp1,temp2);
01225 /* L160: */
01226             }
01227 
01228             result[18] = temp2;
01229 
01230 /*           End of Loop -- Check for RESULT(j) > THRESH */
01231 
01232 L170:
01233             for (j = 1; j <= 19; ++j) {
01234                 if (result[j - 1] >= *thresh) {
01235                     if (nfail == 0) {
01236                         dlahd2_(nout, path);
01237                     }
01238                     io___53.ciunit = *nout;
01239                     s_wsfe(&io___53);
01240                     do_fio(&c__1, (char *)&m, (ftnlen)sizeof(integer));
01241                     do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
01242                     do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
01243                     do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
01244                             ;
01245                     do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
01246                     do_fio(&c__1, (char *)&result[j - 1], (ftnlen)sizeof(
01247                             doublereal));
01248                     e_wsfe();
01249                     ++nfail;
01250                 }
01251 /* L180: */
01252             }
01253             if (! bidiag) {
01254                 ntest += 19;
01255             } else {
01256                 ntest += 5;
01257             }
01258 
01259 L190:
01260             ;
01261         }
01262 /* L200: */
01263     }
01264 
01265 /*     Summary */
01266 
01267     alasum_(path, nout, &nfail, &ntest, &c__0);
01268 
01269     return 0;
01270 
01271 /*     End of DCHKBD */
01272 
01273 
01274 } /* dchkbd_ */


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