191 SUBROUTINE zlahqr( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
192 $ IHIZ, Z, LDZ, INFO )
200 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, N
204 COMPLEX*16 H( LDH, * ), W( * ), Z( LDZ, * )
211 parameter( zero = ( 0.0d0, 0.0d0 ),
212 $ one = ( 1.0d0, 0.0d0 ) )
213 DOUBLE PRECISION RZERO, RONE, HALF
214 parameter( rzero = 0.0d0, rone = 1.0d0, half = 0.5d0 )
215 DOUBLE PRECISION DAT1
216 parameter( dat1 = 3.0d0 / 4.0d0 )
218 parameter( kexsh = 10 )
221 COMPLEX*16 CDUM, H11, H11S, H22, SC, SUM, T, T1, TEMP, U,
223 DOUBLE PRECISION AA, AB, BA, BB, H10, H21, RTEMP, S, SAFMAX,
224 $ safmin, smlnum, sx, t2, tst, ulp
225 INTEGER I, I1, I2, ITS, ITMAX, J, JHI, JLO, K, L, M,
233 DOUBLE PRECISION DLAMCH
234 EXTERNAL zladiv, dlamch
240 DOUBLE PRECISION CABS1
243 INTRINSIC abs, dble, dconjg, dimag, max, min, sqrt
246 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
256 IF( ilo.EQ.ihi )
THEN
257 w( ilo ) = h( ilo, ilo )
262 DO 10 j = ilo, ihi - 3
267 $ h( ihi, ihi-2 ) = zero
276 DO 20 i = ilo + 1, ihi
277 IF( dimag( h( i, i-1 ) ).NE.rzero )
THEN
281 sc = h( i, i-1 ) / cabs1( h( i, i-1 ) )
282 sc = dconjg( sc ) / abs( sc )
283 h( i, i-1 ) = abs( h( i, i-1 ) )
284 CALL zscal( jhi-i+1, sc, h( i, i ), ldh )
285 CALL zscal( min( jhi, i+1 )-jlo+1, dconjg( sc ),
288 $
CALL zscal( ihiz-iloz+1, dconjg( sc ), z( iloz, i ),
298 safmin = dlamch(
'SAFE MINIMUM' )
299 safmax = rone / safmin
300 ulp = dlamch(
'PRECISION' )
301 smlnum = safmin*( dble( nh ) / ulp )
314 itmax = 30 * max( 10, nh )
336 DO 130 its = 0, itmax
340 DO 40 k = i, l + 1, -1
341 IF( cabs1( h( k, k-1 ) ).LE.smlnum )
343 tst = cabs1( h( k-1, k-1 ) ) + cabs1( h( k, k ) )
344 IF( tst.EQ.zero )
THEN
346 $ tst = tst + abs( dble( h( k-1, k-2 ) ) )
348 $ tst = tst + abs( dble( h( k+1, k ) ) )
354 IF( abs( dble( h( k, k-1 ) ) ).LE.ulp*tst )
THEN
355 ab = max( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
356 ba = min( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
357 aa = max( cabs1( h( k, k ) ),
358 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
359 bb = min( cabs1( h( k, k ) ),
360 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
362 IF( ba*( ab / s ).LE.max( smlnum,
363 $ ulp*( bb*( aa / s ) ) ) )
GO TO 50
385 IF( .NOT.wantt )
THEN
390 IF( mod(kdefl,2*kexsh).EQ.0 )
THEN
394 s = dat1*abs( dble( h( i, i-1 ) ) )
396 ELSE IF( mod(kdefl,kexsh).EQ.0 )
THEN
400 s = dat1*abs( dble( h( l+1, l ) ) )
407 u = sqrt( h( i-1, i ) )*sqrt( h( i, i-1 ) )
409 IF( s.NE.rzero )
THEN
410 x = half*( h( i-1, i-1 )-t )
412 s = max( s, cabs1( x ) )
413 y = s*sqrt( ( x / s )**2+( u / s )**2 )
414 IF( sx.GT.rzero )
THEN
415 IF( dble( x / sx )*dble( y )+dimag( x / sx )*
416 $ dimag( y ).LT.rzero )y = -y
418 t = t - u*zladiv( u, ( x+y ) )
424 DO 60 m = i - 1, l + 1, -1
433 h21 = dble( h( m+1, m ) )
434 s = cabs1( h11s ) + abs( h21 )
439 h10 = dble( h( m, m-1 ) )
440 IF( abs( h10 )*abs( h21 ).LE.ulp*
441 $ ( cabs1( h11s )*( cabs1( h11 )+cabs1( h22 ) ) ) )
447 h21 = dble( h( l+1, l ) )
448 s = cabs1( h11s ) + abs( h21 )
472 $
CALL zcopy( 2, h( k, k-1 ), 1, v, 1 )
473 CALL zlarfg( 2, v( 1 ), v( 2 ), 1, t1 )
485 sum = dconjg( t1 )*h( k, j ) + t2*h( k+1, j )
486 h( k, j ) = h( k, j ) - sum
487 h( k+1, j ) = h( k+1, j ) - sum*v2
493 DO 90 j = i1, min( k+2, i )
494 sum = t1*h( j, k ) + t2*h( j, k+1 )
495 h( j, k ) = h( j, k ) - sum
496 h( j, k+1 ) = h( j, k+1 ) - sum*dconjg( v2 )
503 DO 100 j = iloz, ihiz
504 sum = t1*z( j, k ) + t2*z( j, k+1 )
505 z( j, k ) = z( j, k ) - sum
506 z( j, k+1 ) = z( j, k+1 ) - sum*dconjg( v2 )
510 IF( k.EQ.m .AND. m.GT.l )
THEN
518 temp = temp / abs( temp )
519 h( m+1, m ) = h( m+1, m )*dconjg( temp )
521 $ h( m+2, m+1 ) = h( m+2, m+1 )*temp
525 $
CALL zscal( i2-j, temp, h( j, j+1 ), ldh )
526 CALL zscal( j-i1, dconjg( temp ), h( i1, j ),
529 CALL zscal( nz, dconjg( temp ), z( iloz, j ),
540 IF( dimag( temp ).NE.rzero )
THEN
545 $
CALL zscal( i2-i, dconjg( temp ), h( i, i+1 ), ldh )
546 CALL zscal( i-i1, temp, h( i1, i ), 1 )
548 CALL zscal( nz, temp, z( iloz, i ), 1 )