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