![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b ZHGEQZ 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download ZHGEQZ + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhgeqz.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhgeqz.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhgeqz.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE ZHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, 00022 * ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, 00023 * RWORK, INFO ) 00024 * 00025 * .. Scalar Arguments .. 00026 * CHARACTER COMPQ, COMPZ, JOB 00027 * INTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N 00028 * .. 00029 * .. Array Arguments .. 00030 * DOUBLE PRECISION RWORK( * ) 00031 * COMPLEX*16 ALPHA( * ), BETA( * ), H( LDH, * ), 00032 * $ Q( LDQ, * ), T( LDT, * ), WORK( * ), 00033 * $ Z( LDZ, * ) 00034 * .. 00035 * 00036 * 00037 *> \par Purpose: 00038 * ============= 00039 *> 00040 *> \verbatim 00041 *> 00042 *> ZHGEQZ computes the eigenvalues of a complex matrix pair (H,T), 00043 *> where H is an upper Hessenberg matrix and T is upper triangular, 00044 *> using the single-shift QZ method. 00045 *> Matrix pairs of this type are produced by the reduction to 00046 *> generalized upper Hessenberg form of a complex matrix pair (A,B): 00047 *> 00048 *> A = Q1*H*Z1**H, B = Q1*T*Z1**H, 00049 *> 00050 *> as computed by ZGGHRD. 00051 *> 00052 *> If JOB='S', then the Hessenberg-triangular pair (H,T) is 00053 *> also reduced to generalized Schur form, 00054 *> 00055 *> H = Q*S*Z**H, T = Q*P*Z**H, 00056 *> 00057 *> where Q and Z are unitary matrices and S and P are upper triangular. 00058 *> 00059 *> Optionally, the unitary matrix Q from the generalized Schur 00060 *> factorization may be postmultiplied into an input matrix Q1, and the 00061 *> unitary matrix Z may be postmultiplied into an input matrix Z1. 00062 *> If Q1 and Z1 are the unitary matrices from ZGGHRD that reduced 00063 *> the matrix pair (A,B) to generalized Hessenberg form, then the output 00064 *> matrices Q1*Q and Z1*Z are the unitary factors from the generalized 00065 *> Schur factorization of (A,B): 00066 *> 00067 *> A = (Q1*Q)*S*(Z1*Z)**H, B = (Q1*Q)*P*(Z1*Z)**H. 00068 *> 00069 *> To avoid overflow, eigenvalues of the matrix pair (H,T) 00070 *> (equivalently, of (A,B)) are computed as a pair of complex values 00071 *> (alpha,beta). If beta is nonzero, lambda = alpha / beta is an 00072 *> eigenvalue of the generalized nonsymmetric eigenvalue problem (GNEP) 00073 *> A*x = lambda*B*x 00074 *> and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the 00075 *> alternate form of the GNEP 00076 *> mu*A*y = B*y. 00077 *> The values of alpha and beta for the i-th eigenvalue can be read 00078 *> directly from the generalized Schur form: alpha = S(i,i), 00079 *> beta = P(i,i). 00080 *> 00081 *> Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix 00082 *> Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973), 00083 *> pp. 241--256. 00084 *> \endverbatim 00085 * 00086 * Arguments: 00087 * ========== 00088 * 00089 *> \param[in] JOB 00090 *> \verbatim 00091 *> JOB is CHARACTER*1 00092 *> = 'E': Compute eigenvalues only; 00093 *> = 'S': Computer eigenvalues and the Schur form. 00094 *> \endverbatim 00095 *> 00096 *> \param[in] COMPQ 00097 *> \verbatim 00098 *> COMPQ is CHARACTER*1 00099 *> = 'N': Left Schur vectors (Q) are not computed; 00100 *> = 'I': Q is initialized to the unit matrix and the matrix Q 00101 *> of left Schur vectors of (H,T) is returned; 00102 *> = 'V': Q must contain a unitary matrix Q1 on entry and 00103 *> the product Q1*Q is returned. 00104 *> \endverbatim 00105 *> 00106 *> \param[in] COMPZ 00107 *> \verbatim 00108 *> COMPZ is CHARACTER*1 00109 *> = 'N': Right Schur vectors (Z) are not computed; 00110 *> = 'I': Q is initialized to the unit matrix and the matrix Z 00111 *> of right Schur vectors of (H,T) is returned; 00112 *> = 'V': Z must contain a unitary matrix Z1 on entry and 00113 *> the product Z1*Z is returned. 00114 *> \endverbatim 00115 *> 00116 *> \param[in] N 00117 *> \verbatim 00118 *> N is INTEGER 00119 *> The order of the matrices H, T, Q, and Z. N >= 0. 00120 *> \endverbatim 00121 *> 00122 *> \param[in] ILO 00123 *> \verbatim 00124 *> ILO is INTEGER 00125 *> \endverbatim 00126 *> 00127 *> \param[in] IHI 00128 *> \verbatim 00129 *> IHI is INTEGER 00130 *> ILO and IHI mark the rows and columns of H which are in 00131 *> Hessenberg form. It is assumed that A is already upper 00132 *> triangular in rows and columns 1:ILO-1 and IHI+1:N. 00133 *> If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0. 00134 *> \endverbatim 00135 *> 00136 *> \param[in,out] H 00137 *> \verbatim 00138 *> H is COMPLEX*16 array, dimension (LDH, N) 00139 *> On entry, the N-by-N upper Hessenberg matrix H. 00140 *> On exit, if JOB = 'S', H contains the upper triangular 00141 *> matrix S from the generalized Schur factorization. 00142 *> If JOB = 'E', the diagonal of H matches that of S, but 00143 *> the rest of H is unspecified. 00144 *> \endverbatim 00145 *> 00146 *> \param[in] LDH 00147 *> \verbatim 00148 *> LDH is INTEGER 00149 *> The leading dimension of the array H. LDH >= max( 1, N ). 00150 *> \endverbatim 00151 *> 00152 *> \param[in,out] T 00153 *> \verbatim 00154 *> T is COMPLEX*16 array, dimension (LDT, N) 00155 *> On entry, the N-by-N upper triangular matrix T. 00156 *> On exit, if JOB = 'S', T contains the upper triangular 00157 *> matrix P from the generalized Schur factorization. 00158 *> If JOB = 'E', the diagonal of T matches that of P, but 00159 *> the rest of T is unspecified. 00160 *> \endverbatim 00161 *> 00162 *> \param[in] LDT 00163 *> \verbatim 00164 *> LDT is INTEGER 00165 *> The leading dimension of the array T. LDT >= max( 1, N ). 00166 *> \endverbatim 00167 *> 00168 *> \param[out] ALPHA 00169 *> \verbatim 00170 *> ALPHA is COMPLEX*16 array, dimension (N) 00171 *> The complex scalars alpha that define the eigenvalues of 00172 *> GNEP. ALPHA(i) = S(i,i) in the generalized Schur 00173 *> factorization. 00174 *> \endverbatim 00175 *> 00176 *> \param[out] BETA 00177 *> \verbatim 00178 *> BETA is COMPLEX*16 array, dimension (N) 00179 *> The real non-negative scalars beta that define the 00180 *> eigenvalues of GNEP. BETA(i) = P(i,i) in the generalized 00181 *> Schur factorization. 00182 *> 00183 *> Together, the quantities alpha = ALPHA(j) and beta = BETA(j) 00184 *> represent the j-th eigenvalue of the matrix pair (A,B), in 00185 *> one of the forms lambda = alpha/beta or mu = beta/alpha. 00186 *> Since either lambda or mu may overflow, they should not, 00187 *> in general, be computed. 00188 *> \endverbatim 00189 *> 00190 *> \param[in,out] Q 00191 *> \verbatim 00192 *> Q is COMPLEX*16 array, dimension (LDQ, N) 00193 *> On entry, if COMPZ = 'V', the unitary matrix Q1 used in the 00194 *> reduction of (A,B) to generalized Hessenberg form. 00195 *> On exit, if COMPZ = 'I', the unitary matrix of left Schur 00196 *> vectors of (H,T), and if COMPZ = 'V', the unitary matrix of 00197 *> left Schur vectors of (A,B). 00198 *> Not referenced if COMPZ = 'N'. 00199 *> \endverbatim 00200 *> 00201 *> \param[in] LDQ 00202 *> \verbatim 00203 *> LDQ is INTEGER 00204 *> The leading dimension of the array Q. LDQ >= 1. 00205 *> If COMPQ='V' or 'I', then LDQ >= N. 00206 *> \endverbatim 00207 *> 00208 *> \param[in,out] Z 00209 *> \verbatim 00210 *> Z is COMPLEX*16 array, dimension (LDZ, N) 00211 *> On entry, if COMPZ = 'V', the unitary matrix Z1 used in the 00212 *> reduction of (A,B) to generalized Hessenberg form. 00213 *> On exit, if COMPZ = 'I', the unitary matrix of right Schur 00214 *> vectors of (H,T), and if COMPZ = 'V', the unitary matrix of 00215 *> right Schur vectors of (A,B). 00216 *> Not referenced if COMPZ = 'N'. 00217 *> \endverbatim 00218 *> 00219 *> \param[in] LDZ 00220 *> \verbatim 00221 *> LDZ is INTEGER 00222 *> The leading dimension of the array Z. LDZ >= 1. 00223 *> If COMPZ='V' or 'I', then LDZ >= N. 00224 *> \endverbatim 00225 *> 00226 *> \param[out] WORK 00227 *> \verbatim 00228 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) 00229 *> On exit, if INFO >= 0, WORK(1) returns the optimal LWORK. 00230 *> \endverbatim 00231 *> 00232 *> \param[in] LWORK 00233 *> \verbatim 00234 *> LWORK is INTEGER 00235 *> The dimension of the array WORK. LWORK >= max(1,N). 00236 *> 00237 *> If LWORK = -1, then a workspace query is assumed; the routine 00238 *> only calculates the optimal size of the WORK array, returns 00239 *> this value as the first entry of the WORK array, and no error 00240 *> message related to LWORK is issued by XERBLA. 00241 *> \endverbatim 00242 *> 00243 *> \param[out] RWORK 00244 *> \verbatim 00245 *> RWORK is DOUBLE PRECISION array, dimension (N) 00246 *> \endverbatim 00247 *> 00248 *> \param[out] INFO 00249 *> \verbatim 00250 *> INFO is INTEGER 00251 *> = 0: successful exit 00252 *> < 0: if INFO = -i, the i-th argument had an illegal value 00253 *> = 1,...,N: the QZ iteration did not converge. (H,T) is not 00254 *> in Schur form, but ALPHA(i) and BETA(i), 00255 *> i=INFO+1,...,N should be correct. 00256 *> = N+1,...,2*N: the shift calculation failed. (H,T) is not 00257 *> in Schur form, but ALPHA(i) and BETA(i), 00258 *> i=INFO-N+1,...,N should be correct. 00259 *> \endverbatim 00260 * 00261 * Authors: 00262 * ======== 00263 * 00264 *> \author Univ. of Tennessee 00265 *> \author Univ. of California Berkeley 00266 *> \author Univ. of Colorado Denver 00267 *> \author NAG Ltd. 00268 * 00269 *> \date April 2012 00270 * 00271 *> \ingroup complex16GEcomputational 00272 * 00273 *> \par Further Details: 00274 * ===================== 00275 *> 00276 *> \verbatim 00277 *> 00278 *> We assume that complex ABS works as long as its value is less than 00279 *> overflow. 00280 *> \endverbatim 00281 *> 00282 * ===================================================================== 00283 SUBROUTINE ZHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, 00284 $ ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, 00285 $ RWORK, INFO ) 00286 * 00287 * -- LAPACK computational routine (version 3.4.1) -- 00288 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00289 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00290 * April 2012 00291 * 00292 * .. Scalar Arguments .. 00293 CHARACTER COMPQ, COMPZ, JOB 00294 INTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N 00295 * .. 00296 * .. Array Arguments .. 00297 DOUBLE PRECISION RWORK( * ) 00298 COMPLEX*16 ALPHA( * ), BETA( * ), H( LDH, * ), 00299 $ Q( LDQ, * ), T( LDT, * ), WORK( * ), 00300 $ Z( LDZ, * ) 00301 * .. 00302 * 00303 * ===================================================================== 00304 * 00305 * .. Parameters .. 00306 COMPLEX*16 CZERO, CONE 00307 PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ), 00308 $ CONE = ( 1.0D+0, 0.0D+0 ) ) 00309 DOUBLE PRECISION ZERO, ONE 00310 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00311 DOUBLE PRECISION HALF 00312 PARAMETER ( HALF = 0.5D+0 ) 00313 * .. 00314 * .. Local Scalars .. 00315 LOGICAL ILAZR2, ILAZRO, ILQ, ILSCHR, ILZ, LQUERY 00316 INTEGER ICOMPQ, ICOMPZ, IFIRST, IFRSTM, IITER, ILAST, 00317 $ ILASTM, IN, ISCHUR, ISTART, J, JC, JCH, JITER, 00318 $ JR, MAXIT 00319 DOUBLE PRECISION ABSB, ANORM, ASCALE, ATOL, BNORM, BSCALE, BTOL, 00320 $ C, SAFMIN, TEMP, TEMP2, TEMPR, ULP 00321 COMPLEX*16 ABI22, AD11, AD12, AD21, AD22, CTEMP, CTEMP2, 00322 $ CTEMP3, ESHIFT, RTDISC, S, SHIFT, SIGNBC, T1, 00323 $ U12, X 00324 * .. 00325 * .. External Functions .. 00326 LOGICAL LSAME 00327 DOUBLE PRECISION DLAMCH, ZLANHS 00328 EXTERNAL LSAME, DLAMCH, ZLANHS 00329 * .. 00330 * .. External Subroutines .. 00331 EXTERNAL XERBLA, ZLARTG, ZLASET, ZROT, ZSCAL 00332 * .. 00333 * .. Intrinsic Functions .. 00334 INTRINSIC ABS, DBLE, DCMPLX, DCONJG, DIMAG, MAX, MIN, 00335 $ SQRT 00336 * .. 00337 * .. Statement Functions .. 00338 DOUBLE PRECISION ABS1 00339 * .. 00340 * .. Statement Function definitions .. 00341 ABS1( X ) = ABS( DBLE( X ) ) + ABS( DIMAG( X ) ) 00342 * .. 00343 * .. Executable Statements .. 00344 * 00345 * Decode JOB, COMPQ, COMPZ 00346 * 00347 IF( LSAME( JOB, 'E' ) ) THEN 00348 ILSCHR = .FALSE. 00349 ISCHUR = 1 00350 ELSE IF( LSAME( JOB, 'S' ) ) THEN 00351 ILSCHR = .TRUE. 00352 ISCHUR = 2 00353 ELSE 00354 ISCHUR = 0 00355 END IF 00356 * 00357 IF( LSAME( COMPQ, 'N' ) ) THEN 00358 ILQ = .FALSE. 00359 ICOMPQ = 1 00360 ELSE IF( LSAME( COMPQ, 'V' ) ) THEN 00361 ILQ = .TRUE. 00362 ICOMPQ = 2 00363 ELSE IF( LSAME( COMPQ, 'I' ) ) THEN 00364 ILQ = .TRUE. 00365 ICOMPQ = 3 00366 ELSE 00367 ICOMPQ = 0 00368 END IF 00369 * 00370 IF( LSAME( COMPZ, 'N' ) ) THEN 00371 ILZ = .FALSE. 00372 ICOMPZ = 1 00373 ELSE IF( LSAME( COMPZ, 'V' ) ) THEN 00374 ILZ = .TRUE. 00375 ICOMPZ = 2 00376 ELSE IF( LSAME( COMPZ, 'I' ) ) THEN 00377 ILZ = .TRUE. 00378 ICOMPZ = 3 00379 ELSE 00380 ICOMPZ = 0 00381 END IF 00382 * 00383 * Check Argument Values 00384 * 00385 INFO = 0 00386 WORK( 1 ) = MAX( 1, N ) 00387 LQUERY = ( LWORK.EQ.-1 ) 00388 IF( ISCHUR.EQ.0 ) THEN 00389 INFO = -1 00390 ELSE IF( ICOMPQ.EQ.0 ) THEN 00391 INFO = -2 00392 ELSE IF( ICOMPZ.EQ.0 ) THEN 00393 INFO = -3 00394 ELSE IF( N.LT.0 ) THEN 00395 INFO = -4 00396 ELSE IF( ILO.LT.1 ) THEN 00397 INFO = -5 00398 ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THEN 00399 INFO = -6 00400 ELSE IF( LDH.LT.N ) THEN 00401 INFO = -8 00402 ELSE IF( LDT.LT.N ) THEN 00403 INFO = -10 00404 ELSE IF( LDQ.LT.1 .OR. ( ILQ .AND. LDQ.LT.N ) ) THEN 00405 INFO = -14 00406 ELSE IF( LDZ.LT.1 .OR. ( ILZ .AND. LDZ.LT.N ) ) THEN 00407 INFO = -16 00408 ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN 00409 INFO = -18 00410 END IF 00411 IF( INFO.NE.0 ) THEN 00412 CALL XERBLA( 'ZHGEQZ', -INFO ) 00413 RETURN 00414 ELSE IF( LQUERY ) THEN 00415 RETURN 00416 END IF 00417 * 00418 * Quick return if possible 00419 * 00420 * WORK( 1 ) = CMPLX( 1 ) 00421 IF( N.LE.0 ) THEN 00422 WORK( 1 ) = DCMPLX( 1 ) 00423 RETURN 00424 END IF 00425 * 00426 * Initialize Q and Z 00427 * 00428 IF( ICOMPQ.EQ.3 ) 00429 $ CALL ZLASET( 'Full', N, N, CZERO, CONE, Q, LDQ ) 00430 IF( ICOMPZ.EQ.3 ) 00431 $ CALL ZLASET( 'Full', N, N, CZERO, CONE, Z, LDZ ) 00432 * 00433 * Machine Constants 00434 * 00435 IN = IHI + 1 - ILO 00436 SAFMIN = DLAMCH( 'S' ) 00437 ULP = DLAMCH( 'E' )*DLAMCH( 'B' ) 00438 ANORM = ZLANHS( 'F', IN, H( ILO, ILO ), LDH, RWORK ) 00439 BNORM = ZLANHS( 'F', IN, T( ILO, ILO ), LDT, RWORK ) 00440 ATOL = MAX( SAFMIN, ULP*ANORM ) 00441 BTOL = MAX( SAFMIN, ULP*BNORM ) 00442 ASCALE = ONE / MAX( SAFMIN, ANORM ) 00443 BSCALE = ONE / MAX( SAFMIN, BNORM ) 00444 * 00445 * 00446 * Set Eigenvalues IHI+1:N 00447 * 00448 DO 10 J = IHI + 1, N 00449 ABSB = ABS( T( J, J ) ) 00450 IF( ABSB.GT.SAFMIN ) THEN 00451 SIGNBC = DCONJG( T( J, J ) / ABSB ) 00452 T( J, J ) = ABSB 00453 IF( ILSCHR ) THEN 00454 CALL ZSCAL( J-1, SIGNBC, T( 1, J ), 1 ) 00455 CALL ZSCAL( J, SIGNBC, H( 1, J ), 1 ) 00456 ELSE 00457 H( J, J ) = H( J, J )*SIGNBC 00458 END IF 00459 IF( ILZ ) 00460 $ CALL ZSCAL( N, SIGNBC, Z( 1, J ), 1 ) 00461 ELSE 00462 T( J, J ) = CZERO 00463 END IF 00464 ALPHA( J ) = H( J, J ) 00465 BETA( J ) = T( J, J ) 00466 10 CONTINUE 00467 * 00468 * If IHI < ILO, skip QZ steps 00469 * 00470 IF( IHI.LT.ILO ) 00471 $ GO TO 190 00472 * 00473 * MAIN QZ ITERATION LOOP 00474 * 00475 * Initialize dynamic indices 00476 * 00477 * Eigenvalues ILAST+1:N have been found. 00478 * Column operations modify rows IFRSTM:whatever 00479 * Row operations modify columns whatever:ILASTM 00480 * 00481 * If only eigenvalues are being computed, then 00482 * IFRSTM is the row of the last splitting row above row ILAST; 00483 * this is always at least ILO. 00484 * IITER counts iterations since the last eigenvalue was found, 00485 * to tell when to use an extraordinary shift. 00486 * MAXIT is the maximum number of QZ sweeps allowed. 00487 * 00488 ILAST = IHI 00489 IF( ILSCHR ) THEN 00490 IFRSTM = 1 00491 ILASTM = N 00492 ELSE 00493 IFRSTM = ILO 00494 ILASTM = IHI 00495 END IF 00496 IITER = 0 00497 ESHIFT = CZERO 00498 MAXIT = 30*( IHI-ILO+1 ) 00499 * 00500 DO 170 JITER = 1, MAXIT 00501 * 00502 * Check for too many iterations. 00503 * 00504 IF( JITER.GT.MAXIT ) 00505 $ GO TO 180 00506 * 00507 * Split the matrix if possible. 00508 * 00509 * Two tests: 00510 * 1: H(j,j-1)=0 or j=ILO 00511 * 2: T(j,j)=0 00512 * 00513 * Special case: j=ILAST 00514 * 00515 IF( ILAST.EQ.ILO ) THEN 00516 GO TO 60 00517 ELSE 00518 IF( ABS1( H( ILAST, ILAST-1 ) ).LE.ATOL ) THEN 00519 H( ILAST, ILAST-1 ) = CZERO 00520 GO TO 60 00521 END IF 00522 END IF 00523 * 00524 IF( ABS( T( ILAST, ILAST ) ).LE.BTOL ) THEN 00525 T( ILAST, ILAST ) = CZERO 00526 GO TO 50 00527 END IF 00528 * 00529 * General case: j<ILAST 00530 * 00531 DO 40 J = ILAST - 1, ILO, -1 00532 * 00533 * Test 1: for H(j,j-1)=0 or j=ILO 00534 * 00535 IF( J.EQ.ILO ) THEN 00536 ILAZRO = .TRUE. 00537 ELSE 00538 IF( ABS1( H( J, J-1 ) ).LE.ATOL ) THEN 00539 H( J, J-1 ) = CZERO 00540 ILAZRO = .TRUE. 00541 ELSE 00542 ILAZRO = .FALSE. 00543 END IF 00544 END IF 00545 * 00546 * Test 2: for T(j,j)=0 00547 * 00548 IF( ABS( T( J, J ) ).LT.BTOL ) THEN 00549 T( J, J ) = CZERO 00550 * 00551 * Test 1a: Check for 2 consecutive small subdiagonals in A 00552 * 00553 ILAZR2 = .FALSE. 00554 IF( .NOT.ILAZRO ) THEN 00555 IF( ABS1( H( J, J-1 ) )*( ASCALE*ABS1( H( J+1, 00556 $ J ) ) ).LE.ABS1( H( J, J ) )*( ASCALE*ATOL ) ) 00557 $ ILAZR2 = .TRUE. 00558 END IF 00559 * 00560 * If both tests pass (1 & 2), i.e., the leading diagonal 00561 * element of B in the block is zero, split a 1x1 block off 00562 * at the top. (I.e., at the J-th row/column) The leading 00563 * diagonal element of the remainder can also be zero, so 00564 * this may have to be done repeatedly. 00565 * 00566 IF( ILAZRO .OR. ILAZR2 ) THEN 00567 DO 20 JCH = J, ILAST - 1 00568 CTEMP = H( JCH, JCH ) 00569 CALL ZLARTG( CTEMP, H( JCH+1, JCH ), C, S, 00570 $ H( JCH, JCH ) ) 00571 H( JCH+1, JCH ) = CZERO 00572 CALL ZROT( ILASTM-JCH, H( JCH, JCH+1 ), LDH, 00573 $ H( JCH+1, JCH+1 ), LDH, C, S ) 00574 CALL ZROT( ILASTM-JCH, T( JCH, JCH+1 ), LDT, 00575 $ T( JCH+1, JCH+1 ), LDT, C, S ) 00576 IF( ILQ ) 00577 $ CALL ZROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1, 00578 $ C, DCONJG( S ) ) 00579 IF( ILAZR2 ) 00580 $ H( JCH, JCH-1 ) = H( JCH, JCH-1 )*C 00581 ILAZR2 = .FALSE. 00582 IF( ABS1( T( JCH+1, JCH+1 ) ).GE.BTOL ) THEN 00583 IF( JCH+1.GE.ILAST ) THEN 00584 GO TO 60 00585 ELSE 00586 IFIRST = JCH + 1 00587 GO TO 70 00588 END IF 00589 END IF 00590 T( JCH+1, JCH+1 ) = CZERO 00591 20 CONTINUE 00592 GO TO 50 00593 ELSE 00594 * 00595 * Only test 2 passed -- chase the zero to T(ILAST,ILAST) 00596 * Then process as in the case T(ILAST,ILAST)=0 00597 * 00598 DO 30 JCH = J, ILAST - 1 00599 CTEMP = T( JCH, JCH+1 ) 00600 CALL ZLARTG( CTEMP, T( JCH+1, JCH+1 ), C, S, 00601 $ T( JCH, JCH+1 ) ) 00602 T( JCH+1, JCH+1 ) = CZERO 00603 IF( JCH.LT.ILASTM-1 ) 00604 $ CALL ZROT( ILASTM-JCH-1, T( JCH, JCH+2 ), LDT, 00605 $ T( JCH+1, JCH+2 ), LDT, C, S ) 00606 CALL ZROT( ILASTM-JCH+2, H( JCH, JCH-1 ), LDH, 00607 $ H( JCH+1, JCH-1 ), LDH, C, S ) 00608 IF( ILQ ) 00609 $ CALL ZROT( N, Q( 1, JCH ), 1, Q( 1, JCH+1 ), 1, 00610 $ C, DCONJG( S ) ) 00611 CTEMP = H( JCH+1, JCH ) 00612 CALL ZLARTG( CTEMP, H( JCH+1, JCH-1 ), C, S, 00613 $ H( JCH+1, JCH ) ) 00614 H( JCH+1, JCH-1 ) = CZERO 00615 CALL ZROT( JCH+1-IFRSTM, H( IFRSTM, JCH ), 1, 00616 $ H( IFRSTM, JCH-1 ), 1, C, S ) 00617 CALL ZROT( JCH-IFRSTM, T( IFRSTM, JCH ), 1, 00618 $ T( IFRSTM, JCH-1 ), 1, C, S ) 00619 IF( ILZ ) 00620 $ CALL ZROT( N, Z( 1, JCH ), 1, Z( 1, JCH-1 ), 1, 00621 $ C, S ) 00622 30 CONTINUE 00623 GO TO 50 00624 END IF 00625 ELSE IF( ILAZRO ) THEN 00626 * 00627 * Only test 1 passed -- work on J:ILAST 00628 * 00629 IFIRST = J 00630 GO TO 70 00631 END IF 00632 * 00633 * Neither test passed -- try next J 00634 * 00635 40 CONTINUE 00636 * 00637 * (Drop-through is "impossible") 00638 * 00639 INFO = 2*N + 1 00640 GO TO 210 00641 * 00642 * T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a 00643 * 1x1 block. 00644 * 00645 50 CONTINUE 00646 CTEMP = H( ILAST, ILAST ) 00647 CALL ZLARTG( CTEMP, H( ILAST, ILAST-1 ), C, S, 00648 $ H( ILAST, ILAST ) ) 00649 H( ILAST, ILAST-1 ) = CZERO 00650 CALL ZROT( ILAST-IFRSTM, H( IFRSTM, ILAST ), 1, 00651 $ H( IFRSTM, ILAST-1 ), 1, C, S ) 00652 CALL ZROT( ILAST-IFRSTM, T( IFRSTM, ILAST ), 1, 00653 $ T( IFRSTM, ILAST-1 ), 1, C, S ) 00654 IF( ILZ ) 00655 $ CALL ZROT( N, Z( 1, ILAST ), 1, Z( 1, ILAST-1 ), 1, C, S ) 00656 * 00657 * H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHA and BETA 00658 * 00659 60 CONTINUE 00660 ABSB = ABS( T( ILAST, ILAST ) ) 00661 IF( ABSB.GT.SAFMIN ) THEN 00662 SIGNBC = DCONJG( T( ILAST, ILAST ) / ABSB ) 00663 T( ILAST, ILAST ) = ABSB 00664 IF( ILSCHR ) THEN 00665 CALL ZSCAL( ILAST-IFRSTM, SIGNBC, T( IFRSTM, ILAST ), 1 ) 00666 CALL ZSCAL( ILAST+1-IFRSTM, SIGNBC, H( IFRSTM, ILAST ), 00667 $ 1 ) 00668 ELSE 00669 H( ILAST, ILAST ) = H( ILAST, ILAST )*SIGNBC 00670 END IF 00671 IF( ILZ ) 00672 $ CALL ZSCAL( N, SIGNBC, Z( 1, ILAST ), 1 ) 00673 ELSE 00674 T( ILAST, ILAST ) = CZERO 00675 END IF 00676 ALPHA( ILAST ) = H( ILAST, ILAST ) 00677 BETA( ILAST ) = T( ILAST, ILAST ) 00678 * 00679 * Go to next block -- exit if finished. 00680 * 00681 ILAST = ILAST - 1 00682 IF( ILAST.LT.ILO ) 00683 $ GO TO 190 00684 * 00685 * Reset counters 00686 * 00687 IITER = 0 00688 ESHIFT = CZERO 00689 IF( .NOT.ILSCHR ) THEN 00690 ILASTM = ILAST 00691 IF( IFRSTM.GT.ILAST ) 00692 $ IFRSTM = ILO 00693 END IF 00694 GO TO 160 00695 * 00696 * QZ step 00697 * 00698 * This iteration only involves rows/columns IFIRST:ILAST. We 00699 * assume IFIRST < ILAST, and that the diagonal of B is non-zero. 00700 * 00701 70 CONTINUE 00702 IITER = IITER + 1 00703 IF( .NOT.ILSCHR ) THEN 00704 IFRSTM = IFIRST 00705 END IF 00706 * 00707 * Compute the Shift. 00708 * 00709 * At this point, IFIRST < ILAST, and the diagonal elements of 00710 * T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in 00711 * magnitude) 00712 * 00713 IF( ( IITER / 10 )*10.NE.IITER ) THEN 00714 * 00715 * The Wilkinson shift (AEP p.512), i.e., the eigenvalue of 00716 * the bottom-right 2x2 block of A inv(B) which is nearest to 00717 * the bottom-right element. 00718 * 00719 * We factor B as U*D, where U has unit diagonals, and 00720 * compute (A*inv(D))*inv(U). 00721 * 00722 U12 = ( BSCALE*T( ILAST-1, ILAST ) ) / 00723 $ ( BSCALE*T( ILAST, ILAST ) ) 00724 AD11 = ( ASCALE*H( ILAST-1, ILAST-1 ) ) / 00725 $ ( BSCALE*T( ILAST-1, ILAST-1 ) ) 00726 AD21 = ( ASCALE*H( ILAST, ILAST-1 ) ) / 00727 $ ( BSCALE*T( ILAST-1, ILAST-1 ) ) 00728 AD12 = ( ASCALE*H( ILAST-1, ILAST ) ) / 00729 $ ( BSCALE*T( ILAST, ILAST ) ) 00730 AD22 = ( ASCALE*H( ILAST, ILAST ) ) / 00731 $ ( BSCALE*T( ILAST, ILAST ) ) 00732 ABI22 = AD22 - U12*AD21 00733 * 00734 T1 = HALF*( AD11+ABI22 ) 00735 RTDISC = SQRT( T1**2+AD12*AD21-AD11*AD22 ) 00736 TEMP = DBLE( T1-ABI22 )*DBLE( RTDISC ) + 00737 $ DIMAG( T1-ABI22 )*DIMAG( RTDISC ) 00738 IF( TEMP.LE.ZERO ) THEN 00739 SHIFT = T1 + RTDISC 00740 ELSE 00741 SHIFT = T1 - RTDISC 00742 END IF 00743 ELSE 00744 * 00745 * Exceptional shift. Chosen for no particularly good reason. 00746 * 00747 ESHIFT = ESHIFT + H(ILAST,ILAST-1)/T(ILAST-1,ILAST-1) 00748 SHIFT = ESHIFT 00749 END IF 00750 * 00751 * Now check for two consecutive small subdiagonals. 00752 * 00753 DO 80 J = ILAST - 1, IFIRST + 1, -1 00754 ISTART = J 00755 CTEMP = ASCALE*H( J, J ) - SHIFT*( BSCALE*T( J, J ) ) 00756 TEMP = ABS1( CTEMP ) 00757 TEMP2 = ASCALE*ABS1( H( J+1, J ) ) 00758 TEMPR = MAX( TEMP, TEMP2 ) 00759 IF( TEMPR.LT.ONE .AND. TEMPR.NE.ZERO ) THEN 00760 TEMP = TEMP / TEMPR 00761 TEMP2 = TEMP2 / TEMPR 00762 END IF 00763 IF( ABS1( H( J, J-1 ) )*TEMP2.LE.TEMP*ATOL ) 00764 $ GO TO 90 00765 80 CONTINUE 00766 * 00767 ISTART = IFIRST 00768 CTEMP = ASCALE*H( IFIRST, IFIRST ) - 00769 $ SHIFT*( BSCALE*T( IFIRST, IFIRST ) ) 00770 90 CONTINUE 00771 * 00772 * Do an implicit-shift QZ sweep. 00773 * 00774 * Initial Q 00775 * 00776 CTEMP2 = ASCALE*H( ISTART+1, ISTART ) 00777 CALL ZLARTG( CTEMP, CTEMP2, C, S, CTEMP3 ) 00778 * 00779 * Sweep 00780 * 00781 DO 150 J = ISTART, ILAST - 1 00782 IF( J.GT.ISTART ) THEN 00783 CTEMP = H( J, J-1 ) 00784 CALL ZLARTG( CTEMP, H( J+1, J-1 ), C, S, H( J, J-1 ) ) 00785 H( J+1, J-1 ) = CZERO 00786 END IF 00787 * 00788 DO 100 JC = J, ILASTM 00789 CTEMP = C*H( J, JC ) + S*H( J+1, JC ) 00790 H( J+1, JC ) = -DCONJG( S )*H( J, JC ) + C*H( J+1, JC ) 00791 H( J, JC ) = CTEMP 00792 CTEMP2 = C*T( J, JC ) + S*T( J+1, JC ) 00793 T( J+1, JC ) = -DCONJG( S )*T( J, JC ) + C*T( J+1, JC ) 00794 T( J, JC ) = CTEMP2 00795 100 CONTINUE 00796 IF( ILQ ) THEN 00797 DO 110 JR = 1, N 00798 CTEMP = C*Q( JR, J ) + DCONJG( S )*Q( JR, J+1 ) 00799 Q( JR, J+1 ) = -S*Q( JR, J ) + C*Q( JR, J+1 ) 00800 Q( JR, J ) = CTEMP 00801 110 CONTINUE 00802 END IF 00803 * 00804 CTEMP = T( J+1, J+1 ) 00805 CALL ZLARTG( CTEMP, T( J+1, J ), C, S, T( J+1, J+1 ) ) 00806 T( J+1, J ) = CZERO 00807 * 00808 DO 120 JR = IFRSTM, MIN( J+2, ILAST ) 00809 CTEMP = C*H( JR, J+1 ) + S*H( JR, J ) 00810 H( JR, J ) = -DCONJG( S )*H( JR, J+1 ) + C*H( JR, J ) 00811 H( JR, J+1 ) = CTEMP 00812 120 CONTINUE 00813 DO 130 JR = IFRSTM, J 00814 CTEMP = C*T( JR, J+1 ) + S*T( JR, J ) 00815 T( JR, J ) = -DCONJG( S )*T( JR, J+1 ) + C*T( JR, J ) 00816 T( JR, J+1 ) = CTEMP 00817 130 CONTINUE 00818 IF( ILZ ) THEN 00819 DO 140 JR = 1, N 00820 CTEMP = C*Z( JR, J+1 ) + S*Z( JR, J ) 00821 Z( JR, J ) = -DCONJG( S )*Z( JR, J+1 ) + C*Z( JR, J ) 00822 Z( JR, J+1 ) = CTEMP 00823 140 CONTINUE 00824 END IF 00825 150 CONTINUE 00826 * 00827 160 CONTINUE 00828 * 00829 170 CONTINUE 00830 * 00831 * Drop-through = non-convergence 00832 * 00833 180 CONTINUE 00834 INFO = ILAST 00835 GO TO 210 00836 * 00837 * Successful completion of all QZ steps 00838 * 00839 190 CONTINUE 00840 * 00841 * Set Eigenvalues 1:ILO-1 00842 * 00843 DO 200 J = 1, ILO - 1 00844 ABSB = ABS( T( J, J ) ) 00845 IF( ABSB.GT.SAFMIN ) THEN 00846 SIGNBC = DCONJG( T( J, J ) / ABSB ) 00847 T( J, J ) = ABSB 00848 IF( ILSCHR ) THEN 00849 CALL ZSCAL( J-1, SIGNBC, T( 1, J ), 1 ) 00850 CALL ZSCAL( J, SIGNBC, H( 1, J ), 1 ) 00851 ELSE 00852 H( J, J ) = H( J, J )*SIGNBC 00853 END IF 00854 IF( ILZ ) 00855 $ CALL ZSCAL( N, SIGNBC, Z( 1, J ), 1 ) 00856 ELSE 00857 T( J, J ) = CZERO 00858 END IF 00859 ALPHA( J ) = H( J, J ) 00860 BETA( J ) = T( J, J ) 00861 200 CONTINUE 00862 * 00863 * Normal Termination 00864 * 00865 INFO = 0 00866 * 00867 * Exit (other than argument error) -- return optimal workspace size 00868 * 00869 210 CONTINUE 00870 WORK( 1 ) = DCMPLX( N ) 00871 RETURN 00872 * 00873 * End of ZHGEQZ 00874 * 00875 END