193 SUBROUTINE zlahqr( 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*16 H( LDH, * ), W( * ), Z( LDZ, * )
213 parameter( zero = ( 0.0d0, 0.0d0 ),
214 $ one = ( 1.0d0, 0.0d0 ) )
215 DOUBLE PRECISION RZERO, RONE, HALF
216 parameter( rzero = 0.0d0, rone = 1.0d0, half = 0.5d0 )
217 DOUBLE PRECISION DAT1
218 parameter( dat1 = 3.0d0 / 4.0d0 )
220 parameter( kexsh = 10 )
223 COMPLEX*16 CDUM, H11, H11S, H22, SC, SUM, T, T1, TEMP, U,
225 DOUBLE PRECISION 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,
235 DOUBLE PRECISION DLAMCH
236 EXTERNAL zladiv, dlamch
242 DOUBLE PRECISION CABS1
245 INTRINSIC abs, dble, dconjg, dimag, max, min, sqrt
248 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( 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( dimag( h( i, i-1 ) ).NE.rzero )
THEN
283 sc = h( i, i-1 ) / cabs1( h( i, i-1 ) )
284 sc = dconjg( sc ) / abs( sc )
285 h( i, i-1 ) = abs( h( i, i-1 ) )
286 CALL zscal( jhi-i+1, sc, h( i, i ), ldh )
287 CALL zscal( min( jhi, i+1 )-jlo+1, dconjg( sc ),
290 $
CALL zscal( ihiz-iloz+1, dconjg( sc ), z( iloz, i ), 1 )
299 safmin = dlamch(
'SAFE MINIMUM' )
300 safmax = rone / safmin
301 ulp = dlamch(
'PRECISION' )
302 smlnum = safmin*( dble( 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( dble( h( k-1, k-2 ) ) )
349 $ tst = tst + abs( dble( h( k+1, k ) ) )
355 IF( abs( dble( 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( dble( h( i, i-1 ) ) )
397 ELSE IF( mod(kdefl,kexsh).EQ.0 )
THEN
401 s = dat1*abs( dble( 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( dble( x / sx )*dble( y )+dimag( x / sx )*
417 $ dimag( y ).LT.rzero )y = -y
419 t = t - u*zladiv( u, ( x+y ) )
425 DO 60 m = i - 1, l + 1, -1
434 h21 = dble( h( m+1, m ) )
435 s = cabs1( h11s ) + abs( h21 )
440 h10 = dble( h( m, m-1 ) )
441 IF( abs( h10 )*abs( h21 ).LE.ulp*
442 $ ( cabs1( h11s )*( cabs1( h11 )+cabs1( h22 ) ) ) )
448 h21 = dble( h( l+1, l ) )
449 s = cabs1( h11s ) + abs( h21 )
473 $
CALL zcopy( 2, h( k, k-1 ), 1, v, 1 )
474 CALL zlarfg( 2, v( 1 ), v( 2 ), 1, t1 )
486 sum = dconjg( 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*dconjg( 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*dconjg( 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 )*dconjg( temp )
522 $ h( m+2, m+1 ) = h( m+2, m+1 )*temp
526 $
CALL zscal( i2-j, temp, h( j, j+1 ), ldh )
527 CALL zscal( j-i1, dconjg( temp ), h( i1, j ), 1 )
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 )
subroutine zcopy(n, zx, incx, zy, incy)
ZCOPY
subroutine zlahqr(wantt, wantz, n, ilo, ihi, h, ldh, w, iloz, ihiz, z, ldz, info)
ZLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
subroutine zlarfg(n, alpha, x, incx, tau)
ZLARFG generates an elementary reflector (Householder matrix).
subroutine zscal(n, za, zx, incx)
ZSCAL