261 SUBROUTINE slaqr4( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
262 $ ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO )
269 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
273 REAL H( LDH, * ), WI( * ), WORK( * ), WR( * ),
285 parameter( ntiny = 15 )
291 parameter( kexnw = 5 )
297 parameter( kexsh = 6 )
302 parameter( wilk1 = 0.75e0, wilk2 = -0.4375e0 )
304 parameter( zero = 0.0e0, one = 1.0e0 )
307 REAL AA, BB, CC, CS, DD, SN, SS, SWAP
308 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
309 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
310 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
311 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
318 EXTERNAL ilaenv, sroundup_lwork
328 INTRINSIC abs, int, max, min, mod
340 IF( n.LE.ntiny )
THEN
346 $
CALL slahqr( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi,
347 $ iloz, ihiz, z, ldz, info )
376 nwr = ilaenv( 13,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
378 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
385 nsr = ilaenv( 15,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
386 nsr = min( nsr, ( n-3 ) / 6, ihi-ilo )
387 nsr = max( 2, nsr-mod( nsr, 2 ) )
393 CALL slaqr2( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
394 $ ihiz, z, ldz, ls, ld, wr, wi, h, ldh, n, h, ldh,
395 $ n, h, ldh, work, -1 )
399 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
403 IF( lwork.EQ.-1 )
THEN
404 work( 1 ) = sroundup_lwork( lwkopt )
410 nmin = ilaenv( 12,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
411 nmin = max( ntiny, nmin )
415 nibble = ilaenv( 14,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
416 nibble = max( 0, nibble )
421 kacc22 = ilaenv( 16,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
422 kacc22 = max( 0, kacc22 )
423 kacc22 = min( 2, kacc22 )
428 nwmax = min( ( n-1 ) / 3, lwork / 2 )
434 nsmax = min( ( n-3 ) / 6, 2*lwork / 3 )
435 nsmax = nsmax - mod( nsmax, 2 )
443 itmax = max( 30, 2*kexsh )*max( 10, ( ihi-ilo+1 ) )
460 DO 10 k = kbot, ilo + 1, -1
461 IF( h( k, k-1 ).EQ.zero )
485 nwupbd = min( nh, nwmax )
486 IF( ndfl.LT.kexnw )
THEN
487 nw = min( nwupbd, nwr )
489 nw = min( nwupbd, 2*nw )
491 IF( nw.LT.nwmax )
THEN
492 IF( nw.GE.nh-1 )
THEN
495 kwtop = kbot - nw + 1
496 IF( abs( h( kwtop, kwtop-1 ) ).GT.
497 $ abs( h( kwtop-1, kwtop-2 ) ) )nw = nw + 1
500 IF( ndfl.LT.kexnw )
THEN
502 ELSE IF( ndec.GE.0 .OR. nw.GE.nwupbd )
THEN
522 nho = ( n-nw-1 ) - kt + 1
524 nve = ( n-nw ) - kwv + 1
528 CALL slaqr2( wantt, wantz, n, ktop, kbot, nw, h, ldh,
530 $ ihiz, z, ldz, ls, ld, wr, wi, h( kv, 1 ), ldh,
531 $ nho, h( kv, kt ), ldh, nve, h( kwv, 1 ), ldh,
548 IF( ( ld.EQ.0 ) .OR. ( ( 100*ld.LE.nw*nibble ) .AND. ( kbot-
549 $ ktop+1.GT.min( nmin, nwmax ) ) ) )
THEN
555 ns = min( nsmax, nsr, max( 2, kbot-ktop ) )
556 ns = ns - mod( ns, 2 )
565 IF( mod( ndfl, kexsh ).EQ.0 )
THEN
567 DO 30 i = kbot, max( ks+1, ktop+2 ), -2
568 ss = abs( h( i, i-1 ) ) + abs( h( i-1, i-2 ) )
569 aa = wilk1*ss + h( i, i )
573 CALL slanv2( aa, bb, cc, dd, wr( i-1 ),
575 $ wr( i ), wi( i ), cs, sn )
577 IF( ks.EQ.ktop )
THEN
578 wr( ks+1 ) = h( ks+1, ks+1 )
580 wr( ks ) = wr( ks+1 )
581 wi( ks ) = wi( ks+1 )
591 IF( kbot-ks+1.LE.ns / 2 )
THEN
594 CALL slacpy(
'A', ns, ns, h( ks, ks ), ldh,
596 CALL slahqr( .false., .false., ns, 1, ns,
597 $ h( kt, 1 ), ldh, wr( ks ), wi( ks ),
598 $ 1, 1, zdum, 1, inf )
605 IF( ks.GE.kbot )
THEN
606 aa = h( kbot-1, kbot-1 )
607 cc = h( kbot, kbot-1 )
608 bb = h( kbot-1, kbot )
610 CALL slanv2( aa, bb, cc, dd, wr( kbot-1 ),
611 $ wi( kbot-1 ), wr( kbot ),
612 $ wi( kbot ), cs, sn )
617 IF( kbot-ks+1.GT.ns )
THEN
624 DO 50 k = kbot, ks + 1, -1
629 IF( abs( wr( i ) )+abs( wi( i ) ).LT.
630 $ abs( wr( i+1 ) )+abs( wi( i+1 ) ) )
THEN
652 DO 70 i = kbot, ks + 2, -2
653 IF( wi( i ).NE.-wi( i-1 ) )
THEN
657 wr( i-1 ) = wr( i-2 )
662 wi( i-1 ) = wi( i-2 )
671 IF( kbot-ks+1.EQ.2 )
THEN
672 IF( wi( kbot ).EQ.zero )
THEN
673 IF( abs( wr( kbot )-h( kbot, kbot ) ).LT.
674 $ abs( wr( kbot-1 )-h( kbot, kbot ) ) )
THEN
675 wr( kbot-1 ) = wr( kbot )
677 wr( kbot ) = wr( kbot-1 )
687 ns = min( ns, kbot-ks+1 )
688 ns = ns - mod( ns, 2 )
705 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
707 nve = n - kdu - kwv + 1
711 CALL slaqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
712 $ wr( ks ), wi( ks ), h, ldh, iloz, ihiz, z,
713 $ ldz, work, 3, h( ku, 1 ), ldh, nve,
714 $ h( kwv, 1 ), ldh, nho, h( ku, kwh ), ldh )
737 work( 1 ) = sroundup_lwork( lwkopt )