243 SUBROUTINE zlaqr4( WANTT, WANTZ, N, ILO, IHI, H, LDH, W, ILOZ,
244 $ IHIZ, Z, LDZ, WORK, LWORK, INFO )
251 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
255 COMPLEX*16 H( LDH, * ), W( * ), WORK( * ), Z( LDZ, * )
266 parameter( ntiny = 15 )
272 parameter( kexnw = 5 )
278 parameter( kexsh = 6 )
282 DOUBLE PRECISION WILK1
283 parameter( wilk1 = 0.75d0 )
285 parameter( zero = ( 0.0d0, 0.0d0 ),
286 $ one = ( 1.0d0, 0.0d0 ) )
288 parameter( two = 2.0d0 )
291 COMPLEX*16 AA, BB, CC, CDUM, DD, DET, RTDISC, SWAP, TR2
293 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
294 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
295 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
296 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
305 COMPLEX*16 ZDUM( 1, 1 )
311 INTRINSIC abs, dble, dcmplx, dimag, int, max, min, mod,
315 DOUBLE PRECISION CABS1
318 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
330 IF( n.LE.ntiny )
THEN
336 $
CALL zlahqr( wantt, wantz, n, ilo, ihi, h, ldh, w, iloz,
337 $ ihiz, z, ldz, info )
366 nwr = ilaenv( 13,
'ZLAQR4', jbcmpz, n, ilo, ihi, lwork )
368 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
375 nsr = ilaenv( 15,
'ZLAQR4', jbcmpz, n, ilo, ihi, lwork )
376 nsr = min( nsr, ( n-3 ) / 6, ihi-ilo )
377 nsr = max( 2, nsr-mod( nsr, 2 ) )
383 CALL zlaqr2( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
384 $ ihiz, z, ldz, ls, ld, w, h, ldh, n, h, ldh, n, h,
389 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
393 IF( lwork.EQ.-1 )
THEN
394 work( 1 ) = dcmplx( lwkopt, 0 )
400 nmin = ilaenv( 12,
'ZLAQR4', jbcmpz, n, ilo, ihi, lwork )
401 nmin = max( ntiny, nmin )
405 nibble = ilaenv( 14,
'ZLAQR4', jbcmpz, n, ilo, ihi, lwork )
406 nibble = max( 0, nibble )
411 kacc22 = ilaenv( 16,
'ZLAQR4', jbcmpz, n, ilo, ihi, lwork )
412 kacc22 = max( 0, kacc22 )
413 kacc22 = min( 2, kacc22 )
418 nwmax = min( ( n-1 ) / 3, lwork / 2 )
424 nsmax = min( ( n-3 ) / 6, 2*lwork / 3 )
425 nsmax = nsmax - mod( nsmax, 2 )
433 itmax = max( 30, 2*kexsh )*max( 10, ( ihi-ilo+1 ) )
450 DO 10 k = kbot, ilo + 1, -1
451 IF( h( k, k-1 ).EQ.zero )
475 nwupbd = min( nh, nwmax )
476 IF( ndfl.LT.kexnw )
THEN
477 nw = min( nwupbd, nwr )
479 nw = min( nwupbd, 2*nw )
481 IF( nw.LT.nwmax )
THEN
482 IF( nw.GE.nh-1 )
THEN
485 kwtop = kbot - nw + 1
486 IF( cabs1( h( kwtop, kwtop-1 ) ).GT.
487 $ cabs1( h( kwtop-1, kwtop-2 ) ) )nw = nw + 1
490 IF( ndfl.LT.kexnw )
THEN
492 ELSE IF( ndec.GE.0 .OR. nw.GE.nwupbd )
THEN
512 nho = ( n-nw-1 ) - kt + 1
514 nve = ( n-nw ) - kwv + 1
518 CALL zlaqr2( wantt, wantz, n, ktop, kbot, nw, h, ldh,
520 $ ihiz, z, ldz, ls, ld, w, h( kv, 1 ), ldh, nho,
521 $ h( kv, kt ), ldh, nve, h( kwv, 1 ), ldh, work,
538 IF( ( ld.EQ.0 ) .OR. ( ( 100*ld.LE.nw*nibble ) .AND. ( kbot-
539 $ ktop+1.GT.min( nmin, nwmax ) ) ) )
THEN
545 ns = min( nsmax, nsr, max( 2, kbot-ktop ) )
546 ns = ns - mod( ns, 2 )
555 IF( mod( ndfl, kexsh ).EQ.0 )
THEN
557 DO 30 i = kbot, ks + 1, -2
558 w( i ) = h( i, i ) + wilk1*cabs1( h( i, i-1 ) )
569 IF( kbot-ks+1.LE.ns / 2 )
THEN
572 CALL zlacpy(
'A', ns, ns, h( ks, ks ), ldh,
574 CALL zlahqr( .false., .false., ns, 1, ns,
575 $ h( kt, 1 ), ldh, w( ks ), 1, 1, zdum,
586 IF( ks.GE.kbot )
THEN
587 s = cabs1( h( kbot-1, kbot-1 ) ) +
588 $ cabs1( h( kbot, kbot-1 ) ) +
589 $ cabs1( h( kbot-1, kbot ) ) +
590 $ cabs1( h( kbot, kbot ) )
591 aa = h( kbot-1, kbot-1 ) / s
592 cc = h( kbot, kbot-1 ) / s
593 bb = h( kbot-1, kbot ) / s
594 dd = h( kbot, kbot ) / s
595 tr2 = ( aa+dd ) / two
596 det = ( aa-tr2 )*( dd-tr2 ) - bb*cc
597 rtdisc = sqrt( -det )
598 w( kbot-1 ) = ( tr2+rtdisc )*s
599 w( kbot ) = ( tr2-rtdisc )*s
605 IF( kbot-ks+1.GT.ns )
THEN
610 DO 50 k = kbot, ks + 1, -1
615 IF( cabs1( w( i ) ).LT.cabs1( w( i+1 ) ) )
631 IF( kbot-ks+1.EQ.2 )
THEN
632 IF( cabs1( w( kbot )-h( kbot, kbot ) ).LT.
633 $ cabs1( w( kbot-1 )-h( kbot, kbot ) ) )
THEN
634 w( kbot-1 ) = w( kbot )
636 w( kbot ) = w( kbot-1 )
645 ns = min( ns, kbot-ks+1 )
646 ns = ns - mod( ns, 2 )
663 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
665 nve = n - kdu - kwv + 1
669 CALL zlaqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
670 $ w( ks ), h, ldh, iloz, ihiz, z, ldz, work,
671 $ 3, h( ku, 1 ), ldh, nve, h( kwv, 1 ), ldh,
672 $ nho, h( ku, kwh ), ldh )
695 work( 1 ) = dcmplx( lwkopt, 0 )