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


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