LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zhgeqz.f
Go to the documentation of this file.
1*> \brief \b ZHGEQZ
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZHGEQZ + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhgeqz.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhgeqz.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhgeqz.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZHGEQZ( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT,
20* ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK,
21* RWORK, INFO )
22*
23* .. Scalar Arguments ..
24* CHARACTER COMPQ, COMPZ, JOB
25* INTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N
26* ..
27* .. Array Arguments ..
28* DOUBLE PRECISION RWORK( * )
29* COMPLEX*16 ALPHA( * ), BETA( * ), H( LDH, * ),
30* $ Q( LDQ, * ), T( LDT, * ), WORK( * ),
31* $ Z( LDZ, * )
32* ..
33*
34*
35*> \par Purpose:
36* =============
37*>
38*> \verbatim
39*>
40*> ZHGEQZ computes the eigenvalues of a complex matrix pair (H,T),
41*> where H is an upper Hessenberg matrix and T is upper triangular,
42*> using the single-shift QZ method.
43*> Matrix pairs of this type are produced by the reduction to
44*> generalized upper Hessenberg form of a complex matrix pair (A,B):
45*>
46*> A = Q1*H*Z1**H, B = Q1*T*Z1**H,
47*>
48*> as computed by ZGGHRD.
49*>
50*> If JOB='S', then the Hessenberg-triangular pair (H,T) is
51*> also reduced to generalized Schur form,
52*>
53*> H = Q*S*Z**H, T = Q*P*Z**H,
54*>
55*> where Q and Z are unitary matrices and S and P are upper triangular.
56*>
57*> Optionally, the unitary matrix Q from the generalized Schur
58*> factorization may be postmultiplied into an input matrix Q1, and the
59*> unitary matrix Z may be postmultiplied into an input matrix Z1.
60*> If Q1 and Z1 are the unitary matrices from ZGGHRD that reduced
61*> the matrix pair (A,B) to generalized Hessenberg form, then the output
62*> matrices Q1*Q and Z1*Z are the unitary factors from the generalized
63*> Schur factorization of (A,B):
64*>
65*> A = (Q1*Q)*S*(Z1*Z)**H, B = (Q1*Q)*P*(Z1*Z)**H.
66*>
67*> To avoid overflow, eigenvalues of the matrix pair (H,T)
68*> (equivalently, of (A,B)) are computed as a pair of complex values
69*> (alpha,beta). If beta is nonzero, lambda = alpha / beta is an
70*> eigenvalue of the generalized nonsymmetric eigenvalue problem (GNEP)
71*> A*x = lambda*B*x
72*> and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the
73*> alternate form of the GNEP
74*> mu*A*y = B*y.
75*> The values of alpha and beta for the i-th eigenvalue can be read
76*> directly from the generalized Schur form: alpha = S(i,i),
77*> beta = P(i,i).
78*>
79*> Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix
80*> Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973),
81*> pp. 241--256.
82*> \endverbatim
83*
84* Arguments:
85* ==========
86*
87*> \param[in] JOB
88*> \verbatim
89*> JOB is CHARACTER*1
90*> = 'E': Compute eigenvalues only;
91*> = 'S': Computer eigenvalues and the Schur form.
92*> \endverbatim
93*>
94*> \param[in] COMPQ
95*> \verbatim
96*> COMPQ is CHARACTER*1
97*> = 'N': Left Schur vectors (Q) are not computed;
98*> = 'I': Q is initialized to the unit matrix and the matrix Q
99*> of left Schur vectors of (H,T) is returned;
100*> = 'V': Q must contain a unitary matrix Q1 on entry and
101*> the product Q1*Q is returned.
102*> \endverbatim
103*>
104*> \param[in] COMPZ
105*> \verbatim
106*> COMPZ is CHARACTER*1
107*> = 'N': Right Schur vectors (Z) are not computed;
108*> = 'I': Q is initialized to the unit matrix and the matrix Z
109*> of right Schur vectors of (H,T) is returned;
110*> = 'V': Z must contain a unitary matrix Z1 on entry and
111*> the product Z1*Z is returned.
112*> \endverbatim
113*>
114*> \param[in] N
115*> \verbatim
116*> N is INTEGER
117*> The order of the matrices H, T, Q, and Z. N >= 0.
118*> \endverbatim
119*>
120*> \param[in] ILO
121*> \verbatim
122*> ILO is INTEGER
123*> \endverbatim
124*>
125*> \param[in] IHI
126*> \verbatim
127*> IHI is INTEGER
128*> ILO and IHI mark the rows and columns of H which are in
129*> Hessenberg form. It is assumed that A is already upper
130*> triangular in rows and columns 1:ILO-1 and IHI+1:N.
131*> If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0.
132*> \endverbatim
133*>
134*> \param[in,out] H
135*> \verbatim
136*> H is COMPLEX*16 array, dimension (LDH, N)
137*> On entry, the N-by-N upper Hessenberg matrix H.
138*> On exit, if JOB = 'S', H contains the upper triangular
139*> matrix S from the generalized Schur factorization.
140*> If JOB = 'E', the diagonal of H matches that of S, but
141*> the rest of H is unspecified.
142*> \endverbatim
143*>
144*> \param[in] LDH
145*> \verbatim
146*> LDH is INTEGER
147*> The leading dimension of the array H. LDH >= max( 1, N ).
148*> \endverbatim
149*>
150*> \param[in,out] T
151*> \verbatim
152*> T is COMPLEX*16 array, dimension (LDT, N)
153*> On entry, the N-by-N upper triangular matrix T.
154*> On exit, if JOB = 'S', T contains the upper triangular
155*> matrix P from the generalized Schur factorization.
156*> If JOB = 'E', the diagonal of T matches that of P, but
157*> the rest of T is unspecified.
158*> \endverbatim
159*>
160*> \param[in] LDT
161*> \verbatim
162*> LDT is INTEGER
163*> The leading dimension of the array T. LDT >= max( 1, N ).
164*> \endverbatim
165*>
166*> \param[out] ALPHA
167*> \verbatim
168*> ALPHA is COMPLEX*16 array, dimension (N)
169*> The complex scalars alpha that define the eigenvalues of
170*> GNEP. ALPHA(i) = S(i,i) in the generalized Schur
171*> factorization.
172*> \endverbatim
173*>
174*> \param[out] BETA
175*> \verbatim
176*> BETA is COMPLEX*16 array, dimension (N)
177*> The real non-negative scalars beta that define the
178*> eigenvalues of GNEP. BETA(i) = P(i,i) in the generalized
179*> Schur factorization.
180*>
181*> Together, the quantities alpha = ALPHA(j) and beta = BETA(j)
182*> represent the j-th eigenvalue of the matrix pair (A,B), in
183*> one of the forms lambda = alpha/beta or mu = beta/alpha.
184*> Since either lambda or mu may overflow, they should not,
185*> in general, be computed.
186*> \endverbatim
187*>
188*> \param[in,out] Q
189*> \verbatim
190*> Q is COMPLEX*16 array, dimension (LDQ, N)
191*> On entry, if COMPQ = 'V', the unitary matrix Q1 used in the
192*> reduction of (A,B) to generalized Hessenberg form.
193*> On exit, if COMPQ = 'I', the unitary matrix of left Schur
194*> vectors of (H,T), and if COMPQ = 'V', the unitary matrix of
195*> left Schur vectors of (A,B).
196*> Not referenced if COMPQ = 'N'.
197*> \endverbatim
198*>
199*> \param[in] LDQ
200*> \verbatim
201*> LDQ is INTEGER
202*> The leading dimension of the array Q. LDQ >= 1.
203*> If COMPQ='V' or 'I', then LDQ >= N.
204*> \endverbatim
205*>
206*> \param[in,out] Z
207*> \verbatim
208*> Z is COMPLEX*16 array, dimension (LDZ, N)
209*> On entry, if COMPZ = 'V', the unitary matrix Z1 used in the
210*> reduction of (A,B) to generalized Hessenberg form.
211*> On exit, if COMPZ = 'I', the unitary matrix of right Schur
212*> vectors of (H,T), and if COMPZ = 'V', the unitary matrix of
213*> right Schur vectors of (A,B).
214*> Not referenced if COMPZ = 'N'.
215*> \endverbatim
216*>
217*> \param[in] LDZ
218*> \verbatim
219*> LDZ is INTEGER
220*> The leading dimension of the array Z. LDZ >= 1.
221*> If COMPZ='V' or 'I', then LDZ >= N.
222*> \endverbatim
223*>
224*> \param[out] WORK
225*> \verbatim
226*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
227*> On exit, if INFO >= 0, WORK(1) returns the optimal LWORK.
228*> \endverbatim
229*>
230*> \param[in] LWORK
231*> \verbatim
232*> LWORK is INTEGER
233*> The dimension of the array WORK. LWORK >= max(1,N).
234*>
235*> If LWORK = -1, then a workspace query is assumed; the routine
236*> only calculates the optimal size of the WORK array, returns
237*> this value as the first entry of the WORK array, and no error
238*> message related to LWORK is issued by XERBLA.
239*> \endverbatim
240*>
241*> \param[out] RWORK
242*> \verbatim
243*> RWORK is DOUBLE PRECISION array, dimension (N)
244*> \endverbatim
245*>
246*> \param[out] INFO
247*> \verbatim
248*> INFO is INTEGER
249*> = 0: successful exit
250*> < 0: if INFO = -i, the i-th argument had an illegal value
251*> = 1,...,N: the QZ iteration did not converge. (H,T) is not
252*> in Schur form, but ALPHA(i) and BETA(i),
253*> i=INFO+1,...,N should be correct.
254*> = N+1,...,2*N: the shift calculation failed. (H,T) is not
255*> in Schur form, but ALPHA(i) and BETA(i),
256*> i=INFO-N+1,...,N should be correct.
257*> \endverbatim
258*
259* Authors:
260* ========
261*
262*> \author Univ. of Tennessee
263*> \author Univ. of California Berkeley
264*> \author Univ. of Colorado Denver
265*> \author NAG Ltd.
266*
267*> \ingroup hgeqz
268*
269*> \par Further Details:
270* =====================
271*>
272*> \verbatim
273*>
274*> We assume that complex ABS works as long as its value is less than
275*> overflow.
276*> \endverbatim
277*>
278* =====================================================================
279 SUBROUTINE zhgeqz( JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T,
280 $ LDT,
281 $ ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK,
282 $ RWORK, INFO )
283*
284* -- LAPACK computational routine --
285* -- LAPACK is a software package provided by Univ. of Tennessee, --
286* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
287*
288* .. Scalar Arguments ..
289 CHARACTER COMPQ, COMPZ, JOB
290 INTEGER IHI, ILO, INFO, LDH, LDQ, LDT, LDZ, LWORK, N
291* ..
292* .. Array Arguments ..
293 DOUBLE PRECISION RWORK( * )
294 COMPLEX*16 ALPHA( * ), BETA( * ), H( LDH, * ),
295 $ Q( LDQ, * ), T( LDT, * ), WORK( * ),
296 $ z( ldz, * )
297* ..
298*
299* =====================================================================
300*
301* .. Parameters ..
302 COMPLEX*16 CZERO, CONE
303 PARAMETER ( CZERO = ( 0.0d+0, 0.0d+0 ),
304 $ cone = ( 1.0d+0, 0.0d+0 ) )
305 DOUBLE PRECISION ZERO, ONE
306 parameter( zero = 0.0d+0, one = 1.0d+0 )
307 DOUBLE PRECISION HALF
308 parameter( half = 0.5d+0 )
309* ..
310* .. Local Scalars ..
311 LOGICAL ILAZR2, ILAZRO, ILQ, ILSCHR, ILZ, LQUERY
312 INTEGER ICOMPQ, ICOMPZ, IFIRST, IFRSTM, IITER, ILAST,
313 $ ILASTM, IN, ISCHUR, ISTART, J, JC, JCH, JITER,
314 $ jr, maxit
315 DOUBLE PRECISION ABSB, ANORM, ASCALE, ATOL, BNORM, BSCALE, BTOL,
316 $ C, SAFMIN, TEMP, TEMP2, TEMPR, ULP
317 COMPLEX*16 ABI22, AD11, AD12, AD21, AD22, CTEMP, CTEMP2,
318 $ ctemp3, eshift, s, shift, signbc,
319 $ u12, x, abi12, y
320* ..
321* .. External Functions ..
322 COMPLEX*16 ZLADIV
323 LOGICAL LSAME
324 DOUBLE PRECISION DLAMCH, ZLANHS
325 EXTERNAL zladiv, lsame, dlamch, zlanhs
326* ..
327* .. External Subroutines ..
328 EXTERNAL xerbla, zlartg, zlaset, zrot, zscal
329* ..
330* .. Intrinsic Functions ..
331 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min,
332 $ sqrt
333* ..
334* .. Statement Functions ..
335 DOUBLE PRECISION ABS1
336* ..
337* .. Statement Function definitions ..
338 abs1( x ) = abs( dble( x ) ) + abs( dimag( x ) )
339* ..
340* .. Executable Statements ..
341*
342* Decode JOB, COMPQ, COMPZ
343*
344 IF( lsame( job, 'E' ) ) THEN
345 ilschr = .false.
346 ischur = 1
347 ELSE IF( lsame( job, 'S' ) ) THEN
348 ilschr = .true.
349 ischur = 2
350 ELSE
351 ilschr = .true.
352 ischur = 0
353 END IF
354*
355 IF( lsame( compq, 'N' ) ) THEN
356 ilq = .false.
357 icompq = 1
358 ELSE IF( lsame( compq, 'V' ) ) THEN
359 ilq = .true.
360 icompq = 2
361 ELSE IF( lsame( compq, 'I' ) ) THEN
362 ilq = .true.
363 icompq = 3
364 ELSE
365 ilq = .true.
366 icompq = 0
367 END IF
368*
369 IF( lsame( compz, 'N' ) ) THEN
370 ilz = .false.
371 icompz = 1
372 ELSE IF( lsame( compz, 'V' ) ) THEN
373 ilz = .true.
374 icompz = 2
375 ELSE IF( lsame( compz, 'I' ) ) THEN
376 ilz = .true.
377 icompz = 3
378 ELSE
379 ilz = .true.
380 icompz = 0
381 END IF
382*
383* Check Argument Values
384*
385 info = 0
386 work( 1 ) = max( 1, n )
387 lquery = ( lwork.EQ.-1 )
388 IF( ischur.EQ.0 ) THEN
389 info = -1
390 ELSE IF( icompq.EQ.0 ) THEN
391 info = -2
392 ELSE IF( icompz.EQ.0 ) THEN
393 info = -3
394 ELSE IF( n.LT.0 ) THEN
395 info = -4
396 ELSE IF( ilo.LT.1 ) THEN
397 info = -5
398 ELSE IF( ihi.GT.n .OR. ihi.LT.ilo-1 ) THEN
399 info = -6
400 ELSE IF( ldh.LT.n ) THEN
401 info = -8
402 ELSE IF( ldt.LT.n ) THEN
403 info = -10
404 ELSE IF( ldq.LT.1 .OR. ( ilq .AND. ldq.LT.n ) ) THEN
405 info = -14
406 ELSE IF( ldz.LT.1 .OR. ( ilz .AND. ldz.LT.n ) ) THEN
407 info = -16
408 ELSE IF( lwork.LT.max( 1, n ) .AND. .NOT.lquery ) THEN
409 info = -18
410 END IF
411 IF( info.NE.0 ) THEN
412 CALL xerbla( 'ZHGEQZ', -info )
413 RETURN
414 ELSE IF( lquery ) THEN
415 RETURN
416 END IF
417*
418* Quick return if possible
419*
420* WORK( 1 ) = CMPLX( 1 )
421 IF( n.LE.0 ) THEN
422 work( 1 ) = dcmplx( 1 )
423 RETURN
424 END IF
425*
426* Initialize Q and Z
427*
428 IF( icompq.EQ.3 )
429 $ CALL zlaset( 'Full', n, n, czero, cone, q, ldq )
430 IF( icompz.EQ.3 )
431 $ CALL zlaset( 'Full', n, n, czero, cone, z, ldz )
432*
433* Machine Constants
434*
435 in = ihi + 1 - ilo
436 safmin = dlamch( 'S' )
437 ulp = dlamch( 'E' )*dlamch( 'B' )
438 anorm = zlanhs( 'F', in, h( ilo, ilo ), ldh, rwork )
439 bnorm = zlanhs( 'F', in, t( ilo, ilo ), ldt, rwork )
440 atol = max( safmin, ulp*anorm )
441 btol = max( safmin, ulp*bnorm )
442 ascale = one / max( safmin, anorm )
443 bscale = one / max( safmin, bnorm )
444*
445*
446* Set Eigenvalues IHI+1:N
447*
448 DO 10 j = ihi + 1, n
449 absb = abs( t( j, j ) )
450 IF( absb.GT.safmin ) THEN
451 signbc = dconjg( t( j, j ) / absb )
452 t( j, j ) = absb
453 IF( ilschr ) THEN
454 CALL zscal( j-1, signbc, t( 1, j ), 1 )
455 CALL zscal( j, signbc, h( 1, j ), 1 )
456 ELSE
457 CALL zscal( 1, signbc, h( j, j ), 1 )
458 END IF
459 IF( ilz )
460 $ CALL zscal( n, signbc, z( 1, j ), 1 )
461 ELSE
462 t( j, j ) = czero
463 END IF
464 alpha( j ) = h( j, j )
465 beta( j ) = t( j, j )
466 10 CONTINUE
467*
468* If IHI < ILO, skip QZ steps
469*
470 IF( ihi.LT.ilo )
471 $ GO TO 190
472*
473* MAIN QZ ITERATION LOOP
474*
475* Initialize dynamic indices
476*
477* Eigenvalues ILAST+1:N have been found.
478* Column operations modify rows IFRSTM:whatever
479* Row operations modify columns whatever:ILASTM
480*
481* If only eigenvalues are being computed, then
482* IFRSTM is the row of the last splitting row above row ILAST;
483* this is always at least ILO.
484* IITER counts iterations since the last eigenvalue was found,
485* to tell when to use an extraordinary shift.
486* MAXIT is the maximum number of QZ sweeps allowed.
487*
488 ilast = ihi
489 IF( ilschr ) THEN
490 ifrstm = 1
491 ilastm = n
492 ELSE
493 ifrstm = ilo
494 ilastm = ihi
495 END IF
496 iiter = 0
497 eshift = czero
498 maxit = 30*( ihi-ilo+1 )
499*
500 DO 170 jiter = 1, maxit
501*
502* Check for too many iterations.
503*
504 IF( jiter.GT.maxit )
505 $ GO TO 180
506*
507* Split the matrix if possible.
508*
509* Two tests:
510* 1: H(j,j-1)=0 or j=ILO
511* 2: T(j,j)=0
512*
513* Special case: j=ILAST
514*
515 IF( ilast.EQ.ilo ) THEN
516 GO TO 60
517 ELSE
518 IF( abs1( h( ilast, ilast-1 ) ).LE.max( safmin, ulp*(
519 $ abs1( h( ilast, ilast ) ) + abs1( h( ilast-1, ilast-1 )
520 $ ) ) ) ) THEN
521 h( ilast, ilast-1 ) = czero
522 GO TO 60
523 END IF
524 END IF
525*
526 IF( abs( t( ilast, ilast ) ).LE.btol ) THEN
527 t( ilast, ilast ) = czero
528 GO TO 50
529 END IF
530*
531* General case: j<ILAST
532*
533 DO 40 j = ilast - 1, ilo, -1
534*
535* Test 1: for H(j,j-1)=0 or j=ILO
536*
537 IF( j.EQ.ilo ) THEN
538 ilazro = .true.
539 ELSE
540 IF( abs1( h( j, j-1 ) ).LE.max( safmin, ulp*(
541 $ abs1( h( j, j ) ) + abs1( h( j-1, j-1 ) )
542 $ ) ) ) THEN
543 h( j, j-1 ) = czero
544 ilazro = .true.
545 ELSE
546 ilazro = .false.
547 END IF
548 END IF
549*
550* Test 2: for T(j,j)=0
551*
552 IF( abs( t( j, j ) ).LT.btol ) THEN
553 t( j, j ) = czero
554*
555* Test 1a: Check for 2 consecutive small subdiagonals in A
556*
557 ilazr2 = .false.
558 IF( .NOT.ilazro ) THEN
559 IF( abs1( h( j, j-1 ) )*( ascale*abs1( h( j+1,
560 $ j ) ) ).LE.abs1( h( j, j ) )*( ascale*atol ) )
561 $ ilazr2 = .true.
562 END IF
563*
564* If both tests pass (1 & 2), i.e., the leading diagonal
565* element of B in the block is zero, split a 1x1 block off
566* at the top. (I.e., at the J-th row/column) The leading
567* diagonal element of the remainder can also be zero, so
568* this may have to be done repeatedly.
569*
570 IF( ilazro .OR. ilazr2 ) THEN
571 DO 20 jch = j, ilast - 1
572 ctemp = h( jch, jch )
573 CALL zlartg( ctemp, h( jch+1, jch ), c, s,
574 $ h( jch, jch ) )
575 h( jch+1, jch ) = czero
576 CALL zrot( ilastm-jch, h( jch, jch+1 ), ldh,
577 $ h( jch+1, jch+1 ), ldh, c, s )
578 CALL zrot( ilastm-jch, t( jch, jch+1 ), ldt,
579 $ t( jch+1, jch+1 ), ldt, c, s )
580 IF( ilq )
581 $ CALL zrot( n, q( 1, jch ), 1, q( 1, jch+1 ),
582 $ 1,
583 $ c, dconjg( s ) )
584 IF( ilazr2 )
585 $ h( jch, jch-1 ) = h( jch, jch-1 )*c
586 ilazr2 = .false.
587 IF( abs1( t( jch+1, jch+1 ) ).GE.btol ) THEN
588 IF( jch+1.GE.ilast ) THEN
589 GO TO 60
590 ELSE
591 ifirst = jch + 1
592 GO TO 70
593 END IF
594 END IF
595 t( jch+1, jch+1 ) = czero
596 20 CONTINUE
597 GO TO 50
598 ELSE
599*
600* Only test 2 passed -- chase the zero to T(ILAST,ILAST)
601* Then process as in the case T(ILAST,ILAST)=0
602*
603 DO 30 jch = j, ilast - 1
604 ctemp = t( jch, jch+1 )
605 CALL zlartg( ctemp, t( jch+1, jch+1 ), c, s,
606 $ t( jch, jch+1 ) )
607 t( jch+1, jch+1 ) = czero
608 IF( jch.LT.ilastm-1 )
609 $ CALL zrot( ilastm-jch-1, t( jch, jch+2 ),
610 $ ldt,
611 $ t( jch+1, jch+2 ), ldt, c, s )
612 CALL zrot( ilastm-jch+2, h( jch, jch-1 ), ldh,
613 $ h( jch+1, jch-1 ), ldh, c, s )
614 IF( ilq )
615 $ CALL zrot( n, q( 1, jch ), 1, q( 1, jch+1 ),
616 $ 1,
617 $ c, dconjg( s ) )
618 ctemp = h( jch+1, jch )
619 CALL zlartg( ctemp, h( jch+1, jch-1 ), c, s,
620 $ h( jch+1, jch ) )
621 h( jch+1, jch-1 ) = czero
622 CALL zrot( jch+1-ifrstm, h( ifrstm, jch ), 1,
623 $ h( ifrstm, jch-1 ), 1, c, s )
624 CALL zrot( jch-ifrstm, t( ifrstm, jch ), 1,
625 $ t( ifrstm, jch-1 ), 1, c, s )
626 IF( ilz )
627 $ CALL zrot( n, z( 1, jch ), 1, z( 1, jch-1 ),
628 $ 1,
629 $ c, s )
630 30 CONTINUE
631 GO TO 50
632 END IF
633 ELSE IF( ilazro ) THEN
634*
635* Only test 1 passed -- work on J:ILAST
636*
637 ifirst = j
638 GO TO 70
639 END IF
640*
641* Neither test passed -- try next J
642*
643 40 CONTINUE
644*
645* (Drop-through is "impossible")
646*
647 info = 2*n + 1
648 GO TO 210
649*
650* T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a
651* 1x1 block.
652*
653 50 CONTINUE
654 ctemp = h( ilast, ilast )
655 CALL zlartg( ctemp, h( ilast, ilast-1 ), c, s,
656 $ h( ilast, ilast ) )
657 h( ilast, ilast-1 ) = czero
658 CALL zrot( ilast-ifrstm, h( ifrstm, ilast ), 1,
659 $ h( ifrstm, ilast-1 ), 1, c, s )
660 CALL zrot( ilast-ifrstm, t( ifrstm, ilast ), 1,
661 $ t( ifrstm, ilast-1 ), 1, c, s )
662 IF( ilz )
663 $ CALL zrot( n, z( 1, ilast ), 1, z( 1, ilast-1 ), 1, c,
664 $ s )
665*
666* H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHA and BETA
667*
668 60 CONTINUE
669 absb = abs( t( ilast, ilast ) )
670 IF( absb.GT.safmin ) THEN
671 signbc = dconjg( t( ilast, ilast ) / absb )
672 t( ilast, ilast ) = absb
673 IF( ilschr ) THEN
674 CALL zscal( ilast-ifrstm, signbc, t( ifrstm, ilast ),
675 $ 1 )
676 CALL zscal( ilast+1-ifrstm, signbc, h( ifrstm,
677 $ ilast ),
678 $ 1 )
679 ELSE
680 CALL zscal( 1, signbc, h( ilast, ilast ), 1 )
681 END IF
682 IF( ilz )
683 $ CALL zscal( n, signbc, z( 1, ilast ), 1 )
684 ELSE
685 t( ilast, ilast ) = czero
686 END IF
687 alpha( ilast ) = h( ilast, ilast )
688 beta( ilast ) = t( ilast, ilast )
689*
690* Go to next block -- exit if finished.
691*
692 ilast = ilast - 1
693 IF( ilast.LT.ilo )
694 $ GO TO 190
695*
696* Reset counters
697*
698 iiter = 0
699 eshift = czero
700 IF( .NOT.ilschr ) THEN
701 ilastm = ilast
702 IF( ifrstm.GT.ilast )
703 $ ifrstm = ilo
704 END IF
705 GO TO 160
706*
707* QZ step
708*
709* This iteration only involves rows/columns IFIRST:ILAST. We
710* assume IFIRST < ILAST, and that the diagonal of B is non-zero.
711*
712 70 CONTINUE
713 iiter = iiter + 1
714 IF( .NOT.ilschr ) THEN
715 ifrstm = ifirst
716 END IF
717*
718* Compute the Shift.
719*
720* At this point, IFIRST < ILAST, and the diagonal elements of
721* T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in
722* magnitude)
723*
724 IF( ( iiter / 10 )*10.NE.iiter ) THEN
725*
726* The Wilkinson shift (AEP p.512), i.e., the eigenvalue of
727* the bottom-right 2x2 block of A inv(B) which is nearest to
728* the bottom-right element.
729*
730* We factor B as U*D, where U has unit diagonals, and
731* compute (A*inv(D))*inv(U).
732*
733 u12 = ( bscale*t( ilast-1, ilast ) ) /
734 $ ( bscale*t( ilast, ilast ) )
735 ad11 = ( ascale*h( ilast-1, ilast-1 ) ) /
736 $ ( bscale*t( ilast-1, ilast-1 ) )
737 ad21 = ( ascale*h( ilast, ilast-1 ) ) /
738 $ ( bscale*t( ilast-1, ilast-1 ) )
739 ad12 = ( ascale*h( ilast-1, ilast ) ) /
740 $ ( bscale*t( ilast, ilast ) )
741 ad22 = ( ascale*h( ilast, ilast ) ) /
742 $ ( bscale*t( ilast, ilast ) )
743 abi22 = ad22 - u12*ad21
744 abi12 = ad12 - u12*ad11
745*
746 shift = abi22
747 ctemp = sqrt( abi12 )*sqrt( ad21 )
748 temp = abs1( ctemp )
749 IF( ctemp.NE.zero ) THEN
750 x = half*( ad11-shift )
751 temp2 = abs1( x )
752 temp = max( temp, abs1( x ) )
753 y = temp*sqrt( ( x / temp )**2+( ctemp / temp )**2 )
754 IF( temp2.GT.zero ) THEN
755 IF( dble( x / temp2 )*dble( y )+
756 $ dimag( x / temp2 )*dimag( y ).LT.zero )y = -y
757 END IF
758 shift = shift - ctemp*zladiv( ctemp, ( x+y ) )
759 END IF
760 ELSE
761*
762* Exceptional shift. Chosen for no particularly good reason.
763*
764 IF( ( iiter / 20 )*20.EQ.iiter .AND.
765 $ bscale*abs1(t( ilast, ilast )).GT.safmin ) THEN
766 eshift = eshift + ( ascale*h( ilast,
767 $ ilast ) )/( bscale*t( ilast, ilast ) )
768 ELSE
769 eshift = eshift + ( ascale*h( ilast,
770 $ ilast-1 ) )/( bscale*t( ilast-1, ilast-1 ) )
771 END IF
772 shift = eshift
773 END IF
774*
775* Now check for two consecutive small subdiagonals.
776*
777 DO 80 j = ilast - 1, ifirst + 1, -1
778 istart = j
779 ctemp = ascale*h( j, j ) - shift*( bscale*t( j, j ) )
780 temp = abs1( ctemp )
781 temp2 = ascale*abs1( h( j+1, j ) )
782 tempr = max( temp, temp2 )
783 IF( tempr.LT.one .AND. tempr.NE.zero ) THEN
784 temp = temp / tempr
785 temp2 = temp2 / tempr
786 END IF
787 IF( abs1( h( j, j-1 ) )*temp2.LE.temp*atol )
788 $ GO TO 90
789 80 CONTINUE
790*
791 istart = ifirst
792 ctemp = ascale*h( ifirst, ifirst ) -
793 $ shift*( bscale*t( ifirst, ifirst ) )
794 90 CONTINUE
795*
796* Do an implicit-shift QZ sweep.
797*
798* Initial Q
799*
800 ctemp2 = ascale*h( istart+1, istart )
801 CALL zlartg( ctemp, ctemp2, c, s, ctemp3 )
802*
803* Sweep
804*
805 DO 150 j = istart, ilast - 1
806 IF( j.GT.istart ) THEN
807 ctemp = h( j, j-1 )
808 CALL zlartg( ctemp, h( j+1, j-1 ), c, s, h( j, j-1 ) )
809 h( j+1, j-1 ) = czero
810 END IF
811*
812 DO 100 jc = j, ilastm
813 ctemp = c*h( j, jc ) + s*h( j+1, jc )
814 h( j+1, jc ) = -dconjg( s )*h( j, jc ) + c*h( j+1, jc )
815 h( j, jc ) = ctemp
816 ctemp2 = c*t( j, jc ) + s*t( j+1, jc )
817 t( j+1, jc ) = -dconjg( s )*t( j, jc ) + c*t( j+1, jc )
818 t( j, jc ) = ctemp2
819 100 CONTINUE
820 IF( ilq ) THEN
821 DO 110 jr = 1, n
822 ctemp = c*q( jr, j ) + dconjg( s )*q( jr, j+1 )
823 q( jr, j+1 ) = -s*q( jr, j ) + c*q( jr, j+1 )
824 q( jr, j ) = ctemp
825 110 CONTINUE
826 END IF
827*
828 ctemp = t( j+1, j+1 )
829 CALL zlartg( ctemp, t( j+1, j ), c, s, t( j+1, j+1 ) )
830 t( j+1, j ) = czero
831*
832 DO 120 jr = ifrstm, min( j+2, ilast )
833 ctemp = c*h( jr, j+1 ) + s*h( jr, j )
834 h( jr, j ) = -dconjg( s )*h( jr, j+1 ) + c*h( jr, j )
835 h( jr, j+1 ) = ctemp
836 120 CONTINUE
837 DO 130 jr = ifrstm, j
838 ctemp = c*t( jr, j+1 ) + s*t( jr, j )
839 t( jr, j ) = -dconjg( s )*t( jr, j+1 ) + c*t( jr, j )
840 t( jr, j+1 ) = ctemp
841 130 CONTINUE
842 IF( ilz ) THEN
843 DO 140 jr = 1, n
844 ctemp = c*z( jr, j+1 ) + s*z( jr, j )
845 z( jr, j ) = -dconjg( s )*z( jr, j+1 ) + c*z( jr, j )
846 z( jr, j+1 ) = ctemp
847 140 CONTINUE
848 END IF
849 150 CONTINUE
850*
851 160 CONTINUE
852*
853 170 CONTINUE
854*
855* Drop-through = non-convergence
856*
857 180 CONTINUE
858 info = ilast
859 GO TO 210
860*
861* Successful completion of all QZ steps
862*
863 190 CONTINUE
864*
865* Set Eigenvalues 1:ILO-1
866*
867 DO 200 j = 1, ilo - 1
868 absb = abs( t( j, j ) )
869 IF( absb.GT.safmin ) THEN
870 signbc = dconjg( t( j, j ) / absb )
871 t( j, j ) = absb
872 IF( ilschr ) THEN
873 CALL zscal( j-1, signbc, t( 1, j ), 1 )
874 CALL zscal( j, signbc, h( 1, j ), 1 )
875 ELSE
876 CALL zscal( 1, signbc, h( j, j ), 1 )
877 END IF
878 IF( ilz )
879 $ CALL zscal( n, signbc, z( 1, j ), 1 )
880 ELSE
881 t( j, j ) = czero
882 END IF
883 alpha( j ) = h( j, j )
884 beta( j ) = t( j, j )
885 200 CONTINUE
886*
887* Normal Termination
888*
889 info = 0
890*
891* Exit (other than argument error) -- return optimal workspace size
892*
893 210 CONTINUE
894 work( 1 ) = dcmplx( n )
895 RETURN
896*
897* End of ZHGEQZ
898*
899 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zhgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
ZHGEQZ
Definition zhgeqz.f:283
subroutine zlartg(f, g, c, s, r)
ZLARTG generates a plane rotation with real cosine and complex sine.
Definition zlartg.f90:116
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition zlaset.f:104
subroutine zrot(n, cx, incx, cy, incy, c, s)
ZROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.
Definition zrot.f:101
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78