213 SUBROUTINE zggev( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
214 $ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
221 CHARACTER JOBVL, JOBVR
222 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
225 DOUBLE PRECISION RWORK( * )
226 COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
227 $ beta( * ), vl( ldvl, * ), vr( ldvr, * ),
234 DOUBLE PRECISION ZERO, ONE
235 parameter( zero = 0.0d0, one = 1.0d0 )
236 COMPLEX*16 CZERO, CONE
237 parameter( czero = ( 0.0d0, 0.0d0 ),
238 $ cone = ( 1.0d0, 0.0d0 ) )
241 LOGICAL ILASCL, ILBSCL, ILV, ILVL, ILVR, LQUERY
243 INTEGER ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT, ILO,
244 $ in, iright, irows, irwrk, itau, iwrk, jc, jr,
246 DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS,
261 DOUBLE PRECISION DLAMCH, ZLANGE
262 EXTERNAL lsame, ilaenv, dlamch, zlange
265 INTRINSIC abs, dble, dimag, max, sqrt
268 DOUBLE PRECISION ABS1
271 abs1( x ) = abs( dble( x ) ) + abs( dimag( x ) )
277 IF( lsame( jobvl,
'N' ) )
THEN
280 ELSE IF( lsame( jobvl,
'V' ) )
THEN
288 IF( lsame( jobvr,
'N' ) )
THEN
291 ELSE IF( lsame( jobvr,
'V' ) )
THEN
303 lquery = ( lwork.EQ.-1 )
304 IF( ijobvl.LE.0 )
THEN
306 ELSE IF( ijobvr.LE.0 )
THEN
308 ELSE IF( n.LT.0 )
THEN
310 ELSE IF( lda.LT.max( 1, n ) )
THEN
312 ELSE IF( ldb.LT.max( 1, n ) )
THEN
314 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
316 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
329 lwkmin = max( 1, 2*n )
330 lwkopt = max( 1, n + n*ilaenv( 1,
'ZGEQRF',
' ', n, 1, n,
332 lwkopt = max( lwkopt, n +
333 $ n*ilaenv( 1,
'ZUNMQR',
' ', n, 1, n, 0 ) )
335 lwkopt = max( lwkopt, n +
336 $ n*ilaenv( 1,
'ZUNGQR',
' ', n, 1, n, -1 ) )
340 IF( lwork.LT.lwkmin .AND. .NOT.lquery )
345 CALL xerbla(
'ZGGEV ', -info )
347 ELSE IF( lquery )
THEN
358 eps = dlamch(
'E' )*dlamch(
'B' )
359 smlnum = dlamch(
'S' )
360 bignum = one / smlnum
361 smlnum = sqrt( smlnum ) / eps
362 bignum = one / smlnum
366 anrm = zlange(
'M', n, n, a, lda, rwork )
368 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
371 ELSE IF( anrm.GT.bignum )
THEN
376 $
CALL zlascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
380 bnrm = zlange(
'M', n, n, b, ldb, rwork )
382 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
385 ELSE IF( bnrm.GT.bignum )
THEN
390 $
CALL zlascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
398 CALL zggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
399 $ rwork( iright ), rwork( irwrk ), ierr )
404 irows = ihi + 1 - ilo
412 CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
413 $ work( iwrk ), lwork+1-iwrk, ierr )
418 CALL zunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
419 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
420 $ lwork+1-iwrk, ierr )
426 CALL zlaset(
'Full', n, n, czero, cone, vl, ldvl )
427 IF( irows.GT.1 )
THEN
428 CALL zlacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
429 $ vl( ilo+1, ilo ), ldvl )
431 CALL zungqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
432 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
438 $
CALL zlaset(
'Full', n, n, czero, cone, vr, ldvr )
446 CALL zgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
447 $ ldvl, vr, ldvr, ierr )
449 CALL zgghrd(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
450 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, ierr )
464 CALL zhgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
465 $ alpha, beta, vl, ldvl, vr, ldvr, work( iwrk ),
466 $ lwork+1-iwrk, rwork( irwrk ), ierr )
468 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
470 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
493 CALL ztgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl,
495 $ vr, ldvr, n, in, work( iwrk ), rwork( irwrk ),
506 CALL zggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
507 $ rwork( iright ), n, vl, ldvl, ierr )
511 temp = max( temp, abs1( vl( jr, jc ) ) )
517 vl( jr, jc ) = vl( jr, jc )*temp
522 CALL zggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
523 $ rwork( iright ), n, vr, ldvr, ierr )
527 temp = max( temp, abs1( vr( jr, jc ) ) )
533 vr( jr, jc ) = vr( jr, jc )*temp
544 $
CALL zlascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
547 $
CALL zlascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )