LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
sgegv.f
Go to the documentation of this file.
1*> \brief <b> SGEGV computes the eigenvalues and, optionally, the left and/or right eigenvectors of a real matrix pair (A,B).</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SGEGV + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgegv.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgegv.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgegv.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SGEGV( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR, ALPHAI,
20* BETA, VL, LDVL, VR, LDVR, WORK, LWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER JOBVL, JOBVR
24* INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
25* ..
26* .. Array Arguments ..
27* REAL A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
28* $ B( LDB, * ), BETA( * ), VL( LDVL, * ),
29* $ VR( LDVR, * ), WORK( * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> This routine is deprecated and has been replaced by routine SGGEV.
39*>
40*> SGEGV computes the eigenvalues and, optionally, the left and/or right
41*> eigenvectors of a real matrix pair (A,B).
42*> Given two square matrices A and B,
43*> the generalized nonsymmetric eigenvalue problem (GNEP) is to find the
44*> eigenvalues lambda and corresponding (non-zero) eigenvectors x such
45*> that
46*>
47*> A*x = lambda*B*x.
48*>
49*> An alternate form is to find the eigenvalues mu and corresponding
50*> eigenvectors y such that
51*>
52*> mu*A*y = B*y.
53*>
54*> These two forms are equivalent with mu = 1/lambda and x = y if
55*> neither lambda nor mu is zero. In order to deal with the case that
56*> lambda or mu is zero or small, two values alpha and beta are returned
57*> for each eigenvalue, such that lambda = alpha/beta and
58*> mu = beta/alpha.
59*>
60*> The vectors x and y in the above equations are right eigenvectors of
61*> the matrix pair (A,B). Vectors u and v satisfying
62*>
63*> u**H*A = lambda*u**H*B or mu*v**H*A = v**H*B
64*>
65*> are left eigenvectors of (A,B).
66*>
67*> Note: this routine performs "full balancing" on A and B
68*> \endverbatim
69*
70* Arguments:
71* ==========
72*
73*> \param[in] JOBVL
74*> \verbatim
75*> JOBVL is CHARACTER*1
76*> = 'N': do not compute the left generalized eigenvectors;
77*> = 'V': compute the left generalized eigenvectors (returned
78*> in VL).
79*> \endverbatim
80*>
81*> \param[in] JOBVR
82*> \verbatim
83*> JOBVR is CHARACTER*1
84*> = 'N': do not compute the right generalized eigenvectors;
85*> = 'V': compute the right generalized eigenvectors (returned
86*> in VR).
87*> \endverbatim
88*>
89*> \param[in] N
90*> \verbatim
91*> N is INTEGER
92*> The order of the matrices A, B, VL, and VR. N >= 0.
93*> \endverbatim
94*>
95*> \param[in,out] A
96*> \verbatim
97*> A is REAL array, dimension (LDA, N)
98*> On entry, the matrix A.
99*> If JOBVL = 'V' or JOBVR = 'V', then on exit A
100*> contains the real Schur form of A from the generalized Schur
101*> factorization of the pair (A,B) after balancing.
102*> If no eigenvectors were computed, then only the diagonal
103*> blocks from the Schur form will be correct. See SGGHRD and
104*> SHGEQZ for details.
105*> \endverbatim
106*>
107*> \param[in] LDA
108*> \verbatim
109*> LDA is INTEGER
110*> The leading dimension of A. LDA >= max(1,N).
111*> \endverbatim
112*>
113*> \param[in,out] B
114*> \verbatim
115*> B is REAL array, dimension (LDB, N)
116*> On entry, the matrix B.
117*> If JOBVL = 'V' or JOBVR = 'V', then on exit B contains the
118*> upper triangular matrix obtained from B in the generalized
119*> Schur factorization of the pair (A,B) after balancing.
120*> If no eigenvectors were computed, then only those elements of
121*> B corresponding to the diagonal blocks from the Schur form of
122*> A will be correct. See SGGHRD and SHGEQZ for details.
123*> \endverbatim
124*>
125*> \param[in] LDB
126*> \verbatim
127*> LDB is INTEGER
128*> The leading dimension of B. LDB >= max(1,N).
129*> \endverbatim
130*>
131*> \param[out] ALPHAR
132*> \verbatim
133*> ALPHAR is REAL array, dimension (N)
134*> The real parts of each scalar alpha defining an eigenvalue of
135*> GNEP.
136*> \endverbatim
137*>
138*> \param[out] ALPHAI
139*> \verbatim
140*> ALPHAI is REAL array, dimension (N)
141*> The imaginary parts of each scalar alpha defining an
142*> eigenvalue of GNEP. If ALPHAI(j) is zero, then the j-th
143*> eigenvalue is real; if positive, then the j-th and
144*> (j+1)-st eigenvalues are a complex conjugate pair, with
145*> ALPHAI(j+1) = -ALPHAI(j).
146*> \endverbatim
147*>
148*> \param[out] BETA
149*> \verbatim
150*> BETA is REAL array, dimension (N)
151*> The scalars beta that define the eigenvalues of GNEP.
152*>
153*> Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
154*> beta = BETA(j) represent the j-th eigenvalue of the matrix
155*> pair (A,B), in one of the forms lambda = alpha/beta or
156*> mu = beta/alpha. Since either lambda or mu may overflow,
157*> they should not, in general, be computed.
158*> \endverbatim
159*>
160*> \param[out] VL
161*> \verbatim
162*> VL is REAL array, dimension (LDVL,N)
163*> If JOBVL = 'V', the left eigenvectors u(j) are stored
164*> in the columns of VL, in the same order as their eigenvalues.
165*> If the j-th eigenvalue is real, then u(j) = VL(:,j).
166*> If the j-th and (j+1)-st eigenvalues form a complex conjugate
167*> pair, then
168*> u(j) = VL(:,j) + i*VL(:,j+1)
169*> and
170*> u(j+1) = VL(:,j) - i*VL(:,j+1).
171*>
172*> Each eigenvector is scaled so that its largest component has
173*> abs(real part) + abs(imag. part) = 1, except for eigenvectors
174*> corresponding to an eigenvalue with alpha = beta = 0, which
175*> are set to zero.
176*> Not referenced if JOBVL = 'N'.
177*> \endverbatim
178*>
179*> \param[in] LDVL
180*> \verbatim
181*> LDVL is INTEGER
182*> The leading dimension of the matrix VL. LDVL >= 1, and
183*> if JOBVL = 'V', LDVL >= N.
184*> \endverbatim
185*>
186*> \param[out] VR
187*> \verbatim
188*> VR is REAL array, dimension (LDVR,N)
189*> If JOBVR = 'V', the right eigenvectors x(j) are stored
190*> in the columns of VR, in the same order as their eigenvalues.
191*> If the j-th eigenvalue is real, then x(j) = VR(:,j).
192*> If the j-th and (j+1)-st eigenvalues form a complex conjugate
193*> pair, then
194*> x(j) = VR(:,j) + i*VR(:,j+1)
195*> and
196*> x(j+1) = VR(:,j) - i*VR(:,j+1).
197*>
198*> Each eigenvector is scaled so that its largest component has
199*> abs(real part) + abs(imag. part) = 1, except for eigenvalues
200*> corresponding to an eigenvalue with alpha = beta = 0, which
201*> are set to zero.
202*> Not referenced if JOBVR = 'N'.
203*> \endverbatim
204*>
205*> \param[in] LDVR
206*> \verbatim
207*> LDVR is INTEGER
208*> The leading dimension of the matrix VR. LDVR >= 1, and
209*> if JOBVR = 'V', LDVR >= N.
210*> \endverbatim
211*>
212*> \param[out] WORK
213*> \verbatim
214*> WORK is REAL array, dimension (MAX(1,LWORK))
215*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
216*> \endverbatim
217*>
218*> \param[in] LWORK
219*> \verbatim
220*> LWORK is INTEGER
221*> The dimension of the array WORK. LWORK >= max(1,8*N).
222*> For good performance, LWORK must generally be larger.
223*> To compute the optimal value of LWORK, call ILAENV to get
224*> blocksizes (for SGEQRF, SORMQR, and SORGQR.) Then compute:
225*> NB -- MAX of the blocksizes for SGEQRF, SORMQR, and SORGQR;
226*> The optimal LWORK is:
227*> 2*N + MAX( 6*N, N*(NB+1) ).
228*>
229*> If LWORK = -1, then a workspace query is assumed; the routine
230*> only calculates the optimal size of the WORK array, returns
231*> this value as the first entry of the WORK array, and no error
232*> message related to LWORK is issued by XERBLA.
233*> \endverbatim
234*>
235*> \param[out] INFO
236*> \verbatim
237*> INFO is INTEGER
238*> = 0: successful exit
239*> < 0: if INFO = -i, the i-th argument had an illegal value.
240*> = 1,...,N:
241*> The QZ iteration failed. No eigenvectors have been
242*> calculated, but ALPHAR(j), ALPHAI(j), and BETA(j)
243*> should be correct for j=INFO+1,...,N.
244*> > N: errors that usually indicate LAPACK problems:
245*> =N+1: error return from SGGBAL
246*> =N+2: error return from SGEQRF
247*> =N+3: error return from SORMQR
248*> =N+4: error return from SORGQR
249*> =N+5: error return from SGGHRD
250*> =N+6: error return from SHGEQZ (other than failed
251*> iteration)
252*> =N+7: error return from STGEVC
253*> =N+8: error return from SGGBAK (computing VL)
254*> =N+9: error return from SGGBAK (computing VR)
255*> =N+10: error return from SLASCL (various calls)
256*> \endverbatim
257*
258* Authors:
259* ========
260*
261*> \author Univ. of Tennessee
262*> \author Univ. of California Berkeley
263*> \author Univ. of Colorado Denver
264*> \author NAG Ltd.
265*
266*> \ingroup realGEeigen
267*
268*> \par Further Details:
269* =====================
270*>
271*> \verbatim
272*>
273*> Balancing
274*> ---------
275*>
276*> This driver calls SGGBAL to both permute and scale rows and columns
277*> of A and B. The permutations PL and PR are chosen so that PL*A*PR
278*> and PL*B*R will be upper triangular except for the diagonal blocks
279*> A(i:j,i:j) and B(i:j,i:j), with i and j as close together as
280*> possible. The diagonal scaling matrices DL and DR are chosen so
281*> that the pair DL*PL*A*PR*DR, DL*PL*B*PR*DR have elements close to
282*> one (except for the elements that start out zero.)
283*>
284*> After the eigenvalues and eigenvectors of the balanced matrices
285*> have been computed, SGGBAK transforms the eigenvectors back to what
286*> they would have been (in perfect arithmetic) if they had not been
287*> balanced.
288*>
289*> Contents of A and B on Exit
290*> -------- -- - --- - -- ----
291*>
292*> If any eigenvectors are computed (either JOBVL='V' or JOBVR='V' or
293*> both), then on exit the arrays A and B will contain the real Schur
294*> form[*] of the "balanced" versions of A and B. If no eigenvectors
295*> are computed, then only the diagonal blocks will be correct.
296*>
297*> [*] See SHGEQZ, SGEGS, or read the book "Matrix Computations",
298*> by Golub & van Loan, pub. by Johns Hopkins U. Press.
299*> \endverbatim
300*>
301* =====================================================================
302 SUBROUTINE sgegv( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR,
303 $ ALPHAI, BETA, VL, LDVL, VR, LDVR, WORK, LWORK,
304 $ INFO )
305*
306* -- LAPACK driver routine --
307* -- LAPACK is a software package provided by Univ. of Tennessee, --
308* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
309*
310* .. Scalar Arguments ..
311 CHARACTER JOBVL, JOBVR
312 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
313* ..
314* .. Array Arguments ..
315 REAL A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
316 $ B( LDB, * ), BETA( * ), VL( LDVL, * ),
317 $ vr( ldvr, * ), work( * )
318* ..
319*
320* =====================================================================
321*
322* .. Parameters ..
323 REAL ZERO, ONE
324 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
325* ..
326* .. Local Scalars ..
327 LOGICAL ILIMIT, ILV, ILVL, ILVR, LQUERY
328 CHARACTER CHTEMP
329 INTEGER ICOLS, IHI, IINFO, IJOBVL, IJOBVR, ILEFT, ILO,
330 $ in, iright, irows, itau, iwork, jc, jr, lopt,
331 $ lwkmin, lwkopt, nb, nb1, nb2, nb3
332 REAL ABSAI, ABSAR, ABSB, ANRM, ANRM1, ANRM2, BNRM,
333 $ BNRM1, BNRM2, EPS, ONEPLS, SAFMAX, SAFMIN,
334 $ salfai, salfar, sbeta, scale, temp
335* ..
336* .. Local Arrays ..
337 LOGICAL LDUMMA( 1 )
338* ..
339* .. External Subroutines ..
340 EXTERNAL sgeqrf, sggbak, sggbal, sgghrd, shgeqz, slacpy,
342* ..
343* .. External Functions ..
344 LOGICAL LSAME
345 INTEGER ILAENV
346 REAL SLAMCH, SLANGE
347 EXTERNAL ilaenv, lsame, slamch, slange
348* ..
349* .. Intrinsic Functions ..
350 INTRINSIC abs, int, max
351* ..
352* .. Executable Statements ..
353*
354* Decode the input arguments
355*
356 IF( lsame( jobvl, 'N' ) ) THEN
357 ijobvl = 1
358 ilvl = .false.
359 ELSE IF( lsame( jobvl, 'V' ) ) THEN
360 ijobvl = 2
361 ilvl = .true.
362 ELSE
363 ijobvl = -1
364 ilvl = .false.
365 END IF
366*
367 IF( lsame( jobvr, 'N' ) ) THEN
368 ijobvr = 1
369 ilvr = .false.
370 ELSE IF( lsame( jobvr, 'V' ) ) THEN
371 ijobvr = 2
372 ilvr = .true.
373 ELSE
374 ijobvr = -1
375 ilvr = .false.
376 END IF
377 ilv = ilvl .OR. ilvr
378*
379* Test the input arguments
380*
381 lwkmin = max( 8*n, 1 )
382 lwkopt = lwkmin
383 work( 1 ) = lwkopt
384 lquery = ( lwork.EQ.-1 )
385 info = 0
386 IF( ijobvl.LE.0 ) THEN
387 info = -1
388 ELSE IF( ijobvr.LE.0 ) THEN
389 info = -2
390 ELSE IF( n.LT.0 ) THEN
391 info = -3
392 ELSE IF( lda.LT.max( 1, n ) ) THEN
393 info = -5
394 ELSE IF( ldb.LT.max( 1, n ) ) THEN
395 info = -7
396 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) ) THEN
397 info = -12
398 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) ) THEN
399 info = -14
400 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery ) THEN
401 info = -16
402 END IF
403*
404 IF( info.EQ.0 ) THEN
405 nb1 = ilaenv( 1, 'SGEQRF', ' ', n, n, -1, -1 )
406 nb2 = ilaenv( 1, 'SORMQR', ' ', n, n, n, -1 )
407 nb3 = ilaenv( 1, 'SORGQR', ' ', n, n, n, -1 )
408 nb = max( nb1, nb2, nb3 )
409 lopt = 2*n + max( 6*n, n*(nb+1) )
410 work( 1 ) = lopt
411 END IF
412*
413 IF( info.NE.0 ) THEN
414 CALL xerbla( 'SGEGV ', -info )
415 RETURN
416 ELSE IF( lquery ) THEN
417 RETURN
418 END IF
419*
420* Quick return if possible
421*
422 IF( n.EQ.0 )
423 $ RETURN
424*
425* Get machine constants
426*
427 eps = slamch( 'E' )*slamch( 'B' )
428 safmin = slamch( 'S' )
429 safmin = safmin + safmin
430 safmax = one / safmin
431 onepls = one + ( 4*eps )
432*
433* Scale A
434*
435 anrm = slange( 'M', n, n, a, lda, work )
436 anrm1 = anrm
437 anrm2 = one
438 IF( anrm.LT.one ) THEN
439 IF( safmax*anrm.LT.one ) THEN
440 anrm1 = safmin
441 anrm2 = safmax*anrm
442 END IF
443 END IF
444*
445 IF( anrm.GT.zero ) THEN
446 CALL slascl( 'G', -1, -1, anrm, one, n, n, a, lda, iinfo )
447 IF( iinfo.NE.0 ) THEN
448 info = n + 10
449 RETURN
450 END IF
451 END IF
452*
453* Scale B
454*
455 bnrm = slange( 'M', n, n, b, ldb, work )
456 bnrm1 = bnrm
457 bnrm2 = one
458 IF( bnrm.LT.one ) THEN
459 IF( safmax*bnrm.LT.one ) THEN
460 bnrm1 = safmin
461 bnrm2 = safmax*bnrm
462 END IF
463 END IF
464*
465 IF( bnrm.GT.zero ) THEN
466 CALL slascl( 'G', -1, -1, bnrm, one, n, n, b, ldb, iinfo )
467 IF( iinfo.NE.0 ) THEN
468 info = n + 10
469 RETURN
470 END IF
471 END IF
472*
473* Permute the matrix to make it more nearly triangular
474* Workspace layout: (8*N words -- "work" requires 6*N words)
475* left_permutation, right_permutation, work...
476*
477 ileft = 1
478 iright = n + 1
479 iwork = iright + n
480 CALL sggbal( 'P', n, a, lda, b, ldb, ilo, ihi, work( ileft ),
481 $ work( iright ), work( iwork ), iinfo )
482 IF( iinfo.NE.0 ) THEN
483 info = n + 1
484 GO TO 120
485 END IF
486*
487* Reduce B to triangular form, and initialize VL and/or VR
488* Workspace layout: ("work..." must have at least N words)
489* left_permutation, right_permutation, tau, work...
490*
491 irows = ihi + 1 - ilo
492 IF( ilv ) THEN
493 icols = n + 1 - ilo
494 ELSE
495 icols = irows
496 END IF
497 itau = iwork
498 iwork = itau + irows
499 CALL sgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
500 $ work( iwork ), lwork+1-iwork, iinfo )
501 IF( iinfo.GE.0 )
502 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
503 IF( iinfo.NE.0 ) THEN
504 info = n + 2
505 GO TO 120
506 END IF
507*
508 CALL sormqr( 'L', 'T', irows, icols, irows, b( ilo, ilo ), ldb,
509 $ work( itau ), a( ilo, ilo ), lda, work( iwork ),
510 $ lwork+1-iwork, iinfo )
511 IF( iinfo.GE.0 )
512 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
513 IF( iinfo.NE.0 ) THEN
514 info = n + 3
515 GO TO 120
516 END IF
517*
518 IF( ilvl ) THEN
519 CALL slaset( 'Full', n, n, zero, one, vl, ldvl )
520 CALL slacpy( 'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
521 $ vl( ilo+1, ilo ), ldvl )
522 CALL sorgqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
523 $ work( itau ), work( iwork ), lwork+1-iwork,
524 $ iinfo )
525 IF( iinfo.GE.0 )
526 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
527 IF( iinfo.NE.0 ) THEN
528 info = n + 4
529 GO TO 120
530 END IF
531 END IF
532*
533 IF( ilvr )
534 $ CALL slaset( 'Full', n, n, zero, one, vr, ldvr )
535*
536* Reduce to generalized Hessenberg form
537*
538 IF( ilv ) THEN
539*
540* Eigenvectors requested -- work on whole matrix.
541*
542 CALL sgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
543 $ ldvl, vr, ldvr, iinfo )
544 ELSE
545 CALL sgghrd( 'N', 'N', irows, 1, irows, a( ilo, ilo ), lda,
546 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, iinfo )
547 END IF
548 IF( iinfo.NE.0 ) THEN
549 info = n + 5
550 GO TO 120
551 END IF
552*
553* Perform QZ algorithm
554* Workspace layout: ("work..." must have at least 1 word)
555* left_permutation, right_permutation, work...
556*
557 iwork = itau
558 IF( ilv ) THEN
559 chtemp = 'S'
560 ELSE
561 chtemp = 'E'
562 END IF
563 CALL shgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
564 $ alphar, alphai, beta, vl, ldvl, vr, ldvr,
565 $ work( iwork ), lwork+1-iwork, iinfo )
566 IF( iinfo.GE.0 )
567 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
568 IF( iinfo.NE.0 ) THEN
569 IF( iinfo.GT.0 .AND. iinfo.LE.n ) THEN
570 info = iinfo
571 ELSE IF( iinfo.GT.n .AND. iinfo.LE.2*n ) THEN
572 info = iinfo - n
573 ELSE
574 info = n + 6
575 END IF
576 GO TO 120
577 END IF
578*
579 IF( ilv ) THEN
580*
581* Compute Eigenvectors (STGEVC requires 6*N words of workspace)
582*
583 IF( ilvl ) THEN
584 IF( ilvr ) THEN
585 chtemp = 'B'
586 ELSE
587 chtemp = 'L'
588 END IF
589 ELSE
590 chtemp = 'R'
591 END IF
592*
593 CALL stgevc( chtemp, 'B', ldumma, n, a, lda, b, ldb, vl, ldvl,
594 $ vr, ldvr, n, in, work( iwork ), iinfo )
595 IF( iinfo.NE.0 ) THEN
596 info = n + 7
597 GO TO 120
598 END IF
599*
600* Undo balancing on VL and VR, rescale
601*
602 IF( ilvl ) THEN
603 CALL sggbak( 'P', 'L', n, ilo, ihi, work( ileft ),
604 $ work( iright ), n, vl, ldvl, iinfo )
605 IF( iinfo.NE.0 ) THEN
606 info = n + 8
607 GO TO 120
608 END IF
609 DO 50 jc = 1, n
610 IF( alphai( jc ).LT.zero )
611 $ GO TO 50
612 temp = zero
613 IF( alphai( jc ).EQ.zero ) THEN
614 DO 10 jr = 1, n
615 temp = max( temp, abs( vl( jr, jc ) ) )
616 10 CONTINUE
617 ELSE
618 DO 20 jr = 1, n
619 temp = max( temp, abs( vl( jr, jc ) )+
620 $ abs( vl( jr, jc+1 ) ) )
621 20 CONTINUE
622 END IF
623 IF( temp.LT.safmin )
624 $ GO TO 50
625 temp = one / temp
626 IF( alphai( jc ).EQ.zero ) THEN
627 DO 30 jr = 1, n
628 vl( jr, jc ) = vl( jr, jc )*temp
629 30 CONTINUE
630 ELSE
631 DO 40 jr = 1, n
632 vl( jr, jc ) = vl( jr, jc )*temp
633 vl( jr, jc+1 ) = vl( jr, jc+1 )*temp
634 40 CONTINUE
635 END IF
636 50 CONTINUE
637 END IF
638 IF( ilvr ) THEN
639 CALL sggbak( 'P', 'R', n, ilo, ihi, work( ileft ),
640 $ work( iright ), n, vr, ldvr, iinfo )
641 IF( iinfo.NE.0 ) THEN
642 info = n + 9
643 GO TO 120
644 END IF
645 DO 100 jc = 1, n
646 IF( alphai( jc ).LT.zero )
647 $ GO TO 100
648 temp = zero
649 IF( alphai( jc ).EQ.zero ) THEN
650 DO 60 jr = 1, n
651 temp = max( temp, abs( vr( jr, jc ) ) )
652 60 CONTINUE
653 ELSE
654 DO 70 jr = 1, n
655 temp = max( temp, abs( vr( jr, jc ) )+
656 $ abs( vr( jr, jc+1 ) ) )
657 70 CONTINUE
658 END IF
659 IF( temp.LT.safmin )
660 $ GO TO 100
661 temp = one / temp
662 IF( alphai( jc ).EQ.zero ) THEN
663 DO 80 jr = 1, n
664 vr( jr, jc ) = vr( jr, jc )*temp
665 80 CONTINUE
666 ELSE
667 DO 90 jr = 1, n
668 vr( jr, jc ) = vr( jr, jc )*temp
669 vr( jr, jc+1 ) = vr( jr, jc+1 )*temp
670 90 CONTINUE
671 END IF
672 100 CONTINUE
673 END IF
674*
675* End of eigenvector calculation
676*
677 END IF
678*
679* Undo scaling in alpha, beta
680*
681* Note: this does not give the alpha and beta for the unscaled
682* problem.
683*
684* Un-scaling is limited to avoid underflow in alpha and beta
685* if they are significant.
686*
687 DO 110 jc = 1, n
688 absar = abs( alphar( jc ) )
689 absai = abs( alphai( jc ) )
690 absb = abs( beta( jc ) )
691 salfar = anrm*alphar( jc )
692 salfai = anrm*alphai( jc )
693 sbeta = bnrm*beta( jc )
694 ilimit = .false.
695 scale = one
696*
697* Check for significant underflow in ALPHAI
698*
699 IF( abs( salfai ).LT.safmin .AND. absai.GE.
700 $ max( safmin, eps*absar, eps*absb ) ) THEN
701 ilimit = .true.
702 scale = ( onepls*safmin / anrm1 ) /
703 $ max( onepls*safmin, anrm2*absai )
704*
705 ELSE IF( salfai.EQ.zero ) THEN
706*
707* If insignificant underflow in ALPHAI, then make the
708* conjugate eigenvalue real.
709*
710 IF( alphai( jc ).LT.zero .AND. jc.GT.1 ) THEN
711 alphai( jc-1 ) = zero
712 ELSE IF( alphai( jc ).GT.zero .AND. jc.LT.n ) THEN
713 alphai( jc+1 ) = zero
714 END IF
715 END IF
716*
717* Check for significant underflow in ALPHAR
718*
719 IF( abs( salfar ).LT.safmin .AND. absar.GE.
720 $ max( safmin, eps*absai, eps*absb ) ) THEN
721 ilimit = .true.
722 scale = max( scale, ( onepls*safmin / anrm1 ) /
723 $ max( onepls*safmin, anrm2*absar ) )
724 END IF
725*
726* Check for significant underflow in BETA
727*
728 IF( abs( sbeta ).LT.safmin .AND. absb.GE.
729 $ max( safmin, eps*absar, eps*absai ) ) THEN
730 ilimit = .true.
731 scale = max( scale, ( onepls*safmin / bnrm1 ) /
732 $ max( onepls*safmin, bnrm2*absb ) )
733 END IF
734*
735* Check for possible overflow when limiting scaling
736*
737 IF( ilimit ) THEN
738 temp = ( scale*safmin )*max( abs( salfar ), abs( salfai ),
739 $ abs( sbeta ) )
740 IF( temp.GT.one )
741 $ scale = scale / temp
742 IF( scale.LT.one )
743 $ ilimit = .false.
744 END IF
745*
746* Recompute un-scaled ALPHAR, ALPHAI, BETA if necessary.
747*
748 IF( ilimit ) THEN
749 salfar = ( scale*alphar( jc ) )*anrm
750 salfai = ( scale*alphai( jc ) )*anrm
751 sbeta = ( scale*beta( jc ) )*bnrm
752 END IF
753 alphar( jc ) = salfar
754 alphai( jc ) = salfai
755 beta( jc ) = sbeta
756 110 CONTINUE
757*
758 120 CONTINUE
759 work( 1 ) = lwkopt
760*
761 RETURN
762*
763* End of SGEGV
764*
765 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgeqrf(m, n, a, lda, tau, work, lwork, info)
SGEQRF
Definition sgeqrf.f:144
subroutine sggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
SGGBAK
Definition sggbak.f:146
subroutine sggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
SGGBAL
Definition sggbal.f:175
subroutine sgghrd(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, info)
SGGHRD
Definition sgghrd.f:206
subroutine shgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alphar, alphai, beta, q, ldq, z, ldz, work, lwork, info)
SHGEQZ
Definition shgeqz.f:303
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
Definition slacpy.f:101
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition slascl.f:142
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition slaset.f:108
subroutine stgevc(side, howmny, select, n, s, lds, p, ldp, vl, ldvl, vr, ldvr, mm, m, work, info)
STGEVC
Definition stgevc.f:293
subroutine sorgqr(m, n, k, a, lda, tau, work, lwork, info)
SORGQR
Definition sorgqr.f:126
subroutine sormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
SORMQR
Definition sormqr.f:166
subroutine sgegv(jobvl, jobvr, n, a, lda, b, ldb, alphar, alphai, beta, vl, ldvl, vr, ldvr, work, lwork, info)
SGEGV computes the eigenvalues and, optionally, the left and/or right eigenvectors of a real matrix p...
Definition sgegv.f:305