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


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