242 SUBROUTINE ctrevc3( 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
257 COMPLEX T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ),
265 parameter( zero = 0.0e+0, one = 1.0e+0 )
267 parameter( czero = ( 0.0e+0, 0.0e+0 ),
268 $ cone = ( 1.0e+0, 0.0e+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 REAL OVFL, REMAX, SCALE, SMIN, SMLNUM, ULP, UNFL
280 INTEGER ILAENV, ICAMAX
281 REAL SLAMCH, SCASUM, SROUNDUP_LWORK
282 EXTERNAL lsame, ilaenv, icamax, slamch, scasum,
290 INTRINSIC abs, real, cmplx, conjg, aimag, max
296 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
302 bothv = lsame( side,
'B' )
303 rightv = lsame( side,
'R' ) .OR. bothv
304 leftv = lsame( side,
'L' ) .OR. bothv
306 allv = lsame( howmny,
'A' )
307 over = lsame( howmny,
'B' )
308 somev = lsame( howmny,
'S' )
324 nb = ilaenv( 1,
'CTREVC', side // howmny, n, -1, -1, -1 )
325 maxwrk = max( 1, n + 2*n*nb )
326 work(1) = sroundup_lwork(maxwrk)
327 rwork(1) = max( 1, n )
328 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 )
329 IF( .NOT.rightv .AND. .NOT.leftv )
THEN
331 ELSE IF( .NOT.allv .AND. .NOT.over .AND. .NOT.somev )
THEN
333 ELSE IF( n.LT.0 )
THEN
335 ELSE IF( ldt.LT.max( 1, n ) )
THEN
337 ELSE IF( ldvl.LT.1 .OR. ( leftv .AND. ldvl.LT.n ) )
THEN
339 ELSE IF( ldvr.LT.1 .OR. ( rightv .AND. ldvr.LT.n ) )
THEN
341 ELSE IF( mm.LT.m )
THEN
343 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery )
THEN
345 ELSE IF ( lrwork.LT.max( 1, n ) .AND. .NOT.lquery )
THEN
349 CALL xerbla(
'CTREVC3', -info )
351 ELSE IF( lquery )
THEN
363 IF( over .AND. lwork .GE. n + 2*n*nbmin )
THEN
364 nb = (lwork - n) / (2*n)
365 nb = min( nb, nbmax )
366 CALL claset(
'F', n, 1+2*nb, czero, czero, work, n )
373 unfl = slamch(
'Safe minimum' )
375 ulp = slamch(
'Precision' )
376 smlnum = unfl*( n / ulp )
381 work( i ) = t( i, i )
389 rwork( j ) = scasum( j-1, t( 1, j ), 1 )
405 IF( .NOT.
SELECT( ki ) )
408 smin = max( ulp*( cabs1( t( ki, ki ) ) ), smlnum )
413 work( ki + iv*n ) = cone
418 work( k + iv*n ) = -t( k, ki )
425 t( k, k ) = t( k, k ) - t( ki, ki )
426 IF( cabs1( t( k, k ) ).LT.smin )
431 CALL clatrs(
'Upper',
'No transpose',
'Non-unit',
'Y',
432 $ ki-1, t, ldt, work( 1 + iv*n ), scale,
434 work( ki + iv*n ) = scale
442 CALL ccopy( ki, work( 1 + iv*n ), 1, vr( 1, is ), 1 )
444 ii = icamax( ki, vr( 1, is ), 1 )
445 remax = one / cabs1( vr( ii, is ) )
446 CALL csscal( ki, remax, vr( 1, is ), 1 )
452 ELSE IF( nb.EQ.1 )
THEN
456 $
CALL cgemv(
'N', n, ki-1, cone, vr, ldvr,
457 $ work( 1 + iv*n ), 1, cmplx( scale ),
460 ii = icamax( n, vr( 1, ki ), 1 )
461 remax = one / cabs1( vr( ii, ki ) )
462 CALL csscal( n, remax, vr( 1, ki ), 1 )
469 work( k + iv*n ) = czero
475 IF( (iv.EQ.1) .OR. (ki.EQ.1) )
THEN
476 CALL cgemm(
'N',
'N', n, nb-iv+1, ki+nb-iv, cone,
478 $ work( 1 + (iv)*n ), n,
480 $ work( 1 + (nb+iv)*n ), n )
483 ii = icamax( n, work( 1 + (nb+k)*n ), 1 )
484 remax = one / cabs1( work( ii + (nb+k)*n ) )
485 CALL csscal( n, remax, work( 1 + (nb+k)*n ), 1 )
487 CALL clacpy(
'F', n, nb-iv+1,
488 $ work( 1 + (nb+iv)*n ), n,
489 $ vr( 1, ki ), ldvr )
499 t( k, k ) = work( k )
520 IF( .NOT.
SELECT( ki ) )
523 smin = max( ulp*( cabs1( t( ki, ki ) ) ), smlnum )
528 work( ki + iv*n ) = cone
533 work( k + iv*n ) = -conjg( t( ki, k ) )
540 t( k, k ) = t( k, k ) - t( ki, ki )
541 IF( cabs1( t( k, k ) ).LT.smin )
546 CALL clatrs(
'Upper',
'Conjugate transpose',
'Non-unit',
547 $
'Y', n-ki, t( ki+1, ki+1 ), ldt,
548 $ work( ki+1 + iv*n ), scale, rwork, info )
549 work( ki + iv*n ) = scale
557 CALL ccopy( n-ki+1, work( ki + iv*n ), 1, vl(ki,is), 1 )
559 ii = icamax( n-ki+1, vl( ki, is ), 1 ) + ki - 1
560 remax = one / cabs1( vl( ii, is ) )
561 CALL csscal( n-ki+1, remax, vl( ki, is ), 1 )
567 ELSE IF( nb.EQ.1 )
THEN
571 $
CALL cgemv(
'N', n, n-ki, cone, vl( 1, ki+1 ), ldvl,
572 $ work( ki+1 + iv*n ), 1, cmplx( scale ),
575 ii = icamax( n, vl( 1, ki ), 1 )
576 remax = one / cabs1( vl( ii, ki ) )
577 CALL csscal( n, remax, vl( 1, ki ), 1 )
585 work( k + iv*n ) = czero
591 IF( (iv.EQ.nb) .OR. (ki.EQ.n) )
THEN
592 CALL cgemm(
'N',
'N', n, iv, n-ki+iv, cone,
593 $ vl( 1, ki-iv+1 ), ldvl,
594 $ work( ki-iv+1 + (1)*n ), n,
596 $ work( 1 + (nb+1)*n ), n )
599 ii = icamax( n, work( 1 + (nb+k)*n ), 1 )
600 remax = one / cabs1( work( ii + (nb+k)*n ) )
601 CALL csscal( n, remax, work( 1 + (nb+k)*n ), 1 )
604 $ work( 1 + (nb+1)*n ), n,
605 $ vl( 1, ki-iv+1 ), ldvl )
615 t( k, k ) = work( k )
subroutine xerbla(srname, info)
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
subroutine cgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
CGEMV
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine clatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine csscal(n, sa, cx, incx)
CSSCAL
subroutine ctrevc3(side, howmny, select, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, lwork, rwork, lrwork, info)
CTREVC3