263 SUBROUTINE slaqr4( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
264 $ ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO )
271 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
275 REAL H( LDH, * ), WI( * ), WORK( * ), WR( * ),
287 parameter( ntiny = 15 )
293 parameter( kexnw = 5 )
299 parameter( kexsh = 6 )
304 parameter( wilk1 = 0.75e0, wilk2 = -0.4375e0 )
306 parameter( zero = 0.0e0, one = 1.0e0 )
309 REAL AA, BB, CC, CS, DD, SN, SS, SWAP
310 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
311 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
312 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
313 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
320 EXTERNAL ilaenv, sroundup_lwork
329 INTRINSIC abs, int, max, min, mod
341 IF( n.LE.ntiny )
THEN
347 $
CALL slahqr( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi,
348 $ iloz, ihiz, z, ldz, info )
377 nwr = ilaenv( 13,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
379 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
386 nsr = ilaenv( 15,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
387 nsr = min( nsr, ( n-3 ) / 6, ihi-ilo )
388 nsr = max( 2, nsr-mod( nsr, 2 ) )
394 CALL slaqr2( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
395 $ ihiz, z, ldz, ls, ld, wr, wi, h, ldh, n, h, ldh,
396 $ n, h, ldh, work, -1 )
400 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
404 IF( lwork.EQ.-1 )
THEN
405 work( 1 ) = sroundup_lwork( lwkopt )
411 nmin = ilaenv( 12,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
412 nmin = max( ntiny, nmin )
416 nibble = ilaenv( 14,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
417 nibble = max( 0, nibble )
422 kacc22 = ilaenv( 16,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
423 kacc22 = max( 0, kacc22 )
424 kacc22 = min( 2, kacc22 )
429 nwmax = min( ( n-1 ) / 3, lwork / 2 )
435 nsmax = min( ( n-3 ) / 6, 2*lwork / 3 )
436 nsmax = nsmax - mod( nsmax, 2 )
444 itmax = max( 30, 2*kexsh )*max( 10, ( ihi-ilo+1 ) )
461 DO 10 k = kbot, ilo + 1, -1
462 IF( h( k, k-1 ).EQ.zero )
486 nwupbd = min( nh, nwmax )
487 IF( ndfl.LT.kexnw )
THEN
488 nw = min( nwupbd, nwr )
490 nw = min( nwupbd, 2*nw )
492 IF( nw.LT.nwmax )
THEN
493 IF( nw.GE.nh-1 )
THEN
496 kwtop = kbot - nw + 1
497 IF( abs( h( kwtop, kwtop-1 ) ).GT.
498 $ abs( h( kwtop-1, kwtop-2 ) ) )nw = nw + 1
501 IF( ndfl.LT.kexnw )
THEN
503 ELSE IF( ndec.GE.0 .OR. nw.GE.nwupbd )
THEN
523 nho = ( n-nw-1 ) - kt + 1
525 nve = ( n-nw ) - kwv + 1
529 CALL slaqr2( wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz,
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 ), wi( i-1 ),
574 $ wr( i ), wi( i ), cs, sn )
576 IF( ks.EQ.ktop )
THEN
577 wr( ks+1 ) = h( ks+1, ks+1 )
579 wr( ks ) = wr( ks+1 )
580 wi( ks ) = wi( ks+1 )
590 IF( kbot-ks+1.LE.ns / 2 )
THEN
593 CALL slacpy(
'A', ns, ns, h( ks, ks ), ldh,
595 CALL slahqr( .false., .false., ns, 1, ns,
596 $ h( kt, 1 ), ldh, wr( ks ), wi( ks ),
597 $ 1, 1, zdum, 1, inf )
604 IF( ks.GE.kbot )
THEN
605 aa = h( kbot-1, kbot-1 )
606 cc = h( kbot, kbot-1 )
607 bb = h( kbot-1, kbot )
609 CALL slanv2( aa, bb, cc, dd, wr( kbot-1 ),
610 $ wi( kbot-1 ), wr( kbot ),
611 $ wi( kbot ), cs, sn )
616 IF( kbot-ks+1.GT.ns )
THEN
623 DO 50 k = kbot, ks + 1, -1
628 IF( abs( wr( i ) )+abs( wi( i ) ).LT.
629 $ abs( wr( i+1 ) )+abs( wi( i+1 ) ) )
THEN
651 DO 70 i = kbot, ks + 2, -2
652 IF( wi( i ).NE.-wi( i-1 ) )
THEN
656 wr( i-1 ) = wr( i-2 )
661 wi( i-1 ) = wi( i-2 )
670 IF( kbot-ks+1.EQ.2 )
THEN
671 IF( wi( kbot ).EQ.zero )
THEN
672 IF( abs( wr( kbot )-h( kbot, kbot ) ).LT.
673 $ abs( wr( kbot-1 )-h( kbot, kbot ) ) )
THEN
674 wr( kbot-1 ) = wr( kbot )
676 wr( kbot ) = wr( kbot-1 )
686 ns = min( ns, kbot-ks+1 )
687 ns = ns - mod( ns, 2 )
704 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
706 nve = n - kdu - kwv + 1
710 CALL slaqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
711 $ wr( ks ), wi( ks ), h, ldh, iloz, ihiz, z,
712 $ ldz, work, 3, h( ku, 1 ), ldh, nve,
713 $ h( kwv, 1 ), ldh, nho, h( ku, kwh ), ldh )
736 work( 1 ) = sroundup_lwork( lwkopt )
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
subroutine slahqr(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, info)
SLAHQR computes the eigenvalues and Schur factorization of an upper Hessenberg matrix,...
subroutine slanv2(a, b, c, d, rt1r, rt1i, rt2r, rt2i, cs, sn)
SLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric matrix in standard form.
subroutine slaqr2(wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz, ihiz, z, ldz, ns, nd, sr, si, v, ldv, nh, t, ldt, nv, wv, ldwv, work, lwork)
SLAQR2 performs the orthogonal similarity transformation of a Hessenberg matrix to detect and deflate...
subroutine slaqr4(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, work, lwork, info)
SLAQR4 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur de...
subroutine slaqr5(wantt, wantz, kacc22, n, ktop, kbot, nshfts, sr, si, h, ldh, iloz, ihiz, z, ldz, v, ldv, u, ldu, nv, wv, ldwv, nh, wh, ldwh)
SLAQR5 performs a single small-bulge multi-shift QR sweep.