222 SUBROUTINE dggev( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHAR,
224 $ BETA, VL, LDVL, VR, LDVR, WORK, LWORK, INFO )
231 CHARACTER JOBVL, JOBVR
232 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
235 DOUBLE PRECISION A( LDA, * ), ALPHAI( * ), ALPHAR( * ),
236 $ B( LDB, * ), BETA( * ), VL( LDVL, * ),
237 $ vr( ldvr, * ), work( * )
243 DOUBLE PRECISION ZERO, ONE
244 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0 )
247 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
249 INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
250 $ in, iright, irows, itau, iwrk, jc, jr, maxwrk,
252 DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
266 DOUBLE PRECISION DLAMCH, DLANGE
267 EXTERNAL lsame, ilaenv, dlamch, dlange
270 INTRINSIC abs, max, sqrt
276 IF( lsame( jobvl,
'N' ) )
THEN
279 ELSE IF( lsame( jobvl,
'V' ) )
THEN
287 IF( lsame( jobvr,
'N' ) )
THEN
290 ELSE IF( lsame( jobvr,
'V' ) )
THEN
302 lquery = ( lwork.EQ.-1 )
303 IF( ijobvl.LE.0 )
THEN
305 ELSE IF( ijobvr.LE.0 )
THEN
307 ELSE IF( n.LT.0 )
THEN
309 ELSE IF( lda.LT.max( 1, n ) )
THEN
311 ELSE IF( ldb.LT.max( 1, n ) )
THEN
313 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
315 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
328 minwrk = max( 1, 8*n )
329 maxwrk = max( 1, n*( 7 +
330 $ ilaenv( 1,
'DGEQRF',
' ', n, 1, n, 0 ) ) )
331 maxwrk = max( maxwrk, n*( 7 +
332 $ ilaenv( 1,
'DORMQR',
' ', n, 1, n, 0 ) ) )
334 maxwrk = max( maxwrk, n*( 7 +
335 $ ilaenv( 1,
'DORGQR',
' ', n, 1, n, -1 ) ) )
339 IF( lwork.LT.minwrk .AND. .NOT.lquery )
344 CALL xerbla(
'DGGEV ', -info )
346 ELSE IF( lquery )
THEN
358 smlnum = dlamch(
'S' )
359 bignum = one / smlnum
360 smlnum = sqrt( smlnum ) / eps
361 bignum = one / smlnum
365 anrm = dlange(
'M', n, n, a, lda, work )
367 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
370 ELSE IF( anrm.GT.bignum )
THEN
375 $
CALL dlascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
379 bnrm = dlange(
'M', n, n, b, ldb, work )
381 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
384 ELSE IF( bnrm.GT.bignum )
THEN
389 $
CALL dlascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
397 CALL dggbal(
'P', n, a, lda, b, ldb, ilo, ihi, work( ileft ),
398 $ work( iright ), work( iwrk ), ierr )
403 irows = ihi + 1 - ilo
411 CALL dgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
412 $ work( iwrk ), lwork+1-iwrk, ierr )
417 CALL dormqr(
'L',
'T', irows, icols, irows, b( ilo, ilo ), ldb,
418 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
419 $ lwork+1-iwrk, ierr )
425 CALL dlaset(
'Full', n, n, zero, one, vl, ldvl )
426 IF( irows.GT.1 )
THEN
427 CALL dlacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
428 $ vl( ilo+1, ilo ), ldvl )
430 CALL dorgqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
431 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
437 $
CALL dlaset(
'Full', n, n, zero, one, vr, ldvr )
446 CALL dgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
447 $ ldvl, vr, ldvr, ierr )
449 CALL dgghrd(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
450 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, ierr )
463 CALL dhgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
464 $ alphar, alphai, beta, vl, ldvl, vr, ldvr,
465 $ work( iwrk ), lwork+1-iwrk, ierr )
467 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
469 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
490 CALL dtgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl,
492 $ vr, ldvr, n, in, work( iwrk ), ierr )
502 CALL dggbak(
'P',
'L', n, ilo, ihi, work( ileft ),
503 $ work( iright ), n, vl, ldvl, ierr )
505 IF( alphai( jc ).LT.zero )
508 IF( alphai( jc ).EQ.zero )
THEN
510 temp = max( temp, abs( vl( jr, jc ) ) )
514 temp = max( temp, abs( vl( jr, jc ) )+
515 $ abs( vl( jr, jc+1 ) ) )
521 IF( alphai( jc ).EQ.zero )
THEN
523 vl( jr, jc ) = vl( jr, jc )*temp
527 vl( jr, jc ) = vl( jr, jc )*temp
528 vl( jr, jc+1 ) = vl( jr, jc+1 )*temp
534 CALL dggbak(
'P',
'R', n, ilo, ihi, work( ileft ),
535 $ work( iright ), n, vr, ldvr, ierr )
537 IF( alphai( jc ).LT.zero )
540 IF( alphai( jc ).EQ.zero )
THEN
542 temp = max( temp, abs( vr( jr, jc ) ) )
546 temp = max( temp, abs( vr( jr, jc ) )+
547 $ abs( vr( jr, jc+1 ) ) )
553 IF( alphai( jc ).EQ.zero )
THEN
555 vr( jr, jc ) = vr( jr, jc )*temp
559 vr( jr, jc ) = vr( jr, jc )*temp
560 vr( jr, jc+1 ) = vr( jr, jc+1 )*temp
575 CALL dlascl(
'G', 0, 0, anrmto, anrm, n, 1, alphar, n,
577 CALL dlascl(
'G', 0, 0, anrmto, anrm, n, 1, alphai, n,
582 CALL dlascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )