LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
dggevx.f
Go to the documentation of this file.
1*> \brief <b> DGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download DGGEVX + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dggevx.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dggevx.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dggevx.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE DGGEVX( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, B, LDB,
20* ALPHAR, ALPHAI, BETA, VL, LDVL, VR, LDVR, ILO,
21* IHI, LSCALE, RSCALE, ABNRM, BBNRM, RCONDE,
22* RCONDV, WORK, LWORK, IWORK, BWORK, INFO )
23*
24* .. Scalar Arguments ..
25* CHARACTER BALANC, JOBVL, JOBVR, SENSE
26* INTEGER IHI, ILO, INFO, LDA, LDB, LDVL, LDVR, LWORK, N
27* DOUBLE PRECISION ABNRM, BBNRM
28* ..
29* .. Array Arguments ..
30* LOGICAL BWORK( * )
31* INTEGER IWORK( * )
32* DOUBLE PRECISION A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
33* $ B( LDB, * ), BETA( * ), LSCALE( * ),
34* $ RCONDE( * ), RCONDV( * ), RSCALE( * ),
35* $ VL( LDVL, * ), VR( LDVR, * ), WORK( * )
36* ..
37*
38*
39*> \par Purpose:
40* =============
41*>
42*> \verbatim
43*>
44*> DGGEVX computes for a pair of N-by-N real nonsymmetric matrices (A,B)
45*> the generalized eigenvalues, and optionally, the left and/or right
46*> generalized eigenvectors.
47*>
48*> Optionally also, it computes a balancing transformation to improve
49*> the conditioning of the eigenvalues and eigenvectors (ILO, IHI,
50*> LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for
51*> the eigenvalues (RCONDE), and reciprocal condition numbers for the
52*> right eigenvectors (RCONDV).
53*>
54*> A generalized eigenvalue for a pair of matrices (A,B) is a scalar
55*> lambda or a ratio alpha/beta = lambda, such that A - lambda*B is
56*> singular. It is usually represented as the pair (alpha,beta), as
57*> there is a reasonable interpretation for beta=0, and even for both
58*> being zero.
59*>
60*> The right eigenvector v(j) corresponding to the eigenvalue lambda(j)
61*> of (A,B) satisfies
62*>
63*> A * v(j) = lambda(j) * B * v(j) .
64*>
65*> The left eigenvector u(j) corresponding to the eigenvalue lambda(j)
66*> of (A,B) satisfies
67*>
68*> u(j)**H * A = lambda(j) * u(j)**H * B.
69*>
70*> where u(j)**H is the conjugate-transpose of u(j).
71*>
72*> \endverbatim
73*
74* Arguments:
75* ==========
76*
77*> \param[in] BALANC
78*> \verbatim
79*> BALANC is CHARACTER*1
80*> Specifies the balance option to be performed.
81*> = 'N': do not diagonally scale or permute;
82*> = 'P': permute only;
83*> = 'S': scale only;
84*> = 'B': both permute and scale.
85*> Computed reciprocal condition numbers will be for the
86*> matrices after permuting and/or balancing. Permuting does
87*> not change condition numbers (in exact arithmetic), but
88*> balancing does.
89*> \endverbatim
90*>
91*> \param[in] JOBVL
92*> \verbatim
93*> JOBVL is CHARACTER*1
94*> = 'N': do not compute the left generalized eigenvectors;
95*> = 'V': compute the left generalized eigenvectors.
96*> \endverbatim
97*>
98*> \param[in] JOBVR
99*> \verbatim
100*> JOBVR is CHARACTER*1
101*> = 'N': do not compute the right generalized eigenvectors;
102*> = 'V': compute the right generalized eigenvectors.
103*> \endverbatim
104*>
105*> \param[in] SENSE
106*> \verbatim
107*> SENSE is CHARACTER*1
108*> Determines which reciprocal condition numbers are computed.
109*> = 'N': none are computed;
110*> = 'E': computed for eigenvalues only;
111*> = 'V': computed for eigenvectors only;
112*> = 'B': computed for eigenvalues and eigenvectors.
113*> \endverbatim
114*>
115*> \param[in] N
116*> \verbatim
117*> N is INTEGER
118*> The order of the matrices A, B, VL, and VR. N >= 0.
119*> \endverbatim
120*>
121*> \param[in,out] A
122*> \verbatim
123*> A is DOUBLE PRECISION array, dimension (LDA, N)
124*> On entry, the matrix A in the pair (A,B).
125*> On exit, A has been overwritten. If JOBVL='V' or JOBVR='V'
126*> or both, then A contains the first part of the real Schur
127*> form of the "balanced" versions of the input A and B.
128*> \endverbatim
129*>
130*> \param[in] LDA
131*> \verbatim
132*> LDA is INTEGER
133*> The leading dimension of A. LDA >= max(1,N).
134*> \endverbatim
135*>
136*> \param[in,out] B
137*> \verbatim
138*> B is DOUBLE PRECISION array, dimension (LDB, N)
139*> On entry, the matrix B in the pair (A,B).
140*> On exit, B has been overwritten. If JOBVL='V' or JOBVR='V'
141*> or both, then B contains the second part of the real Schur
142*> form of the "balanced" versions of the input A and B.
143*> \endverbatim
144*>
145*> \param[in] LDB
146*> \verbatim
147*> LDB is INTEGER
148*> The leading dimension of B. LDB >= max(1,N).
149*> \endverbatim
150*>
151*> \param[out] ALPHAR
152*> \verbatim
153*> ALPHAR is DOUBLE PRECISION array, dimension (N)
154*> \endverbatim
155*>
156*> \param[out] ALPHAI
157*> \verbatim
158*> ALPHAI is DOUBLE PRECISION array, dimension (N)
159*> \endverbatim
160*>
161*> \param[out] BETA
162*> \verbatim
163*> BETA is DOUBLE PRECISION array, dimension (N)
164*> On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
165*> be the generalized eigenvalues. If ALPHAI(j) is zero, then
166*> the j-th eigenvalue is real; if positive, then the j-th and
167*> (j+1)-st eigenvalues are a complex conjugate pair, with
168*> ALPHAI(j+1) negative.
169*>
170*> Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
171*> may easily over- or underflow, and BETA(j) may even be zero.
172*> Thus, the user should avoid naively computing the ratio
173*> ALPHA/BETA. However, ALPHAR and ALPHAI will be always less
174*> than and usually comparable with norm(A) in magnitude, and
175*> BETA always less than and usually comparable with norm(B).
176*> \endverbatim
177*>
178*> \param[out] VL
179*> \verbatim
180*> VL is DOUBLE PRECISION array, dimension (LDVL,N)
181*> If JOBVL = 'V', the left eigenvectors u(j) are stored one
182*> after another in the columns of VL, in the same order as
183*> their eigenvalues. If the j-th eigenvalue is real, then
184*> u(j) = VL(:,j), the j-th column of VL. If the j-th and
185*> (j+1)-th eigenvalues form a complex conjugate pair, then
186*> u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1).
187*> Each eigenvector will be scaled so the largest component have
188*> abs(real part) + abs(imag. part) = 1.
189*> Not referenced if JOBVL = 'N'.
190*> \endverbatim
191*>
192*> \param[in] LDVL
193*> \verbatim
194*> LDVL is INTEGER
195*> The leading dimension of the matrix VL. LDVL >= 1, and
196*> if JOBVL = 'V', LDVL >= N.
197*> \endverbatim
198*>
199*> \param[out] VR
200*> \verbatim
201*> VR is DOUBLE PRECISION array, dimension (LDVR,N)
202*> If JOBVR = 'V', the right eigenvectors v(j) are stored one
203*> after another in the columns of VR, in the same order as
204*> their eigenvalues. If the j-th eigenvalue is real, then
205*> v(j) = VR(:,j), the j-th column of VR. If the j-th and
206*> (j+1)-th eigenvalues form a complex conjugate pair, then
207*> v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1).
208*> Each eigenvector will be scaled so the largest component have
209*> abs(real part) + abs(imag. part) = 1.
210*> Not referenced if JOBVR = 'N'.
211*> \endverbatim
212*>
213*> \param[in] LDVR
214*> \verbatim
215*> LDVR is INTEGER
216*> The leading dimension of the matrix VR. LDVR >= 1, and
217*> if JOBVR = 'V', LDVR >= N.
218*> \endverbatim
219*>
220*> \param[out] ILO
221*> \verbatim
222*> ILO is INTEGER
223*> \endverbatim
224*>
225*> \param[out] IHI
226*> \verbatim
227*> IHI is INTEGER
228*> ILO and IHI are integer values such that on exit
229*> A(i,j) = 0 and B(i,j) = 0 if i > j and
230*> j = 1,...,ILO-1 or i = IHI+1,...,N.
231*> If BALANC = 'N' or 'S', ILO = 1 and IHI = N.
232*> \endverbatim
233*>
234*> \param[out] LSCALE
235*> \verbatim
236*> LSCALE is DOUBLE PRECISION array, dimension (N)
237*> Details of the permutations and scaling factors applied
238*> to the left side of A and B. If PL(j) is the index of the
239*> row interchanged with row j, and DL(j) is the scaling
240*> factor applied to row j, then
241*> LSCALE(j) = PL(j) for j = 1,...,ILO-1
242*> = DL(j) for j = ILO,...,IHI
243*> = PL(j) for j = IHI+1,...,N.
244*> The order in which the interchanges are made is N to IHI+1,
245*> then 1 to ILO-1.
246*> \endverbatim
247*>
248*> \param[out] RSCALE
249*> \verbatim
250*> RSCALE is DOUBLE PRECISION array, dimension (N)
251*> Details of the permutations and scaling factors applied
252*> to the right side of A and B. If PR(j) is the index of the
253*> column interchanged with column j, and DR(j) is the scaling
254*> factor applied to column j, then
255*> RSCALE(j) = PR(j) for j = 1,...,ILO-1
256*> = DR(j) for j = ILO,...,IHI
257*> = PR(j) for j = IHI+1,...,N
258*> The order in which the interchanges are made is N to IHI+1,
259*> then 1 to ILO-1.
260*> \endverbatim
261*>
262*> \param[out] ABNRM
263*> \verbatim
264*> ABNRM is DOUBLE PRECISION
265*> The one-norm of the balanced matrix A.
266*> \endverbatim
267*>
268*> \param[out] BBNRM
269*> \verbatim
270*> BBNRM is DOUBLE PRECISION
271*> The one-norm of the balanced matrix B.
272*> \endverbatim
273*>
274*> \param[out] RCONDE
275*> \verbatim
276*> RCONDE is DOUBLE PRECISION array, dimension (N)
277*> If SENSE = 'E' or 'B', the reciprocal condition numbers of
278*> the eigenvalues, stored in consecutive elements of the array.
279*> For a complex conjugate pair of eigenvalues two consecutive
280*> elements of RCONDE are set to the same value. Thus RCONDE(j),
281*> RCONDV(j), and the j-th columns of VL and VR all correspond
282*> to the j-th eigenpair.
283*> If SENSE = 'N or 'V', RCONDE is not referenced.
284*> \endverbatim
285*>
286*> \param[out] RCONDV
287*> \verbatim
288*> RCONDV is DOUBLE PRECISION array, dimension (N)
289*> If SENSE = 'V' or 'B', the estimated reciprocal condition
290*> numbers of the eigenvectors, stored in consecutive elements
291*> of the array. For a complex eigenvector two consecutive
292*> elements of RCONDV are set to the same value. If the
293*> eigenvalues cannot be reordered to compute RCONDV(j),
294*> RCONDV(j) is set to 0; this can only occur when the true
295*> value would be very small anyway.
296*> If SENSE = 'N' or 'E', RCONDV is not referenced.
297*> \endverbatim
298*>
299*> \param[out] WORK
300*> \verbatim
301*> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
302*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
303*> \endverbatim
304*>
305*> \param[in] LWORK
306*> \verbatim
307*> LWORK is INTEGER
308*> The dimension of the array WORK. LWORK >= max(1,2*N).
309*> If BALANC = 'S' or 'B', or JOBVL = 'V', or JOBVR = 'V',
310*> LWORK >= max(1,6*N).
311*> If SENSE = 'E' or 'B', LWORK >= max(1,10*N).
312*> If SENSE = 'V' or 'B', LWORK >= 2*N*N+8*N+16.
313*>
314*> If LWORK = -1, then a workspace query is assumed; the routine
315*> only calculates the optimal size of the WORK array, returns
316*> this value as the first entry of the WORK array, and no error
317*> message related to LWORK is issued by XERBLA.
318*> \endverbatim
319*>
320*> \param[out] IWORK
321*> \verbatim
322*> IWORK is INTEGER array, dimension (N+6)
323*> If SENSE = 'E', IWORK is not referenced.
324*> \endverbatim
325*>
326*> \param[out] BWORK
327*> \verbatim
328*> BWORK is LOGICAL array, dimension (N)
329*> If SENSE = 'N', BWORK is not referenced.
330*> \endverbatim
331*>
332*> \param[out] INFO
333*> \verbatim
334*> INFO is INTEGER
335*> = 0: successful exit
336*> < 0: if INFO = -i, the i-th argument had an illegal value.
337*> = 1,...,N:
338*> The QZ iteration failed. No eigenvectors have been
339*> calculated, but ALPHAR(j), ALPHAI(j), and BETA(j)
340*> should be correct for j=INFO+1,...,N.
341*> > N: =N+1: other than QZ iteration failed in DHGEQZ.
342*> =N+2: error return from DTGEVC.
343*> \endverbatim
344*
345* Authors:
346* ========
347*
348*> \author Univ. of Tennessee
349*> \author Univ. of California Berkeley
350*> \author Univ. of Colorado Denver
351*> \author NAG Ltd.
352*
353*> \ingroup ggevx
354*
355*> \par Further Details:
356* =====================
357*>
358*> \verbatim
359*>
360*> Balancing a matrix pair (A,B) includes, first, permuting rows and
361*> columns to isolate eigenvalues, second, applying diagonal similarity
362*> transformation to the rows and columns to make the rows and columns
363*> as close in norm as possible. The computed reciprocal condition
364*> numbers correspond to the balanced matrix. Permuting rows and columns
365*> will not change the condition numbers (in exact arithmetic) but
366*> diagonal scaling will. For further explanation of balancing, see
367*> section 4.11.1.2 of LAPACK Users' Guide.
368*>
369*> An approximate error bound on the chordal distance between the i-th
370*> computed generalized eigenvalue w and the corresponding exact
371*> eigenvalue lambda is
372*>
373*> chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I)
374*>
375*> An approximate error bound for the angle between the i-th computed
376*> eigenvector VL(i) or VR(i) is given by
377*>
378*> EPS * norm(ABNRM, BBNRM) / DIF(i).
379*>
380*> For further explanation of the reciprocal condition numbers RCONDE
381*> and RCONDV, see section 4.11 of LAPACK User's Guide.
382*> \endverbatim
383*>
384* =====================================================================
385 SUBROUTINE dggevx( BALANC, JOBVL, JOBVR, SENSE, N, A, LDA, B,
386 $ LDB,
387 $ ALPHAR, ALPHAI, BETA, VL, LDVL, VR, LDVR, ILO,
388 $ IHI, LSCALE, RSCALE, ABNRM, BBNRM, RCONDE,
389 $ RCONDV, WORK, LWORK, IWORK, BWORK, INFO )
390*
391* -- LAPACK driver routine --
392* -- LAPACK is a software package provided by Univ. of Tennessee, --
393* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
394*
395* .. Scalar Arguments ..
396 CHARACTER BALANC, JOBVL, JOBVR, SENSE
397 INTEGER IHI, ILO, INFO, LDA, LDB, LDVL, LDVR, LWORK, N
398 DOUBLE PRECISION ABNRM, BBNRM
399* ..
400* .. Array Arguments ..
401 LOGICAL BWORK( * )
402 INTEGER IWORK( * )
403 DOUBLE PRECISION A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
404 $ B( LDB, * ), BETA( * ), LSCALE( * ),
405 $ rconde( * ), rcondv( * ), rscale( * ),
406 $ vl( ldvl, * ), vr( ldvr, * ), work( * )
407* ..
408*
409* =====================================================================
410*
411* .. Parameters ..
412 DOUBLE PRECISION ZERO, ONE
413 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0 )
414* ..
415* .. Local Scalars ..
416 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY, NOSCL,
417 $ pair, wantsb, wantse, wantsn, wantsv
418 CHARACTER CHTEMP
419 INTEGER I, ICOLS, IERR, IJOBVL, IJOBVR, IN, IROWS,
420 $ itau, iwrk, iwrk1, j, jc, jr, m, maxwrk,
421 $ minwrk, mm
422 DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
423 $ smlnum, temp
424* ..
425* .. Local Arrays ..
426 LOGICAL LDUMMA( 1 )
427* ..
428* .. External Subroutines ..
429 EXTERNAL DGEQRF, DGGBAK, DGGBAL, DGGHRD, DHGEQZ,
430 $ dlacpy,
432 $ xerbla
433* ..
434* .. External Functions ..
435 LOGICAL LSAME
436 INTEGER ILAENV
437 DOUBLE PRECISION DLAMCH, DLANGE
438 EXTERNAL LSAME, ILAENV, DLAMCH, DLANGE
439* ..
440* .. Intrinsic Functions ..
441 INTRINSIC abs, max, sqrt
442* ..
443* .. Executable Statements ..
444*
445* Decode the input arguments
446*
447 IF( lsame( jobvl, 'N' ) ) THEN
448 ijobvl = 1
449 ilvl = .false.
450 ELSE IF( lsame( jobvl, 'V' ) ) THEN
451 ijobvl = 2
452 ilvl = .true.
453 ELSE
454 ijobvl = -1
455 ilvl = .false.
456 END IF
457*
458 IF( lsame( jobvr, 'N' ) ) THEN
459 ijobvr = 1
460 ilvr = .false.
461 ELSE IF( lsame( jobvr, 'V' ) ) THEN
462 ijobvr = 2
463 ilvr = .true.
464 ELSE
465 ijobvr = -1
466 ilvr = .false.
467 END IF
468 ilv = ilvl .OR. ilvr
469*
470 noscl = lsame( balanc, 'N' ) .OR. lsame( balanc, 'P' )
471 wantsn = lsame( sense, 'N' )
472 wantse = lsame( sense, 'E' )
473 wantsv = lsame( sense, 'V' )
474 wantsb = lsame( sense, 'B' )
475*
476* Test the input arguments
477*
478 info = 0
479 lquery = ( lwork.EQ.-1 )
480 IF( .NOT.( lsame( balanc, 'N' ) .OR. lsame( balanc,
481 $ 'S' ) .OR.
482 $ lsame( balanc, 'P' ) .OR.
483 $ lsame( balanc, 'B' ) ) )
484 $ THEN
485 info = -1
486 ELSE IF( ijobvl.LE.0 ) THEN
487 info = -2
488 ELSE IF( ijobvr.LE.0 ) THEN
489 info = -3
490 ELSE IF( .NOT.( wantsn .OR. wantse .OR. wantsb .OR. wantsv ) )
491 $ THEN
492 info = -4
493 ELSE IF( n.LT.0 ) THEN
494 info = -5
495 ELSE IF( lda.LT.max( 1, n ) ) THEN
496 info = -7
497 ELSE IF( ldb.LT.max( 1, n ) ) THEN
498 info = -9
499 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) ) THEN
500 info = -14
501 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) ) THEN
502 info = -16
503 END IF
504*
505* Compute workspace
506* (Note: Comments in the code beginning "Workspace:" describe the
507* minimal amount of workspace needed at that point in the code,
508* as well as the preferred amount for good performance.
509* NB refers to the optimal block size for the immediately
510* following subroutine, as returned by ILAENV. The workspace is
511* computed assuming ILO = 1 and IHI = N, the worst case.)
512*
513 IF( info.EQ.0 ) THEN
514 IF( n.EQ.0 ) THEN
515 minwrk = 1
516 maxwrk = 1
517 ELSE
518 IF( noscl .AND. .NOT.ilv ) THEN
519 minwrk = 2*n
520 ELSE
521 minwrk = 6*n
522 END IF
523 IF( wantse .OR. wantsb ) THEN
524 minwrk = 10*n
525 END IF
526 IF( wantsv .OR. wantsb ) THEN
527 minwrk = max( minwrk, 2*n*( n + 4 ) + 16 )
528 END IF
529 maxwrk = minwrk
530 maxwrk = max( maxwrk,
531 $ n + n*ilaenv( 1, 'DGEQRF', ' ', n, 1, n,
532 $ 0 ) )
533 maxwrk = max( maxwrk,
534 $ n + n*ilaenv( 1, 'DORMQR', ' ', n, 1, n,
535 $ 0 ) )
536 IF( ilvl ) THEN
537 maxwrk = max( maxwrk, n +
538 $ n*ilaenv( 1, 'DORGQR', ' ', n, 1, n,
539 $ 0 ) )
540 END IF
541 END IF
542 work( 1 ) = maxwrk
543*
544 IF( lwork.LT.minwrk .AND. .NOT.lquery ) THEN
545 info = -26
546 END IF
547 END IF
548*
549 IF( info.NE.0 ) THEN
550 CALL xerbla( 'DGGEVX', -info )
551 RETURN
552 ELSE IF( lquery ) THEN
553 RETURN
554 END IF
555*
556* Quick return if possible
557*
558 IF( n.EQ.0 )
559 $ RETURN
560*
561*
562* Get machine constants
563*
564 eps = dlamch( 'P' )
565 smlnum = dlamch( 'S' )
566 bignum = one / smlnum
567 smlnum = sqrt( smlnum ) / eps
568 bignum = one / smlnum
569*
570* Scale A if max element outside range [SMLNUM,BIGNUM]
571*
572 anrm = dlange( 'M', n, n, a, lda, work )
573 ilascl = .false.
574 IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
575 anrmto = smlnum
576 ilascl = .true.
577 ELSE IF( anrm.GT.bignum ) THEN
578 anrmto = bignum
579 ilascl = .true.
580 END IF
581 IF( ilascl )
582 $ CALL dlascl( 'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
583*
584* Scale B if max element outside range [SMLNUM,BIGNUM]
585*
586 bnrm = dlange( 'M', n, n, b, ldb, work )
587 ilbscl = .false.
588 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum ) THEN
589 bnrmto = smlnum
590 ilbscl = .true.
591 ELSE IF( bnrm.GT.bignum ) THEN
592 bnrmto = bignum
593 ilbscl = .true.
594 END IF
595 IF( ilbscl )
596 $ CALL dlascl( 'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
597*
598* Permute and/or balance the matrix pair (A,B)
599* (Workspace: need 6*N if BALANC = 'S' or 'B', 1 otherwise)
600*
601 CALL dggbal( balanc, n, a, lda, b, ldb, ilo, ihi, lscale,
602 $ rscale,
603 $ work, ierr )
604*
605* Compute ABNRM and BBNRM
606*
607 abnrm = dlange( '1', n, n, a, lda, work( 1 ) )
608 IF( ilascl ) THEN
609 work( 1 ) = abnrm
610 CALL dlascl( 'G', 0, 0, anrmto, anrm, 1, 1, work( 1 ), 1,
611 $ ierr )
612 abnrm = work( 1 )
613 END IF
614*
615 bbnrm = dlange( '1', n, n, b, ldb, work( 1 ) )
616 IF( ilbscl ) THEN
617 work( 1 ) = bbnrm
618 CALL dlascl( 'G', 0, 0, bnrmto, bnrm, 1, 1, work( 1 ), 1,
619 $ ierr )
620 bbnrm = work( 1 )
621 END IF
622*
623* Reduce B to triangular form (QR decomposition of B)
624* (Workspace: need N, prefer N*NB )
625*
626 irows = ihi + 1 - ilo
627 IF( ilv .OR. .NOT.wantsn ) THEN
628 icols = n + 1 - ilo
629 ELSE
630 icols = irows
631 END IF
632 itau = 1
633 iwrk = itau + irows
634 CALL dgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
635 $ work( iwrk ), lwork+1-iwrk, ierr )
636*
637* Apply the orthogonal transformation to A
638* (Workspace: need N, prefer N*NB)
639*
640 CALL dormqr( 'L', 'T', irows, icols, irows, b( ilo, ilo ), ldb,
641 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
642 $ lwork+1-iwrk, ierr )
643*
644* Initialize VL and/or VR
645* (Workspace: need N, prefer N*NB)
646*
647 IF( ilvl ) THEN
648 CALL dlaset( 'Full', n, n, zero, one, vl, ldvl )
649 IF( irows.GT.1 ) THEN
650 CALL dlacpy( 'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
651 $ vl( ilo+1, ilo ), ldvl )
652 END IF
653 CALL dorgqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
654 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
655 END IF
656*
657 IF( ilvr )
658 $ CALL dlaset( 'Full', n, n, zero, one, vr, ldvr )
659*
660* Reduce to generalized Hessenberg form
661* (Workspace: none needed)
662*
663 IF( ilv .OR. .NOT.wantsn ) THEN
664*
665* Eigenvectors requested -- work on whole matrix.
666*
667 CALL dgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
668 $ ldvl, vr, ldvr, ierr )
669 ELSE
670 CALL dgghrd( 'N', 'N', irows, 1, irows, a( ilo, ilo ), lda,
671 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, ierr )
672 END IF
673*
674* Perform QZ algorithm (Compute eigenvalues, and optionally, the
675* Schur forms and Schur vectors)
676* (Workspace: need N)
677*
678 IF( ilv .OR. .NOT.wantsn ) THEN
679 chtemp = 'S'
680 ELSE
681 chtemp = 'E'
682 END IF
683*
684 CALL dhgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
685 $ alphar, alphai, beta, vl, ldvl, vr, ldvr, work,
686 $ lwork, ierr )
687 IF( ierr.NE.0 ) THEN
688 IF( ierr.GT.0 .AND. ierr.LE.n ) THEN
689 info = ierr
690 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n ) THEN
691 info = ierr - n
692 ELSE
693 info = n + 1
694 END IF
695 GO TO 130
696 END IF
697*
698* Compute Eigenvectors and estimate condition numbers if desired
699* (Workspace: DTGEVC: need 6*N
700* DTGSNA: need 2*N*(N+2)+16 if SENSE = 'V' or 'B',
701* need N otherwise )
702*
703 IF( ilv .OR. .NOT.wantsn ) THEN
704 IF( ilv ) THEN
705 IF( ilvl ) THEN
706 IF( ilvr ) THEN
707 chtemp = 'B'
708 ELSE
709 chtemp = 'L'
710 END IF
711 ELSE
712 chtemp = 'R'
713 END IF
714*
715 CALL dtgevc( chtemp, 'B', ldumma, n, a, lda, b, ldb, vl,
716 $ ldvl, vr, ldvr, n, in, work, ierr )
717 IF( ierr.NE.0 ) THEN
718 info = n + 2
719 GO TO 130
720 END IF
721 END IF
722*
723 IF( .NOT.wantsn ) THEN
724*
725* compute eigenvectors (DTGEVC) and estimate condition
726* numbers (DTGSNA). Note that the definition of the condition
727* number is not invariant under transformation (u,v) to
728* (Q*u, Z*v), where (u,v) are eigenvectors of the generalized
729* Schur form (S,T), Q and Z are orthogonal matrices. In order
730* to avoid using extra 2*N*N workspace, we have to recalculate
731* eigenvectors and estimate one condition numbers at a time.
732*
733 pair = .false.
734 DO 20 i = 1, n
735*
736 IF( pair ) THEN
737 pair = .false.
738 GO TO 20
739 END IF
740 mm = 1
741 IF( i.LT.n ) THEN
742 IF( a( i+1, i ).NE.zero ) THEN
743 pair = .true.
744 mm = 2
745 END IF
746 END IF
747*
748 DO 10 j = 1, n
749 bwork( j ) = .false.
750 10 CONTINUE
751 IF( mm.EQ.1 ) THEN
752 bwork( i ) = .true.
753 ELSE IF( mm.EQ.2 ) THEN
754 bwork( i ) = .true.
755 bwork( i+1 ) = .true.
756 END IF
757*
758 iwrk = mm*n + 1
759 iwrk1 = iwrk + mm*n
760*
761* Compute a pair of left and right eigenvectors.
762* (compute workspace: need up to 4*N + 6*N)
763*
764 IF( wantse .OR. wantsb ) THEN
765 CALL dtgevc( 'B', 'S', bwork, n, a, lda, b, ldb,
766 $ work( 1 ), n, work( iwrk ), n, mm, m,
767 $ work( iwrk1 ), ierr )
768 IF( ierr.NE.0 ) THEN
769 info = n + 2
770 GO TO 130
771 END IF
772 END IF
773*
774 CALL dtgsna( sense, 'S', bwork, n, a, lda, b, ldb,
775 $ work( 1 ), n, work( iwrk ), n, rconde( i ),
776 $ rcondv( i ), mm, m, work( iwrk1 ),
777 $ lwork-iwrk1+1, iwork, ierr )
778*
779 20 CONTINUE
780 END IF
781 END IF
782*
783* Undo balancing on VL and VR and normalization
784* (Workspace: none needed)
785*
786 IF( ilvl ) THEN
787 CALL dggbak( balanc, 'L', n, ilo, ihi, lscale, rscale, n,
788 $ vl,
789 $ ldvl, ierr )
790*
791 DO 70 jc = 1, n
792 IF( alphai( jc ).LT.zero )
793 $ GO TO 70
794 temp = zero
795 IF( alphai( jc ).EQ.zero ) THEN
796 DO 30 jr = 1, n
797 temp = max( temp, abs( vl( jr, jc ) ) )
798 30 CONTINUE
799 ELSE
800 DO 40 jr = 1, n
801 temp = max( temp, abs( vl( jr, jc ) )+
802 $ abs( vl( jr, jc+1 ) ) )
803 40 CONTINUE
804 END IF
805 IF( temp.LT.smlnum )
806 $ GO TO 70
807 temp = one / temp
808 IF( alphai( jc ).EQ.zero ) THEN
809 DO 50 jr = 1, n
810 vl( jr, jc ) = vl( jr, jc )*temp
811 50 CONTINUE
812 ELSE
813 DO 60 jr = 1, n
814 vl( jr, jc ) = vl( jr, jc )*temp
815 vl( jr, jc+1 ) = vl( jr, jc+1 )*temp
816 60 CONTINUE
817 END IF
818 70 CONTINUE
819 END IF
820 IF( ilvr ) THEN
821 CALL dggbak( balanc, 'R', n, ilo, ihi, lscale, rscale, n,
822 $ vr,
823 $ ldvr, ierr )
824 DO 120 jc = 1, n
825 IF( alphai( jc ).LT.zero )
826 $ GO TO 120
827 temp = zero
828 IF( alphai( jc ).EQ.zero ) THEN
829 DO 80 jr = 1, n
830 temp = max( temp, abs( vr( jr, jc ) ) )
831 80 CONTINUE
832 ELSE
833 DO 90 jr = 1, n
834 temp = max( temp, abs( vr( jr, jc ) )+
835 $ abs( vr( jr, jc+1 ) ) )
836 90 CONTINUE
837 END IF
838 IF( temp.LT.smlnum )
839 $ GO TO 120
840 temp = one / temp
841 IF( alphai( jc ).EQ.zero ) THEN
842 DO 100 jr = 1, n
843 vr( jr, jc ) = vr( jr, jc )*temp
844 100 CONTINUE
845 ELSE
846 DO 110 jr = 1, n
847 vr( jr, jc ) = vr( jr, jc )*temp
848 vr( jr, jc+1 ) = vr( jr, jc+1 )*temp
849 110 CONTINUE
850 END IF
851 120 CONTINUE
852 END IF
853*
854* Undo scaling if necessary
855*
856 130 CONTINUE
857*
858 IF( ilascl ) THEN
859 CALL dlascl( 'G', 0, 0, anrmto, anrm, n, 1, alphar, n,
860 $ ierr )
861 CALL dlascl( 'G', 0, 0, anrmto, anrm, n, 1, alphai, n,
862 $ ierr )
863 END IF
864*
865 IF( ilbscl ) THEN
866 CALL dlascl( 'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
867 END IF
868*
869 work( 1 ) = maxwrk
870 RETURN
871*
872* End of DGGEVX
873*
874 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dggevx(balanc, jobvl, jobvr, sense, n, a, lda, b, ldb, alphar, alphai, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work, lwork, iwork, bwork, info)
DGGEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices
Definition dggevx.f:390
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
Definition dlacpy.f:101
subroutine dlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
DLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition dlascl.f:142
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition dlaset.f:108
subroutine dtgevc(side, howmny, select, n, s, lds, p, ldp, vl, ldvl, vr, ldvr, mm, m, work, info)
DTGEVC
Definition dtgevc.f:293
subroutine dtgsna(job, howmny, select, n, a, lda, b, ldb, vl, ldvl, vr, ldvr, s, dif, mm, m, work, lwork, iwork, info)
DTGSNA
Definition dtgsna.f:379
subroutine dorgqr(m, n, k, a, lda, tau, work, lwork, info)
DORGQR
Definition dorgqr.f:126
subroutine dormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
DORMQR
Definition dormqr.f:165