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


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