193 SUBROUTINE clahqr( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
194 $ IHIZ, Z, LDZ, INFO )
202 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, N
206 COMPLEX H( LDH, * ), W( * ), Z( LDZ, * )
213 parameter( zero = ( 0.0e0, 0.0e0 ),
214 $ one = ( 1.0e0, 0.0e0 ) )
215 REAL RZERO, RONE, HALF
216 parameter( rzero = 0.0e0, rone = 1.0e0, half = 0.5e0 )
218 parameter( dat1 = 3.0e0 / 4.0e0 )
220 parameter( kexsh = 10 )
223 COMPLEX CDUM, H11, H11S, H22, SC, SUM, T, T1, TEMP, U,
225 REAL AA, AB, BA, BB, H10, H21, RTEMP, S, SAFMAX,
226 $ safmin, smlnum, sx, t2, tst, ulp
227 INTEGER I, I1, I2, ITS, ITMAX, J, JHI, JLO, K, L, M,
236 EXTERNAL cladiv, slamch
245 INTRINSIC abs, aimag, conjg, max, min, real, sqrt
248 cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
258 IF( ilo.EQ.ihi )
THEN
259 w( ilo ) = h( ilo, ilo )
264 DO 10 j = ilo, ihi - 3
269 $ h( ihi, ihi-2 ) = zero
278 DO 20 i = ilo + 1, ihi
279 IF( aimag( h( i, i-1 ) ).NE.rzero )
THEN
283 sc = h( i, i-1 ) / cabs1( h( i, i-1 ) )
284 sc = conjg( sc ) / abs( sc )
285 h( i, i-1 ) = abs( h( i, i-1 ) )
286 CALL cscal( jhi-i+1, sc, h( i, i ), ldh )
287 CALL cscal( min( jhi, i+1 )-jlo+1, conjg( sc ), h( jlo, i ),
290 $
CALL cscal( ihiz-iloz+1, conjg( sc ), z( iloz, i ), 1 )
299 safmin = slamch(
'SAFE MINIMUM' )
300 safmax = rone / safmin
301 ulp = slamch(
'PRECISION' )
302 smlnum = safmin*( real( nh ) / ulp )
315 itmax = 30 * max( 10, nh )
337 DO 130 its = 0, itmax
341 DO 40 k = i, l + 1, -1
342 IF( cabs1( h( k, k-1 ) ).LE.smlnum )
344 tst = cabs1( h( k-1, k-1 ) ) + cabs1( h( k, k ) )
345 IF( tst.EQ.zero )
THEN
347 $ tst = tst + abs( real( h( k-1, k-2 ) ) )
349 $ tst = tst + abs( real( h( k+1, k ) ) )
355 IF( abs( real( h( k, k-1 ) ) ).LE.ulp*tst )
THEN
356 ab = max( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
357 ba = min( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
358 aa = max( cabs1( h( k, k ) ),
359 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
360 bb = min( cabs1( h( k, k ) ),
361 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
363 IF( ba*( ab / s ).LE.max( smlnum,
364 $ ulp*( bb*( aa / s ) ) ) )
GO TO 50
386 IF( .NOT.wantt )
THEN
391 IF( mod(kdefl,2*kexsh).EQ.0 )
THEN
395 s = dat1*abs( real( h( i, i-1 ) ) )
397 ELSE IF( mod(kdefl,kexsh).EQ.0 )
THEN
401 s = dat1*abs( real( h( l+1, l ) ) )
408 u = sqrt( h( i-1, i ) )*sqrt( h( i, i-1 ) )
410 IF( s.NE.rzero )
THEN
411 x = half*( h( i-1, i-1 )-t )
413 s = max( s, cabs1( x ) )
414 y = s*sqrt( ( x / s )**2+( u / s )**2 )
415 IF( sx.GT.rzero )
THEN
416 IF( real( x / sx )*real( y )+aimag( x / sx )*
417 $ aimag( y ).LT.rzero )y = -y
419 t = t - u*cladiv( u, ( x+y ) )
425 DO 60 m = i - 1, l + 1, -1
434 h21 = real( h( m+1, m ) )
435 s = cabs1( h11s ) + abs( h21 )
440 h10 = real( h( m, m-1 ) )
441 IF( abs( h10 )*abs( h21 ).LE.ulp*
442 $ ( cabs1( h11s )*( cabs1( h11 )+cabs1( h22 ) ) ) )
448 h21 = real( h( l+1, l ) )
449 s = cabs1( h11s ) + abs( h21 )
473 $
CALL ccopy( 2, h( k, k-1 ), 1, v, 1 )
474 CALL clarfg( 2, v( 1 ), v( 2 ), 1, t1 )
486 sum = conjg( t1 )*h( k, j ) + t2*h( k+1, j )
487 h( k, j ) = h( k, j ) - sum
488 h( k+1, j ) = h( k+1, j ) - sum*v2
494 DO 90 j = i1, min( k+2, i )
495 sum = t1*h( j, k ) + t2*h( j, k+1 )
496 h( j, k ) = h( j, k ) - sum
497 h( j, k+1 ) = h( j, k+1 ) - sum*conjg( v2 )
504 DO 100 j = iloz, ihiz
505 sum = t1*z( j, k ) + t2*z( j, k+1 )
506 z( j, k ) = z( j, k ) - sum
507 z( j, k+1 ) = z( j, k+1 ) - sum*conjg( v2 )
511 IF( k.EQ.m .AND. m.GT.l )
THEN
519 temp = temp / abs( temp )
520 h( m+1, m ) = h( m+1, m )*conjg( temp )
522 $ h( m+2, m+1 ) = h( m+2, m+1 )*temp
526 $
CALL cscal( i2-j, temp, h( j, j+1 ), ldh )
527 CALL cscal( j-i1, conjg( temp ), h( i1, j ), 1 )
529 CALL cscal( nz, conjg( temp ), z( iloz, j ), 1 )
539 IF( aimag( temp ).NE.rzero )
THEN
544 $
CALL cscal( i2-i, conjg( temp ), h( i, i+1 ), ldh )
545 CALL cscal( i-i1, temp, h( i1, i ), 1 )
547 CALL cscal( nz, temp, z( iloz, i ), 1 )
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine clahqr(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, info)
CLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
subroutine clarfg(n, alpha, x, incx, tau)
CLARFG generates an elementary reflector (Householder matrix).
subroutine cscal(n, ca, cx, incx)
CSCAL