ddrgsx.c
Go to the documentation of this file.
00001 /* ddrgsx.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 m, n, mplusn, k;
00020     logical fs;
00021 } mn_;
00022 
00023 #define mn_1 mn_
00024 
00025 /* Table of constant values */
00026 
00027 static integer c__1 = 1;
00028 static integer c__0 = 0;
00029 static integer c_n1 = -1;
00030 static doublereal c_b26 = 0.;
00031 static integer c__3 = 3;
00032 static integer c__5 = 5;
00033 
00034 /* Subroutine */ int ddrgsx_(integer *nsize, integer *ncmax, doublereal *
00035         thresh, integer *nin, integer *nout, doublereal *a, integer *lda, 
00036         doublereal *b, doublereal *ai, doublereal *bi, doublereal *z__, 
00037         doublereal *q, doublereal *alphar, doublereal *alphai, doublereal *
00038         beta, doublereal *c__, integer *ldc, doublereal *s, doublereal *work, 
00039         integer *lwork, integer *iwork, integer *liwork, logical *bwork, 
00040         integer *info)
00041 {
00042     /* Format strings */
00043     static char fmt_9999[] = "(\002 DDRGSX: \002,a,\002 returned INFO=\002,i"
00044             "6,\002.\002,/9x,\002N=\002,i6,\002, JTYPE=\002,i6,\002)\002)";
00045     static char fmt_9997[] = "(\002 DDRGSX: DGET53 returned INFO=\002,i1,"
00046             "\002 for eigenvalue \002,i6,\002.\002,/9x,\002N=\002,i6,\002, JT"
00047             "YPE=\002,i6,\002)\002)";
00048     static char fmt_9996[] = "(\002 DDRGSX: S not in Schur form at eigenvalu"
00049             "e \002,i6,\002.\002,/9x,\002N=\002,i6,\002, JTYPE=\002,i6,\002"
00050             ")\002)";
00051     static char fmt_9995[] = "(/1x,a3,\002 -- Real Expert Generalized Schur "
00052             "form\002,\002 problem driver\002)";
00053     static char fmt_9993[] = "(\002 Matrix types: \002,/\002  1:  A is a blo"
00054             "ck diagonal matrix of Jordan blocks \002,\002and B is the identi"
00055             "ty \002,/\002      matrix, \002,/\002  2:  A and B are upper tri"
00056             "angular matrices, \002,/\002  3:  A and B are as type 2, but eac"
00057             "h second diagonal \002,\002block in A_11 and \002,/\002      eac"
00058             "h third diaongal block in A_22 are 2x2 blocks,\002,/\002  4:  A "
00059             "and B are block diagonal matrices, \002,/\002  5:  (A,B) has pot"
00060             "entially close or common \002,\002eigenvalues.\002,/)";
00061     static char fmt_9992[] = "(/\002 Tests performed:  (S is Schur, T is tri"
00062             "angular, \002,\002Q and Z are \002,a,\002,\002,/19x,\002 a is al"
00063             "pha, b is beta, and \002,a,\002 means \002,a,\002.)\002,/\002  1"
00064             " = | A - Q S Z\002,a,\002 | / ( |A| n ulp )      2 = | B - Q T "
00065             "Z\002,a,\002 | / ( |B| n ulp )\002,/\002  3 = | I - QQ\002,a,"
00066             "\002 | / ( n ulp )             4 = | I - ZZ\002,a,\002 | / ( n u"
00067             "lp )\002,/\002  5 = 1/ULP  if A is not in \002,\002Schur form "
00068             "S\002,/\002  6 = difference between (alpha,beta)\002,\002 and di"
00069             "agonals of (S,T)\002,/\002  7 = 1/ULP  if SDIM is not the correc"
00070             "t number of \002,\002selected eigenvalues\002,/\002  8 = 1/ULP  "
00071             "if DIFEST/DIFTRU > 10*THRESH or \002,\002DIFTRU/DIFEST > 10*THRE"
00072             "SH\002,/\002  9 = 1/ULP  if DIFEST <> 0 or DIFTRU > ULP*norm(A,B"
00073             ") \002,\002when reordering fails\002,/\002 10 = 1/ULP  if PLEST/"
00074             "PLTRU > THRESH or \002,\002PLTRU/PLEST > THRESH\002,/\002    ( T"
00075             "est 10 is only for input examples )\002,/)";
00076     static char fmt_9991[] = "(\002 Matrix order=\002,i2,\002, type=\002,i2"
00077             ",\002, a=\002,d10.4,\002, order(A_11)=\002,i2,\002, result \002,"
00078             "i2,\002 is \002,0p,f8.2)";
00079     static char fmt_9990[] = "(\002 Matrix order=\002,i2,\002, type=\002,i2"
00080             ",\002, a=\002,d10.4,\002, order(A_11)=\002,i2,\002, result \002,"
00081             "i2,\002 is \002,0p,d10.4)";
00082     static char fmt_9998[] = "(\002 DDRGSX: \002,a,\002 returned INFO=\002,i"
00083             "6,\002.\002,/9x,\002N=\002,i6,\002, Input Example #\002,i2,\002"
00084             ")\002)";
00085     static char fmt_9994[] = "(\002Input Example\002)";
00086     static char fmt_9989[] = "(\002 Input example #\002,i2,\002, matrix orde"
00087             "r=\002,i4,\002,\002,\002 result \002,i2,\002 is\002,0p,f8.2)";
00088     static char fmt_9988[] = "(\002 Input example #\002,i2,\002, matrix orde"
00089             "r=\002,i4,\002,\002,\002 result \002,i2,\002 is\002,1p,d10.3)";
00090 
00091     /* System generated locals */
00092     integer a_dim1, a_offset, ai_dim1, ai_offset, b_dim1, b_offset, bi_dim1, 
00093             bi_offset, c_dim1, c_offset, q_dim1, q_offset, z_dim1, z_offset, 
00094             i__1, i__2, i__3, i__4;
00095     doublereal d__1, d__2, d__3, d__4, d__5, d__6, d__7, d__8, d__9, d__10;
00096 
00097     /* Builtin functions */
00098     double sqrt(doublereal);
00099     integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void),
00100              s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
00101             e_rsle(void);
00102 
00103     /* Local variables */
00104     integer i__, j, i1, mm;
00105     doublereal pl[2];
00106     integer mn2, qba, qbb;
00107     doublereal ulp, temp1, temp2;
00108     extern /* Subroutine */ int dget51_(integer *, integer *, doublereal *, 
00109             integer *, doublereal *, integer *, doublereal *, integer *, 
00110             doublereal *, integer *, doublereal *, doublereal *), dget53_(
00111             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00112             doublereal *, doublereal *, doublereal *, integer *);
00113     doublereal abnrm;
00114     integer ifunc, iinfo, linfo;
00115     char sense[1];
00116     integer nerrs, ntest;
00117     extern /* Subroutine */ int dlakf2_(integer *, integer *, doublereal *, 
00118             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00119              integer *);
00120     doublereal pltru;
00121     extern /* Subroutine */ int dlatm5_(integer *, integer *, integer *, 
00122             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00123             integer *, doublereal *, integer *, doublereal *, integer *, 
00124             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00125             integer *, doublereal *, integer *, integer *), dlabad_(
00126             doublereal *, doublereal *);
00127     doublereal thrsh2;
00128     logical ilabad;
00129     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00130             integer *, doublereal *, integer *, doublereal *);
00131     integer bdspac;
00132     extern /* Subroutine */ int dgesvd_(char *, char *, integer *, integer *, 
00133             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00134             doublereal *, integer *, doublereal *, integer *, integer *), dlacpy_(char *, integer *, integer *, doublereal 
00135             *, integer *, doublereal *, integer *);
00136     doublereal difest[2];
00137     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00138             integer *, integer *);
00139     extern /* Subroutine */ int dlaset_(char *, integer *, integer *, 
00140             doublereal *, doublereal *, doublereal *, integer *);
00141     doublereal bignum;
00142     extern /* Subroutine */ int dggesx_(char *, char *, char *, L_fp, char *, 
00143             integer *, doublereal *, integer *, doublereal *, integer *, 
00144             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00145              integer *, doublereal *, integer *, doublereal *, doublereal *, 
00146             doublereal *, integer *, integer *, integer *, logical *, integer 
00147             *), alasvm_(char *, integer *, 
00148             integer *, integer *, integer *), xerbla_(char *, integer 
00149             *);
00150     doublereal weight, diftru;
00151     extern logical dlctsx_();
00152     integer minwrk, maxwrk;
00153     doublereal smlnum, ulpinv;
00154     integer nptknt;
00155     doublereal result[10];
00156     integer ntestt, prtype;
00157 
00158     /* Fortran I/O blocks */
00159     static cilist io___22 = { 0, 0, 0, fmt_9999, 0 };
00160     static cilist io___31 = { 0, 0, 0, fmt_9997, 0 };
00161     static cilist io___32 = { 0, 0, 0, fmt_9996, 0 };
00162     static cilist io___35 = { 0, 0, 0, fmt_9995, 0 };
00163     static cilist io___36 = { 0, 0, 0, fmt_9993, 0 };
00164     static cilist io___37 = { 0, 0, 0, fmt_9992, 0 };
00165     static cilist io___39 = { 0, 0, 0, fmt_9991, 0 };
00166     static cilist io___40 = { 0, 0, 0, fmt_9990, 0 };
00167     static cilist io___42 = { 0, 0, 1, 0, 0 };
00168     static cilist io___43 = { 0, 0, 1, 0, 0 };
00169     static cilist io___44 = { 0, 0, 0, 0, 0 };
00170     static cilist io___45 = { 0, 0, 0, 0, 0 };
00171     static cilist io___46 = { 0, 0, 0, 0, 0 };
00172     static cilist io___48 = { 0, 0, 0, fmt_9998, 0 };
00173     static cilist io___49 = { 0, 0, 0, fmt_9997, 0 };
00174     static cilist io___50 = { 0, 0, 0, fmt_9996, 0 };
00175     static cilist io___51 = { 0, 0, 0, fmt_9995, 0 };
00176     static cilist io___52 = { 0, 0, 0, fmt_9994, 0 };
00177     static cilist io___53 = { 0, 0, 0, fmt_9992, 0 };
00178     static cilist io___54 = { 0, 0, 0, fmt_9989, 0 };
00179     static cilist io___55 = { 0, 0, 0, fmt_9988, 0 };
00180 
00181 
00182 
00183 /*  -- LAPACK test routine (version 3.1) -- */
00184 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00185 /*     November 2006 */
00186 
00187 /*     .. Scalar Arguments .. */
00188 /*     .. */
00189 /*     .. Array Arguments .. */
00190 /*     .. */
00191 
00192 /*  Purpose */
00193 /*  ======= */
00194 
00195 /*  DDRGSX checks the nonsymmetric generalized eigenvalue (Schur form) */
00196 /*  problem expert driver DGGESX. */
00197 
00198 /*  DGGESX factors A and B as Q S Z' and Q T Z', where ' means */
00199 /*  transpose, T is upper triangular, S is in generalized Schur form */
00200 /*  (block upper triangular, with 1x1 and 2x2 blocks on the diagonal, */
00201 /*  the 2x2 blocks corresponding to complex conjugate pairs of */
00202 /*  generalized eigenvalues), and Q and Z are orthogonal.  It also */
00203 /*  computes the generalized eigenvalues (alpha(1),beta(1)), ..., */
00204 /*  (alpha(n),beta(n)). Thus, w(j) = alpha(j)/beta(j) is a root of the */
00205 /*  characteristic equation */
00206 
00207 /*      det( A - w(j) B ) = 0 */
00208 
00209 /*  Optionally it also reorders the eigenvalues so that a selected */
00210 /*  cluster of eigenvalues appears in the leading diagonal block of the */
00211 /*  Schur forms; computes a reciprocal condition number for the average */
00212 /*  of the selected eigenvalues; and computes a reciprocal condition */
00213 /*  number for the right and left deflating subspaces corresponding to */
00214 /*  the selected eigenvalues. */
00215 
00216 /*  When DDRGSX is called with NSIZE > 0, five (5) types of built-in */
00217 /*  matrix pairs are used to test the routine DGGESX. */
00218 
00219 /*  When DDRGSX is called with NSIZE = 0, it reads in test matrix data */
00220 /*  to test DGGESX. */
00221 
00222 /*  For each matrix pair, the following tests will be performed and */
00223 /*  compared with the threshhold THRESH except for the tests (7) and (9): */
00224 
00225 /*  (1)   | A - Q S Z' | / ( |A| n ulp ) */
00226 
00227 /*  (2)   | B - Q T Z' | / ( |B| n ulp ) */
00228 
00229 /*  (3)   | I - QQ' | / ( n ulp ) */
00230 
00231 /*  (4)   | I - ZZ' | / ( n ulp ) */
00232 
00233 /*  (5)   if A is in Schur form (i.e. quasi-triangular form) */
00234 
00235 /*  (6)   maximum over j of D(j)  where: */
00236 
00237 /*        if alpha(j) is real: */
00238 /*                      |alpha(j) - S(j,j)|        |beta(j) - T(j,j)| */
00239 /*            D(j) = ------------------------ + ----------------------- */
00240 /*                   max(|alpha(j)|,|S(j,j)|)   max(|beta(j)|,|T(j,j)|) */
00241 
00242 /*        if alpha(j) is complex: */
00243 /*                                  | det( s S - w T ) | */
00244 /*            D(j) = --------------------------------------------------- */
00245 /*                   ulp max( s norm(S), |w| norm(T) )*norm( s S - w T ) */
00246 
00247 /*            and S and T are here the 2 x 2 diagonal blocks of S and T */
00248 /*            corresponding to the j-th and j+1-th eigenvalues. */
00249 
00250 /*  (7)   if sorting worked and SDIM is the number of eigenvalues */
00251 /*        which were selected. */
00252 
00253 /*  (8)   the estimated value DIF does not differ from the true values of */
00254 /*        Difu and Difl more than a factor 10*THRESH. If the estimate DIF */
00255 /*        equals zero the corresponding true values of Difu and Difl */
00256 /*        should be less than EPS*norm(A, B). If the true value of Difu */
00257 /*        and Difl equal zero, the estimate DIF should be less than */
00258 /*        EPS*norm(A, B). */
00259 
00260 /*  (9)   If INFO = N+3 is returned by DGGESX, the reordering "failed" */
00261 /*        and we check that DIF = PL = PR = 0 and that the true value of */
00262 /*        Difu and Difl is < EPS*norm(A, B). We count the events when */
00263 /*        INFO=N+3. */
00264 
00265 /*  For read-in test matrices, the above tests are run except that the */
00266 /*  exact value for DIF (and PL) is input data.  Additionally, there is */
00267 /*  one more test run for read-in test matrices: */
00268 
00269 /*  (10)  the estimated value PL does not differ from the true value of */
00270 /*        PLTRU more than a factor THRESH. If the estimate PL equals */
00271 /*        zero the corresponding true value of PLTRU should be less than */
00272 /*        EPS*norm(A, B). If the true value of PLTRU equal zero, the */
00273 /*        estimate PL should be less than EPS*norm(A, B). */
00274 
00275 /*  Note that for the built-in tests, a total of 10*NSIZE*(NSIZE-1) */
00276 /*  matrix pairs are generated and tested. NSIZE should be kept small. */
00277 
00278 /*  SVD (routine DGESVD) is used for computing the true value of DIF_u */
00279 /*  and DIF_l when testing the built-in test problems. */
00280 
00281 /*  Built-in Test Matrices */
00282 /*  ====================== */
00283 
00284 /*  All built-in test matrices are the 2 by 2 block of triangular */
00285 /*  matrices */
00286 
00287 /*           A = [ A11 A12 ]    and      B = [ B11 B12 ] */
00288 /*               [     A22 ]                 [     B22 ] */
00289 
00290 /*  where for different type of A11 and A22 are given as the following. */
00291 /*  A12 and B12 are chosen so that the generalized Sylvester equation */
00292 
00293 /*           A11*R - L*A22 = -A12 */
00294 /*           B11*R - L*B22 = -B12 */
00295 
00296 /*  have prescribed solution R and L. */
00297 
00298 /*  Type 1:  A11 = J_m(1,-1) and A_22 = J_k(1-a,1). */
00299 /*           B11 = I_m, B22 = I_k */
00300 /*           where J_k(a,b) is the k-by-k Jordan block with ``a'' on */
00301 /*           diagonal and ``b'' on superdiagonal. */
00302 
00303 /*  Type 2:  A11 = (a_ij) = ( 2(.5-sin(i)) ) and */
00304 /*           B11 = (b_ij) = ( 2(.5-sin(ij)) ) for i=1,...,m, j=i,...,m */
00305 /*           A22 = (a_ij) = ( 2(.5-sin(i+j)) ) and */
00306 /*           B22 = (b_ij) = ( 2(.5-sin(ij)) ) for i=m+1,...,k, j=i,...,k */
00307 
00308 /*  Type 3:  A11, A22 and B11, B22 are chosen as for Type 2, but each */
00309 /*           second diagonal block in A_11 and each third diagonal block */
00310 /*           in A_22 are made as 2 by 2 blocks. */
00311 
00312 /*  Type 4:  A11 = ( 20(.5 - sin(ij)) ) and B22 = ( 2(.5 - sin(i+j)) ) */
00313 /*              for i=1,...,m,  j=1,...,m and */
00314 /*           A22 = ( 20(.5 - sin(i+j)) ) and B22 = ( 2(.5 - sin(ij)) ) */
00315 /*              for i=m+1,...,k,  j=m+1,...,k */
00316 
00317 /*  Type 5:  (A,B) and have potentially close or common eigenvalues and */
00318 /*           very large departure from block diagonality A_11 is chosen */
00319 /*           as the m x m leading submatrix of A_1: */
00320 /*                   |  1  b                            | */
00321 /*                   | -b  1                            | */
00322 /*                   |        1+d  b                    | */
00323 /*                   |         -b 1+d                   | */
00324 /*            A_1 =  |                  d  1            | */
00325 /*                   |                 -1  d            | */
00326 /*                   |                        -d  1     | */
00327 /*                   |                        -1 -d     | */
00328 /*                   |                               1  | */
00329 /*           and A_22 is chosen as the k x k leading submatrix of A_2: */
00330 /*                   | -1  b                            | */
00331 /*                   | -b -1                            | */
00332 /*                   |       1-d  b                     | */
00333 /*                   |       -b  1-d                    | */
00334 /*            A_2 =  |                 d 1+b            | */
00335 /*                   |               -1-b d             | */
00336 /*                   |                       -d  1+b    | */
00337 /*                   |                      -1+b  -d    | */
00338 /*                   |                              1-d | */
00339 /*           and matrix B are chosen as identity matrices (see DLATM5). */
00340 
00341 
00342 /*  Arguments */
00343 /*  ========= */
00344 
00345 /*  NSIZE   (input) INTEGER */
00346 /*          The maximum size of the matrices to use. NSIZE >= 0. */
00347 /*          If NSIZE = 0, no built-in tests matrices are used, but */
00348 /*          read-in test matrices are used to test DGGESX. */
00349 
00350 /*  NCMAX   (input) INTEGER */
00351 /*          Maximum allowable NMAX for generating Kroneker matrix */
00352 /*          in call to DLAKF2 */
00353 
00354 /*  THRESH  (input) DOUBLE PRECISION */
00355 /*          A test will count as "failed" if the "error", computed as */
00356 /*          described above, exceeds THRESH.  Note that the error */
00357 /*          is scaled to be O(1), so THRESH should be a reasonably */
00358 /*          small multiple of 1, e.g., 10 or 100.  In particular, */
00359 /*          it should not depend on the precision (single vs. double) */
00360 /*          or the size of the matrix.  THRESH >= 0. */
00361 
00362 /*  NIN     (input) INTEGER */
00363 /*          The FORTRAN unit number for reading in the data file of */
00364 /*          problems to solve. */
00365 
00366 /*  NOUT    (input) INTEGER */
00367 /*          The FORTRAN unit number for printing out error messages */
00368 /*          (e.g., if a routine returns IINFO not equal to 0.) */
00369 
00370 /*  A       (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE) */
00371 /*          Used to store the matrix whose eigenvalues are to be */
00372 /*          computed.  On exit, A contains the last matrix actually used. */
00373 
00374 /*  LDA     (input) INTEGER */
00375 /*          The leading dimension of A, B, AI, BI, Z and Q, */
00376 /*          LDA >= max( 1, NSIZE ). For the read-in test, */
00377 /*          LDA >= max( 1, N ), N is the size of the test matrices. */
00378 
00379 /*  B       (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE) */
00380 /*          Used to store the matrix whose eigenvalues are to be */
00381 /*          computed.  On exit, B contains the last matrix actually used. */
00382 
00383 /*  AI      (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE) */
00384 /*          Copy of A, modified by DGGESX. */
00385 
00386 /*  BI      (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE) */
00387 /*          Copy of B, modified by DGGESX. */
00388 
00389 /*  Z       (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE) */
00390 /*          Z holds the left Schur vectors computed by DGGESX. */
00391 
00392 /*  Q       (workspace) DOUBLE PRECISION array, dimension (LDA, NSIZE) */
00393 /*          Q holds the right Schur vectors computed by DGGESX. */
00394 
00395 /*  ALPHAR  (workspace) DOUBLE PRECISION array, dimension (NSIZE) */
00396 /*  ALPHAI  (workspace) DOUBLE PRECISION array, dimension (NSIZE) */
00397 /*  BETA    (workspace) DOUBLE PRECISION array, dimension (NSIZE) */
00398 /*          On exit, (ALPHAR + ALPHAI*i)/BETA are the eigenvalues. */
00399 
00400 /*  C       (workspace) DOUBLE PRECISION array, dimension (LDC, LDC) */
00401 /*          Store the matrix generated by subroutine DLAKF2, this is the */
00402 /*          matrix formed by Kronecker products used for estimating */
00403 /*          DIF. */
00404 
00405 /*  LDC     (input) INTEGER */
00406 /*          The leading dimension of C. LDC >= max(1, LDA*LDA/2 ). */
00407 
00408 /*  S       (workspace) DOUBLE PRECISION array, dimension (LDC) */
00409 /*          Singular values of C */
00410 
00411 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00412 
00413 /*  LWORK   (input) INTEGER */
00414 /*          The dimension of the array WORK. */
00415 /*          LWORK >= MAX( 5*NSIZE*NSIZE/2 - 2, 10*(NSIZE+1) ) */
00416 
00417 /*  IWORK   (workspace) INTEGER array, dimension (LIWORK) */
00418 
00419 /*  LIWORK  (input) INTEGER */
00420 /*          The dimension of the array IWORK. LIWORK >= NSIZE + 6. */
00421 
00422 /*  BWORK   (workspace) LOGICAL array, dimension (LDA) */
00423 
00424 /*  INFO    (output) INTEGER */
00425 /*          = 0:  successful exit */
00426 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00427 /*          > 0:  A routine returned an error code. */
00428 
00429 /*  ===================================================================== */
00430 
00431 /*     .. Parameters .. */
00432 /*     .. */
00433 /*     .. Local Scalars .. */
00434 /*     .. */
00435 /*     .. Local Arrays .. */
00436 /*     .. */
00437 /*     .. External Functions .. */
00438 /*     .. */
00439 /*     .. External Subroutines .. */
00440 /*     .. */
00441 /*     .. Intrinsic Functions .. */
00442 /*     .. */
00443 /*     .. Scalars in Common .. */
00444 /*     .. */
00445 /*     .. Common blocks .. */
00446 /*     .. */
00447 /*     .. Executable Statements .. */
00448 
00449 /*     Check for errors */
00450 
00451     /* Parameter adjustments */
00452     q_dim1 = *lda;
00453     q_offset = 1 + q_dim1;
00454     q -= q_offset;
00455     z_dim1 = *lda;
00456     z_offset = 1 + z_dim1;
00457     z__ -= z_offset;
00458     bi_dim1 = *lda;
00459     bi_offset = 1 + bi_dim1;
00460     bi -= bi_offset;
00461     ai_dim1 = *lda;
00462     ai_offset = 1 + ai_dim1;
00463     ai -= ai_offset;
00464     b_dim1 = *lda;
00465     b_offset = 1 + b_dim1;
00466     b -= b_offset;
00467     a_dim1 = *lda;
00468     a_offset = 1 + a_dim1;
00469     a -= a_offset;
00470     --alphar;
00471     --alphai;
00472     --beta;
00473     c_dim1 = *ldc;
00474     c_offset = 1 + c_dim1;
00475     c__ -= c_offset;
00476     --s;
00477     --work;
00478     --iwork;
00479     --bwork;
00480 
00481     /* Function Body */
00482     if (*nsize < 0) {
00483         *info = -1;
00484     } else if (*thresh < 0.) {
00485         *info = -2;
00486     } else if (*nin <= 0) {
00487         *info = -3;
00488     } else if (*nout <= 0) {
00489         *info = -4;
00490     } else if (*lda < 1 || *lda < *nsize) {
00491         *info = -6;
00492     } else if (*ldc < 1 || *ldc < *nsize * *nsize / 2) {
00493         *info = -17;
00494     } else if (*liwork < *nsize + 6) {
00495         *info = -21;
00496     }
00497 
00498 /*     Compute workspace */
00499 /*      (Note: Comments in the code beginning "Workspace:" describe the */
00500 /*       minimal amount of workspace needed at that point in the code, */
00501 /*       as well as the preferred amount for good performance. */
00502 /*       NB refers to the optimal block size for the immediately */
00503 /*       following subroutine, as returned by ILAENV.) */
00504 
00505     minwrk = 1;
00506     if (*info == 0 && *lwork >= 1) {
00507 /* Computing MAX */
00508         i__1 = (*nsize + 1) * 10, i__2 = *nsize * 5 * *nsize / 2;
00509         minwrk = max(i__1,i__2);
00510 
00511 /*        workspace for sggesx */
00512 
00513         maxwrk = (*nsize + 1) * 9 + *nsize * ilaenv_(&c__1, "DGEQRF", " ", 
00514                 nsize, &c__1, nsize, &c__0);
00515 /* Computing MAX */
00516         i__1 = maxwrk, i__2 = (*nsize + 1) * 9 + *nsize * ilaenv_(&c__1, 
00517                 "DORGQR", " ", nsize, &c__1, nsize, &c_n1);
00518         maxwrk = max(i__1,i__2);
00519 
00520 /*        workspace for dgesvd */
00521 
00522         bdspac = *nsize * 5 * *nsize / 2;
00523 /* Computing MAX */
00524         i__3 = *nsize * *nsize / 2;
00525         i__4 = *nsize * *nsize / 2;
00526         i__1 = maxwrk, i__2 = *nsize * 3 * *nsize / 2 + *nsize * *nsize * 
00527                 ilaenv_(&c__1, "DGEBRD", " ", &i__3, &i__4, &c_n1, &c_n1);
00528         maxwrk = max(i__1,i__2);
00529         maxwrk = max(maxwrk,bdspac);
00530 
00531         maxwrk = max(maxwrk,minwrk);
00532 
00533         work[1] = (doublereal) maxwrk;
00534     }
00535 
00536     if (*lwork < minwrk) {
00537         *info = -19;
00538     }
00539 
00540     if (*info != 0) {
00541         i__1 = -(*info);
00542         xerbla_("DDRGSX", &i__1);
00543         return 0;
00544     }
00545 
00546 /*     Important constants */
00547 
00548     ulp = dlamch_("P");
00549     ulpinv = 1. / ulp;
00550     smlnum = dlamch_("S") / ulp;
00551     bignum = 1. / smlnum;
00552     dlabad_(&smlnum, &bignum);
00553     thrsh2 = *thresh * 10.;
00554     ntestt = 0;
00555     nerrs = 0;
00556 
00557 /*     Go to the tests for read-in matrix pairs */
00558 
00559     ifunc = 0;
00560     if (*nsize == 0) {
00561         goto L70;
00562     }
00563 
00564 /*     Test the built-in matrix pairs. */
00565 /*     Loop over different functions (IFUNC) of DGGESX, types (PRTYPE) */
00566 /*     of test matrices, different size (M+N) */
00567 
00568     prtype = 0;
00569     qba = 3;
00570     qbb = 4;
00571     weight = sqrt(ulp);
00572 
00573     for (ifunc = 0; ifunc <= 3; ++ifunc) {
00574         for (prtype = 1; prtype <= 5; ++prtype) {
00575             i__1 = *nsize - 1;
00576             for (mn_1.m = 1; mn_1.m <= i__1; ++mn_1.m) {
00577                 i__2 = *nsize - mn_1.m;
00578                 for (mn_1.n = 1; mn_1.n <= i__2; ++mn_1.n) {
00579 
00580                     weight = 1. / weight;
00581                     mn_1.mplusn = mn_1.m + mn_1.n;
00582 
00583 /*                 Generate test matrices */
00584 
00585                     mn_1.fs = TRUE_;
00586                     mn_1.k = 0;
00587 
00588                     dlaset_("Full", &mn_1.mplusn, &mn_1.mplusn, &c_b26, &
00589                             c_b26, &ai[ai_offset], lda);
00590                     dlaset_("Full", &mn_1.mplusn, &mn_1.mplusn, &c_b26, &
00591                             c_b26, &bi[bi_offset], lda);
00592 
00593                     dlatm5_(&prtype, &mn_1.m, &mn_1.n, &ai[ai_offset], lda, &
00594                             ai[mn_1.m + 1 + (mn_1.m + 1) * ai_dim1], lda, &ai[
00595                             (mn_1.m + 1) * ai_dim1 + 1], lda, &bi[bi_offset], 
00596                             lda, &bi[mn_1.m + 1 + (mn_1.m + 1) * bi_dim1], 
00597                             lda, &bi[(mn_1.m + 1) * bi_dim1 + 1], lda, &q[
00598                             q_offset], lda, &z__[z_offset], lda, &weight, &
00599                             qba, &qbb);
00600 
00601 /*                 Compute the Schur factorization and swapping the */
00602 /*                 m-by-m (1,1)-blocks with n-by-n (2,2)-blocks. */
00603 /*                 Swapping is accomplished via the function DLCTSX */
00604 /*                 which is supplied below. */
00605 
00606                     if (ifunc == 0) {
00607                         *(unsigned char *)sense = 'N';
00608                     } else if (ifunc == 1) {
00609                         *(unsigned char *)sense = 'E';
00610                     } else if (ifunc == 2) {
00611                         *(unsigned char *)sense = 'V';
00612                     } else if (ifunc == 3) {
00613                         *(unsigned char *)sense = 'B';
00614                     }
00615 
00616                     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &ai[ai_offset]
00617 , lda, &a[a_offset], lda);
00618                     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &bi[bi_offset]
00619 , lda, &b[b_offset], lda);
00620 
00621                     dggesx_("V", "V", "S", (L_fp)dlctsx_, sense, &mn_1.mplusn, 
00622                              &ai[ai_offset], lda, &bi[bi_offset], lda, &mm, &
00623                             alphar[1], &alphai[1], &beta[1], &q[q_offset], 
00624                             lda, &z__[z_offset], lda, pl, difest, &work[1], 
00625                             lwork, &iwork[1], liwork, &bwork[1], &linfo);
00626 
00627                     if (linfo != 0 && linfo != mn_1.mplusn + 2) {
00628                         result[0] = ulpinv;
00629                         io___22.ciunit = *nout;
00630                         s_wsfe(&io___22);
00631                         do_fio(&c__1, "DGGESX", (ftnlen)6);
00632                         do_fio(&c__1, (char *)&linfo, (ftnlen)sizeof(integer))
00633                                 ;
00634                         do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(
00635                                 integer));
00636                         do_fio(&c__1, (char *)&prtype, (ftnlen)sizeof(integer)
00637                                 );
00638                         e_wsfe();
00639                         *info = linfo;
00640                         goto L30;
00641                     }
00642 
00643 /*                 Compute the norm(A, B) */
00644 
00645                     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &ai[ai_offset]
00646 , lda, &work[1], &mn_1.mplusn);
00647                     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &bi[bi_offset]
00648 , lda, &work[mn_1.mplusn * mn_1.mplusn + 1], &
00649                             mn_1.mplusn);
00650                     i__3 = mn_1.mplusn << 1;
00651                     abnrm = dlange_("Fro", &mn_1.mplusn, &i__3, &work[1], &
00652                             mn_1.mplusn, &work[1]);
00653 
00654 /*                 Do tests (1) to (4) */
00655 
00656                     dget51_(&c__1, &mn_1.mplusn, &a[a_offset], lda, &ai[
00657                             ai_offset], lda, &q[q_offset], lda, &z__[z_offset]
00658 , lda, &work[1], result);
00659                     dget51_(&c__1, &mn_1.mplusn, &b[b_offset], lda, &bi[
00660                             bi_offset], lda, &q[q_offset], lda, &z__[z_offset]
00661 , lda, &work[1], &result[1]);
00662                     dget51_(&c__3, &mn_1.mplusn, &b[b_offset], lda, &bi[
00663                             bi_offset], lda, &q[q_offset], lda, &q[q_offset], 
00664                             lda, &work[1], &result[2]);
00665                     dget51_(&c__3, &mn_1.mplusn, &b[b_offset], lda, &bi[
00666                             bi_offset], lda, &z__[z_offset], lda, &z__[
00667                             z_offset], lda, &work[1], &result[3]);
00668                     ntest = 4;
00669 
00670 /*                 Do tests (5) and (6): check Schur form of A and */
00671 /*                 compare eigenvalues with diagonals. */
00672 
00673                     temp1 = 0.;
00674                     result[4] = 0.;
00675                     result[5] = 0.;
00676 
00677                     i__3 = mn_1.mplusn;
00678                     for (j = 1; j <= i__3; ++j) {
00679                         ilabad = FALSE_;
00680                         if (alphai[j] == 0.) {
00681 /* Computing MAX */
00682                             d__7 = smlnum, d__8 = (d__2 = alphar[j], abs(d__2)
00683                                     ), d__7 = max(d__7,d__8), d__8 = (d__3 = 
00684                                     ai[j + j * ai_dim1], abs(d__3));
00685 /* Computing MAX */
00686                             d__9 = smlnum, d__10 = (d__5 = beta[j], abs(d__5))
00687                                     , d__9 = max(d__9,d__10), d__10 = (d__6 = 
00688                                     bi[j + j * bi_dim1], abs(d__6));
00689                             temp2 = ((d__1 = alphar[j] - ai[j + j * ai_dim1], 
00690                                     abs(d__1)) / max(d__7,d__8) + (d__4 = 
00691                                     beta[j] - bi[j + j * bi_dim1], abs(d__4)) 
00692                                     / max(d__9,d__10)) / ulp;
00693                             if (j < mn_1.mplusn) {
00694                                 if (ai[j + 1 + j * ai_dim1] != 0.) {
00695                                     ilabad = TRUE_;
00696                                     result[4] = ulpinv;
00697                                 }
00698                             }
00699                             if (j > 1) {
00700                                 if (ai[j + (j - 1) * ai_dim1] != 0.) {
00701                                     ilabad = TRUE_;
00702                                     result[4] = ulpinv;
00703                                 }
00704                             }
00705                         } else {
00706                             if (alphai[j] > 0.) {
00707                                 i1 = j;
00708                             } else {
00709                                 i1 = j - 1;
00710                             }
00711                             if (i1 <= 0 || i1 >= mn_1.mplusn) {
00712                                 ilabad = TRUE_;
00713                             } else if (i1 < mn_1.mplusn - 1) {
00714                                 if (ai[i1 + 2 + (i1 + 1) * ai_dim1] != 0.) {
00715                                     ilabad = TRUE_;
00716                                     result[4] = ulpinv;
00717                                 }
00718                             } else if (i1 > 1) {
00719                                 if (ai[i1 + (i1 - 1) * ai_dim1] != 0.) {
00720                                     ilabad = TRUE_;
00721                                     result[4] = ulpinv;
00722                                 }
00723                             }
00724                             if (! ilabad) {
00725                                 dget53_(&ai[i1 + i1 * ai_dim1], lda, &bi[i1 + 
00726                                         i1 * bi_dim1], lda, &beta[j], &alphar[
00727                                         j], &alphai[j], &temp2, &iinfo);
00728                                 if (iinfo >= 3) {
00729                                     io___31.ciunit = *nout;
00730                                     s_wsfe(&io___31);
00731                                     do_fio(&c__1, (char *)&iinfo, (ftnlen)
00732                                             sizeof(integer));
00733                                     do_fio(&c__1, (char *)&j, (ftnlen)sizeof(
00734                                             integer));
00735                                     do_fio(&c__1, (char *)&mn_1.mplusn, (
00736                                             ftnlen)sizeof(integer));
00737                                     do_fio(&c__1, (char *)&prtype, (ftnlen)
00738                                             sizeof(integer));
00739                                     e_wsfe();
00740                                     *info = abs(iinfo);
00741                                 }
00742                             } else {
00743                                 temp2 = ulpinv;
00744                             }
00745                         }
00746                         temp1 = max(temp1,temp2);
00747                         if (ilabad) {
00748                             io___32.ciunit = *nout;
00749                             s_wsfe(&io___32);
00750                             do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer))
00751                                     ;
00752                             do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)
00753                                     sizeof(integer));
00754                             do_fio(&c__1, (char *)&prtype, (ftnlen)sizeof(
00755                                     integer));
00756                             e_wsfe();
00757                         }
00758 /* L10: */
00759                     }
00760                     result[5] = temp1;
00761                     ntest += 2;
00762 
00763 /*                 Test (7) (if sorting worked) */
00764 
00765                     result[6] = 0.;
00766                     if (linfo == mn_1.mplusn + 3) {
00767                         result[6] = ulpinv;
00768                     } else if (mm != mn_1.n) {
00769                         result[6] = ulpinv;
00770                     }
00771                     ++ntest;
00772 
00773 /*                 Test (8): compare the estimated value DIF and its */
00774 /*                 value. first, compute the exact DIF. */
00775 
00776                     result[7] = 0.;
00777                     mn2 = mm * (mn_1.mplusn - mm) << 1;
00778                     if (ifunc >= 2 && mn2 <= *ncmax * *ncmax) {
00779 
00780 /*                    Note: for either following two causes, there are */
00781 /*                    almost same number of test cases fail the test. */
00782 
00783                         i__3 = mn_1.mplusn - mm;
00784                         dlakf2_(&mm, &i__3, &ai[ai_offset], lda, &ai[mm + 1 + 
00785                                 (mm + 1) * ai_dim1], &bi[bi_offset], &bi[mm + 
00786                                 1 + (mm + 1) * bi_dim1], &c__[c_offset], ldc);
00787 
00788                         i__3 = *lwork - 2;
00789                         dgesvd_("N", "N", &mn2, &mn2, &c__[c_offset], ldc, &s[
00790                                 1], &work[1], &c__1, &work[2], &c__1, &work[3]
00791 , &i__3, info);
00792                         diftru = s[mn2];
00793 
00794                         if (difest[1] == 0.) {
00795                             if (diftru > abnrm * ulp) {
00796                                 result[7] = ulpinv;
00797                             }
00798                         } else if (diftru == 0.) {
00799                             if (difest[1] > abnrm * ulp) {
00800                                 result[7] = ulpinv;
00801                             }
00802                         } else if (diftru > thrsh2 * difest[1] || diftru * 
00803                                 thrsh2 < difest[1]) {
00804 /* Computing MAX */
00805                             d__1 = diftru / difest[1], d__2 = difest[1] / 
00806                                     diftru;
00807                             result[7] = max(d__1,d__2);
00808                         }
00809                         ++ntest;
00810                     }
00811 
00812 /*                 Test (9) */
00813 
00814                     result[8] = 0.;
00815                     if (linfo == mn_1.mplusn + 2) {
00816                         if (diftru > abnrm * ulp) {
00817                             result[8] = ulpinv;
00818                         }
00819                         if (ifunc > 1 && difest[1] != 0.) {
00820                             result[8] = ulpinv;
00821                         }
00822                         if (ifunc == 1 && pl[0] != 0.) {
00823                             result[8] = ulpinv;
00824                         }
00825                         ++ntest;
00826                     }
00827 
00828                     ntestt += ntest;
00829 
00830 /*                 Print out tests which fail. */
00831 
00832                     for (j = 1; j <= 9; ++j) {
00833                         if (result[j - 1] >= *thresh) {
00834 
00835 /*                       If this is the first test to fail, */
00836 /*                       print a header to the data file. */
00837 
00838                             if (nerrs == 0) {
00839                                 io___35.ciunit = *nout;
00840                                 s_wsfe(&io___35);
00841                                 do_fio(&c__1, "SGX", (ftnlen)3);
00842                                 e_wsfe();
00843 
00844 /*                          Matrix types */
00845 
00846                                 io___36.ciunit = *nout;
00847                                 s_wsfe(&io___36);
00848                                 e_wsfe();
00849 
00850 /*                          Tests performed */
00851 
00852                                 io___37.ciunit = *nout;
00853                                 s_wsfe(&io___37);
00854                                 do_fio(&c__1, "orthogonal", (ftnlen)10);
00855                                 do_fio(&c__1, "'", (ftnlen)1);
00856                                 do_fio(&c__1, "transpose", (ftnlen)9);
00857                                 for (i__ = 1; i__ <= 4; ++i__) {
00858                                     do_fio(&c__1, "'", (ftnlen)1);
00859                                 }
00860                                 e_wsfe();
00861 
00862                             }
00863                             ++nerrs;
00864                             if (result[j - 1] < 1e4) {
00865                                 io___39.ciunit = *nout;
00866                                 s_wsfe(&io___39);
00867                                 do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)
00868                                         sizeof(integer));
00869                                 do_fio(&c__1, (char *)&prtype, (ftnlen)sizeof(
00870                                         integer));
00871                                 do_fio(&c__1, (char *)&weight, (ftnlen)sizeof(
00872                                         doublereal));
00873                                 do_fio(&c__1, (char *)&mn_1.m, (ftnlen)sizeof(
00874                                         integer));
00875                                 do_fio(&c__1, (char *)&j, (ftnlen)sizeof(
00876                                         integer));
00877                                 do_fio(&c__1, (char *)&result[j - 1], (ftnlen)
00878                                         sizeof(doublereal));
00879                                 e_wsfe();
00880                             } else {
00881                                 io___40.ciunit = *nout;
00882                                 s_wsfe(&io___40);
00883                                 do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)
00884                                         sizeof(integer));
00885                                 do_fio(&c__1, (char *)&prtype, (ftnlen)sizeof(
00886                                         integer));
00887                                 do_fio(&c__1, (char *)&weight, (ftnlen)sizeof(
00888                                         doublereal));
00889                                 do_fio(&c__1, (char *)&mn_1.m, (ftnlen)sizeof(
00890                                         integer));
00891                                 do_fio(&c__1, (char *)&j, (ftnlen)sizeof(
00892                                         integer));
00893                                 do_fio(&c__1, (char *)&result[j - 1], (ftnlen)
00894                                         sizeof(doublereal));
00895                                 e_wsfe();
00896                             }
00897                         }
00898 /* L20: */
00899                     }
00900 
00901 L30:
00902                     ;
00903                 }
00904 /* L40: */
00905             }
00906 /* L50: */
00907         }
00908 /* L60: */
00909     }
00910 
00911     goto L150;
00912 
00913 L70:
00914 
00915 /*     Read in data from file to check accuracy of condition estimation */
00916 /*     Read input data until N=0 */
00917 
00918     nptknt = 0;
00919 
00920 L80:
00921     io___42.ciunit = *nin;
00922     i__1 = s_rsle(&io___42);
00923     if (i__1 != 0) {
00924         goto L140;
00925     }
00926     i__1 = do_lio(&c__3, &c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(integer))
00927             ;
00928     if (i__1 != 0) {
00929         goto L140;
00930     }
00931     i__1 = e_rsle();
00932     if (i__1 != 0) {
00933         goto L140;
00934     }
00935     if (mn_1.mplusn == 0) {
00936         goto L140;
00937     }
00938     io___43.ciunit = *nin;
00939     i__1 = s_rsle(&io___43);
00940     if (i__1 != 0) {
00941         goto L140;
00942     }
00943     i__1 = do_lio(&c__3, &c__1, (char *)&mn_1.n, (ftnlen)sizeof(integer));
00944     if (i__1 != 0) {
00945         goto L140;
00946     }
00947     i__1 = e_rsle();
00948     if (i__1 != 0) {
00949         goto L140;
00950     }
00951     i__1 = mn_1.mplusn;
00952     for (i__ = 1; i__ <= i__1; ++i__) {
00953         io___44.ciunit = *nin;
00954         s_rsle(&io___44);
00955         i__2 = mn_1.mplusn;
00956         for (j = 1; j <= i__2; ++j) {
00957             do_lio(&c__5, &c__1, (char *)&ai[i__ + j * ai_dim1], (ftnlen)
00958                     sizeof(doublereal));
00959         }
00960         e_rsle();
00961 /* L90: */
00962     }
00963     i__1 = mn_1.mplusn;
00964     for (i__ = 1; i__ <= i__1; ++i__) {
00965         io___45.ciunit = *nin;
00966         s_rsle(&io___45);
00967         i__2 = mn_1.mplusn;
00968         for (j = 1; j <= i__2; ++j) {
00969             do_lio(&c__5, &c__1, (char *)&bi[i__ + j * bi_dim1], (ftnlen)
00970                     sizeof(doublereal));
00971         }
00972         e_rsle();
00973 /* L100: */
00974     }
00975     io___46.ciunit = *nin;
00976     s_rsle(&io___46);
00977     do_lio(&c__5, &c__1, (char *)&pltru, (ftnlen)sizeof(doublereal));
00978     do_lio(&c__5, &c__1, (char *)&diftru, (ftnlen)sizeof(doublereal));
00979     e_rsle();
00980 
00981     ++nptknt;
00982     mn_1.fs = TRUE_;
00983     mn_1.k = 0;
00984     mn_1.m = mn_1.mplusn - mn_1.n;
00985 
00986     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &ai[ai_offset], lda, &a[
00987             a_offset], lda);
00988     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &bi[bi_offset], lda, &b[
00989             b_offset], lda);
00990 
00991 /*     Compute the Schur factorization while swaping the */
00992 /*     m-by-m (1,1)-blocks with n-by-n (2,2)-blocks. */
00993 
00994     dggesx_("V", "V", "S", (L_fp)dlctsx_, "B", &mn_1.mplusn, &ai[ai_offset], 
00995             lda, &bi[bi_offset], lda, &mm, &alphar[1], &alphai[1], &beta[1], &
00996             q[q_offset], lda, &z__[z_offset], lda, pl, difest, &work[1], 
00997             lwork, &iwork[1], liwork, &bwork[1], &linfo);
00998 
00999     if (linfo != 0 && linfo != mn_1.mplusn + 2) {
01000         result[0] = ulpinv;
01001         io___48.ciunit = *nout;
01002         s_wsfe(&io___48);
01003         do_fio(&c__1, "DGGESX", (ftnlen)6);
01004         do_fio(&c__1, (char *)&linfo, (ftnlen)sizeof(integer));
01005         do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(integer));
01006         do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
01007         e_wsfe();
01008         goto L130;
01009     }
01010 
01011 /*     Compute the norm(A, B) */
01012 /*        (should this be norm of (A,B) or (AI,BI)?) */
01013 
01014     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &ai[ai_offset], lda, &work[1], 
01015              &mn_1.mplusn);
01016     dlacpy_("Full", &mn_1.mplusn, &mn_1.mplusn, &bi[bi_offset], lda, &work[
01017             mn_1.mplusn * mn_1.mplusn + 1], &mn_1.mplusn);
01018     i__1 = mn_1.mplusn << 1;
01019     abnrm = dlange_("Fro", &mn_1.mplusn, &i__1, &work[1], &mn_1.mplusn, &work[
01020             1]);
01021 
01022 /*     Do tests (1) to (4) */
01023 
01024     dget51_(&c__1, &mn_1.mplusn, &a[a_offset], lda, &ai[ai_offset], lda, &q[
01025             q_offset], lda, &z__[z_offset], lda, &work[1], result);
01026     dget51_(&c__1, &mn_1.mplusn, &b[b_offset], lda, &bi[bi_offset], lda, &q[
01027             q_offset], lda, &z__[z_offset], lda, &work[1], &result[1]);
01028     dget51_(&c__3, &mn_1.mplusn, &b[b_offset], lda, &bi[bi_offset], lda, &q[
01029             q_offset], lda, &q[q_offset], lda, &work[1], &result[2]);
01030     dget51_(&c__3, &mn_1.mplusn, &b[b_offset], lda, &bi[bi_offset], lda, &z__[
01031             z_offset], lda, &z__[z_offset], lda, &work[1], &result[3]);
01032 
01033 /*     Do tests (5) and (6): check Schur form of A and compare */
01034 /*     eigenvalues with diagonals. */
01035 
01036     ntest = 6;
01037     temp1 = 0.;
01038     result[4] = 0.;
01039     result[5] = 0.;
01040 
01041     i__1 = mn_1.mplusn;
01042     for (j = 1; j <= i__1; ++j) {
01043         ilabad = FALSE_;
01044         if (alphai[j] == 0.) {
01045 /* Computing MAX */
01046             d__7 = smlnum, d__8 = (d__2 = alphar[j], abs(d__2)), d__7 = max(
01047                     d__7,d__8), d__8 = (d__3 = ai[j + j * ai_dim1], abs(d__3))
01048                     ;
01049 /* Computing MAX */
01050             d__9 = smlnum, d__10 = (d__5 = beta[j], abs(d__5)), d__9 = max(
01051                     d__9,d__10), d__10 = (d__6 = bi[j + j * bi_dim1], abs(
01052                     d__6));
01053             temp2 = ((d__1 = alphar[j] - ai[j + j * ai_dim1], abs(d__1)) / 
01054                     max(d__7,d__8) + (d__4 = beta[j] - bi[j + j * bi_dim1], 
01055                     abs(d__4)) / max(d__9,d__10)) / ulp;
01056             if (j < mn_1.mplusn) {
01057                 if (ai[j + 1 + j * ai_dim1] != 0.) {
01058                     ilabad = TRUE_;
01059                     result[4] = ulpinv;
01060                 }
01061             }
01062             if (j > 1) {
01063                 if (ai[j + (j - 1) * ai_dim1] != 0.) {
01064                     ilabad = TRUE_;
01065                     result[4] = ulpinv;
01066                 }
01067             }
01068         } else {
01069             if (alphai[j] > 0.) {
01070                 i1 = j;
01071             } else {
01072                 i1 = j - 1;
01073             }
01074             if (i1 <= 0 || i1 >= mn_1.mplusn) {
01075                 ilabad = TRUE_;
01076             } else if (i1 < mn_1.mplusn - 1) {
01077                 if (ai[i1 + 2 + (i1 + 1) * ai_dim1] != 0.) {
01078                     ilabad = TRUE_;
01079                     result[4] = ulpinv;
01080                 }
01081             } else if (i1 > 1) {
01082                 if (ai[i1 + (i1 - 1) * ai_dim1] != 0.) {
01083                     ilabad = TRUE_;
01084                     result[4] = ulpinv;
01085                 }
01086             }
01087             if (! ilabad) {
01088                 dget53_(&ai[i1 + i1 * ai_dim1], lda, &bi[i1 + i1 * bi_dim1], 
01089                         lda, &beta[j], &alphar[j], &alphai[j], &temp2, &iinfo)
01090                         ;
01091                 if (iinfo >= 3) {
01092                     io___49.ciunit = *nout;
01093                     s_wsfe(&io___49);
01094                     do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
01095                     do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
01096                     do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(
01097                             integer));
01098                     do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
01099                     e_wsfe();
01100                     *info = abs(iinfo);
01101                 }
01102             } else {
01103                 temp2 = ulpinv;
01104             }
01105         }
01106         temp1 = max(temp1,temp2);
01107         if (ilabad) {
01108             io___50.ciunit = *nout;
01109             s_wsfe(&io___50);
01110             do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
01111             do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(integer));
01112             do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
01113             e_wsfe();
01114         }
01115 /* L110: */
01116     }
01117     result[5] = temp1;
01118 
01119 /*     Test (7) (if sorting worked)  <--------- need to be checked. */
01120 
01121     ntest = 7;
01122     result[6] = 0.;
01123     if (linfo == mn_1.mplusn + 3) {
01124         result[6] = ulpinv;
01125     }
01126 
01127 /*     Test (8): compare the estimated value of DIF and its true value. */
01128 
01129     ntest = 8;
01130     result[7] = 0.;
01131     if (difest[1] == 0.) {
01132         if (diftru > abnrm * ulp) {
01133             result[7] = ulpinv;
01134         }
01135     } else if (diftru == 0.) {
01136         if (difest[1] > abnrm * ulp) {
01137             result[7] = ulpinv;
01138         }
01139     } else if (diftru > thrsh2 * difest[1] || diftru * thrsh2 < difest[1]) {
01140 /* Computing MAX */
01141         d__1 = diftru / difest[1], d__2 = difest[1] / diftru;
01142         result[7] = max(d__1,d__2);
01143     }
01144 
01145 /*     Test (9) */
01146 
01147     ntest = 9;
01148     result[8] = 0.;
01149     if (linfo == mn_1.mplusn + 2) {
01150         if (diftru > abnrm * ulp) {
01151             result[8] = ulpinv;
01152         }
01153         if (ifunc > 1 && difest[1] != 0.) {
01154             result[8] = ulpinv;
01155         }
01156         if (ifunc == 1 && pl[0] != 0.) {
01157             result[8] = ulpinv;
01158         }
01159     }
01160 
01161 /*     Test (10): compare the estimated value of PL and it true value. */
01162 
01163     ntest = 10;
01164     result[9] = 0.;
01165     if (pl[0] == 0.) {
01166         if (pltru > abnrm * ulp) {
01167             result[9] = ulpinv;
01168         }
01169     } else if (pltru == 0.) {
01170         if (pl[0] > abnrm * ulp) {
01171             result[9] = ulpinv;
01172         }
01173     } else if (pltru > *thresh * pl[0] || pltru * *thresh < pl[0]) {
01174         result[9] = ulpinv;
01175     }
01176 
01177     ntestt += ntest;
01178 
01179 /*     Print out tests which fail. */
01180 
01181     i__1 = ntest;
01182     for (j = 1; j <= i__1; ++j) {
01183         if (result[j - 1] >= *thresh) {
01184 
01185 /*           If this is the first test to fail, */
01186 /*           print a header to the data file. */
01187 
01188             if (nerrs == 0) {
01189                 io___51.ciunit = *nout;
01190                 s_wsfe(&io___51);
01191                 do_fio(&c__1, "SGX", (ftnlen)3);
01192                 e_wsfe();
01193 
01194 /*              Matrix types */
01195 
01196                 io___52.ciunit = *nout;
01197                 s_wsfe(&io___52);
01198                 e_wsfe();
01199 
01200 /*              Tests performed */
01201 
01202                 io___53.ciunit = *nout;
01203                 s_wsfe(&io___53);
01204                 do_fio(&c__1, "orthogonal", (ftnlen)10);
01205                 do_fio(&c__1, "'", (ftnlen)1);
01206                 do_fio(&c__1, "transpose", (ftnlen)9);
01207                 for (i__ = 1; i__ <= 4; ++i__) {
01208                     do_fio(&c__1, "'", (ftnlen)1);
01209                 }
01210                 e_wsfe();
01211 
01212             }
01213             ++nerrs;
01214             if (result[j - 1] < 1e4) {
01215                 io___54.ciunit = *nout;
01216                 s_wsfe(&io___54);
01217                 do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
01218                 do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(integer));
01219                 do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
01220                 do_fio(&c__1, (char *)&result[j - 1], (ftnlen)sizeof(
01221                         doublereal));
01222                 e_wsfe();
01223             } else {
01224                 io___55.ciunit = *nout;
01225                 s_wsfe(&io___55);
01226                 do_fio(&c__1, (char *)&nptknt, (ftnlen)sizeof(integer));
01227                 do_fio(&c__1, (char *)&mn_1.mplusn, (ftnlen)sizeof(integer));
01228                 do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
01229                 do_fio(&c__1, (char *)&result[j - 1], (ftnlen)sizeof(
01230                         doublereal));
01231                 e_wsfe();
01232             }
01233         }
01234 
01235 /* L120: */
01236     }
01237 
01238 L130:
01239     goto L80;
01240 L140:
01241 
01242 L150:
01243 
01244 /*     Summary */
01245 
01246     alasvm_("SGX", nout, &nerrs, &ntestt, &c__0);
01247 
01248     work[1] = (doublereal) maxwrk;
01249 
01250     return 0;
01251 
01252 
01253 
01254 
01255 
01256 
01257 
01258 
01259 
01260 /*     End of DDRGSX */
01261 
01262 } /* ddrgsx_ */


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