378 SUBROUTINE dtgsna( JOB, HOWMNY, SELECT, N, A, LDA, B, LDB, VL,
379 $ LDVL, VR, LDVR, S, DIF, MM, M, WORK, LWORK,
387 CHARACTER HOWMNY, JOB
388 INTEGER INFO, LDA, LDB, LDVL, LDVR, LWORK, M, MM, N
393 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), DIF( * ), S( * ),
394 $ vl( ldvl, * ), vr( ldvr, * ), work( * )
401 PARAMETER ( DIFDRI = 3 )
402 DOUBLE PRECISION ZERO, ONE, TWO, FOUR
403 parameter( zero = 0.0d+0, one = 1.0d+0, two = 2.0d+0,
407 LOGICAL LQUERY, PAIR, SOMCON, WANTBH, WANTDF, WANTS
408 INTEGER I, IERR, IFST, ILST, IZ, K, KS, LWMIN, N1, N2
409 DOUBLE PRECISION ALPHAI, ALPHAR, ALPRQT, BETA, C1, C2, COND,
410 $ eps, lnrm, rnrm, root1, root2, scale, smlnum,
411 $ tmpii, tmpir, tmpri, tmprr, uhav, uhavi, uhbv,
415 DOUBLE PRECISION DUMMY( 1 ), DUMMY1( 1 )
419 DOUBLE PRECISION DDOT, DLAMCH, DLAPY2, DNRM2
420 EXTERNAL lsame, ddot, dlamch, dlapy2, dnrm2
426 INTRINSIC max, min, sqrt
432 wantbh = lsame( job,
'B' )
433 wants = lsame( job,
'E' ) .OR. wantbh
434 wantdf = lsame( job,
'V' ) .OR. wantbh
436 somcon = lsame( howmny,
'S' )
439 lquery = ( lwork.EQ.-1 )
441 IF( .NOT.wants .AND. .NOT.wantdf )
THEN
443 ELSE IF( .NOT.lsame( howmny,
'A' ) .AND. .NOT.somcon )
THEN
445 ELSE IF( n.LT.0 )
THEN
447 ELSE IF( lda.LT.max( 1, n ) )
THEN
449 ELSE IF( ldb.LT.max( 1, n ) )
THEN
451 ELSE IF( wants .AND. ldvl.LT.n )
THEN
453 ELSE IF( wants .AND. ldvr.LT.n )
THEN
468 IF( a( k+1, k ).EQ.zero )
THEN
473 IF(
SELECT( k ) .OR.
SELECT( k+1 ) )
488 ELSE IF( lsame( job,
'V' ) .OR. lsame( job,
'B' ) )
THEN
489 lwmin = 2*n*( n + 2 ) + 16
497 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
503 CALL xerbla(
'DTGSNA', -info )
505 ELSE IF( lquery )
THEN
517 smlnum = dlamch(
'S' ) / eps
530 $ pair = a( k+1, k ).NE.zero
538 IF( .NOT.
SELECT( k ) .AND. .NOT.
SELECT( k+1 ) )
541 IF( .NOT.
SELECT( k ) )
557 rnrm = dlapy2( dnrm2( n, vr( 1, ks ), 1 ),
558 $ dnrm2( n, vr( 1, ks+1 ), 1 ) )
559 lnrm = dlapy2( dnrm2( n, vl( 1, ks ), 1 ),
560 $ dnrm2( n, vl( 1, ks+1 ), 1 ) )
561 CALL dgemv(
'N', n, n, one, a, lda, vr( 1, ks ), 1, zero,
563 tmprr = ddot( n, work, 1, vl( 1, ks ), 1 )
564 tmpri = ddot( n, work, 1, vl( 1, ks+1 ), 1 )
565 CALL dgemv(
'N', n, n, one, a, lda, vr( 1, ks+1 ), 1,
567 tmpii = ddot( n, work, 1, vl( 1, ks+1 ), 1 )
568 tmpir = ddot( n, work, 1, vl( 1, ks ), 1 )
570 uhavi = tmpir - tmpri
571 CALL dgemv(
'N', n, n, one, b, ldb, vr( 1, ks ), 1, zero,
573 tmprr = ddot( n, work, 1, vl( 1, ks ), 1 )
574 tmpri = ddot( n, work, 1, vl( 1, ks+1 ), 1 )
575 CALL dgemv(
'N', n, n, one, b, ldb, vr( 1, ks+1 ), 1,
577 tmpii = ddot( n, work, 1, vl( 1, ks+1 ), 1 )
578 tmpir = ddot( n, work, 1, vl( 1, ks ), 1 )
580 uhbvi = tmpir - tmpri
581 uhav = dlapy2( uhav, uhavi )
582 uhbv = dlapy2( uhbv, uhbvi )
583 cond = dlapy2( uhav, uhbv )
584 s( ks ) = cond / ( rnrm*lnrm )
591 rnrm = dnrm2( n, vr( 1, ks ), 1 )
592 lnrm = dnrm2( n, vl( 1, ks ), 1 )
593 CALL dgemv(
'N', n, n, one, a, lda, vr( 1, ks ), 1, zero,
595 uhav = ddot( n, work, 1, vl( 1, ks ), 1 )
596 CALL dgemv(
'N', n, n, one, b, ldb, vr( 1, ks ), 1, zero,
598 uhbv = ddot( n, work, 1, vl( 1, ks ), 1 )
599 cond = dlapy2( uhav, uhbv )
600 IF( cond.EQ.zero )
THEN
603 s( ks ) = cond / ( rnrm*lnrm )
610 dif( ks ) = dlapy2( a( 1, 1 ), b( 1, 1 ) )
621 work( 1 ) = a( k, k )
622 work( 2 ) = a( k+1, k )
623 work( 3 ) = a( k, k+1 )
624 work( 4 ) = a( k+1, k+1 )
625 work( 5 ) = b( k, k )
626 work( 6 ) = b( k+1, k )
627 work( 7 ) = b( k, k+1 )
628 work( 8 ) = b( k+1, k+1 )
629 CALL dlag2( work, 2, work( 5 ), 2, smlnum*eps, beta,
630 $ dummy1( 1 ), alphar, dummy( 1 ), alphai )
632 c1 = two*( alphar*alphar+alphai*alphai+beta*beta )
633 c2 = four*beta*beta*alphai*alphai
634 root1 = c1 + sqrt( c1*c1-4.0d0*c2 )
637 cond = min( sqrt( root1 ), sqrt( root2 ) )
643 CALL dlacpy(
'Full', n, n, a, lda, work, n )
644 CALL dlacpy(
'Full', n, n, b, ldb, work( n*n+1 ), n )
648 CALL dtgexc( .false., .false., n, work, n, work( n*n+1 ), n,
649 $ dummy, 1, dummy1, 1, ifst, ilst,
650 $ work( n*n*2+1 ), lwork-2*n*n, ierr )
666 IF( work( 2 ).NE.zero )
674 CALL dtgsyl(
'N', difdri, n2, n1, work( n*n1+n1+1 ),
675 $ n, work, n, work( n1+1 ), n,
676 $ work( n*n1+n1+i ), n, work( i ), n,
677 $ work( n1+i ), n, scale, dif( ks ),
678 $ work( iz+1 ), lwork-2*n*n, iwork, ierr )
681 $ dif( ks ) = min( max( one, alprqt )*dif( ks ),
686 $ dif( ks+1 ) = dif( ks )
subroutine xerbla(srname, info)
subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
DGEMV
subroutine dlacpy(uplo, m, n, a, lda, b, ldb)
DLACPY copies all or part of one two-dimensional array to another.
subroutine dlag2(a, lda, b, ldb, safmin, scale1, scale2, wr1, wr2, wi)
DLAG2 computes the eigenvalues of a 2-by-2 generalized eigenvalue problem, with scaling as necessary ...
subroutine dtgexc(wantq, wantz, n, a, lda, b, ldb, q, ldq, z, ldz, ifst, ilst, work, lwork, info)
DTGEXC
subroutine dtgsna(job, howmny, select, n, a, lda, b, ldb, vl, ldvl, vr, ldvr, s, dif, mm, m, work, lwork, iwork, info)
DTGSNA
subroutine dtgsyl(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, dif, work, lwork, iwork, info)
DTGSYL