280 SUBROUTINE zgegv( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA,
281 $ VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO )
288 CHARACTER JOBVL, JOBVR
289 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, N
292 DOUBLE PRECISION RWORK( * )
293 COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
294 $ beta( * ), vl( ldvl, * ), vr( ldvr, * ),
301 DOUBLE PRECISION ZERO, ONE
302 parameter( zero = 0.0d0, one = 1.0d0 )
303 COMPLEX*16 CZERO, CONE
304 parameter( czero = ( 0.0d0, 0.0d0 ),
305 $ cone = ( 1.0d0, 0.0d0 ) )
308 LOGICAL ILIMIT, ILV, ILVL, ILVR, LQUERY
310 INTEGER ICOLS, IHI, IINFO, IJOBVL, IJOBVR, ILEFT, ILO,
311 $ in, iright, irows, irwork, itau, iwork, jc, jr,
312 $ lopt, lwkmin, lwkopt, nb, nb1, nb2, nb3
313 DOUBLE PRECISION ABSAI, ABSAR, ABSB, ANRM, ANRM1, ANRM2, BNRM,
314 $ bnrm1, bnrm2, eps, safmax, safmin, salfai,
315 $ salfar, sbeta, scale, temp
328 DOUBLE PRECISION DLAMCH, ZLANGE
329 EXTERNAL lsame, ilaenv, dlamch, zlange
332 INTRINSIC abs, dble, dcmplx, dimag, int, max
335 DOUBLE PRECISION ABS1
338 abs1( x ) = abs( dble( x ) ) + abs( dimag( x ) )
344 IF( lsame( jobvl,
'N' ) )
THEN
347 ELSE IF( lsame( jobvl,
'V' ) )
THEN
355 IF( lsame( jobvr,
'N' ) )
THEN
358 ELSE IF( lsame( jobvr,
'V' ) )
THEN
369 lwkmin = max( 2*n, 1 )
372 lquery = ( lwork.EQ.-1 )
374 IF( ijobvl.LE.0 )
THEN
376 ELSE IF( ijobvr.LE.0 )
THEN
378 ELSE IF( n.LT.0 )
THEN
380 ELSE IF( lda.LT.max( 1, n ) )
THEN
382 ELSE IF( ldb.LT.max( 1, n ) )
THEN
384 ELSE IF( ldvl.LT.1 .OR. ( ilvl .AND. ldvl.LT.n ) )
THEN
386 ELSE IF( ldvr.LT.1 .OR. ( ilvr .AND. ldvr.LT.n ) )
THEN
388 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery )
THEN
393 nb1 = ilaenv( 1,
'ZGEQRF',
' ', n, n, -1, -1 )
394 nb2 = ilaenv( 1,
'ZUNMQR',
' ', n, n, n, -1 )
395 nb3 = ilaenv( 1,
'ZUNGQR',
' ', n, n, n, -1 )
396 nb = max( nb1, nb2, nb3 )
397 lopt = max( 2*n, n*( nb+1 ) )
402 CALL xerbla(
'ZGEGV ', -info )
404 ELSE IF( lquery )
THEN
415 eps = dlamch(
'E' )*dlamch(
'B' )
416 safmin = dlamch(
'S' )
417 safmin = safmin + safmin
418 safmax = one / safmin
422 anrm = zlange(
'M', n, n, a, lda, rwork )
425 IF( anrm.LT.one )
THEN
426 IF( safmax*anrm.LT.one )
THEN
432 IF( anrm.GT.zero )
THEN
433 CALL zlascl(
'G', -1, -1, anrm, one, n, n, a, lda, iinfo )
434 IF( iinfo.NE.0 )
THEN
442 bnrm = zlange(
'M', n, n, b, ldb, rwork )
445 IF( bnrm.LT.one )
THEN
446 IF( safmax*bnrm.LT.one )
THEN
452 IF( bnrm.GT.zero )
THEN
453 CALL zlascl(
'G', -1, -1, bnrm, one, n, n, b, ldb, iinfo )
454 IF( iinfo.NE.0 )
THEN
466 CALL zggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
467 $ rwork( iright ), rwork( irwork ), iinfo )
468 IF( iinfo.NE.0 )
THEN
475 irows = ihi + 1 - ilo
483 CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
484 $ work( iwork ), lwork+1-iwork, iinfo )
486 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
487 IF( iinfo.NE.0 )
THEN
492 CALL zunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
493 $ work( itau ), a( ilo, ilo ), lda, work( iwork ),
494 $ lwork+1-iwork, iinfo )
496 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
497 IF( iinfo.NE.0 )
THEN
503 CALL zlaset(
'Full', n, n, czero, cone, vl, ldvl )
504 CALL zlacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
505 $ vl( ilo+1, ilo ), ldvl )
506 CALL zungqr( irows, irows, irows, vl( ilo, ilo ), ldvl,
507 $ work( itau ), work( iwork ), lwork+1-iwork,
510 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
511 IF( iinfo.NE.0 )
THEN
518 $
CALL zlaset(
'Full', n, n, czero, cone, vr, ldvr )
526 CALL zgghrd( jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb, vl,
527 $ ldvl, vr, ldvr, iinfo )
529 CALL zgghrd(
'N',
'N', irows, 1, irows, a( ilo, ilo ), lda,
530 $ b( ilo, ilo ), ldb, vl, ldvl, vr, ldvr, iinfo )
532 IF( iinfo.NE.0 )
THEN
545 CALL zhgeqz( chtemp, jobvl, jobvr, n, ilo, ihi, a, lda, b, ldb,
546 $ alpha, beta, vl, ldvl, vr, ldvr, work( iwork ),
547 $ lwork+1-iwork, rwork( irwork ), iinfo )
549 $ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
550 IF( iinfo.NE.0 )
THEN
551 IF( iinfo.GT.0 .AND. iinfo.LE.n )
THEN
553 ELSE IF( iinfo.GT.n .AND. iinfo.LE.2*n )
THEN
575 CALL ztgevc( chtemp,
'B', ldumma, n, a, lda, b, ldb, vl, ldvl,
576 $ vr, ldvr, n, in, work( iwork ), rwork( irwork ),
578 IF( iinfo.NE.0 )
THEN
586 CALL zggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
587 $ rwork( iright ), n, vl, ldvl, iinfo )
588 IF( iinfo.NE.0 )
THEN
595 temp = max( temp, abs1( vl( jr, jc ) ) )
601 vl( jr, jc ) = vl( jr, jc )*temp
606 CALL zggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
607 $ rwork( iright ), n, vr, ldvr, iinfo )
608 IF( iinfo.NE.0 )
THEN
615 temp = max( temp, abs1( vr( jr, jc ) ) )
621 vr( jr, jc ) = vr( jr, jc )*temp
639 absar = abs( dble( alpha( jc ) ) )
640 absai = abs( dimag( alpha( jc ) ) )
641 absb = abs( dble( beta( jc ) ) )
642 salfar = anrm*dble( alpha( jc ) )
643 salfai = anrm*dimag( alpha( jc ) )
644 sbeta = bnrm*dble( beta( jc ) )
650 IF( abs( salfai ).LT.safmin .AND. absai.GE.
651 $ max( safmin, eps*absar, eps*absb ) )
THEN
653 scale = ( safmin / anrm1 ) / max( safmin, anrm2*absai )
658 IF( abs( salfar ).LT.safmin .AND. absar.GE.
659 $ max( safmin, eps*absai, eps*absb ) )
THEN
661 scale = max( scale, ( safmin / anrm1 ) /
662 $ max( safmin, anrm2*absar ) )
667 IF( abs( sbeta ).LT.safmin .AND. absb.GE.
668 $ max( safmin, eps*absar, eps*absai ) )
THEN
670 scale = max( scale, ( safmin / bnrm1 ) /
671 $ max( safmin, bnrm2*absb ) )
677 temp = ( scale*safmin )*max( abs( salfar ), abs( salfai ),
680 $ scale = scale / temp
688 salfar = ( scale*dble( alpha( jc ) ) )*anrm
689 salfai = ( scale*dimag( alpha( jc ) ) )*anrm
690 sbeta = ( scale*beta( jc ) )*bnrm
692 alpha( jc ) = dcmplx( salfar, salfai )
subroutine xerbla(srname, info)
subroutine zgeqrf(m, n, a, lda, tau, work, lwork, info)
ZGEQRF
subroutine zggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
ZGGBAK
subroutine zggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
ZGGBAL
subroutine zgghrd(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, info)
ZGGHRD
subroutine zhgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
ZHGEQZ
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine ztgevc(side, howmny, select, n, s, lds, p, ldp, vl, ldvl, vr, ldvr, mm, m, work, rwork, info)
ZTGEVC
subroutine zungqr(m, n, k, a, lda, tau, work, lwork, info)
ZUNGQR
subroutine zunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMQR
subroutine zgegv(jobvl, jobvr, n, a, lda, b, ldb, alpha, beta, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
ZGEGV computes the eigenvalues and, optionally, the left and/or right eigenvectors of a complex matri...