LAPACK 3.3.1 Linear Algebra PACKage

# ddrvgg.f

Go to the documentation of this file.
```00001       SUBROUTINE DDRVGG( NSIZES, NN, NTYPES, DOTYPE, ISEED, THRESH,
00002      \$                   THRSHN, NOUNIT, A, LDA, B, S, T, S2, T2, Q,
00003      \$                   LDQ, Z, ALPHR1, ALPHI1, BETA1, ALPHR2, ALPHI2,
00004      \$                   BETA2, VL, VR, WORK, LWORK, RESULT, INFO )
00005 *
00006 *  -- LAPACK test routine (version 3.1) --
00007 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00008 *     November 2006
00009 *
00010 *     .. Scalar Arguments ..
00011       INTEGER            INFO, LDA, LDQ, LWORK, NOUNIT, NSIZES, NTYPES
00012       DOUBLE PRECISION   THRESH, THRSHN
00013 *     ..
00014 *     .. Array Arguments ..
00015       LOGICAL            DOTYPE( * )
00016       INTEGER            ISEED( 4 ), NN( * )
00017       DOUBLE PRECISION   A( LDA, * ), ALPHI1( * ), ALPHI2( * ),
00018      \$                   ALPHR1( * ), ALPHR2( * ), B( LDA, * ),
00019      \$                   BETA1( * ), BETA2( * ), Q( LDQ, * ),
00020      \$                   RESULT( * ), S( LDA, * ), S2( LDA, * ),
00021      \$                   T( LDA, * ), T2( LDA, * ), VL( LDQ, * ),
00022      \$                   VR( LDQ, * ), WORK( * ), Z( LDQ, * )
00023 *     ..
00024 *
00025 *  Purpose
00026 *  =======
00027 *
00028 *  DDRVGG  checks the nonsymmetric generalized eigenvalue driver
00029 *  routines.
00030 *                                T          T        T
00031 *  DGEGS factors A and B as Q S Z  and Q T Z , where   means
00032 *  transpose, T is upper triangular, S is in generalized Schur form
00033 *  (block upper triangular, with 1x1 and 2x2 blocks on the diagonal,
00034 *  the 2x2 blocks corresponding to complex conjugate pairs of
00035 *  generalized eigenvalues), and Q and Z are orthogonal.  It also
00036 *  computes the generalized eigenvalues (alpha(1),beta(1)), ...,
00037 *  (alpha(n),beta(n)), where alpha(j)=S(j,j) and beta(j)=P(j,j) --
00038 *  thus, w(j) = alpha(j)/beta(j) is a root of the generalized
00039 *  eigenvalue problem
00040 *
00041 *      det( A - w(j) B ) = 0
00042 *
00043 *  and m(j) = beta(j)/alpha(j) is a root of the essentially equivalent
00044 *  problem
00045 *
00046 *      det( m(j) A - B ) = 0
00047 *
00048 *  DGEGV computes the generalized eigenvalues (alpha(1),beta(1)), ...,
00049 *  (alpha(n),beta(n)), the matrix L whose columns contain the
00050 *  generalized left eigenvectors l, and the matrix R whose columns
00051 *  contain the generalized right eigenvectors r for the pair (A,B).
00052 *
00053 *  When DDRVGG is called, a number of matrix "sizes" ("n's") and a
00054 *  number of matrix "types" are specified.  For each size ("n")
00055 *  and each type of matrix, one matrix will be generated and used
00056 *  to test the nonsymmetric eigenroutines.  For each matrix, 7
00057 *  tests will be performed and compared with the threshhold THRESH:
00058 *
00059 *  Results from DGEGS:
00060 *
00061 *                   T
00062 *  (1)   | A - Q S Z  | / ( |A| n ulp )
00063 *
00064 *                   T
00065 *  (2)   | B - Q T Z  | / ( |B| n ulp )
00066 *
00067 *                T
00068 *  (3)   | I - QQ  | / ( n ulp )
00069 *
00070 *                T
00071 *  (4)   | I - ZZ  | / ( n ulp )
00072 *
00073 *  (5)   maximum over j of D(j)  where:
00074 *
00075 *  if alpha(j) is real:
00076 *                      |alpha(j) - S(j,j)|        |beta(j) - T(j,j)|
00077 *            D(j) = ------------------------ + -----------------------
00078 *                   max(|alpha(j)|,|S(j,j)|)   max(|beta(j)|,|T(j,j)|)
00079 *
00080 *  if alpha(j) is complex:
00081 *                                  | det( s S - w T ) |
00082 *            D(j) = ---------------------------------------------------
00083 *                   ulp max( s norm(S), |w| norm(T) )*norm( s S - w T )
00084 *
00085 *            and S and T are here the 2 x 2 diagonal blocks of S and T
00086 *            corresponding to the j-th eigenvalue.
00087 *
00088 *  Results from DGEGV:
00089 *
00090 *  (6)   max over all left eigenvalue/-vector pairs (beta/alpha,l) of
00091 *
00092 *     | l**H * (beta A - alpha B) | / ( ulp max( |beta A|, |alpha B| ) )
00093 *
00094 *        where l**H is the conjugate tranpose of l.
00095 *
00096 *  (7)   max over all right eigenvalue/-vector pairs (beta/alpha,r) of
00097 *
00098 *        | (beta A - alpha B) r | / ( ulp max( |beta A|, |alpha B| ) )
00099 *
00100 *  Test Matrices
00101 *  ---- --------
00102 *
00103 *  The sizes of the test matrices are specified by an array
00104 *  NN(1:NSIZES); the value of each element NN(j) specifies one size.
00105 *  The "types" are specified by a logical array DOTYPE( 1:NTYPES ); if
00106 *  DOTYPE(j) is .TRUE., then matrix type "j" will be generated.
00107 *  Currently, the list of possible types is:
00108 *
00109 *  (1)  ( 0, 0 )         (a pair of zero matrices)
00110 *
00111 *  (2)  ( I, 0 )         (an identity and a zero matrix)
00112 *
00113 *  (3)  ( 0, I )         (an identity and a zero matrix)
00114 *
00115 *  (4)  ( I, I )         (a pair of identity matrices)
00116 *
00117 *          t   t
00118 *  (5)  ( J , J  )       (a pair of transposed Jordan blocks)
00119 *
00120 *                                      t                ( I   0  )
00121 *  (6)  ( X, Y )         where  X = ( J   0  )  and Y = (      t )
00122 *                                   ( 0   I  )          ( 0   J  )
00123 *                        and I is a k x k identity and J a (k+1)x(k+1)
00124 *                        Jordan block; k=(N-1)/2
00125 *
00126 *  (7)  ( D, I )         where D is diag( 0, 1,..., N-1 ) (a diagonal
00127 *                        matrix with those diagonal entries.)
00128 *  (8)  ( I, D )
00129 *
00130 *  (9)  ( big*D, small*I ) where "big" is near overflow and small=1/big
00131 *
00132 *  (10) ( small*D, big*I )
00133 *
00134 *  (11) ( big*I, small*D )
00135 *
00136 *  (12) ( small*I, big*D )
00137 *
00138 *  (13) ( big*D, big*I )
00139 *
00140 *  (14) ( small*D, small*I )
00141 *
00142 *  (15) ( D1, D2 )        where D1 is diag( 0, 0, 1, ..., N-3, 0 ) and
00143 *                         D2 is diag( 0, N-3, N-4,..., 1, 0, 0 )
00144 *            t   t
00145 *  (16) Q ( J , J ) Z     where Q and Z are random orthogonal matrices.
00146 *
00147 *  (17) Q ( T1, T2 ) Z    where T1 and T2 are upper triangular matrices
00148 *                         with random O(1) entries above the diagonal
00149 *                         and diagonal entries diag(T1) =
00150 *                         ( 0, 0, 1, ..., N-3, 0 ) and diag(T2) =
00151 *                         ( 0, N-3, N-4,..., 1, 0, 0 )
00152 *
00153 *  (18) Q ( T1, T2 ) Z    diag(T1) = ( 0, 0, 1, 1, s, ..., s, 0 )
00154 *                         diag(T2) = ( 0, 1, 0, 1,..., 1, 0 )
00155 *                         s = machine precision.
00156 *
00157 *  (19) Q ( T1, T2 ) Z    diag(T1)=( 0,0,1,1, 1-d, ..., 1-(N-5)*d=s, 0 )
00158 *                         diag(T2) = ( 0, 1, 0, 1, ..., 1, 0 )
00159 *
00160 *                                                         N-5
00161 *  (20) Q ( T1, T2 ) Z    diag(T1)=( 0, 0, 1, 1, a, ..., a   =s, 0 )
00162 *                         diag(T2) = ( 0, 1, 0, 1, ..., 1, 0, 0 )
00163 *
00164 *  (21) Q ( T1, T2 ) Z    diag(T1)=( 0, 0, 1, r1, r2, ..., r(N-4), 0 )
00165 *                         diag(T2) = ( 0, 1, 0, 1, ..., 1, 0, 0 )
00166 *                         where r1,..., r(N-4) are random.
00167 *
00168 *  (22) Q ( big*T1, small*T2 ) Z    diag(T1) = ( 0, 0, 1, ..., N-3, 0 )
00169 *                                   diag(T2) = ( 0, 1, ..., 1, 0, 0 )
00170 *
00171 *  (23) Q ( small*T1, big*T2 ) Z    diag(T1) = ( 0, 0, 1, ..., N-3, 0 )
00172 *                                   diag(T2) = ( 0, 1, ..., 1, 0, 0 )
00173 *
00174 *  (24) Q ( small*T1, small*T2 ) Z  diag(T1) = ( 0, 0, 1, ..., N-3, 0 )
00175 *                                   diag(T2) = ( 0, 1, ..., 1, 0, 0 )
00176 *
00177 *  (25) Q ( big*T1, big*T2 ) Z      diag(T1) = ( 0, 0, 1, ..., N-3, 0 )
00178 *                                   diag(T2) = ( 0, 1, ..., 1, 0, 0 )
00179 *
00180 *  (26) Q ( T1, T2 ) Z     where T1 and T2 are random upper-triangular
00181 *                          matrices.
00182 *
00183 *  Arguments
00184 *  =========
00185 *
00186 *  NSIZES  (input) INTEGER
00187 *          The number of sizes of matrices to use.  If it is zero,
00188 *          DDRVGG does nothing.  It must be at least zero.
00189 *
00190 *  NN      (input) INTEGER array, dimension (NSIZES)
00191 *          An array containing the sizes to be used for the matrices.
00192 *          Zero values will be skipped.  The values must be at least
00193 *          zero.
00194 *
00195 *  NTYPES  (input) INTEGER
00196 *          The number of elements in DOTYPE.   If it is zero, DDRVGG
00197 *          does nothing.  It must be at least zero.  If it is MAXTYP+1
00198 *          and NSIZES is 1, then an additional type, MAXTYP+1 is
00199 *          defined, which is to use whatever matrix is in A.  This
00200 *          is only useful if DOTYPE(1:MAXTYP) is .FALSE. and
00201 *          DOTYPE(MAXTYP+1) is .TRUE. .
00202 *
00203 *  DOTYPE  (input) LOGICAL array, dimension (NTYPES)
00204 *          If DOTYPE(j) is .TRUE., then for each size in NN a
00205 *          matrix of that size and of type j will be generated.
00206 *          If NTYPES is smaller than the maximum number of types
00207 *          defined (PARAMETER MAXTYP), then types NTYPES+1 through
00208 *          MAXTYP will not be generated.  If NTYPES is larger
00209 *          than MAXTYP, DOTYPE(MAXTYP+1) through DOTYPE(NTYPES)
00210 *          will be ignored.
00211 *
00212 *  ISEED   (input/output) INTEGER array, dimension (4)
00213 *          On entry ISEED specifies the seed of the random number
00214 *          generator. The array elements should be between 0 and 4095;
00215 *          if not they will be reduced mod 4096.  Also, ISEED(4) must
00216 *          be odd.  The random number generator uses a linear
00217 *          congruential sequence limited to small integers, and so
00218 *          should produce machine independent random numbers. The
00219 *          values of ISEED are changed on exit, and can be used in the
00220 *          next call to DDRVGG to continue the same random number
00221 *          sequence.
00222 *
00223 *  THRESH  (input) DOUBLE PRECISION
00224 *          A test will count as "failed" if the "error", computed as
00225 *          described above, exceeds THRESH.  Note that the error is
00226 *          scaled to be O(1), so THRESH should be a reasonably small
00227 *          multiple of 1, e.g., 10 or 100.  In particular, it should
00228 *          not depend on the precision (single vs. double) or the size
00229 *          of the matrix.  It must be at least zero.
00230 *
00231 *  THRSHN  (input) DOUBLE PRECISION
00232 *          Threshhold for reporting eigenvector normalization error.
00233 *          If the normalization of any eigenvector differs from 1 by
00234 *          more than THRSHN*ulp, then a special error message will be
00235 *          printed.  (This is handled separately from the other tests,
00236 *          since only a compiler or programming error should cause an
00237 *          error message, at least if THRSHN is at least 5--10.)
00238 *
00239 *  NOUNIT  (input) INTEGER
00240 *          The FORTRAN unit number for printing out error messages
00241 *          (e.g., if a routine returns IINFO not equal to 0.)
00242 *
00243 *  A       (input/workspace) DOUBLE PRECISION array, dimension
00244 *                            (LDA, max(NN))
00245 *          Used to hold the original A matrix.  Used as input only
00246 *          if NTYPES=MAXTYP+1, DOTYPE(1:MAXTYP)=.FALSE., and
00247 *          DOTYPE(MAXTYP+1)=.TRUE.
00248 *
00249 *  LDA     (input) INTEGER
00250 *          The leading dimension of A, B, S, T, S2, and T2.
00251 *          It must be at least 1 and at least max( NN ).
00252 *
00253 *  B       (input/workspace) DOUBLE PRECISION array, dimension
00254 *                            (LDA, max(NN))
00255 *          Used to hold the original B matrix.  Used as input only
00256 *          if NTYPES=MAXTYP+1, DOTYPE(1:MAXTYP)=.FALSE., and
00257 *          DOTYPE(MAXTYP+1)=.TRUE.
00258 *
00259 *  S       (workspace) DOUBLE PRECISION array, dimension (LDA, max(NN))
00260 *          The Schur form matrix computed from A by DGEGS.  On exit, S
00261 *          contains the Schur form matrix corresponding to the matrix
00262 *          in A.
00263 *
00264 *  T       (workspace) DOUBLE PRECISION array, dimension (LDA, max(NN))
00265 *          The upper triangular matrix computed from B by DGEGS.
00266 *
00267 *  S2      (workspace) DOUBLE PRECISION array, dimension (LDA, max(NN))
00268 *          The matrix computed from A by DGEGV.  This will be the
00269 *          Schur form of some matrix related to A, but will not, in
00270 *          general, be the same as S.
00271 *
00272 *  T2      (workspace) DOUBLE PRECISION array, dimension (LDA, max(NN))
00273 *          The matrix computed from B by DGEGV.  This will be the
00274 *          Schur form of some matrix related to B, but will not, in
00275 *          general, be the same as T.
00276 *
00277 *  Q       (workspace) DOUBLE PRECISION array, dimension (LDQ, max(NN))
00278 *          The (left) orthogonal matrix computed by DGEGS.
00279 *
00280 *  LDQ     (input) INTEGER
00281 *          The leading dimension of Q, Z, VL, and VR.  It must
00282 *          be at least 1 and at least max( NN ).
00283 *
00284 *  Z       (workspace) DOUBLE PRECISION array of
00285 *                             dimension( LDQ, max(NN) )
00286 *          The (right) orthogonal matrix computed by DGEGS.
00287 *
00288 *  ALPHR1  (workspace) DOUBLE PRECISION array, dimension (max(NN))
00289 *  ALPHI1  (workspace) DOUBLE PRECISION array, dimension (max(NN))
00290 *  BETA1   (workspace) DOUBLE PRECISION array, dimension (max(NN))
00291 *
00292 *          The generalized eigenvalues of (A,B) computed by DGEGS.
00293 *          ( ALPHR1(k)+ALPHI1(k)*i ) / BETA1(k) is the k-th
00294 *          generalized eigenvalue of the matrices in A and B.
00295 *
00296 *  ALPHR2  (workspace) DOUBLE PRECISION array, dimension (max(NN))
00297 *  ALPHI2  (workspace) DOUBLE PRECISION array, dimension (max(NN))
00298 *  BETA2   (workspace) DOUBLE PRECISION array, dimension (max(NN))
00299 *
00300 *          The generalized eigenvalues of (A,B) computed by DGEGV.
00301 *          ( ALPHR2(k)+ALPHI2(k)*i ) / BETA2(k) is the k-th
00302 *          generalized eigenvalue of the matrices in A and B.
00303 *
00304 *  VL      (workspace) DOUBLE PRECISION array, dimension (LDQ, max(NN))
00305 *          The (block lower triangular) left eigenvector matrix for
00306 *          the matrices in A and B.  (See DTGEVC for the format.)
00307 *
00308 *  VR      (workspace) DOUBLE PRECISION array, dimension (LDQ, max(NN))
00309 *          The (block upper triangular) right eigenvector matrix for
00310 *          the matrices in A and B.  (See DTGEVC for the format.)
00311 *
00312 *  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK)
00313 *
00314 *  LWORK   (input) INTEGER
00315 *          The number of entries in WORK.  This must be at least
00316 *          2*N + MAX( 6*N, N*(NB+1), (k+1)*(2*k+N+1) ), where
00317 *          "k" is the sum of the blocksize and number-of-shifts for
00318 *          DHGEQZ, and NB is the greatest of the blocksizes for
00319 *          DGEQRF, DORMQR, and DORGQR.  (The blocksizes and the
00320 *          number-of-shifts are retrieved through calls to ILAENV.)
00321 *
00322 *  RESULT  (output) DOUBLE PRECISION array, dimension (15)
00323 *          The values computed by the tests described above.
00324 *          The values are currently limited to 1/ulp, to avoid
00325 *          overflow.
00326 *
00327 *  INFO    (output) INTEGER
00328 *          = 0:  successful exit
00329 *          < 0:  if INFO = -i, the i-th argument had an illegal value.
00330 *          > 0:  A routine returned an error code.  INFO is the
00331 *                absolute value of the INFO value returned.
00332 *
00333 *  =====================================================================
00334 *
00335 *     .. Parameters ..
00336       DOUBLE PRECISION   ZERO, ONE
00337       PARAMETER          ( ZERO = 0.0D0, ONE = 1.0D0 )
00338       INTEGER            MAXTYP
00339       PARAMETER          ( MAXTYP = 26 )
00340 *     ..
00341 *     .. Local Scalars ..
00343       INTEGER            I1, IADD, IINFO, IN, J, JC, JR, JSIZE, JTYPE,
00344      \$                   LWKOPT, MTYPES, N, N1, NB, NBZ, NERRS, NMATS,
00345      \$                   NMAX, NS, NTEST, NTESTT
00346       DOUBLE PRECISION   SAFMAX, SAFMIN, TEMP1, TEMP2, ULP, ULPINV
00347 *     ..
00348 *     .. Local Arrays ..
00349       INTEGER            IASIGN( MAXTYP ), IBSIGN( MAXTYP ),
00350      \$                   IOLDSD( 4 ), KADD( 6 ), KAMAGN( MAXTYP ),
00351      \$                   KATYPE( MAXTYP ), KAZERO( MAXTYP ),
00352      \$                   KBMAGN( MAXTYP ), KBTYPE( MAXTYP ),
00353      \$                   KBZERO( MAXTYP ), KCLASS( MAXTYP ),
00354      \$                   KTRIAN( MAXTYP ), KZ1( 6 ), KZ2( 6 )
00355       DOUBLE PRECISION   DUMMA( 4 ), RMAGN( 0: 3 )
00356 *     ..
00357 *     .. External Functions ..
00358       INTEGER            ILAENV
00359       DOUBLE PRECISION   DLAMCH, DLARND
00360       EXTERNAL           ILAENV, DLAMCH, DLARND
00361 *     ..
00362 *     .. External Subroutines ..
00363       EXTERNAL           ALASVM, DGEGS, DGEGV, DGET51, DGET52, DGET53,
00364      \$                   DLABAD, DLACPY, DLARFG, DLASET, DLATM4, DORM2R,
00365      \$                   XERBLA
00366 *     ..
00367 *     .. Intrinsic Functions ..
00368       INTRINSIC          ABS, DBLE, MAX, MIN, SIGN
00369 *     ..
00370 *     .. Data statements ..
00371       DATA               KCLASS / 15*1, 10*2, 1*3 /
00372       DATA               KZ1 / 0, 1, 2, 1, 3, 3 /
00373       DATA               KZ2 / 0, 0, 1, 2, 1, 1 /
00374       DATA               KADD / 0, 0, 0, 0, 3, 2 /
00375       DATA               KATYPE / 0, 1, 0, 1, 2, 3, 4, 1, 4, 4, 1, 1, 4,
00376      \$                   4, 4, 2, 4, 5, 8, 7, 9, 4*4, 0 /
00377       DATA               KBTYPE / 0, 0, 1, 1, 2, -3, 1, 4, 1, 1, 4, 4,
00378      \$                   1, 1, -4, 2, -4, 8*8, 0 /
00379       DATA               KAZERO / 6*1, 2, 1, 2*2, 2*1, 2*2, 3, 1, 3,
00380      \$                   4*5, 4*3, 1 /
00381       DATA               KBZERO / 6*1, 1, 2, 2*1, 2*2, 2*1, 4, 1, 4,
00382      \$                   4*6, 4*4, 1 /
00383       DATA               KAMAGN / 8*1, 2, 3, 2, 3, 2, 3, 7*1, 2, 3, 3,
00384      \$                   2, 1 /
00385       DATA               KBMAGN / 8*1, 3, 2, 3, 2, 2, 3, 7*1, 3, 2, 3,
00386      \$                   2, 1 /
00387       DATA               KTRIAN / 16*0, 10*1 /
00388       DATA               IASIGN / 6*0, 2, 0, 2*2, 2*0, 3*2, 0, 2, 3*0,
00389      \$                   5*2, 0 /
00390       DATA               IBSIGN / 7*0, 2, 2*0, 2*2, 2*0, 2, 0, 2, 9*0 /
00391 *     ..
00392 *     .. Executable Statements ..
00393 *
00394 *     Check for errors
00395 *
00396       INFO = 0
00397 *
00399       NMAX = 1
00400       DO 10 J = 1, NSIZES
00401          NMAX = MAX( NMAX, NN( J ) )
00402          IF( NN( J ).LT.0 )
00404    10 CONTINUE
00405 *
00406 *     Maximum blocksize and shift -- we assume that blocksize and number
00407 *     of shifts are monotone increasing functions of N.
00408 *
00409       NB = MAX( 1, ILAENV( 1, 'DGEQRF', ' ', NMAX, NMAX, -1, -1 ),
00410      \$     ILAENV( 1, 'DORMQR', 'LT', NMAX, NMAX, NMAX, -1 ),
00411      \$     ILAENV( 1, 'DORGQR', ' ', NMAX, NMAX, NMAX, -1 ) )
00412       NBZ = ILAENV( 1, 'DHGEQZ', 'SII', NMAX, 1, NMAX, 0 )
00413       NS = ILAENV( 4, 'DHGEQZ', 'SII', NMAX, 1, NMAX, 0 )
00414       I1 = NBZ + NS
00415       LWKOPT = 2*NMAX + MAX( 6*NMAX, NMAX*( NB+1 ),
00416      \$         ( 2*I1+NMAX+1 )*( I1+1 ) )
00417 *
00418 *     Check for errors
00419 *
00420       IF( NSIZES.LT.0 ) THEN
00421          INFO = -1
00422       ELSE IF( BADNN ) THEN
00423          INFO = -2
00424       ELSE IF( NTYPES.LT.0 ) THEN
00425          INFO = -3
00426       ELSE IF( THRESH.LT.ZERO ) THEN
00427          INFO = -6
00428       ELSE IF( LDA.LE.1 .OR. LDA.LT.NMAX ) THEN
00429          INFO = -10
00430       ELSE IF( LDQ.LE.1 .OR. LDQ.LT.NMAX ) THEN
00431          INFO = -19
00432       ELSE IF( LWKOPT.GT.LWORK ) THEN
00433          INFO = -30
00434       END IF
00435 *
00436       IF( INFO.NE.0 ) THEN
00437          CALL XERBLA( 'DDRVGG', -INFO )
00438          RETURN
00439       END IF
00440 *
00441 *     Quick return if possible
00442 *
00443       IF( NSIZES.EQ.0 .OR. NTYPES.EQ.0 )
00444      \$   RETURN
00445 *
00446       SAFMIN = DLAMCH( 'Safe minimum' )
00447       ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
00448       SAFMIN = SAFMIN / ULP
00449       SAFMAX = ONE / SAFMIN
00450       CALL DLABAD( SAFMIN, SAFMAX )
00451       ULPINV = ONE / ULP
00452 *
00453 *     The values RMAGN(2:3) depend on N, see below.
00454 *
00455       RMAGN( 0 ) = ZERO
00456       RMAGN( 1 ) = ONE
00457 *
00458 *     Loop over sizes, types
00459 *
00460       NTESTT = 0
00461       NERRS = 0
00462       NMATS = 0
00463 *
00464       DO 170 JSIZE = 1, NSIZES
00465          N = NN( JSIZE )
00466          N1 = MAX( 1, N )
00467          RMAGN( 2 ) = SAFMAX*ULP / DBLE( N1 )
00468          RMAGN( 3 ) = SAFMIN*ULPINV*N1
00469 *
00470          IF( NSIZES.NE.1 ) THEN
00471             MTYPES = MIN( MAXTYP, NTYPES )
00472          ELSE
00473             MTYPES = MIN( MAXTYP+1, NTYPES )
00474          END IF
00475 *
00476          DO 160 JTYPE = 1, MTYPES
00477             IF( .NOT.DOTYPE( JTYPE ) )
00478      \$         GO TO 160
00479             NMATS = NMATS + 1
00480             NTEST = 0
00481 *
00482 *           Save ISEED in case of an error.
00483 *
00484             DO 20 J = 1, 4
00485                IOLDSD( J ) = ISEED( J )
00486    20       CONTINUE
00487 *
00488 *           Initialize RESULT
00489 *
00490             DO 30 J = 1, 15
00491                RESULT( J ) = ZERO
00492    30       CONTINUE
00493 *
00494 *           Compute A and B
00495 *
00496 *           Description of control parameters:
00497 *
00498 *           KZLASS: =1 means w/o rotation, =2 means w/ rotation,
00499 *                   =3 means random.
00500 *           KATYPE: the "type" to be passed to DLATM4 for computing A.
00501 *           KAZERO: the pattern of zeros on the diagonal for A:
00502 *                   =1: ( xxx ), =2: (0, xxx ) =3: ( 0, 0, xxx, 0 ),
00503 *                   =4: ( 0, xxx, 0, 0 ), =5: ( 0, 0, 1, xxx, 0 ),
00504 *                   =6: ( 0, 1, 0, xxx, 0 ).  (xxx means a string of
00505 *                   non-zero entries.)
00506 *           KAMAGN: the magnitude of the matrix: =0: zero, =1: O(1),
00507 *                   =2: large, =3: small.
00508 *           IASIGN: 1 if the diagonal elements of A are to be
00509 *                   multiplied by a random magnitude 1 number, =2 if
00510 *                   randomly chosen diagonal blocks are to be rotated
00511 *                   to form 2x2 blocks.
00512 *           KBTYPE, KBZERO, KBMAGN, IBSIGN: the same, but for B.
00513 *           KTRIAN: =0: don't fill in the upper triangle, =1: do.
00514 *           KZ1, KZ2, KADD: used to implement KAZERO and KBZERO.
00515 *           RMAGN: used to implement KAMAGN and KBMAGN.
00516 *
00517             IF( MTYPES.GT.MAXTYP )
00518      \$         GO TO 110
00519             IINFO = 0
00520             IF( KCLASS( JTYPE ).LT.3 ) THEN
00521 *
00522 *              Generate A (w/o rotation)
00523 *
00524                IF( ABS( KATYPE( JTYPE ) ).EQ.3 ) THEN
00525                   IN = 2*( ( N-1 ) / 2 ) + 1
00526                   IF( IN.NE.N )
00527      \$               CALL DLASET( 'Full', N, N, ZERO, ZERO, A, LDA )
00528                ELSE
00529                   IN = N
00530                END IF
00531                CALL DLATM4( KATYPE( JTYPE ), IN, KZ1( KAZERO( JTYPE ) ),
00532      \$                      KZ2( KAZERO( JTYPE ) ), IASIGN( JTYPE ),
00533      \$                      RMAGN( KAMAGN( JTYPE ) ), ULP,
00534      \$                      RMAGN( KTRIAN( JTYPE )*KAMAGN( JTYPE ) ), 2,
00535      \$                      ISEED, A, LDA )
00539 *
00540 *              Generate B (w/o rotation)
00541 *
00542                IF( ABS( KBTYPE( JTYPE ) ).EQ.3 ) THEN
00543                   IN = 2*( ( N-1 ) / 2 ) + 1
00544                   IF( IN.NE.N )
00545      \$               CALL DLASET( 'Full', N, N, ZERO, ZERO, B, LDA )
00546                ELSE
00547                   IN = N
00548                END IF
00549                CALL DLATM4( KBTYPE( JTYPE ), IN, KZ1( KBZERO( JTYPE ) ),
00550      \$                      KZ2( KBZERO( JTYPE ) ), IBSIGN( JTYPE ),
00551      \$                      RMAGN( KBMAGN( JTYPE ) ), ONE,
00552      \$                      RMAGN( KTRIAN( JTYPE )*KBMAGN( JTYPE ) ), 2,
00553      \$                      ISEED, B, LDA )
00557 *
00558                IF( KCLASS( JTYPE ).EQ.2 .AND. N.GT.0 ) THEN
00559 *
00560 *                 Include rotations
00561 *
00562 *                 Generate Q, Z as Householder transformations times
00563 *                 a diagonal matrix.
00564 *
00565                   DO 50 JC = 1, N - 1
00566                      DO 40 JR = JC, N
00567                         Q( JR, JC ) = DLARND( 3, ISEED )
00568                         Z( JR, JC ) = DLARND( 3, ISEED )
00569    40                CONTINUE
00570                      CALL DLARFG( N+1-JC, Q( JC, JC ), Q( JC+1, JC ), 1,
00571      \$                            WORK( JC ) )
00572                      WORK( 2*N+JC ) = SIGN( ONE, Q( JC, JC ) )
00573                      Q( JC, JC ) = ONE
00574                      CALL DLARFG( N+1-JC, Z( JC, JC ), Z( JC+1, JC ), 1,
00575      \$                            WORK( N+JC ) )
00576                      WORK( 3*N+JC ) = SIGN( ONE, Z( JC, JC ) )
00577                      Z( JC, JC ) = ONE
00578    50             CONTINUE
00579                   Q( N, N ) = ONE
00580                   WORK( N ) = ZERO
00581                   WORK( 3*N ) = SIGN( ONE, DLARND( 2, ISEED ) )
00582                   Z( N, N ) = ONE
00583                   WORK( 2*N ) = ZERO
00584                   WORK( 4*N ) = SIGN( ONE, DLARND( 2, ISEED ) )
00585 *
00586 *                 Apply the diagonal matrices
00587 *
00588                   DO 70 JC = 1, N
00589                      DO 60 JR = 1, N
00590                         A( JR, JC ) = WORK( 2*N+JR )*WORK( 3*N+JC )*
00591      \$                                A( JR, JC )
00592                         B( JR, JC ) = WORK( 2*N+JR )*WORK( 3*N+JC )*
00593      \$                                B( JR, JC )
00594    60                CONTINUE
00595    70             CONTINUE
00596                   CALL DORM2R( 'L', 'N', N, N, N-1, Q, LDQ, WORK, A,
00597      \$                         LDA, WORK( 2*N+1 ), IINFO )
00598                   IF( IINFO.NE.0 )
00599      \$               GO TO 100
00600                   CALL DORM2R( 'R', 'T', N, N, N-1, Z, LDQ, WORK( N+1 ),
00601      \$                         A, LDA, WORK( 2*N+1 ), IINFO )
00602                   IF( IINFO.NE.0 )
00603      \$               GO TO 100
00604                   CALL DORM2R( 'L', 'N', N, N, N-1, Q, LDQ, WORK, B,
00605      \$                         LDA, WORK( 2*N+1 ), IINFO )
00606                   IF( IINFO.NE.0 )
00607      \$               GO TO 100
00608                   CALL DORM2R( 'R', 'T', N, N, N-1, Z, LDQ, WORK( N+1 ),
00609      \$                         B, LDA, WORK( 2*N+1 ), IINFO )
00610                   IF( IINFO.NE.0 )
00611      \$               GO TO 100
00612                END IF
00613             ELSE
00614 *
00615 *              Random matrices
00616 *
00617                DO 90 JC = 1, N
00618                   DO 80 JR = 1, N
00619                      A( JR, JC ) = RMAGN( KAMAGN( JTYPE ) )*
00620      \$                             DLARND( 2, ISEED )
00621                      B( JR, JC ) = RMAGN( KBMAGN( JTYPE ) )*
00622      \$                             DLARND( 2, ISEED )
00623    80             CONTINUE
00624    90          CONTINUE
00625             END IF
00626 *
00627   100       CONTINUE
00628 *
00629             IF( IINFO.NE.0 ) THEN
00630                WRITE( NOUNIT, FMT = 9999 )'Generator', IINFO, N, JTYPE,
00631      \$            IOLDSD
00632                INFO = ABS( IINFO )
00633                RETURN
00634             END IF
00635 *
00636   110       CONTINUE
00637 *
00638 *           Call DGEGS to compute H, T, Q, Z, alpha, and beta.
00639 *
00640             CALL DLACPY( ' ', N, N, A, LDA, S, LDA )
00641             CALL DLACPY( ' ', N, N, B, LDA, T, LDA )
00642             NTEST = 1
00643             RESULT( 1 ) = ULPINV
00644 *
00645             CALL DGEGS( 'V', 'V', N, S, LDA, T, LDA, ALPHR1, ALPHI1,
00646      \$                  BETA1, Q, LDQ, Z, LDQ, WORK, LWORK, IINFO )
00647             IF( IINFO.NE.0 ) THEN
00648                WRITE( NOUNIT, FMT = 9999 )'DGEGS', IINFO, N, JTYPE,
00649      \$            IOLDSD
00650                INFO = ABS( IINFO )
00651                GO TO 140
00652             END IF
00653 *
00654             NTEST = 4
00655 *
00656 *           Do tests 1--4
00657 *
00658             CALL DGET51( 1, N, A, LDA, S, LDA, Q, LDQ, Z, LDQ, WORK,
00659      \$                   RESULT( 1 ) )
00660             CALL DGET51( 1, N, B, LDA, T, LDA, Q, LDQ, Z, LDQ, WORK,
00661      \$                   RESULT( 2 ) )
00662             CALL DGET51( 3, N, B, LDA, T, LDA, Q, LDQ, Q, LDQ, WORK,
00663      \$                   RESULT( 3 ) )
00664             CALL DGET51( 3, N, B, LDA, T, LDA, Z, LDQ, Z, LDQ, WORK,
00665      \$                   RESULT( 4 ) )
00666 *
00667 *           Do test 5: compare eigenvalues with diagonals.
00668 *           Also check Schur form of A.
00669 *
00670             TEMP1 = ZERO
00671 *
00672             DO 120 J = 1, N
00674                IF( ALPHI1( J ).EQ.ZERO ) THEN
00675                   TEMP2 = ( ABS( ALPHR1( J )-S( J, J ) ) /
00676      \$                    MAX( SAFMIN, ABS( ALPHR1( J ) ), ABS( S( J,
00677      \$                    J ) ) )+ABS( BETA1( J )-T( J, J ) ) /
00678      \$                    MAX( SAFMIN, ABS( BETA1( J ) ), ABS( T( J,
00679      \$                    J ) ) ) ) / ULP
00680                   IF( J.LT.N ) THEN
00681                      IF( S( J+1, J ).NE.ZERO )
00683                   END IF
00684                   IF( J.GT.1 ) THEN
00685                      IF( S( J, J-1 ).NE.ZERO )
00687                   END IF
00688                ELSE
00689                   IF( ALPHI1( J ).GT.ZERO ) THEN
00690                      I1 = J
00691                   ELSE
00692                      I1 = J - 1
00693                   END IF
00694                   IF( I1.LE.0 .OR. I1.GE.N ) THEN
00696                   ELSE IF( I1.LT.N-1 ) THEN
00697                      IF( S( I1+2, I1+1 ).NE.ZERO )
00699                   ELSE IF( I1.GT.1 ) THEN
00700                      IF( S( I1, I1-1 ).NE.ZERO )
00702                   END IF
00704                      CALL DGET53( S( I1, I1 ), LDA, T( I1, I1 ), LDA,
00705      \$                            BETA1( J ), ALPHR1( J ), ALPHI1( J ),
00706      \$                            TEMP2, IINFO )
00707                      IF( IINFO.GE.3 ) THEN
00708                         WRITE( NOUNIT, FMT = 9997 )IINFO, J, N, JTYPE,
00709      \$                     IOLDSD
00710                         INFO = ABS( IINFO )
00711                      END IF
00712                   ELSE
00713                      TEMP2 = ULPINV
00714                   END IF
00715                END IF
00716                TEMP1 = MAX( TEMP1, TEMP2 )
00718                   WRITE( NOUNIT, FMT = 9996 )J, N, JTYPE, IOLDSD
00719                END IF
00720   120       CONTINUE
00721             RESULT( 5 ) = TEMP1
00722 *
00723 *           Call DGEGV to compute S2, T2, VL, and VR, do tests.
00724 *
00725 *           Eigenvalues and Eigenvectors
00726 *
00727             CALL DLACPY( ' ', N, N, A, LDA, S2, LDA )
00728             CALL DLACPY( ' ', N, N, B, LDA, T2, LDA )
00729             NTEST = 6
00730             RESULT( 6 ) = ULPINV
00731 *
00732             CALL DGEGV( 'V', 'V', N, S2, LDA, T2, LDA, ALPHR2, ALPHI2,
00733      \$                  BETA2, VL, LDQ, VR, LDQ, WORK, LWORK, IINFO )
00734             IF( IINFO.NE.0 ) THEN
00735                WRITE( NOUNIT, FMT = 9999 )'DGEGV', IINFO, N, JTYPE,
00736      \$            IOLDSD
00737                INFO = ABS( IINFO )
00738                GO TO 140
00739             END IF
00740 *
00741             NTEST = 7
00742 *
00743 *           Do Tests 6 and 7
00744 *
00745             CALL DGET52( .TRUE., N, A, LDA, B, LDA, VL, LDQ, ALPHR2,
00746      \$                   ALPHI2, BETA2, WORK, DUMMA( 1 ) )
00747             RESULT( 6 ) = DUMMA( 1 )
00748             IF( DUMMA( 2 ).GT.THRSHN ) THEN
00749                WRITE( NOUNIT, FMT = 9998 )'Left', 'DGEGV', DUMMA( 2 ),
00750      \$            N, JTYPE, IOLDSD
00751             END IF
00752 *
00753             CALL DGET52( .FALSE., N, A, LDA, B, LDA, VR, LDQ, ALPHR2,
00754      \$                   ALPHI2, BETA2, WORK, DUMMA( 1 ) )
00755             RESULT( 7 ) = DUMMA( 1 )
00756             IF( DUMMA( 2 ).GT.THRESH ) THEN
00757                WRITE( NOUNIT, FMT = 9998 )'Right', 'DGEGV', DUMMA( 2 ),
00758      \$            N, JTYPE, IOLDSD
00759             END IF
00760 *
00761 *           Check form of Complex eigenvalues.
00762 *
00763             DO 130 J = 1, N
00765                IF( ALPHI2( J ).GT.ZERO ) THEN
00766                   IF( J.EQ.N ) THEN
00768                   ELSE IF( ALPHI2( J+1 ).GE.ZERO ) THEN
00770                   END IF
00771                ELSE IF( ALPHI2( J ).LT.ZERO ) THEN
00772                   IF( J.EQ.1 ) THEN
00774                   ELSE IF( ALPHI2( J-1 ).LE.ZERO ) THEN
00776                   END IF
00777                END IF
00779                   WRITE( NOUNIT, FMT = 9996 )J, N, JTYPE, IOLDSD
00780                END IF
00781   130       CONTINUE
00782 *
00783 *           End of Loop -- Check for RESULT(j) > THRESH
00784 *
00785   140       CONTINUE
00786 *
00787             NTESTT = NTESTT + NTEST
00788 *
00789 *           Print out tests which fail.
00790 *
00791             DO 150 JR = 1, NTEST
00792                IF( RESULT( JR ).GE.THRESH ) THEN
00793 *
00794 *                 If this is the first test to fail,
00795 *                 print a header to the data file.
00796 *
00797                   IF( NERRS.EQ.0 ) THEN
00798                      WRITE( NOUNIT, FMT = 9995 )'DGG'
00799 *
00800 *                    Matrix types
00801 *
00802                      WRITE( NOUNIT, FMT = 9994 )
00803                      WRITE( NOUNIT, FMT = 9993 )
00804                      WRITE( NOUNIT, FMT = 9992 )'Orthogonal'
00805 *
00806 *                    Tests performed
00807 *
00808                      WRITE( NOUNIT, FMT = 9991 )'orthogonal', '''',
00809      \$                  'transpose', ( '''', J = 1, 5 )
00810 *
00811                   END IF
00812                   NERRS = NERRS + 1
00813                   IF( RESULT( JR ).LT.10000.0D0 ) THEN
00814                      WRITE( NOUNIT, FMT = 9990 )N, JTYPE, IOLDSD, JR,
00815      \$                  RESULT( JR )
00816                   ELSE
00817                      WRITE( NOUNIT, FMT = 9989 )N, JTYPE, IOLDSD, JR,
00818      \$                  RESULT( JR )
00819                   END IF
00820                END IF
00821   150       CONTINUE
00822 *
00823   160    CONTINUE
00824   170 CONTINUE
00825 *
00826 *     Summary
00827 *
00828       CALL ALASVM( 'DGG', NOUNIT, NERRS, NTESTT, 0 )
00829       RETURN
00830 *
00831  9999 FORMAT( ' DDRVGG: ', A, ' returned INFO=', I6, '.', / 9X, 'N=',
00832      \$      I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ), I5, ')' )
00833 *
00834  9998 FORMAT( ' DDRVGG: ', A, ' Eigenvectors from ', A, ' incorrectly ',
00835      \$      'normalized.', / ' Bits of error=', 0P, G10.3, ',', 9X,
00836      \$      'N=', I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ), I5,
00837      \$      ')' )
00838 *
00839  9997 FORMAT( ' DDRVGG: DGET53 returned INFO=', I1, ' for eigenvalue ',
00840      \$      I6, '.', / 9X, 'N=', I6, ', JTYPE=', I6, ', ISEED=(',
00841      \$      3( I5, ',' ), I5, ')' )
00842 *
00843  9996 FORMAT( ' DDRVGG: S not in Schur form at eigenvalue ', I6, '.',
00844      \$      / 9X, 'N=', I6, ', JTYPE=', I6, ', ISEED=(', 3( I5, ',' ),
00845      \$      I5, ')' )
00846 *
00847  9995 FORMAT( / 1X, A3, ' -- Real Generalized eigenvalue problem driver'
00848      \$       )
00849 *
00850  9994 FORMAT( ' Matrix types (see DDRVGG for details): ' )
00851 *
00852  9993 FORMAT( ' Special Matrices:', 23X,
00853      \$      '(J''=transposed Jordan block)',
00854      \$      / '   1=(0,0)  2=(I,0)  3=(0,I)  4=(I,I)  5=(J'',J'')  ',
00855      \$      '6=(diag(J'',I), diag(I,J''))', / ' Diagonal Matrices:  ( ',
00856      \$      'D=diag(0,1,2,...) )', / '   7=(D,I)   9=(large*D, small*I',
00857      \$      ')  11=(large*I, small*D)  13=(large*D, large*I)', /
00858      \$      '   8=(I,D)  10=(small*D, large*I)  12=(small*I, large*D) ',
00859      \$      ' 14=(small*D, small*I)', / '  15=(D, reversed D)' )
00860  9992 FORMAT( ' Matrices Rotated by Random ', A, ' Matrices U, V:',
00861      \$      / '  16=Transposed Jordan Blocks             19=geometric ',
00862      \$      'alpha, beta=0,1', / '  17=arithm. alpha&beta             ',
00863      \$      '      20=arithmetic alpha, beta=0,1', / '  18=clustered ',
00864      \$      'alpha, beta=0,1            21=random alpha, beta=0,1',
00865      \$      / ' Large & Small Matrices:', / '  22=(large, small)   ',
00866      \$      '23=(small,large)    24=(small,small)    25=(large,large)',
00867      \$      / '  26=random O(1) matrices.' )
00868 *
00869  9991 FORMAT( / ' Tests performed:  (S is Schur, T is triangular, ',
00870      \$      'Q and Z are ', A, ',', / 20X,
00871      \$      'l and r are the appropriate left and right', / 19X,
00872      \$      'eigenvectors, resp., a is alpha, b is beta, and', / 19X, A,
00873      \$      ' means ', A, '.)', / ' 1 = | A - Q S Z', A,
00874      \$      ' | / ( |A| n ulp )      2 = | B - Q T Z', A,
00875      \$      ' | / ( |B| n ulp )', / ' 3 = | I - QQ', A,
00876      \$      ' | / ( n ulp )             4 = | I - ZZ', A,
00877      \$      ' | / ( n ulp )', /
00878      \$      ' 5 = difference between (alpha,beta) and diagonals of',
00879      \$      ' (S,T)', / ' 6 = max | ( b A - a B )', A,
00880      \$      ' l | / const.   7 = max | ( b A - a B ) r | / const.',
00881      \$      / 1X )
00882  9990 FORMAT( ' Matrix order=', I5, ', type=', I2, ', seed=',
00883      \$      4( I4, ',' ), ' result ', I3, ' is', 0P, F8.2 )
00884  9989 FORMAT( ' Matrix order=', I5, ', type=', I2, ', seed=',
00885      \$      4( I4, ',' ), ' result ', I3, ' is', 1P, D10.3 )
00886 *
00887 *     End of DDRVGG
00888 *
00889       END
```