220 SUBROUTINE dtrevc( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,
221 $ LDVR, MM, M, WORK, INFO )
228 CHARACTER HOWMNY, SIDE
229 INTEGER INFO, LDT, LDVL, LDVR, M, MM, N
233 DOUBLE PRECISION T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),
240 DOUBLE PRECISION ZERO, ONE
241 parameter( zero = 0.0d+0, one = 1.0d+0 )
244 LOGICAL ALLV, BOTHV, LEFTV, OVER, PAIR, RIGHTV, SOMEV
245 INTEGER I, IERR, II, IP, IS, J, J1, J2, JNXT, K, KI, N2
246 DOUBLE PRECISION BETA, BIGNUM, EMAX, OVFL, REC, REMAX, SCALE,
247 $ smin, smlnum, ulp, unfl, vcrit, vmax, wi, wr,
253 DOUBLE PRECISION DDOT, DLAMCH
254 EXTERNAL lsame, idamax, ddot, dlamch
260 INTRINSIC abs, max, sqrt
263 DOUBLE PRECISION X( 2, 2 )
269 bothv = lsame( side,
'B' )
270 rightv = lsame( side,
'R' ) .OR. bothv
271 leftv = lsame( side,
'L' ) .OR. bothv
273 allv = lsame( howmny,
'A' )
274 over = lsame( howmny,
'B' )
275 somev = lsame( howmny,
'S' )
278 IF( .NOT.rightv .AND. .NOT.leftv )
THEN
280 ELSE IF( .NOT.allv .AND. .NOT.over .AND. .NOT.somev )
THEN
282 ELSE IF( n.LT.0 )
THEN
284 ELSE IF( ldt.LT.max( 1, n ) )
THEN
286 ELSE IF( ldvl.LT.1 .OR. ( leftv .AND. ldvl.LT.n ) )
THEN
288 ELSE IF( ldvr.LT.1 .OR. ( rightv .AND. ldvr.LT.n ) )
THEN
302 SELECT( j ) = .false.
305 IF( t( j+1, j ).EQ.zero )
THEN
310 IF(
SELECT( j ) .OR.
SELECT( j+1 ) )
THEN
330 CALL xerbla(
'DTREVC', -info )
341 unfl = dlamch(
'Safe minimum' )
343 ulp = dlamch(
'Precision' )
344 smlnum = unfl*( n / ulp )
345 bignum = ( one-ulp ) / smlnum
354 work( j ) = work( j ) + abs( t( i, j ) )
377 IF( t( ki, ki-1 ).EQ.zero )
384 IF( .NOT.
SELECT( ki ) )
387 IF( .NOT.
SELECT( ki-1 ) )
397 $ wi = sqrt( abs( t( ki, ki-1 ) ) )*
398 $ sqrt( abs( t( ki-1, ki ) ) )
399 smin = max( ulp*( abs( wr )+abs( wi ) ), smlnum )
410 work( k+n ) = -t( k, ki )
417 DO 60 j = ki - 1, 1, -1
424 IF( t( j, j-1 ).NE.zero )
THEN
434 CALL dlaln2( .false., 1, 1, smin, one, t( j, j ),
435 $ ldt, one, one, work( j+n ), n, wr,
436 $ zero, x, 2, scale, xnorm, ierr )
441 IF( xnorm.GT.one )
THEN
442 IF( work( j ).GT.bignum / xnorm )
THEN
443 x( 1, 1 ) = x( 1, 1 ) / xnorm
444 scale = scale / xnorm
451 $
CALL dscal( ki, scale, work( 1+n ), 1 )
452 work( j+n ) = x( 1, 1 )
456 CALL daxpy( j-1, -x( 1, 1 ), t( 1, j ), 1,
463 CALL dlaln2( .false., 2, 1, smin, one,
464 $ t( j-1, j-1 ), ldt, one, one,
465 $ work( j-1+n ), n, wr, zero, x, 2,
466 $ scale, xnorm, ierr )
471 IF( xnorm.GT.one )
THEN
472 beta = max( work( j-1 ), work( j ) )
473 IF( beta.GT.bignum / xnorm )
THEN
474 x( 1, 1 ) = x( 1, 1 ) / xnorm
475 x( 2, 1 ) = x( 2, 1 ) / xnorm
476 scale = scale / xnorm
483 $
CALL dscal( ki, scale, work( 1+n ), 1 )
484 work( j-1+n ) = x( 1, 1 )
485 work( j+n ) = x( 2, 1 )
489 CALL daxpy( j-2, -x( 1, 1 ), t( 1, j-1 ), 1,
491 CALL daxpy( j-2, -x( 2, 1 ), t( 1, j ), 1,
499 CALL dcopy( ki, work( 1+n ), 1, vr( 1, is ), 1 )
501 ii = idamax( ki, vr( 1, is ), 1 )
502 remax = one / abs( vr( ii, is ) )
503 CALL dscal( ki, remax, vr( 1, is ), 1 )
510 $
CALL dgemv(
'N', n, ki-1, one, vr, ldvr,
511 $ work( 1+n ), 1, work( ki+n ),
514 ii = idamax( n, vr( 1, ki ), 1 )
515 remax = one / abs( vr( ii, ki ) )
516 CALL dscal( n, remax, vr( 1, ki ), 1 )
527 IF( abs( t( ki-1, ki ) ).GE.abs( t( ki, ki-1 ) ) )
THEN
529 work( ki+n2 ) = wi / t( ki-1, ki )
531 work( ki-1+n ) = -wi / t( ki, ki-1 )
535 work( ki-1+n2 ) = zero
540 work( k+n ) = -work( ki-1+n )*t( k, ki-1 )
541 work( k+n2 ) = -work( ki+n2 )*t( k, ki )
548 DO 90 j = ki - 2, 1, -1
555 IF( t( j, j-1 ).NE.zero )
THEN
565 CALL dlaln2( .false., 1, 2, smin, one, t( j, j ),
566 $ ldt, one, one, work( j+n ), n, wr, wi,
567 $ x, 2, scale, xnorm, ierr )
572 IF( xnorm.GT.one )
THEN
573 IF( work( j ).GT.bignum / xnorm )
THEN
574 x( 1, 1 ) = x( 1, 1 ) / xnorm
575 x( 1, 2 ) = x( 1, 2 ) / xnorm
576 scale = scale / xnorm
582 IF( scale.NE.one )
THEN
583 CALL dscal( ki, scale, work( 1+n ), 1 )
584 CALL dscal( ki, scale, work( 1+n2 ), 1 )
586 work( j+n ) = x( 1, 1 )
587 work( j+n2 ) = x( 1, 2 )
591 CALL daxpy( j-1, -x( 1, 1 ), t( 1, j ), 1,
593 CALL daxpy( j-1, -x( 1, 2 ), t( 1, j ), 1,
600 CALL dlaln2( .false., 2, 2, smin, one,
601 $ t( j-1, j-1 ), ldt, one, one,
602 $ work( j-1+n ), n, wr, wi, x, 2, scale,
608 IF( xnorm.GT.one )
THEN
609 beta = max( work( j-1 ), work( j ) )
610 IF( beta.GT.bignum / xnorm )
THEN
612 x( 1, 1 ) = x( 1, 1 )*rec
613 x( 1, 2 ) = x( 1, 2 )*rec
614 x( 2, 1 ) = x( 2, 1 )*rec
615 x( 2, 2 ) = x( 2, 2 )*rec
622 IF( scale.NE.one )
THEN
623 CALL dscal( ki, scale, work( 1+n ), 1 )
624 CALL dscal( ki, scale, work( 1+n2 ), 1 )
626 work( j-1+n ) = x( 1, 1 )
627 work( j+n ) = x( 2, 1 )
628 work( j-1+n2 ) = x( 1, 2 )
629 work( j+n2 ) = x( 2, 2 )
633 CALL daxpy( j-2, -x( 1, 1 ), t( 1, j-1 ), 1,
635 CALL daxpy( j-2, -x( 2, 1 ), t( 1, j ), 1,
637 CALL daxpy( j-2, -x( 1, 2 ), t( 1, j-1 ), 1,
639 CALL daxpy( j-2, -x( 2, 2 ), t( 1, j ), 1,
647 CALL dcopy( ki, work( 1+n ), 1, vr( 1, is-1 ), 1 )
648 CALL dcopy( ki, work( 1+n2 ), 1, vr( 1, is ), 1 )
652 emax = max( emax, abs( vr( k, is-1 ) )+
653 $ abs( vr( k, is ) ) )
657 CALL dscal( ki, remax, vr( 1, is-1 ), 1 )
658 CALL dscal( ki, remax, vr( 1, is ), 1 )
668 CALL dgemv(
'N', n, ki-2, one, vr, ldvr,
669 $ work( 1+n ), 1, work( ki-1+n ),
671 CALL dgemv(
'N', n, ki-2, one, vr, ldvr,
672 $ work( 1+n2 ), 1, work( ki+n2 ),
675 CALL dscal( n, work( ki-1+n ), vr( 1, ki-1 ), 1 )
676 CALL dscal( n, work( ki+n2 ), vr( 1, ki ), 1 )
681 emax = max( emax, abs( vr( k, ki-1 ) )+
682 $ abs( vr( k, ki ) ) )
685 CALL dscal( n, remax, vr( 1, ki-1 ), 1 )
686 CALL dscal( n, remax, vr( 1, ki ), 1 )
713 IF( t( ki+1, ki ).EQ.zero )
719 IF( .NOT.
SELECT( ki ) )
728 $ wi = sqrt( abs( t( ki, ki+1 ) ) )*
729 $ sqrt( abs( t( ki+1, ki ) ) )
730 smin = max( ulp*( abs( wr )+abs( wi ) ), smlnum )
741 work( k+n ) = -t( ki, k )
758 IF( t( j+1, j ).NE.zero )
THEN
771 IF( work( j ).GT.vcrit )
THEN
773 CALL dscal( n-ki+1, rec, work( ki+n ), 1 )
778 work( j+n ) = work( j+n ) -
779 $ ddot( j-ki-1, t( ki+1, j ), 1,
780 $ work( ki+1+n ), 1 )
784 CALL dlaln2( .false., 1, 1, smin, one, t( j, j ),
785 $ ldt, one, one, work( j+n ), n, wr,
786 $ zero, x, 2, scale, xnorm, ierr )
791 $
CALL dscal( n-ki+1, scale, work( ki+n ), 1 )
792 work( j+n ) = x( 1, 1 )
793 vmax = max( abs( work( j+n ) ), vmax )
794 vcrit = bignum / vmax
803 beta = max( work( j ), work( j+1 ) )
804 IF( beta.GT.vcrit )
THEN
806 CALL dscal( n-ki+1, rec, work( ki+n ), 1 )
811 work( j+n ) = work( j+n ) -
812 $ ddot( j-ki-1, t( ki+1, j ), 1,
813 $ work( ki+1+n ), 1 )
815 work( j+1+n ) = work( j+1+n ) -
816 $ ddot( j-ki-1, t( ki+1, j+1 ), 1,
817 $ work( ki+1+n ), 1 )
823 CALL dlaln2( .true., 2, 1, smin, one, t( j, j ),
824 $ ldt, one, one, work( j+n ), n, wr,
825 $ zero, x, 2, scale, xnorm, ierr )
830 $
CALL dscal( n-ki+1, scale, work( ki+n ), 1 )
831 work( j+n ) = x( 1, 1 )
832 work( j+1+n ) = x( 2, 1 )
834 vmax = max( abs( work( j+n ) ),
835 $ abs( work( j+1+n ) ), vmax )
836 vcrit = bignum / vmax
844 CALL dcopy( n-ki+1, work( ki+n ), 1, vl( ki, is ), 1 )
846 ii = idamax( n-ki+1, vl( ki, is ), 1 ) + ki - 1
847 remax = one / abs( vl( ii, is ) )
848 CALL dscal( n-ki+1, remax, vl( ki, is ), 1 )
857 $
CALL dgemv(
'N', n, n-ki, one, vl( 1, ki+1 ), ldvl,
858 $ work( ki+1+n ), 1, work( ki+n ),
861 ii = idamax( n, vl( 1, ki ), 1 )
862 remax = one / abs( vl( ii, ki ) )
863 CALL dscal( n, remax, vl( 1, ki ), 1 )
875 IF( abs( t( ki, ki+1 ) ).GE.abs( t( ki+1, ki ) ) )
THEN
876 work( ki+n ) = wi / t( ki, ki+1 )
877 work( ki+1+n2 ) = one
880 work( ki+1+n2 ) = -wi / t( ki+1, ki )
882 work( ki+1+n ) = zero
888 work( k+n ) = -work( ki+n )*t( ki, k )
889 work( k+n2 ) = -work( ki+1+n2 )*t( ki+1, k )
906 IF( t( j+1, j ).NE.zero )
THEN
919 IF( work( j ).GT.vcrit )
THEN
921 CALL dscal( n-ki+1, rec, work( ki+n ), 1 )
922 CALL dscal( n-ki+1, rec, work( ki+n2 ), 1 )
927 work( j+n ) = work( j+n ) -
928 $ ddot( j-ki-2, t( ki+2, j ), 1,
929 $ work( ki+2+n ), 1 )
930 work( j+n2 ) = work( j+n2 ) -
931 $ ddot( j-ki-2, t( ki+2, j ), 1,
932 $ work( ki+2+n2 ), 1 )
936 CALL dlaln2( .false., 1, 2, smin, one, t( j, j ),
937 $ ldt, one, one, work( j+n ), n, wr,
938 $ -wi, x, 2, scale, xnorm, ierr )
942 IF( scale.NE.one )
THEN
943 CALL dscal( n-ki+1, scale, work( ki+n ), 1 )
944 CALL dscal( n-ki+1, scale, work( ki+n2 ), 1 )
946 work( j+n ) = x( 1, 1 )
947 work( j+n2 ) = x( 1, 2 )
948 vmax = max( abs( work( j+n ) ),
949 $ abs( work( j+n2 ) ), vmax )
950 vcrit = bignum / vmax
959 beta = max( work( j ), work( j+1 ) )
960 IF( beta.GT.vcrit )
THEN
962 CALL dscal( n-ki+1, rec, work( ki+n ), 1 )
963 CALL dscal( n-ki+1, rec, work( ki+n2 ), 1 )
968 work( j+n ) = work( j+n ) -
969 $ ddot( j-ki-2, t( ki+2, j ), 1,
970 $ work( ki+2+n ), 1 )
972 work( j+n2 ) = work( j+n2 ) -
973 $ ddot( j-ki-2, t( ki+2, j ), 1,
974 $ work( ki+2+n2 ), 1 )
976 work( j+1+n ) = work( j+1+n ) -
977 $ ddot( j-ki-2, t( ki+2, j+1 ), 1,
978 $ work( ki+2+n ), 1 )
980 work( j+1+n2 ) = work( j+1+n2 ) -
981 $ ddot( j-ki-2, t( ki+2, j+1 ), 1,
982 $ work( ki+2+n2 ), 1 )
988 CALL dlaln2( .true., 2, 2, smin, one, t( j, j ),
989 $ ldt, one, one, work( j+n ), n, wr,
990 $ -wi, x, 2, scale, xnorm, ierr )
994 IF( scale.NE.one )
THEN
995 CALL dscal( n-ki+1, scale, work( ki+n ), 1 )
996 CALL dscal( n-ki+1, scale, work( ki+n2 ), 1 )
998 work( j+n ) = x( 1, 1 )
999 work( j+n2 ) = x( 1, 2 )
1000 work( j+1+n ) = x( 2, 1 )
1001 work( j+1+n2 ) = x( 2, 2 )
1002 vmax = max( abs( x( 1, 1 ) ), abs( x( 1, 2 ) ),
1003 $ abs( x( 2, 1 ) ), abs( x( 2, 2 ) ), vmax )
1004 vcrit = bignum / vmax
1011 IF( .NOT.over )
THEN
1012 CALL dcopy( n-ki+1, work( ki+n ), 1, vl( ki, is ), 1 )
1013 CALL dcopy( n-ki+1, work( ki+n2 ), 1, vl( ki, is+1 ),
1018 emax = max( emax, abs( vl( k, is ) )+
1019 $ abs( vl( k, is+1 ) ) )
1022 CALL dscal( n-ki+1, remax, vl( ki, is ), 1 )
1023 CALL dscal( n-ki+1, remax, vl( ki, is+1 ), 1 )
1025 DO 230 k = 1, ki - 1
1027 vl( k, is+1 ) = zero
1030 IF( ki.LT.n-1 )
THEN
1031 CALL dgemv(
'N', n, n-ki-1, one, vl( 1, ki+2 ),
1032 $ ldvl, work( ki+2+n ), 1, work( ki+n ),
1034 CALL dgemv(
'N', n, n-ki-1, one, vl( 1, ki+2 ),
1035 $ ldvl, work( ki+2+n2 ), 1,
1036 $ work( ki+1+n2 ), vl( 1, ki+1 ), 1 )
1038 CALL dscal( n, work( ki+n ), vl( 1, ki ), 1 )
1039 CALL dscal( n, work( ki+1+n2 ), vl( 1, ki+1 ), 1 )
1044 emax = max( emax, abs( vl( k, ki ) )+
1045 $ abs( vl( k, ki+1 ) ) )
1048 CALL dscal( n, remax, vl( 1, ki ), 1 )
1049 CALL dscal( n, remax, vl( 1, ki+1 ), 1 )
subroutine xerbla(srname, info)
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
DGEMV
subroutine dlaln2(ltrans, na, nw, smin, ca, a, lda, d1, d2, b, ldb, wr, wi, x, ldx, scale, xnorm, info)
DLALN2 solves a 1-by-1 or 2-by-2 linear system of equations of the specified form.
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dtrevc(side, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, info)
DTREVC