242 SUBROUTINE ztrevc3( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR,
243 $ LDVR, MM, M, WORK, LWORK, RWORK, LRWORK, INFO)
251 CHARACTER HOWMNY, SIDE
252 INTEGER INFO, LDT, LDVL, LDVR, LWORK, LRWORK, M, MM, N
256 DOUBLE PRECISION RWORK( * )
257 COMPLEX*16 T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),
264 DOUBLE PRECISION ZERO, ONE
265 parameter( zero = 0.0d+0, one = 1.0d+0 )
266 COMPLEX*16 CZERO, CONE
267 parameter( czero = ( 0.0d+0, 0.0d+0 ),
268 $ cone = ( 1.0d+0, 0.0d+0 ) )
270 parameter( nbmin = 8, nbmax = 128 )
273 LOGICAL ALLV, BOTHV, LEFTV, LQUERY, OVER, RIGHTV, SOMEV
274 INTEGER I, II, IS, J, K, KI, IV, MAXWRK, NB
275 DOUBLE PRECISION OVFL, REMAX, SCALE, SMIN, SMLNUM, ULP, UNFL
280 INTEGER ILAENV, IZAMAX
281 DOUBLE PRECISION DLAMCH, DZASUM
282 EXTERNAL lsame, ilaenv, izamax, dlamch, dzasum
289 INTRINSIC abs, dble, dcmplx, conjg, dimag, max
292 DOUBLE PRECISION CABS1
295 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
301 bothv = lsame( side,
'B' )
302 rightv = lsame( side,
'R' ) .OR. bothv
303 leftv = lsame( side,
'L' ) .OR. bothv
305 allv = lsame( howmny,
'A' )
306 over = lsame( howmny,
'B' )
307 somev = lsame( howmny,
'S' )
323 nb = ilaenv( 1,
'ZTREVC', side // howmny, n, -1, -1, -1 )
324 maxwrk = max( 1, n + 2*n*nb )
326 rwork(1) = max( 1, n )
327 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 )
328 IF( .NOT.rightv .AND. .NOT.leftv )
THEN
330 ELSE IF( .NOT.allv .AND. .NOT.over .AND. .NOT.somev )
THEN
332 ELSE IF( n.LT.0 )
THEN
334 ELSE IF( ldt.LT.max( 1, n ) )
THEN
336 ELSE IF( ldvl.LT.1 .OR. ( leftv .AND. ldvl.LT.n ) )
THEN
338 ELSE IF( ldvr.LT.1 .OR. ( rightv .AND. ldvr.LT.n ) )
THEN
340 ELSE IF( mm.LT.m )
THEN
342 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery )
THEN
344 ELSE IF ( lrwork.LT.max( 1, n ) .AND. .NOT.lquery )
THEN
348 CALL xerbla(
'ZTREVC3', -info )
350 ELSE IF( lquery )
THEN
362 IF( over .AND. lwork .GE. n + 2*n*nbmin )
THEN
363 nb = (lwork - n) / (2*n)
364 nb = min( nb, nbmax )
365 CALL zlaset(
'F', n, 1+2*nb, czero, czero, work, n )
372 unfl = dlamch(
'Safe minimum' )
374 ulp = dlamch(
'Precision' )
375 smlnum = unfl*( n / ulp )
380 work( i ) = t( i, i )
388 rwork( j ) = dzasum( j-1, t( 1, j ), 1 )
404 IF( .NOT.
SELECT( ki ) )
407 smin = max( ulp*( cabs1( t( ki, ki ) ) ), smlnum )
412 work( ki + iv*n ) = cone
417 work( k + iv*n ) = -t( k, ki )
424 t( k, k ) = t( k, k ) - t( ki, ki )
425 IF( cabs1( t( k, k ) ).LT.smin )
430 CALL zlatrs(
'Upper',
'No transpose',
'Non-unit',
'Y',
431 $ ki-1, t, ldt, work( 1 + iv*n ), scale,
433 work( ki + iv*n ) = scale
441 CALL zcopy( ki, work( 1 + iv*n ), 1, vr( 1, is ), 1 )
443 ii = izamax( ki, vr( 1, is ), 1 )
444 remax = one / cabs1( vr( ii, is ) )
445 CALL zdscal( ki, remax, vr( 1, is ), 1 )
451 ELSE IF( nb.EQ.1 )
THEN
455 $
CALL zgemv(
'N', n, ki-1, cone, vr, ldvr,
456 $ work( 1 + iv*n ), 1, dcmplx( scale ),
459 ii = izamax( n, vr( 1, ki ), 1 )
460 remax = one / cabs1( vr( ii, ki ) )
461 CALL zdscal( n, remax, vr( 1, ki ), 1 )
468 work( k + iv*n ) = czero
474 IF( (iv.EQ.1) .OR. (ki.EQ.1) )
THEN
475 CALL zgemm(
'N',
'N', n, nb-iv+1, ki+nb-iv, cone,
477 $ work( 1 + (iv)*n ), n,
479 $ work( 1 + (nb+iv)*n ), n )
482 ii = izamax( n, work( 1 + (nb+k)*n ), 1 )
483 remax = one / cabs1( work( ii + (nb+k)*n ) )
484 CALL zdscal( n, remax, work( 1 + (nb+k)*n ), 1 )
486 CALL zlacpy(
'F', n, nb-iv+1,
487 $ work( 1 + (nb+iv)*n ), n,
488 $ vr( 1, ki ), ldvr )
498 t( k, k ) = work( k )
519 IF( .NOT.
SELECT( ki ) )
522 smin = max( ulp*( cabs1( t( ki, ki ) ) ), smlnum )
527 work( ki + iv*n ) = cone
532 work( k + iv*n ) = -conjg( t( ki, k ) )
539 t( k, k ) = t( k, k ) - t( ki, ki )
540 IF( cabs1( t( k, k ) ).LT.smin )
545 CALL zlatrs(
'Upper',
'Conjugate transpose',
'Non-unit',
546 $
'Y', n-ki, t( ki+1, ki+1 ), ldt,
547 $ work( ki+1 + iv*n ), scale, rwork, info )
548 work( ki + iv*n ) = scale
556 CALL zcopy( n-ki+1, work( ki + iv*n ), 1, vl(ki,is), 1 )
558 ii = izamax( n-ki+1, vl( ki, is ), 1 ) + ki - 1
559 remax = one / cabs1( vl( ii, is ) )
560 CALL zdscal( n-ki+1, remax, vl( ki, is ), 1 )
566 ELSE IF( nb.EQ.1 )
THEN
570 $
CALL zgemv(
'N', n, n-ki, cone, vl( 1, ki+1 ), ldvl,
571 $ work( ki+1 + iv*n ), 1, dcmplx( scale ),
574 ii = izamax( n, vl( 1, ki ), 1 )
575 remax = one / cabs1( vl( ii, ki ) )
576 CALL zdscal( n, remax, vl( 1, ki ), 1 )
584 work( k + iv*n ) = czero
590 IF( (iv.EQ.nb) .OR. (ki.EQ.n) )
THEN
591 CALL zgemm(
'N',
'N', n, iv, n-ki+iv, cone,
592 $ vl( 1, ki-iv+1 ), ldvl,
593 $ work( ki-iv+1 + (1)*n ), n,
595 $ work( 1 + (nb+1)*n ), n )
598 ii = izamax( n, work( 1 + (nb+k)*n ), 1 )
599 remax = one / cabs1( work( ii + (nb+k)*n ) )
600 CALL zdscal( n, remax, work( 1 + (nb+k)*n ), 1 )
603 $ work( 1 + (nb+1)*n ), n,
604 $ vl( 1, ki-iv+1 ), ldvl )
614 t( k, k ) = work( k )
subroutine xerbla(srname, info)
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
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 zlatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
ZLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine ztrevc3(side, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, lwork, rwork, lrwork, info)
ZTREVC3