LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
ztgsen.f
Go to the documentation of this file.
1*> \brief \b ZTGSEN
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZTGSEN + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgsen.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgsen.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgsen.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZTGSEN( IJOB, WANTQ, WANTZ, SELECT, N, A, LDA, B, LDB,
20* ALPHA, BETA, Q, LDQ, Z, LDZ, M, PL, PR, DIF,
21* WORK, LWORK, IWORK, LIWORK, INFO )
22*
23* .. Scalar Arguments ..
24* LOGICAL WANTQ, WANTZ
25* INTEGER IJOB, INFO, LDA, LDB, LDQ, LDZ, LIWORK, LWORK,
26* $ M, N
27* DOUBLE PRECISION PL, PR
28* ..
29* .. Array Arguments ..
30* LOGICAL SELECT( * )
31* INTEGER IWORK( * )
32* DOUBLE PRECISION DIF( * )
33* COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
34* $ BETA( * ), Q( LDQ, * ), WORK( * ), Z( LDZ, * )
35* ..
36*
37*
38*> \par Purpose:
39* =============
40*>
41*> \verbatim
42*>
43*> ZTGSEN reorders the generalized Schur decomposition of a complex
44*> matrix pair (A, B) (in terms of an unitary equivalence trans-
45*> formation Q**H * (A, B) * Z), so that a selected cluster of eigenvalues
46*> appears in the leading diagonal blocks of the pair (A,B). The leading
47*> columns of Q and Z form unitary bases of the corresponding left and
48*> right eigenspaces (deflating subspaces). (A, B) must be in
49*> generalized Schur canonical form, that is, A and B are both upper
50*> triangular.
51*>
52*> ZTGSEN also computes the generalized eigenvalues
53*>
54*> w(j)= ALPHA(j) / BETA(j)
55*>
56*> of the reordered matrix pair (A, B).
57*>
58*> Optionally, the routine computes estimates of reciprocal condition
59*> numbers for eigenvalues and eigenspaces. These are Difu[(A11,B11),
60*> (A22,B22)] and Difl[(A11,B11), (A22,B22)], i.e. the separation(s)
61*> between the matrix pairs (A11, B11) and (A22,B22) that correspond to
62*> the selected cluster and the eigenvalues outside the cluster, resp.,
63*> and norms of "projections" onto left and right eigenspaces w.r.t.
64*> the selected cluster in the (1,1)-block.
65*>
66*> \endverbatim
67*
68* Arguments:
69* ==========
70*
71*> \param[in] IJOB
72*> \verbatim
73*> IJOB is INTEGER
74*> Specifies whether condition numbers are required for the
75*> cluster of eigenvalues (PL and PR) or the deflating subspaces
76*> (Difu and Difl):
77*> =0: Only reorder w.r.t. SELECT. No extras.
78*> =1: Reciprocal of norms of "projections" onto left and right
79*> eigenspaces w.r.t. the selected cluster (PL and PR).
80*> =2: Upper bounds on Difu and Difl. F-norm-based estimate
81*> (DIF(1:2)).
82*> =3: Estimate of Difu and Difl. 1-norm-based estimate
83*> (DIF(1:2)).
84*> About 5 times as expensive as IJOB = 2.
85*> =4: Compute PL, PR and DIF (i.e. 0, 1 and 2 above): Economic
86*> version to get it all.
87*> =5: Compute PL, PR and DIF (i.e. 0, 1 and 3 above)
88*> \endverbatim
89*>
90*> \param[in] WANTQ
91*> \verbatim
92*> WANTQ is LOGICAL
93*> .TRUE. : update the left transformation matrix Q;
94*> .FALSE.: do not update Q.
95*> \endverbatim
96*>
97*> \param[in] WANTZ
98*> \verbatim
99*> WANTZ is LOGICAL
100*> .TRUE. : update the right transformation matrix Z;
101*> .FALSE.: do not update Z.
102*> \endverbatim
103*>
104*> \param[in] SELECT
105*> \verbatim
106*> SELECT is LOGICAL array, dimension (N)
107*> SELECT specifies the eigenvalues in the selected cluster. To
108*> select an eigenvalue w(j), SELECT(j) must be set to
109*> .TRUE..
110*> \endverbatim
111*>
112*> \param[in] N
113*> \verbatim
114*> N is INTEGER
115*> The order of the matrices A and B. N >= 0.
116*> \endverbatim
117*>
118*> \param[in,out] A
119*> \verbatim
120*> A is COMPLEX*16 array, dimension(LDA,N)
121*> On entry, the upper triangular matrix A, in generalized
122*> Schur canonical form.
123*> On exit, A is overwritten by the reordered matrix A.
124*> \endverbatim
125*>
126*> \param[in] LDA
127*> \verbatim
128*> LDA is INTEGER
129*> The leading dimension of the array A. LDA >= max(1,N).
130*> \endverbatim
131*>
132*> \param[in,out] B
133*> \verbatim
134*> B is COMPLEX*16 array, dimension(LDB,N)
135*> On entry, the upper triangular matrix B, in generalized
136*> Schur canonical form.
137*> On exit, B is overwritten by the reordered matrix B.
138*> \endverbatim
139*>
140*> \param[in] LDB
141*> \verbatim
142*> LDB is INTEGER
143*> The leading dimension of the array B. LDB >= max(1,N).
144*> \endverbatim
145*>
146*> \param[out] ALPHA
147*> \verbatim
148*> ALPHA is COMPLEX*16 array, dimension (N)
149*> \endverbatim
150*>
151*> \param[out] BETA
152*> \verbatim
153*> BETA is COMPLEX*16 array, dimension (N)
154*>
155*> The diagonal elements of A and B, respectively,
156*> when the pair (A,B) has been reduced to generalized Schur
157*> form. ALPHA(i)/BETA(i) i=1,...,N are the generalized
158*> eigenvalues.
159*> \endverbatim
160*>
161*> \param[in,out] Q
162*> \verbatim
163*> Q is COMPLEX*16 array, dimension (LDQ,N)
164*> On entry, if WANTQ = .TRUE., Q is an N-by-N matrix.
165*> On exit, Q has been postmultiplied by the left unitary
166*> transformation matrix which reorder (A, B); The leading M
167*> columns of Q form orthonormal bases for the specified pair of
168*> left eigenspaces (deflating subspaces).
169*> If WANTQ = .FALSE., Q is not referenced.
170*> \endverbatim
171*>
172*> \param[in] LDQ
173*> \verbatim
174*> LDQ is INTEGER
175*> The leading dimension of the array Q. LDQ >= 1.
176*> If WANTQ = .TRUE., LDQ >= N.
177*> \endverbatim
178*>
179*> \param[in,out] Z
180*> \verbatim
181*> Z is COMPLEX*16 array, dimension (LDZ,N)
182*> On entry, if WANTZ = .TRUE., Z is an N-by-N matrix.
183*> On exit, Z has been postmultiplied by the left unitary
184*> transformation matrix which reorder (A, B); The leading M
185*> columns of Z form orthonormal bases for the specified pair of
186*> left eigenspaces (deflating subspaces).
187*> If WANTZ = .FALSE., Z is not referenced.
188*> \endverbatim
189*>
190*> \param[in] LDZ
191*> \verbatim
192*> LDZ is INTEGER
193*> The leading dimension of the array Z. LDZ >= 1.
194*> If WANTZ = .TRUE., LDZ >= N.
195*> \endverbatim
196*>
197*> \param[out] M
198*> \verbatim
199*> M is INTEGER
200*> The dimension of the specified pair of left and right
201*> eigenspaces, (deflating subspaces) 0 <= M <= N.
202*> \endverbatim
203*>
204*> \param[out] PL
205*> \verbatim
206*> PL is DOUBLE PRECISION
207*> \endverbatim
208*>
209*> \param[out] PR
210*> \verbatim
211*> PR is DOUBLE PRECISION
212*>
213*> If IJOB = 1, 4 or 5, PL, PR are lower bounds on the
214*> reciprocal of the norm of "projections" onto left and right
215*> eigenspace with respect to the selected cluster.
216*> 0 < PL, PR <= 1.
217*> If M = 0 or M = N, PL = PR = 1.
218*> If IJOB = 0, 2 or 3 PL, PR are not referenced.
219*> \endverbatim
220*>
221*> \param[out] DIF
222*> \verbatim
223*> DIF is DOUBLE PRECISION array, dimension (2).
224*> If IJOB >= 2, DIF(1:2) store the estimates of Difu and Difl.
225*> If IJOB = 2 or 4, DIF(1:2) are F-norm-based upper bounds on
226*> Difu and Difl. If IJOB = 3 or 5, DIF(1:2) are 1-norm-based
227*> estimates of Difu and Difl, computed using reversed
228*> communication with ZLACN2.
229*> If M = 0 or N, DIF(1:2) = F-norm([A, B]).
230*> If IJOB = 0 or 1, DIF is not referenced.
231*> \endverbatim
232*>
233*> \param[out] WORK
234*> \verbatim
235*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
236*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
237*> \endverbatim
238*>
239*> \param[in] LWORK
240*> \verbatim
241*> LWORK is INTEGER
242*> The dimension of the array WORK. LWORK >= 1
243*> If IJOB = 1, 2 or 4, LWORK >= 2*M*(N-M)
244*> If IJOB = 3 or 5, LWORK >= 4*M*(N-M)
245*>
246*> If LWORK = -1, then a workspace query is assumed; the routine
247*> only calculates the optimal size of the WORK array, returns
248*> this value as the first entry of the WORK array, and no error
249*> message related to LWORK is issued by XERBLA.
250*> \endverbatim
251*>
252*> \param[out] IWORK
253*> \verbatim
254*> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
255*> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
256*> \endverbatim
257*>
258*> \param[in] LIWORK
259*> \verbatim
260*> LIWORK is INTEGER
261*> The dimension of the array IWORK. LIWORK >= 1.
262*> If IJOB = 1, 2 or 4, LIWORK >= N+2;
263*> If IJOB = 3 or 5, LIWORK >= MAX(N+2, 2*M*(N-M));
264*>
265*> If LIWORK = -1, then a workspace query is assumed; the
266*> routine only calculates the optimal size of the IWORK array,
267*> returns this value as the first entry of the IWORK array, and
268*> no error message related to LIWORK is issued by XERBLA.
269*> \endverbatim
270*>
271*> \param[out] INFO
272*> \verbatim
273*> INFO is INTEGER
274*> =0: Successful exit.
275*> <0: If INFO = -i, the i-th argument had an illegal value.
276*> =1: Reordering of (A, B) failed because the transformed
277*> matrix pair (A, B) would be too far from generalized
278*> Schur form; the problem is very ill-conditioned.
279*> (A, B) may have been partially reordered.
280*> If requested, 0 is returned in DIF(*), PL and PR.
281*> \endverbatim
282*
283* Authors:
284* ========
285*
286*> \author Univ. of Tennessee
287*> \author Univ. of California Berkeley
288*> \author Univ. of Colorado Denver
289*> \author NAG Ltd.
290*
291*> \ingroup tgsen
292*
293*> \par Further Details:
294* =====================
295*>
296*> \verbatim
297*>
298*> ZTGSEN first collects the selected eigenvalues by computing unitary
299*> U and W that move them to the top left corner of (A, B). In other
300*> words, the selected eigenvalues are the eigenvalues of (A11, B11) in
301*>
302*> U**H*(A, B)*W = (A11 A12) (B11 B12) n1
303*> ( 0 A22),( 0 B22) n2
304*> n1 n2 n1 n2
305*>
306*> where N = n1+n2 and U**H means the conjugate transpose of U. The first
307*> n1 columns of U and W span the specified pair of left and right
308*> eigenspaces (deflating subspaces) of (A, B).
309*>
310*> If (A, B) has been obtained from the generalized real Schur
311*> decomposition of a matrix pair (C, D) = Q*(A, B)*Z**H, then the
312*> reordered generalized Schur form of (C, D) is given by
313*>
314*> (C, D) = (Q*U)*(U**H *(A, B)*W)*(Z*W)**H,
315*>
316*> and the first n1 columns of Q*U and Z*W span the corresponding
317*> deflating subspaces of (C, D) (Q and Z store Q*U and Z*W, resp.).
318*>
319*> Note that if the selected eigenvalue is sufficiently ill-conditioned,
320*> then its value may differ significantly from its value before
321*> reordering.
322*>
323*> The reciprocal condition numbers of the left and right eigenspaces
324*> spanned by the first n1 columns of U and W (or Q*U and Z*W) may
325*> be returned in DIF(1:2), corresponding to Difu and Difl, resp.
326*>
327*> The Difu and Difl are defined as:
328*>
329*> Difu[(A11, B11), (A22, B22)] = sigma-min( Zu )
330*> and
331*> Difl[(A11, B11), (A22, B22)] = Difu[(A22, B22), (A11, B11)],
332*>
333*> where sigma-min(Zu) is the smallest singular value of the
334*> (2*n1*n2)-by-(2*n1*n2) matrix
335*>
336*> Zu = [ kron(In2, A11) -kron(A22**H, In1) ]
337*> [ kron(In2, B11) -kron(B22**H, In1) ].
338*>
339*> Here, Inx is the identity matrix of size nx and A22**H is the
340*> conjugate transpose of A22. kron(X, Y) is the Kronecker product between
341*> the matrices X and Y.
342*>
343*> When DIF(2) is small, small changes in (A, B) can cause large changes
344*> in the deflating subspace. An approximate (asymptotic) bound on the
345*> maximum angular error in the computed deflating subspaces is
346*>
347*> EPS * norm((A, B)) / DIF(2),
348*>
349*> where EPS is the machine precision.
350*>
351*> The reciprocal norm of the projectors on the left and right
352*> eigenspaces associated with (A11, B11) may be returned in PL and PR.
353*> They are computed as follows. First we compute L and R so that
354*> P*(A, B)*Q is block diagonal, where
355*>
356*> P = ( I -L ) n1 Q = ( I R ) n1
357*> ( 0 I ) n2 and ( 0 I ) n2
358*> n1 n2 n1 n2
359*>
360*> and (L, R) is the solution to the generalized Sylvester equation
361*>
362*> A11*R - L*A22 = -A12
363*> B11*R - L*B22 = -B12
364*>
365*> Then PL = (F-norm(L)**2+1)**(-1/2) and PR = (F-norm(R)**2+1)**(-1/2).
366*> An approximate (asymptotic) bound on the average absolute error of
367*> the selected eigenvalues is
368*>
369*> EPS * norm((A, B)) / PL.
370*>
371*> There are also global error bounds which valid for perturbations up
372*> to a certain restriction: A lower bound (x) on the smallest
373*> F-norm(E,F) for which an eigenvalue of (A11, B11) may move and
374*> coalesce with an eigenvalue of (A22, B22) under perturbation (E,F),
375*> (i.e. (A + E, B + F), is
376*>
377*> x = min(Difu,Difl)/((1/(PL*PL)+1/(PR*PR))**(1/2)+2*max(1/PL,1/PR)).
378*>
379*> An approximate bound on x can be computed from DIF(1:2), PL and PR.
380*>
381*> If y = ( F-norm(E,F) / x) <= 1, the angles between the perturbed
382*> (L', R') and unperturbed (L, R) left and right deflating subspaces
383*> associated with the selected cluster in the (1,1)-blocks can be
384*> bounded as
385*>
386*> max-angle(L, L') <= arctan( y * PL / (1 - y * (1 - PL * PL)**(1/2))
387*> max-angle(R, R') <= arctan( y * PR / (1 - y * (1 - PR * PR)**(1/2))
388*>
389*> See LAPACK User's Guide section 4.11 or the following references
390*> for more information.
391*>
392*> Note that if the default method for computing the Frobenius-norm-
393*> based estimate DIF is not wanted (see ZLATDF), then the parameter
394*> IDIFJB (see below) should be changed from 3 to 4 (routine ZLATDF
395*> (IJOB = 2 will be used)). See ZTGSYL for more details.
396*> \endverbatim
397*
398*> \par Contributors:
399* ==================
400*>
401*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
402*> Umea University, S-901 87 Umea, Sweden.
403*
404*> \par References:
405* ================
406*>
407*> [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the
408*> Generalized Real Schur Form of a Regular Matrix Pair (A, B), in
409*> M.S. Moonen et al (eds), Linear Algebra for Large Scale and
410*> Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
411*> \n
412*> [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified
413*> Eigenvalues of a Regular Matrix Pair (A, B) and Condition
414*> Estimation: Theory, Algorithms and Software, Report
415*> UMINF - 94.04, Department of Computing Science, Umea University,
416*> S-901 87 Umea, Sweden, 1994. Also as LAPACK Working Note 87.
417*> To appear in Numerical Algorithms, 1996.
418*> \n
419*> [3] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software
420*> for Solving the Generalized Sylvester Equation and Estimating the
421*> Separation between Regular Matrix Pairs, Report UMINF - 93.23,
422*> Department of Computing Science, Umea University, S-901 87 Umea,
423*> Sweden, December 1993, Revised April 1994, Also as LAPACK working
424*> Note 75. To appear in ACM Trans. on Math. Software, Vol 22, No 1,
425*> 1996.
426*>
427* =====================================================================
428 SUBROUTINE ztgsen( IJOB, WANTQ, WANTZ, SELECT, N, A, LDA, B,
429 $ LDB,
430 $ ALPHA, BETA, Q, LDQ, Z, LDZ, M, PL, PR, DIF,
431 $ WORK, LWORK, IWORK, LIWORK, INFO )
432*
433* -- LAPACK computational routine --
434* -- LAPACK is a software package provided by Univ. of Tennessee, --
435* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
436*
437* .. Scalar Arguments ..
438 LOGICAL WANTQ, WANTZ
439 INTEGER IJOB, INFO, LDA, LDB, LDQ, LDZ, LIWORK, LWORK,
440 $ M, N
441 DOUBLE PRECISION PL, PR
442* ..
443* .. Array Arguments ..
444 LOGICAL SELECT( * )
445 INTEGER IWORK( * )
446 DOUBLE PRECISION DIF( * )
447 COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
448 $ beta( * ), q( ldq, * ), work( * ), z( ldz, * )
449* ..
450*
451* =====================================================================
452*
453* .. Parameters ..
454 INTEGER IDIFJB
455 PARAMETER ( IDIFJB = 3 )
456 double precision zero, one
457 parameter( zero = 0.0d+0, one = 1.0d+0 )
458* ..
459* .. Local Scalars ..
460 LOGICAL LQUERY, SWAP, WANTD, WANTD1, WANTD2, WANTP
461 INTEGER I, IERR, IJB, K, KASE, KS, LIWMIN, LWMIN, MN2,
462 $ N1, N2
463 DOUBLE PRECISION DSCALE, DSUM, RDSCAL, SAFMIN
464 COMPLEX*16 TEMP1, TEMP2
465* ..
466* .. Local Arrays ..
467 INTEGER ISAVE( 3 )
468* ..
469* .. External Subroutines ..
470 EXTERNAL xerbla, zlacn2, zlacpy, zlassq, zscal,
471 $ ztgexc,
472 $ ztgsyl
473* ..
474* .. Intrinsic Functions ..
475 INTRINSIC abs, dcmplx, dconjg, max, sqrt
476* ..
477* .. External Functions ..
478 DOUBLE PRECISION DLAMCH
479 EXTERNAL DLAMCH
480* ..
481* .. Executable Statements ..
482*
483* Decode and test the input parameters
484*
485 info = 0
486 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
487*
488 IF( ijob.LT.0 .OR. ijob.GT.5 ) THEN
489 info = -1
490 ELSE IF( n.LT.0 ) THEN
491 info = -5
492 ELSE IF( lda.LT.max( 1, n ) ) THEN
493 info = -7
494 ELSE IF( ldb.LT.max( 1, n ) ) THEN
495 info = -9
496 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) ) THEN
497 info = -13
498 ELSE IF( ldz.LT.1 .OR. ( wantz .AND. ldz.LT.n ) ) THEN
499 info = -15
500 END IF
501*
502 IF( info.NE.0 ) THEN
503 CALL xerbla( 'ZTGSEN', -info )
504 RETURN
505 END IF
506*
507 ierr = 0
508*
509 wantp = ijob.EQ.1 .OR. ijob.GE.4
510 wantd1 = ijob.EQ.2 .OR. ijob.EQ.4
511 wantd2 = ijob.EQ.3 .OR. ijob.EQ.5
512 wantd = wantd1 .OR. wantd2
513*
514* Set M to the dimension of the specified pair of deflating
515* subspaces.
516*
517 m = 0
518 IF( .NOT.lquery .OR. ijob.NE.0 ) THEN
519 DO 10 k = 1, n
520 alpha( k ) = a( k, k )
521 beta( k ) = b( k, k )
522 IF( k.LT.n ) THEN
523 IF( SELECT( k ) )
524 $ m = m + 1
525 ELSE
526 IF( SELECT( n ) )
527 $ m = m + 1
528 END IF
529 10 CONTINUE
530 END IF
531*
532 IF( ijob.EQ.1 .OR. ijob.EQ.2 .OR. ijob.EQ.4 ) THEN
533 lwmin = max( 1, 2*m*( n-m ) )
534 liwmin = max( 1, n+2 )
535 ELSE IF( ijob.EQ.3 .OR. ijob.EQ.5 ) THEN
536 lwmin = max( 1, 4*m*( n-m ) )
537 liwmin = max( 1, 2*m*( n-m ), n+2 )
538 ELSE
539 lwmin = 1
540 liwmin = 1
541 END IF
542*
543 work( 1 ) = lwmin
544 iwork( 1 ) = liwmin
545*
546 IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
547 info = -21
548 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery ) THEN
549 info = -23
550 END IF
551*
552 IF( info.NE.0 ) THEN
553 CALL xerbla( 'ZTGSEN', -info )
554 RETURN
555 ELSE IF( lquery ) THEN
556 RETURN
557 END IF
558*
559* Quick return if possible.
560*
561 IF( m.EQ.n .OR. m.EQ.0 ) THEN
562 IF( wantp ) THEN
563 pl = one
564 pr = one
565 END IF
566 IF( wantd ) THEN
567 dscale = zero
568 dsum = one
569 DO 20 i = 1, n
570 CALL zlassq( n, a( 1, i ), 1, dscale, dsum )
571 CALL zlassq( n, b( 1, i ), 1, dscale, dsum )
572 20 CONTINUE
573 dif( 1 ) = dscale*sqrt( dsum )
574 dif( 2 ) = dif( 1 )
575 END IF
576 GO TO 70
577 END IF
578*
579* Get machine constant
580*
581 safmin = dlamch( 'S' )
582*
583* Collect the selected blocks at the top-left corner of (A, B).
584*
585 ks = 0
586 DO 30 k = 1, n
587 swap = SELECT( k )
588 IF( swap ) THEN
589 ks = ks + 1
590*
591* Swap the K-th block to position KS. Compute unitary Q
592* and Z that will swap adjacent diagonal blocks in (A, B).
593*
594 IF( k.NE.ks )
595 $ CALL ztgexc( wantq, wantz, n, a, lda, b, ldb, q, ldq,
596 $ z,
597 $ ldz, k, ks, ierr )
598*
599 IF( ierr.GT.0 ) THEN
600*
601* Swap is rejected: exit.
602*
603 info = 1
604 IF( wantp ) THEN
605 pl = zero
606 pr = zero
607 END IF
608 IF( wantd ) THEN
609 dif( 1 ) = zero
610 dif( 2 ) = zero
611 END IF
612 GO TO 70
613 END IF
614 END IF
615 30 CONTINUE
616 IF( wantp ) THEN
617*
618* Solve generalized Sylvester equation for R and L:
619* A11 * R - L * A22 = A12
620* B11 * R - L * B22 = B12
621*
622 n1 = m
623 n2 = n - m
624 i = n1 + 1
625 CALL zlacpy( 'Full', n1, n2, a( 1, i ), lda, work, n1 )
626 CALL zlacpy( 'Full', n1, n2, b( 1, i ), ldb,
627 $ work( n1*n2+1 ),
628 $ n1 )
629 ijb = 0
630 CALL ztgsyl( 'N', ijb, n1, n2, a, lda, a( i, i ), lda, work,
631 $ n1, b, ldb, b( i, i ), ldb, work( n1*n2+1 ), n1,
632 $ dscale, dif( 1 ), work( n1*n2*2+1 ),
633 $ lwork-2*n1*n2, iwork, ierr )
634*
635* Estimate the reciprocal of norms of "projections" onto
636* left and right eigenspaces
637*
638 rdscal = zero
639 dsum = one
640 CALL zlassq( n1*n2, work, 1, rdscal, dsum )
641 pl = rdscal*sqrt( dsum )
642 IF( pl.EQ.zero ) THEN
643 pl = one
644 ELSE
645 pl = dscale / ( sqrt( dscale*dscale / pl+pl )*sqrt( pl ) )
646 END IF
647 rdscal = zero
648 dsum = one
649 CALL zlassq( n1*n2, work( n1*n2+1 ), 1, rdscal, dsum )
650 pr = rdscal*sqrt( dsum )
651 IF( pr.EQ.zero ) THEN
652 pr = one
653 ELSE
654 pr = dscale / ( sqrt( dscale*dscale / pr+pr )*sqrt( pr ) )
655 END IF
656 END IF
657 IF( wantd ) THEN
658*
659* Compute estimates Difu and Difl.
660*
661 IF( wantd1 ) THEN
662 n1 = m
663 n2 = n - m
664 i = n1 + 1
665 ijb = idifjb
666*
667* Frobenius norm-based Difu estimate.
668*
669 CALL ztgsyl( 'N', ijb, n1, n2, a, lda, a( i, i ), lda,
670 $ work,
671 $ n1, b, ldb, b( i, i ), ldb, work( n1*n2+1 ),
672 $ n1, dscale, dif( 1 ), work( n1*n2*2+1 ),
673 $ lwork-2*n1*n2, iwork, ierr )
674*
675* Frobenius norm-based Difl estimate.
676*
677 CALL ztgsyl( 'N', ijb, n2, n1, a( i, i ), lda, a, lda,
678 $ work,
679 $ n2, b( i, i ), ldb, b, ldb, work( n1*n2+1 ),
680 $ n2, dscale, dif( 2 ), work( n1*n2*2+1 ),
681 $ lwork-2*n1*n2, iwork, ierr )
682 ELSE
683*
684* Compute 1-norm-based estimates of Difu and Difl using
685* reversed communication with ZLACN2. In each step a
686* generalized Sylvester equation or a transposed variant
687* is solved.
688*
689 kase = 0
690 n1 = m
691 n2 = n - m
692 i = n1 + 1
693 ijb = 0
694 mn2 = 2*n1*n2
695*
696* 1-norm-based estimate of Difu.
697*
698 40 CONTINUE
699 CALL zlacn2( mn2, work( mn2+1 ), work, dif( 1 ), kase,
700 $ isave )
701 IF( kase.NE.0 ) THEN
702 IF( kase.EQ.1 ) THEN
703*
704* Solve generalized Sylvester equation
705*
706 CALL ztgsyl( 'N', ijb, n1, n2, a, lda, a( i, i ),
707 $ lda,
708 $ work, n1, b, ldb, b( i, i ), ldb,
709 $ work( n1*n2+1 ), n1, dscale, dif( 1 ),
710 $ work( n1*n2*2+1 ), lwork-2*n1*n2, iwork,
711 $ ierr )
712 ELSE
713*
714* Solve the transposed variant.
715*
716 CALL ztgsyl( 'C', ijb, n1, n2, a, lda, a( i, i ),
717 $ lda,
718 $ work, n1, b, ldb, b( i, i ), ldb,
719 $ work( n1*n2+1 ), n1, dscale, dif( 1 ),
720 $ work( n1*n2*2+1 ), lwork-2*n1*n2, iwork,
721 $ ierr )
722 END IF
723 GO TO 40
724 END IF
725 dif( 1 ) = dscale / dif( 1 )
726*
727* 1-norm-based estimate of Difl.
728*
729 50 CONTINUE
730 CALL zlacn2( mn2, work( mn2+1 ), work, dif( 2 ), kase,
731 $ isave )
732 IF( kase.NE.0 ) THEN
733 IF( kase.EQ.1 ) THEN
734*
735* Solve generalized Sylvester equation
736*
737 CALL ztgsyl( 'N', ijb, n2, n1, a( i, i ), lda, a,
738 $ lda,
739 $ work, n2, b( i, i ), ldb, b, ldb,
740 $ work( n1*n2+1 ), n2, dscale, dif( 2 ),
741 $ work( n1*n2*2+1 ), lwork-2*n1*n2, iwork,
742 $ ierr )
743 ELSE
744*
745* Solve the transposed variant.
746*
747 CALL ztgsyl( 'C', ijb, n2, n1, a( i, i ), lda, a,
748 $ lda,
749 $ work, n2, b, ldb, b( i, i ), ldb,
750 $ work( n1*n2+1 ), n2, dscale, dif( 2 ),
751 $ work( n1*n2*2+1 ), lwork-2*n1*n2, iwork,
752 $ ierr )
753 END IF
754 GO TO 50
755 END IF
756 dif( 2 ) = dscale / dif( 2 )
757 END IF
758 END IF
759*
760* If B(K,K) is complex, make it real and positive (normalization
761* of the generalized Schur form) and Store the generalized
762* eigenvalues of reordered pair (A, B)
763*
764 DO 60 k = 1, n
765 dscale = abs( b( k, k ) )
766 IF( dscale.GT.safmin ) THEN
767 temp1 = dconjg( b( k, k ) / dscale )
768 temp2 = b( k, k ) / dscale
769 b( k, k ) = dscale
770 CALL zscal( n-k, temp1, b( k, k+1 ), ldb )
771 CALL zscal( n-k+1, temp1, a( k, k ), lda )
772 IF( wantq )
773 $ CALL zscal( n, temp2, q( 1, k ), 1 )
774 ELSE
775 b( k, k ) = dcmplx( zero, zero )
776 END IF
777*
778 alpha( k ) = a( k, k )
779 beta( k ) = b( k, k )
780*
781 60 CONTINUE
782*
783 70 CONTINUE
784*
785 work( 1 ) = lwmin
786 iwork( 1 ) = liwmin
787*
788 RETURN
789*
790* End of ZTGSEN
791*
792 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zlacn2(n, v, x, est, kase, isave)
ZLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition zlacn2.f:131
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
Definition zlacpy.f:101
subroutine zlassq(n, x, incx, scale, sumsq)
ZLASSQ updates a sum of squares represented in scaled form.
Definition zlassq.f90:122
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
subroutine ztgexc(wantq, wantz, n, a, lda, b, ldb, q, ldq, z, ldz, ifst, ilst, info)
ZTGEXC
Definition ztgexc.f:198
subroutine ztgsen(ijob, wantq, wantz, select, n, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, m, pl, pr, dif, work, lwork, iwork, liwork, info)
ZTGSEN
Definition ztgsen.f:432
subroutine ztgsyl(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, dif, work, lwork, iwork, info)
ZTGSYL
Definition ztgsyl.f:294