217 SUBROUTINE ztgevc( SIDE, HOWMNY, SELECT, N, S, LDS, P, LDP, VL,
218 $ LDVL, VR, LDVR, MM, M, WORK, RWORK, INFO )
225 CHARACTER HOWMNY, SIDE
226 INTEGER INFO, LDP, LDS, LDVL, LDVR, M, MM, N
230 DOUBLE PRECISION RWORK( * )
231 COMPLEX*16 P( LDP, * ), S( LDS, * ), VL( LDVL, * ),
232 $ vr( ldvr, * ), work( * )
239 DOUBLE PRECISION ZERO, ONE
240 parameter( zero = 0.0d+0, one = 1.0d+0 )
241 COMPLEX*16 CZERO, CONE
242 parameter( czero = ( 0.0d+0, 0.0d+0 ),
243 $ cone = ( 1.0d+0, 0.0d+0 ) )
246 LOGICAL COMPL, COMPR, ILALL, ILBACK, ILBBAD, ILCOMP,
248 INTEGER I, IBEG, IEIG, IEND, IHWMNY, IM, ISIDE, ISRC,
250 DOUBLE PRECISION ACOEFA, ACOEFF, ANORM, ASCALE, BCOEFA, BIG,
251 $ bignum, bnorm, bscale, dmin, safmin, sbeta,
252 $ scale, small, temp, ulp, xmax
253 COMPLEX*16 BCOEFF, CA, CB, D, SALPHA, SUM, SUMA, SUMB, X
257 DOUBLE PRECISION DLAMCH
259 EXTERNAL lsame, dlamch, zladiv
265 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min
268 DOUBLE PRECISION ABS1
271 abs1( x ) = abs( dble( x ) ) + abs( dimag( x ) )
277 IF( lsame( howmny,
'A' ) )
THEN
281 ELSE IF( lsame( howmny,
'S' ) )
THEN
285 ELSE IF( lsame( howmny,
'B' ) )
THEN
293 IF( lsame( side,
'R' ) )
THEN
297 ELSE IF( lsame( side,
'L' ) )
THEN
301 ELSE IF( lsame( side,
'B' ) )
THEN
310 IF( iside.LT.0 )
THEN
312 ELSE IF( ihwmny.LT.0 )
THEN
314 ELSE IF( n.LT.0 )
THEN
316 ELSE IF( lds.LT.max( 1, n ) )
THEN
318 ELSE IF( ldp.LT.max( 1, n ) )
THEN
322 CALL xerbla(
'ZTGEVC', -info )
328 IF( .NOT.ilall )
THEN
342 IF( dimag( p( j, j ) ).NE.zero )
348 ELSE IF( compl .AND. ldvl.LT.n .OR. ldvl.LT.1 )
THEN
350 ELSE IF( compr .AND. ldvr.LT.n .OR. ldvr.LT.1 )
THEN
352 ELSE IF( mm.LT.im )
THEN
356 CALL xerbla(
'ZTGEVC', -info )
368 safmin = dlamch(
'Safe minimum' )
370 ulp = dlamch(
'Epsilon' )*dlamch(
'Base' )
371 small = safmin*n / ulp
373 bignum = one / ( safmin*n )
379 anorm = abs1( s( 1, 1 ) )
380 bnorm = abs1( p( 1, 1 ) )
387 rwork( j ) = rwork( j ) + abs1( s( i, j ) )
388 rwork( n+j ) = rwork( n+j ) + abs1( p( i, j ) )
390 anorm = max( anorm, rwork( j )+abs1( s( j, j ) ) )
391 bnorm = max( bnorm, rwork( n+j )+abs1( p( j, j ) ) )
394 ascale = one / max( anorm, safmin )
395 bscale = one / max( bnorm, safmin )
408 ilcomp =
SELECT( je )
413 IF( abs1( s( je, je ) ).LE.safmin .AND.
414 $ abs( dble( p( je, je ) ) ).LE.safmin )
THEN
419 vl( jr, ieig ) = czero
421 vl( ieig, ieig ) = cone
430 temp = one / max( abs1( s( je, je ) )*ascale,
431 $ abs( dble( p( je, je ) ) )*bscale, safmin )
432 salpha = ( temp*s( je, je ) )*ascale
433 sbeta = ( temp*dble( p( je, je ) ) )*bscale
434 acoeff = sbeta*ascale
435 bcoeff = salpha*bscale
439 lsa = abs( sbeta ).GE.safmin .AND. abs( acoeff ).LT.small
440 lsb = abs1( salpha ).GE.safmin .AND. abs1( bcoeff ).LT.
445 $ scale = ( small / abs( sbeta ) )*min( anorm, big )
447 $ scale = max( scale, ( small / abs1( salpha ) )*
448 $ min( bnorm, big ) )
449 IF( lsa .OR. lsb )
THEN
450 scale = min( scale, one /
451 $ ( safmin*max( one, abs( acoeff ),
452 $ abs1( bcoeff ) ) ) )
454 acoeff = ascale*( scale*sbeta )
456 acoeff = scale*acoeff
459 bcoeff = bscale*( scale*salpha )
461 bcoeff = scale*bcoeff
465 acoefa = abs( acoeff )
466 bcoefa = abs1( bcoeff )
472 dmin = max( ulp*acoefa*anorm, ulp*bcoefa*bnorm, safmin )
489 IF( acoefa*rwork( j )+bcoefa*rwork( n+j ).GT.bignum*
492 work( jr ) = temp*work( jr )
500 suma = suma + dconjg( s( jr, j ) )*work( jr )
501 sumb = sumb + dconjg( p( jr, j ) )*work( jr )
503 sum = acoeff*suma - dconjg( bcoeff )*sumb
509 d = dconjg( acoeff*s( j, j )-bcoeff*p( j, j ) )
510 IF( abs1( d ).LE.dmin )
513 IF( abs1( d ).LT.one )
THEN
514 IF( abs1( sum ).GE.bignum*abs1( d ) )
THEN
515 temp = one / abs1( sum )
517 work( jr ) = temp*work( jr )
523 work( j ) = zladiv( -sum, d )
524 xmax = max( xmax, abs1( work( j ) ) )
530 CALL zgemv(
'N', n, n+1-je, cone, vl( 1, je ), ldvl,
531 $ work( je ), 1, czero, work( n+1 ), 1 )
543 xmax = max( xmax, abs1( work( ( isrc-1 )*n+jr ) ) )
546 IF( xmax.GT.safmin )
THEN
549 vl( jr, ieig ) = temp*work( ( isrc-1 )*n+jr )
555 DO 130 jr = 1, ibeg - 1
556 vl( jr, ieig ) = czero
574 ilcomp =
SELECT( je )
579 IF( abs1( s( je, je ) ).LE.safmin .AND.
580 $ abs( dble( p( je, je ) ) ).LE.safmin )
THEN
585 vr( jr, ieig ) = czero
587 vr( ieig, ieig ) = cone
596 temp = one / max( abs1( s( je, je ) )*ascale,
597 $ abs( dble( p( je, je ) ) )*bscale, safmin )
598 salpha = ( temp*s( je, je ) )*ascale
599 sbeta = ( temp*dble( p( je, je ) ) )*bscale
600 acoeff = sbeta*ascale
601 bcoeff = salpha*bscale
605 lsa = abs( sbeta ).GE.safmin .AND. abs( acoeff ).LT.small
606 lsb = abs1( salpha ).GE.safmin .AND. abs1( bcoeff ).LT.
611 $ scale = ( small / abs( sbeta ) )*min( anorm, big )
613 $ scale = max( scale, ( small / abs1( salpha ) )*
614 $ min( bnorm, big ) )
615 IF( lsa .OR. lsb )
THEN
616 scale = min( scale, one /
617 $ ( safmin*max( one, abs( acoeff ),
618 $ abs1( bcoeff ) ) ) )
620 acoeff = ascale*( scale*sbeta )
622 acoeff = scale*acoeff
625 bcoeff = bscale*( scale*salpha )
627 bcoeff = scale*bcoeff
631 acoefa = abs( acoeff )
632 bcoefa = abs1( bcoeff )
638 dmin = max( ulp*acoefa*anorm, ulp*bcoefa*bnorm, safmin )
645 DO 170 jr = 1, je - 1
646 work( jr ) = acoeff*s( jr, je ) - bcoeff*p( jr, je )
650 DO 210 j = je - 1, 1, -1
655 d = acoeff*s( j, j ) - bcoeff*p( j, j )
656 IF( abs1( d ).LE.dmin )
659 IF( abs1( d ).LT.one )
THEN
660 IF( abs1( work( j ) ).GE.bignum*abs1( d ) )
THEN
661 temp = one / abs1( work( j ) )
663 work( jr ) = temp*work( jr )
668 work( j ) = zladiv( -work( j ), d )
674 IF( abs1( work( j ) ).GT.one )
THEN
675 temp = one / abs1( work( j ) )
676 IF( acoefa*rwork( j )+bcoefa*rwork( n+j ).GE.
679 work( jr ) = temp*work( jr )
684 ca = acoeff*work( j )
685 cb = bcoeff*work( j )
687 work( jr ) = work( jr ) + ca*s( jr, j ) -
696 CALL zgemv(
'N', n, je, cone, vr, ldvr, work, 1,
697 $ czero, work( n+1 ), 1 )
709 xmax = max( xmax, abs1( work( ( isrc-1 )*n+jr ) ) )
712 IF( xmax.GT.safmin )
THEN
715 vr( jr, ieig ) = temp*work( ( isrc-1 )*n+jr )
721 DO 240 jr = iend + 1, n
722 vr( jr, ieig ) = czero
subroutine xerbla(srname, info)
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
subroutine ztgevc(side, howmny, select, n, s, lds, p, ldp, vl, ldvl, vr, ldvr, mm, m, work, rwork, info)
ZTGEVC