1 SUBROUTINE dlahqr( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
2 $ ILOZ, IHIZ, Z, LDZ, INFO )
11 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, N
14 DOUBLE PRECISION H( LDH, * ), WI( * ), WR( * ), Z( LDZ, * )
102 DOUBLE PRECISION ZERO, ONE, HALF
103 parameter( zero = 0.0d+0, one = 1.0d+0, half = 0.5d0 )
104 DOUBLE PRECISION DAT1, DAT2
105 parameter( dat1 = 0.75d+0, dat2 = -0.4375d+0 )
108 INTEGER I, I1, I2, ITN, ITS, J, K, L, M, NH, NR, NZ
109 DOUBLE PRECISION AVE, CS, DISC, H00, H10, H11, H12, H21, H22,
110 $ h33, h33s, h43h34, h44, h44s, ovfl, s, smlnum,
111 $ sn, sum, t1, t2, t3, tst1, ulp, unfl, v1, v2,
115 DOUBLE PRECISION V( 3 ), WORK( 1 )
118 DOUBLE PRECISION DLAMCH, DLANHS
119 EXTERNAL dlamch, dlanhs
125 INTRINSIC abs, max, min, sign, sqrt
135 IF( ilo.EQ.ihi )
THEN
136 wr( ilo ) = h( ilo, ilo )
147 unfl = dlamch(
'Safe minimum' )
150 ulp = dlamch(
'Precision' )
151 smlnum = unfl*( nh / ulp )
186 DO 20 k = i, l + 1, -1
187 tst1 = abs( h( k-1, k-1 ) ) + abs( h( k, k ) )
189 $ tst1 = dlanhs(
'1', i-l+1, h( l, l ), ldh, work )
190 IF( abs( h( k, k-1 ) ).LE.max( ulp*tst1, smlnum ) )
211 IF( .NOT.wantt )
THEN
216 IF( its.EQ.10 .OR. its.EQ.20 )
THEN
220 s = abs( h( i, i-1 ) ) + abs( h( i-1, i-2 ) )
221 h44 = dat1*s + h( i, i )
231 h43h34 = h( i, i-1 )*h( i-1, i )
232 s = h( i-1, i-2 )*h( i-1, i-2 )
233 disc = ( h33-h44 )*half
234 disc = disc*disc + h43h34
235 IF( disc.GT.zero )
THEN
240 ave = half*( h33+h44 )
241 IF( abs( h33 )-abs( h44 ).GT.zero )
THEN
242 h33 = h33*h44 - h43h34
243 h44 = h33 / ( sign( disc, ave )+ave )
245 h44 = sign( disc, ave ) + ave
254 DO 40 m = i - 2, l, -1
265 v1 = ( h33s*h44s-h43h34 ) / h21 + h12
266 v2 = h22 - h11 - h33s - h44s
268 s = abs( v1 ) + abs( v2 ) + abs( v3 )
279 tst1 = abs( v1 )*( abs( h00 )+abs( h11 )+abs( h22 ) )
280 IF( abs( h10 )*( abs( v2 )+abs( v3 ) ).LE.ulp*tst1 )
300 $
CALL dcopy( nr, h( k, k-1 ), 1, v, 1 )
301 CALL dlarfg( nr, v( 1 ), v( 2 ), 1, t1 )
306 $ h( k+2, k-1 ) = zero
307 ELSE IF( m.GT.l )
THEN
308 h( k, k-1 ) = -h( k, k-1 )
320 sum = h( k, j ) + v2*h( k+1, j ) + v3*h( k+2, j )
321 h( k, j ) = h( k, j ) - sum*t1
322 h( k+1, j ) = h( k+1, j ) - sum*t2
323 h( k+2, j ) = h( k+2, j ) - sum*t3
329 DO 70 j = i1, min( k+3, i )
330 sum = h( j, k ) + v2*h( j, k+1 ) + v3*h( j, k+2 )
331 h( j, k ) = h( j, k ) - sum*t1
332 h( j, k+1 ) = h( j, k+1 ) - sum*t2
333 h( j, k+2 ) = h( j, k+2 ) - sum*t3
341 sum = z( j, k ) + v2*z( j, k+1 ) + v3*z( j, k+2 )
342 z( j, k ) = z( j, k ) - sum*t1
343 z( j, k+1 ) = z( j, k+1 ) - sum*t2
344 z( j, k+2 ) = z( j, k+2 ) - sum*t3
347 ELSE IF( nr.EQ.2 )
THEN
353 sum = h( k, j ) + v2*h( k+1, j )
354 h( k, j ) = h( k, j ) - sum*t1
355 h( k+1, j ) = h( k+1, j ) - sum*t2
362 sum = h( j, k ) + v2*h( j, k+1 )
363 h( j, k ) = h( j, k ) - sum*t1
364 h( j, k+1 ) = h( j, k+1 ) - sum*t2
371 DO 110 j = iloz, ihiz
372 sum = z( j, k ) + v2*z( j, k+1 )
373 z( j, k ) = z( j, k ) - sum*t1
374 z( j, k+1 ) = z( j, k+1 ) - sum*t2
395 ELSE IF( l.EQ.i-1 )
THEN
402 CALL dlanv2( h( i-1, i-1 ), h( i-1, i ), h( i, i-1 ),
403 $ h( i, i ), wr( i-1 ), wi( i-1 ), wr( i ), wi( i ),
411 $
CALL drot( i2-i, h( i-1, i+1 ), ldh, h( i, i+1 ), ldh,
413 CALL drot( i-i1-1, h( i1, i-1 ), 1, h( i1, i ), 1, cs, sn )
419 CALL drot( nz, z( iloz, i-1 ), 1, z( iloz, i ), 1, cs, sn )
subroutine dcopy(n, dx, incx, dy, incy)
subroutine dlabad(SMALL, LARGE)
subroutine dlahqr(WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, ILOZ, IHIZ, Z, LDZ, INFO)
subroutine dlanv2(A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN)
subroutine dlarfg(N, ALPHA, X, INCX, TAU)
subroutine drot(n, dx, incx, dy, incy, c, s)