LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
chgeqz.f
Go to the documentation of this file.
1*> \brief \b CHGEQZ
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CHGEQZ + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chgeqz.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chgeqz.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chgeqz.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CHGEQZ( 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* REAL RWORK( * )
29* COMPLEX 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*> CHGEQZ 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 CGGHRD.
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 CGGHRD 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 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 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 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 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 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 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 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 REAL 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 chgeqz( 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 REAL RWORK( * )
294 COMPLEX ALPHA( * ), BETA( * ), H( LDH, * ),
295 $ Q( LDQ, * ), T( LDT, * ), WORK( * ),
296 $ z( ldz, * )
297* ..
298*
299* =====================================================================
300*
301* .. Parameters ..
302 COMPLEX CZERO, CONE
303 PARAMETER ( CZERO = ( 0.0e+0, 0.0e+0 ),
304 $ cone = ( 1.0e+0, 0.0e+0 ) )
305 REAL ZERO, ONE
306 parameter( zero = 0.0e+0, one = 1.0e+0 )
307 REAL HALF
308 parameter( half = 0.5e+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 REAL ABSB, ANORM, ASCALE, ATOL, BNORM, BSCALE, BTOL,
316 $ C, SAFMIN, TEMP, TEMP2, TEMPR, ULP
317 COMPLEX ABI22, AD11, AD12, AD21, AD22, CTEMP, CTEMP2,
318 $ ctemp3, eshift, s, shift, signbc,
319 $ u12, x, abi12, y
320* ..
321* .. External Functions ..
322 COMPLEX CLADIV
323 LOGICAL LSAME
324 REAL CLANHS, SLAMCH
325 EXTERNAL cladiv, lsame, clanhs, slamch
326* ..
327* .. External Subroutines ..
328 EXTERNAL clartg, claset, crot, cscal, xerbla
329* ..
330* .. Intrinsic Functions ..
331 INTRINSIC abs, aimag, cmplx, conjg, max, min, real, sqrt
332* ..
333* .. Statement Functions ..
334 REAL ABS1
335* ..
336* .. Statement Function definitions ..
337 abs1( x ) = abs( real( x ) ) + abs( aimag( x ) )
338* ..
339* .. Executable Statements ..
340*
341* Decode JOB, COMPQ, COMPZ
342*
343 IF( lsame( job, 'E' ) ) THEN
344 ilschr = .false.
345 ischur = 1
346 ELSE IF( lsame( job, 'S' ) ) THEN
347 ilschr = .true.
348 ischur = 2
349 ELSE
350 ilschr = .true.
351 ischur = 0
352 END IF
353*
354 IF( lsame( compq, 'N' ) ) THEN
355 ilq = .false.
356 icompq = 1
357 ELSE IF( lsame( compq, 'V' ) ) THEN
358 ilq = .true.
359 icompq = 2
360 ELSE IF( lsame( compq, 'I' ) ) THEN
361 ilq = .true.
362 icompq = 3
363 ELSE
364 ilq = .true.
365 icompq = 0
366 END IF
367*
368 IF( lsame( compz, 'N' ) ) THEN
369 ilz = .false.
370 icompz = 1
371 ELSE IF( lsame( compz, 'V' ) ) THEN
372 ilz = .true.
373 icompz = 2
374 ELSE IF( lsame( compz, 'I' ) ) THEN
375 ilz = .true.
376 icompz = 3
377 ELSE
378 ilz = .true.
379 icompz = 0
380 END IF
381*
382* Check Argument Values
383*
384 info = 0
385 work( 1 ) = cmplx( max( 1, n ) )
386 lquery = ( lwork.EQ.-1 )
387 IF( ischur.EQ.0 ) THEN
388 info = -1
389 ELSE IF( icompq.EQ.0 ) THEN
390 info = -2
391 ELSE IF( icompz.EQ.0 ) THEN
392 info = -3
393 ELSE IF( n.LT.0 ) THEN
394 info = -4
395 ELSE IF( ilo.LT.1 ) THEN
396 info = -5
397 ELSE IF( ihi.GT.n .OR. ihi.LT.ilo-1 ) THEN
398 info = -6
399 ELSE IF( ldh.LT.n ) THEN
400 info = -8
401 ELSE IF( ldt.LT.n ) THEN
402 info = -10
403 ELSE IF( ldq.LT.1 .OR. ( ilq .AND. ldq.LT.n ) ) THEN
404 info = -14
405 ELSE IF( ldz.LT.1 .OR. ( ilz .AND. ldz.LT.n ) ) THEN
406 info = -16
407 ELSE IF( lwork.LT.max( 1, n ) .AND. .NOT.lquery ) THEN
408 info = -18
409 END IF
410 IF( info.NE.0 ) THEN
411 CALL xerbla( 'CHGEQZ', -info )
412 RETURN
413 ELSE IF( lquery ) THEN
414 RETURN
415 END IF
416*
417* Quick return if possible
418*
419* WORK( 1 ) = CMPLX( 1 )
420 IF( n.LE.0 ) THEN
421 work( 1 ) = cmplx( 1 )
422 RETURN
423 END IF
424*
425* Initialize Q and Z
426*
427 IF( icompq.EQ.3 )
428 $ CALL claset( 'Full', n, n, czero, cone, q, ldq )
429 IF( icompz.EQ.3 )
430 $ CALL claset( 'Full', n, n, czero, cone, z, ldz )
431*
432* Machine Constants
433*
434 in = ihi + 1 - ilo
435 safmin = slamch( 'S' )
436 ulp = slamch( 'E' )*slamch( 'B' )
437 anorm = clanhs( 'F', in, h( ilo, ilo ), ldh, rwork )
438 bnorm = clanhs( 'F', in, t( ilo, ilo ), ldt, rwork )
439 atol = max( safmin, ulp*anorm )
440 btol = max( safmin, ulp*bnorm )
441 ascale = one / max( safmin, anorm )
442 bscale = one / max( safmin, bnorm )
443*
444*
445* Set Eigenvalues IHI+1:N
446*
447 DO 10 j = ihi + 1, n
448 absb = abs( t( j, j ) )
449 IF( absb.GT.safmin ) THEN
450 signbc = conjg( t( j, j ) / absb )
451 t( j, j ) = absb
452 IF( ilschr ) THEN
453 CALL cscal( j-1, signbc, t( 1, j ), 1 )
454 CALL cscal( j, signbc, h( 1, j ), 1 )
455 ELSE
456 CALL cscal( 1, signbc, h( j, j ), 1 )
457 END IF
458 IF( ilz )
459 $ CALL cscal( n, signbc, z( 1, j ), 1 )
460 ELSE
461 t( j, j ) = czero
462 END IF
463 alpha( j ) = h( j, j )
464 beta( j ) = t( j, j )
465 10 CONTINUE
466*
467* If IHI < ILO, skip QZ steps
468*
469 IF( ihi.LT.ilo )
470 $ GO TO 190
471*
472* MAIN QZ ITERATION LOOP
473*
474* Initialize dynamic indices
475*
476* Eigenvalues ILAST+1:N have been found.
477* Column operations modify rows IFRSTM:whatever
478* Row operations modify columns whatever:ILASTM
479*
480* If only eigenvalues are being computed, then
481* IFRSTM is the row of the last splitting row above row ILAST;
482* this is always at least ILO.
483* IITER counts iterations since the last eigenvalue was found,
484* to tell when to use an extraordinary shift.
485* MAXIT is the maximum number of QZ sweeps allowed.
486*
487 ilast = ihi
488 IF( ilschr ) THEN
489 ifrstm = 1
490 ilastm = n
491 ELSE
492 ifrstm = ilo
493 ilastm = ihi
494 END IF
495 iiter = 0
496 eshift = czero
497 maxit = 30*( ihi-ilo+1 )
498*
499 DO 170 jiter = 1, maxit
500*
501* Check for too many iterations.
502*
503 IF( jiter.GT.maxit )
504 $ GO TO 180
505*
506* Split the matrix if possible.
507*
508* Two tests:
509* 1: H(j,j-1)=0 or j=ILO
510* 2: T(j,j)=0
511*
512* Special case: j=ILAST
513*
514 IF( ilast.EQ.ilo ) THEN
515 GO TO 60
516 ELSE
517 IF( abs1( h( ilast, ilast-1 ) ).LE.max( safmin, ulp*(
518 $ abs1( h( ilast, ilast ) ) + abs1( h( ilast-1, ilast-1 )
519 $ ) ) ) ) THEN
520 h( ilast, ilast-1 ) = czero
521 GO TO 60
522 END IF
523 END IF
524*
525 IF( abs( t( ilast, ilast ) ).LE.btol ) THEN
526 t( ilast, ilast ) = czero
527 GO TO 50
528 END IF
529*
530* General case: j<ILAST
531*
532 DO 40 j = ilast - 1, ilo, -1
533*
534* Test 1: for H(j,j-1)=0 or j=ILO
535*
536 IF( j.EQ.ilo ) THEN
537 ilazro = .true.
538 ELSE
539 IF( abs1( h( j, j-1 ) ).LE.max( safmin, ulp*(
540 $ abs1( h( j, j ) ) + abs1( h( j-1, j-1 ) )
541 $ ) ) ) THEN
542 h( j, j-1 ) = czero
543 ilazro = .true.
544 ELSE
545 ilazro = .false.
546 END IF
547 END IF
548*
549* Test 2: for T(j,j)=0
550*
551 IF( abs( t( j, j ) ).LT.btol ) THEN
552 t( j, j ) = czero
553*
554* Test 1a: Check for 2 consecutive small subdiagonals in A
555*
556 ilazr2 = .false.
557 IF( .NOT.ilazro ) THEN
558 IF( abs1( h( j, j-1 ) )*( ascale*abs1( h( j+1,
559 $ j ) ) ).LE.abs1( h( j, j ) )*( ascale*atol ) )
560 $ ilazr2 = .true.
561 END IF
562*
563* If both tests pass (1 & 2), i.e., the leading diagonal
564* element of B in the block is zero, split a 1x1 block off
565* at the top. (I.e., at the J-th row/column) The leading
566* diagonal element of the remainder can also be zero, so
567* this may have to be done repeatedly.
568*
569 IF( ilazro .OR. ilazr2 ) THEN
570 DO 20 jch = j, ilast - 1
571 ctemp = h( jch, jch )
572 CALL clartg( ctemp, h( jch+1, jch ), c, s,
573 $ h( jch, jch ) )
574 h( jch+1, jch ) = czero
575 CALL crot( ilastm-jch, h( jch, jch+1 ), ldh,
576 $ h( jch+1, jch+1 ), ldh, c, s )
577 CALL crot( ilastm-jch, t( jch, jch+1 ), ldt,
578 $ t( jch+1, jch+1 ), ldt, c, s )
579 IF( ilq )
580 $ CALL crot( n, q( 1, jch ), 1, q( 1, jch+1 ),
581 $ 1,
582 $ c, conjg( s ) )
583 IF( ilazr2 )
584 $ h( jch, jch-1 ) = h( jch, jch-1 )*c
585 ilazr2 = .false.
586 IF( abs1( t( jch+1, jch+1 ) ).GE.btol ) THEN
587 IF( jch+1.GE.ilast ) THEN
588 GO TO 60
589 ELSE
590 ifirst = jch + 1
591 GO TO 70
592 END IF
593 END IF
594 t( jch+1, jch+1 ) = czero
595 20 CONTINUE
596 GO TO 50
597 ELSE
598*
599* Only test 2 passed -- chase the zero to T(ILAST,ILAST)
600* Then process as in the case T(ILAST,ILAST)=0
601*
602 DO 30 jch = j, ilast - 1
603 ctemp = t( jch, jch+1 )
604 CALL clartg( ctemp, t( jch+1, jch+1 ), c, s,
605 $ t( jch, jch+1 ) )
606 t( jch+1, jch+1 ) = czero
607 IF( jch.LT.ilastm-1 )
608 $ CALL crot( ilastm-jch-1, t( jch, jch+2 ),
609 $ ldt,
610 $ t( jch+1, jch+2 ), ldt, c, s )
611 CALL crot( ilastm-jch+2, h( jch, jch-1 ), ldh,
612 $ h( jch+1, jch-1 ), ldh, c, s )
613 IF( ilq )
614 $ CALL crot( n, q( 1, jch ), 1, q( 1, jch+1 ),
615 $ 1,
616 $ c, conjg( s ) )
617 ctemp = h( jch+1, jch )
618 CALL clartg( ctemp, h( jch+1, jch-1 ), c, s,
619 $ h( jch+1, jch ) )
620 h( jch+1, jch-1 ) = czero
621 CALL crot( jch+1-ifrstm, h( ifrstm, jch ), 1,
622 $ h( ifrstm, jch-1 ), 1, c, s )
623 CALL crot( jch-ifrstm, t( ifrstm, jch ), 1,
624 $ t( ifrstm, jch-1 ), 1, c, s )
625 IF( ilz )
626 $ CALL crot( n, z( 1, jch ), 1, z( 1, jch-1 ),
627 $ 1,
628 $ c, s )
629 30 CONTINUE
630 GO TO 50
631 END IF
632 ELSE IF( ilazro ) THEN
633*
634* Only test 1 passed -- work on J:ILAST
635*
636 ifirst = j
637 GO TO 70
638 END IF
639*
640* Neither test passed -- try next J
641*
642 40 CONTINUE
643*
644* (Drop-through is "impossible")
645*
646 info = 2*n + 1
647 GO TO 210
648*
649* T(ILAST,ILAST)=0 -- clear H(ILAST,ILAST-1) to split off a
650* 1x1 block.
651*
652 50 CONTINUE
653 ctemp = h( ilast, ilast )
654 CALL clartg( ctemp, h( ilast, ilast-1 ), c, s,
655 $ h( ilast, ilast ) )
656 h( ilast, ilast-1 ) = czero
657 CALL crot( ilast-ifrstm, h( ifrstm, ilast ), 1,
658 $ h( ifrstm, ilast-1 ), 1, c, s )
659 CALL crot( ilast-ifrstm, t( ifrstm, ilast ), 1,
660 $ t( ifrstm, ilast-1 ), 1, c, s )
661 IF( ilz )
662 $ CALL crot( n, z( 1, ilast ), 1, z( 1, ilast-1 ), 1, c,
663 $ s )
664*
665* H(ILAST,ILAST-1)=0 -- Standardize B, set ALPHA and BETA
666*
667 60 CONTINUE
668 absb = abs( t( ilast, ilast ) )
669 IF( absb.GT.safmin ) THEN
670 signbc = conjg( t( ilast, ilast ) / absb )
671 t( ilast, ilast ) = absb
672 IF( ilschr ) THEN
673 CALL cscal( ilast-ifrstm, signbc, t( ifrstm, ilast ),
674 $ 1 )
675 CALL cscal( ilast+1-ifrstm, signbc, h( ifrstm,
676 $ ilast ),
677 $ 1 )
678 ELSE
679 CALL cscal( 1, signbc, h( ilast, ilast ), 1 )
680 END IF
681 IF( ilz )
682 $ CALL cscal( n, signbc, z( 1, ilast ), 1 )
683 ELSE
684 t( ilast, ilast ) = czero
685 END IF
686 alpha( ilast ) = h( ilast, ilast )
687 beta( ilast ) = t( ilast, ilast )
688*
689* Go to next block -- exit if finished.
690*
691 ilast = ilast - 1
692 IF( ilast.LT.ilo )
693 $ GO TO 190
694*
695* Reset counters
696*
697 iiter = 0
698 eshift = czero
699 IF( .NOT.ilschr ) THEN
700 ilastm = ilast
701 IF( ifrstm.GT.ilast )
702 $ ifrstm = ilo
703 END IF
704 GO TO 160
705*
706* QZ step
707*
708* This iteration only involves rows/columns IFIRST:ILAST. We
709* assume IFIRST < ILAST, and that the diagonal of B is non-zero.
710*
711 70 CONTINUE
712 iiter = iiter + 1
713 IF( .NOT.ilschr ) THEN
714 ifrstm = ifirst
715 END IF
716*
717* Compute the Shift.
718*
719* At this point, IFIRST < ILAST, and the diagonal elements of
720* T(IFIRST:ILAST,IFIRST,ILAST) are larger than BTOL (in
721* magnitude)
722*
723 IF( ( iiter / 10 )*10.NE.iiter ) THEN
724*
725* The Wilkinson shift (AEP p.512), i.e., the eigenvalue of
726* the bottom-right 2x2 block of A inv(B) which is nearest to
727* the bottom-right element.
728*
729* We factor B as U*D, where U has unit diagonals, and
730* compute (A*inv(D))*inv(U).
731*
732 u12 = ( bscale*t( ilast-1, ilast ) ) /
733 $ ( bscale*t( ilast, ilast ) )
734 ad11 = ( ascale*h( ilast-1, ilast-1 ) ) /
735 $ ( bscale*t( ilast-1, ilast-1 ) )
736 ad21 = ( ascale*h( ilast, ilast-1 ) ) /
737 $ ( bscale*t( ilast-1, ilast-1 ) )
738 ad12 = ( ascale*h( ilast-1, ilast ) ) /
739 $ ( bscale*t( ilast, ilast ) )
740 ad22 = ( ascale*h( ilast, ilast ) ) /
741 $ ( bscale*t( ilast, ilast ) )
742 abi22 = ad22 - u12*ad21
743 abi12 = ad12 - u12*ad11
744*
745 shift = abi22
746 ctemp = sqrt( abi12 )*sqrt( ad21 )
747 temp = abs1( ctemp )
748 IF( ctemp.NE.zero ) THEN
749 x = half*( ad11-shift )
750 temp2 = abs1( x )
751 temp = max( temp, abs1( x ) )
752 y = temp*sqrt( ( x / temp )**2+( ctemp / temp )**2 )
753 IF( temp2.GT.zero ) THEN
754 IF( real( x / temp2 )*real( y )+
755 $ aimag( x / temp2 )*aimag( y ).LT.zero )y = -y
756 END IF
757 shift = shift - ctemp*cladiv( ctemp, ( x+y ) )
758 END IF
759 ELSE
760*
761* Exceptional shift. Chosen for no particularly good reason.
762*
763 IF( ( iiter / 20 )*20.EQ.iiter .AND.
764 $ bscale*abs1(t( ilast, ilast )).GT.safmin ) THEN
765 eshift = eshift + ( ascale*h( ilast,
766 $ ilast ) )/( bscale*t( ilast, ilast ) )
767 ELSE
768 eshift = eshift + ( ascale*h( ilast,
769 $ ilast-1 ) )/( bscale*t( ilast-1, ilast-1 ) )
770 END IF
771 shift = eshift
772 END IF
773*
774* Now check for two consecutive small subdiagonals.
775*
776 DO 80 j = ilast - 1, ifirst + 1, -1
777 istart = j
778 ctemp = ascale*h( j, j ) - shift*( bscale*t( j, j ) )
779 temp = abs1( ctemp )
780 temp2 = ascale*abs1( h( j+1, j ) )
781 tempr = max( temp, temp2 )
782 IF( tempr.LT.one .AND. tempr.NE.zero ) THEN
783 temp = temp / tempr
784 temp2 = temp2 / tempr
785 END IF
786 IF( abs1( h( j, j-1 ) )*temp2.LE.temp*atol )
787 $ GO TO 90
788 80 CONTINUE
789*
790 istart = ifirst
791 ctemp = ascale*h( ifirst, ifirst ) -
792 $ shift*( bscale*t( ifirst, ifirst ) )
793 90 CONTINUE
794*
795* Do an implicit-shift QZ sweep.
796*
797* Initial Q
798*
799 ctemp2 = ascale*h( istart+1, istart )
800 CALL clartg( ctemp, ctemp2, c, s, ctemp3 )
801*
802* Sweep
803*
804 DO 150 j = istart, ilast - 1
805 IF( j.GT.istart ) THEN
806 ctemp = h( j, j-1 )
807 CALL clartg( ctemp, h( j+1, j-1 ), c, s, h( j, j-1 ) )
808 h( j+1, j-1 ) = czero
809 END IF
810*
811 DO 100 jc = j, ilastm
812 ctemp = c*h( j, jc ) + s*h( j+1, jc )
813 h( j+1, jc ) = -conjg( s )*h( j, jc ) + c*h( j+1, jc )
814 h( j, jc ) = ctemp
815 ctemp2 = c*t( j, jc ) + s*t( j+1, jc )
816 t( j+1, jc ) = -conjg( s )*t( j, jc ) + c*t( j+1, jc )
817 t( j, jc ) = ctemp2
818 100 CONTINUE
819 IF( ilq ) THEN
820 DO 110 jr = 1, n
821 ctemp = c*q( jr, j ) + conjg( s )*q( jr, j+1 )
822 q( jr, j+1 ) = -s*q( jr, j ) + c*q( jr, j+1 )
823 q( jr, j ) = ctemp
824 110 CONTINUE
825 END IF
826*
827 ctemp = t( j+1, j+1 )
828 CALL clartg( ctemp, t( j+1, j ), c, s, t( j+1, j+1 ) )
829 t( j+1, j ) = czero
830*
831 DO 120 jr = ifrstm, min( j+2, ilast )
832 ctemp = c*h( jr, j+1 ) + s*h( jr, j )
833 h( jr, j ) = -conjg( s )*h( jr, j+1 ) + c*h( jr, j )
834 h( jr, j+1 ) = ctemp
835 120 CONTINUE
836 DO 130 jr = ifrstm, j
837 ctemp = c*t( jr, j+1 ) + s*t( jr, j )
838 t( jr, j ) = -conjg( s )*t( jr, j+1 ) + c*t( jr, j )
839 t( jr, j+1 ) = ctemp
840 130 CONTINUE
841 IF( ilz ) THEN
842 DO 140 jr = 1, n
843 ctemp = c*z( jr, j+1 ) + s*z( jr, j )
844 z( jr, j ) = -conjg( s )*z( jr, j+1 ) + c*z( jr, j )
845 z( jr, j+1 ) = ctemp
846 140 CONTINUE
847 END IF
848 150 CONTINUE
849*
850 160 CONTINUE
851*
852 170 CONTINUE
853*
854* Drop-through = non-convergence
855*
856 180 CONTINUE
857 info = ilast
858 GO TO 210
859*
860* Successful completion of all QZ steps
861*
862 190 CONTINUE
863*
864* Set Eigenvalues 1:ILO-1
865*
866 DO 200 j = 1, ilo - 1
867 absb = abs( t( j, j ) )
868 IF( absb.GT.safmin ) THEN
869 signbc = conjg( t( j, j ) / absb )
870 t( j, j ) = absb
871 IF( ilschr ) THEN
872 CALL cscal( j-1, signbc, t( 1, j ), 1 )
873 CALL cscal( j, signbc, h( 1, j ), 1 )
874 ELSE
875 CALL cscal( 1, signbc, h( j, j ), 1 )
876 END IF
877 IF( ilz )
878 $ CALL cscal( n, signbc, z( 1, j ), 1 )
879 ELSE
880 t( j, j ) = czero
881 END IF
882 alpha( j ) = h( j, j )
883 beta( j ) = t( j, j )
884 200 CONTINUE
885*
886* Normal Termination
887*
888 info = 0
889*
890* Exit (other than argument error) -- return optimal workspace size
891*
892 210 CONTINUE
893 work( 1 ) = cmplx( n )
894 RETURN
895*
896* End of CHGEQZ
897*
898 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine chgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
CHGEQZ
Definition chgeqz.f:283
subroutine clartg(f, g, c, s, r)
CLARTG generates a plane rotation with real cosine and complex sine.
Definition clartg.f90:116
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition claset.f:104
subroutine crot(n, cx, incx, cy, incy, c, s)
CROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.
Definition crot.f:101
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78