195 SUBROUTINE zlahqr( 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*16 h( ldh, * ), w( * ), z( ldz, * )
215 parameter( itmax = 30 )
217 parameter( zero = ( 0.0d0, 0.0d0 ),
218 $ one = ( 1.0d0, 0.0d0 ) )
219 DOUBLE PRECISION rzero, rone, half
220 parameter( rzero = 0.0d0, rone = 1.0d0, half = 0.5d0 )
221 DOUBLE PRECISION dat1
222 parameter( dat1 = 3.0d0 / 4.0d0 )
225 COMPLEX*16 cdum, h11, h11s, h22, sc, sum, t, t1, temp, u,
227 DOUBLE PRECISION aa, ab, ba, bb, h10, h21, rtemp, s, safmax,
228 $ safmin, smlnum, sx, t2, tst, ulp
229 INTEGER i, i1, i2, its, j, jhi, jlo, k, l, m, nh, nz
243 DOUBLE PRECISION cabs1
246 INTRINSIC abs, dble, dconjg, dimag, max, min, sqrt
249 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
259 IF( ilo.EQ.ihi )
THEN
260 w( ilo ) = h( ilo, ilo )
265 DO 10 j = ilo, ihi - 3
270 $ h( ihi, ihi-2 ) = zero
279 DO 20 i = ilo + 1, ihi
280 IF( dimag( h( i, i-1 ) ).NE.rzero )
THEN
284 sc = h( i, i-1 ) / cabs1( h( i, i-1 ) )
285 sc = dconjg( sc ) / abs( sc )
286 h( i, i-1 ) = abs( h( i, i-1 ) )
287 CALL
zscal( jhi-i+1, sc, h( i, i ), ldh )
288 CALL
zscal( min( jhi, i+1 )-jlo+1, dconjg( sc ),
291 $ CALL
zscal( ihiz-iloz+1, dconjg( sc ), z( iloz, i ), 1 )
300 safmin =
dlamch(
'SAFE MINIMUM' )
301 safmax = rone / safmin
302 CALL
dlabad( safmin, safmax )
303 ulp =
dlamch(
'PRECISION' )
304 smlnum = safmin*( dble( nh ) / ulp )
331 DO 130 its = 0, itmax
335 DO 40 k = i, l + 1, -1
336 IF( cabs1( h( k, k-1 ) ).LE.smlnum )
338 tst = cabs1( h( k-1, k-1 ) ) + cabs1( h( k, k ) )
339 IF( tst.EQ.zero )
THEN
341 $ tst = tst + abs( dble( h( k-1, k-2 ) ) )
343 $ tst = tst + abs( dble( h( k+1, k ) ) )
349 IF( abs( dble( h( k, k-1 ) ) ).LE.ulp*tst )
THEN
350 ab = max( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
351 ba = min( cabs1( h( k, k-1 ) ), cabs1( h( k-1, k ) ) )
352 aa = max( cabs1( h( k, k ) ),
353 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
354 bb = min( cabs1( h( k, k ) ),
355 $ cabs1( h( k-1, k-1 )-h( k, k ) ) )
357 IF( ba*( ab / s ).LE.max( smlnum,
358 $ ulp*( bb*( aa / s ) ) ) )go to 50
379 IF( .NOT.wantt )
THEN
388 s = dat1*abs( dble( h( l+1, l ) ) )
390 ELSE IF( its.EQ.20 )
THEN
394 s = dat1*abs( dble( h( i, i-1 ) ) )
401 u = sqrt( h( i-1, i ) )*sqrt( h( i, i-1 ) )
403 IF( s.NE.rzero )
THEN
404 x = half*( h( i-1, i-1 )-t )
406 s = max( s, cabs1( x ) )
407 y = s*sqrt( ( x / s )**2+( u / s )**2 )
408 IF( sx.GT.rzero )
THEN
409 IF( dble( x / sx )*dble( y )+dimag( x / sx )*
410 $ dimag( y ).LT.rzero )y = -y
412 t = t - u*
zladiv( u, ( x+y ) )
418 DO 60 m = i - 1, l + 1, -1
427 h21 = dble( h( m+1, m ) )
428 s = cabs1( h11s ) + abs( h21 )
433 h10 = dble( h( m, m-1 ) )
434 IF( abs( h10 )*abs( h21 ).LE.ulp*
435 $ ( cabs1( h11s )*( cabs1( h11 )+cabs1( h22 ) ) ) )
441 h21 = dble( h( l+1, l ) )
442 s = cabs1( h11s ) + abs( h21 )
466 $ CALL
zcopy( 2, h( k, k-1 ), 1, v, 1 )
467 CALL
zlarfg( 2, v( 1 ), v( 2 ), 1, t1 )
479 sum = dconjg( t1 )*h( k, j ) + t2*h( k+1, j )
480 h( k, j ) = h( k, j ) - sum
481 h( k+1, j ) = h( k+1, j ) - sum*v2
487 DO 90 j = i1, min( k+2, i )
488 sum = t1*h( j, k ) + t2*h( j, k+1 )
489 h( j, k ) = h( j, k ) - sum
490 h( j, k+1 ) = h( j, k+1 ) - sum*dconjg( v2 )
497 DO 100 j = iloz, ihiz
498 sum = t1*z( j, k ) + t2*z( j, k+1 )
499 z( j, k ) = z( j, k ) - sum
500 z( j, k+1 ) = z( j, k+1 ) - sum*dconjg( v2 )
504 IF( k.EQ.m .AND. m.GT.l )
THEN
512 temp = temp / abs( temp )
513 h( m+1, m ) = h( m+1, m )*dconjg( temp )
515 $ h( m+2, m+1 ) = h( m+2, m+1 )*temp
519 $ CALL
zscal( i2-j, temp, h( j, j+1 ), ldh )
520 CALL
zscal( j-i1, dconjg( temp ), h( i1, j ), 1 )
522 CALL
zscal( nz, dconjg( temp ), z( iloz, j ),
533 IF( dimag( temp ).NE.rzero )
THEN
538 $ CALL
zscal( i2-i, dconjg( temp ), h( i, i+1 ), ldh )
539 CALL
zscal( i-i1, temp, h( i1, i ), 1 )
541 CALL
zscal( nz, temp, z( iloz, i ), 1 )