195 SUBROUTINE clahqr( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
196 $ ihiz, z, ldz, info )
204 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, N
208 COMPLEX H( ldh, * ), W( * ), Z( ldz, * )
215 parameter ( zero = ( 0.0e0, 0.0e0 ),
216 $ one = ( 1.0e0, 0.0e0 ) )
217 REAL RZERO, RONE, HALF
218 parameter ( rzero = 0.0e0, rone = 1.0e0, half = 0.5e0 )
220 parameter ( dat1 = 3.0e0 / 4.0e0 )
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 CALL slabad( safmin, safmax )
302 ulp = slamch(
'PRECISION' )
303 smlnum = safmin*(
REAL( NH ) / ULP )
316 itmax = 30 * max( 10, nh )
334 DO 130 its = 0, itmax
338 DO 40 k = i, l + 1, -1
339 IF( cabs1( h( k, k-1 ) ).LE.smlnum )
341 tst = cabs1( h( k-1, k-1 ) ) + cabs1( h( k, k ) )
342 IF( tst.EQ.zero )
THEN
344 $ tst = tst + abs(
REAL( H( K-1, K-2 ) ) )
346 $ tst = tst + abs(
REAL( H( K+1, K ) ) )
352 IF( abs(
REAL( H( K, K-1 ) ) ).LE.ulp*tst ) then
353 ab = max( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
354 ba = min( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
355 aa = max( cabs1( h( k, k ) ),
356 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
357 bb = min( cabs1( h( k, k ) ),
358 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
360 IF( ba*( ab / s ).LE.max( smlnum,
361 $ ulp*( bb*( aa / s ) ) ) )
GO TO 50
382 IF( .NOT.wantt )
THEN
391 s = dat1*abs(
REAL( H( L+1, L ) ) )
393 ELSE IF( its.EQ.20 )
THEN
397 s = dat1*abs(
REAL( H( I, I-1 ) ) )
404 u = sqrt( h( i-1, i ) )*sqrt( h( i, i-1 ) )
406 IF( s.NE.rzero )
THEN
407 x = half*( h( i-1, i-1 )-t )
409 s = max( s, cabs1( x ) )
410 y = s*sqrt( ( x / s )**2+( u / s )**2 )
411 IF( sx.GT.rzero )
THEN
412 IF(
REAL( x / sx )*
REAL( y )+AIMAG( x / sx )*
413 $ aimag( y ).LT.rzero )y = -y
415 t = t - u*cladiv( u, ( x+y ) )
421 DO 60 m = i - 1, l + 1, -1
430 h21 =
REAL( H( M+1, M ) )
431 s = cabs1( h11s ) + abs( h21 )
436 h10 =
REAL( H( M, M-1 ) )
437 IF( abs( h10 )*abs( h21 ).LE.ulp*
438 $ ( cabs1( h11s )*( cabs1( h11 )+cabs1( h22 ) ) ) )
444 h21 =
REAL( H( L+1, L ) )
445 s = cabs1( h11s ) + abs( h21 )
469 $
CALL ccopy( 2, h( k, k-1 ), 1, v, 1 )
470 CALL clarfg( 2, v( 1 ), v( 2 ), 1, t1 )
482 sum = conjg( t1 )*h( k, j ) + t2*h( k+1, j )
483 h( k, j ) = h( k, j ) - sum
484 h( k+1, j ) = h( k+1, j ) - sum*v2
490 DO 90 j = i1, min( k+2, i )
491 sum = t1*h( j, k ) + t2*h( j, k+1 )
492 h( j, k ) = h( j, k ) - sum
493 h( j, k+1 ) = h( j, k+1 ) - sum*conjg( v2 )
500 DO 100 j = iloz, ihiz
501 sum = t1*z( j, k ) + t2*z( j, k+1 )
502 z( j, k ) = z( j, k ) - sum
503 z( j, k+1 ) = z( j, k+1 ) - sum*conjg( v2 )
507 IF( k.EQ.m .AND. m.GT.l )
THEN
515 temp = temp / abs( temp )
516 h( m+1, m ) = h( m+1, m )*conjg( temp )
518 $ h( m+2, m+1 ) = h( m+2, m+1 )*temp
522 $
CALL cscal( i2-j, temp, h( j, j+1 ), ldh )
523 CALL cscal( j-i1, conjg( temp ), h( i1, j ), 1 )
525 CALL cscal( nz, conjg( temp ), z( iloz, j ), 1 )
535 IF( aimag( temp ).NE.rzero )
THEN
540 $
CALL cscal( i2-i, conjg( temp ), h( i, i+1 ), ldh )
541 CALL cscal( i-i1, temp, h( i1, i ), 1 )
543 CALL cscal( nz, temp, z( iloz, i ), 1 )
subroutine slabad(SMALL, LARGE)
SLABAD
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, using the double-shift/single-shift QR algorithm.
subroutine cscal(N, CA, CX, INCX)
CSCAL
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
subroutine clarfg(N, ALPHA, X, INCX, TAU)
CLARFG generates an elementary reflector (Householder matrix).