265 SUBROUTINE slaqr4( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
266 $ iloz, ihiz, z, ldz, work, lwork, info )
274 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
278 REAL H( ldh, * ), WI( * ), WORK( * ), WR( * ),
290 parameter ( ntiny = 11 )
296 parameter ( kexnw = 5 )
302 parameter ( kexsh = 6 )
307 parameter ( wilk1 = 0.75e0, wilk2 = -0.4375e0 )
309 parameter ( zero = 0.0e0, one = 1.0e0 )
312 REAL AA, BB, CC, CS, DD, SN, SS, SWAP
313 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
314 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
315 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
316 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
331 INTRINSIC abs, int, max, min, mod, real
343 IF( n.LE.ntiny )
THEN
349 $
CALL slahqr( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi,
350 $ iloz, ihiz, z, ldz, info )
379 nwr = ilaenv( 13,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
381 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
388 nsr = ilaenv( 15,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
389 nsr = min( nsr, ( n+6 ) / 9, ihi-ilo )
390 nsr = max( 2, nsr-mod( nsr, 2 ) )
396 CALL slaqr2( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
397 $ ihiz, z, ldz, ls, ld, wr, wi, h, ldh, n, h, ldh,
398 $ n, h, ldh, work, -1 )
402 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
406 IF( lwork.EQ.-1 )
THEN
407 work( 1 ) =
REAL( lwkopt )
413 nmin = ilaenv( 12,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
414 nmin = max( ntiny, nmin )
418 nibble = ilaenv( 14,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
419 nibble = max( 0, nibble )
424 kacc22 = ilaenv( 16,
'SLAQR4', jbcmpz, n, ilo, ihi, lwork )
425 kacc22 = max( 0, kacc22 )
426 kacc22 = min( 2, kacc22 )
431 nwmax = min( ( n-1 ) / 3, lwork / 2 )
437 nsmax = min( ( n+6 ) / 9, 2*lwork / 3 )
438 nsmax = nsmax - mod( nsmax, 2 )
446 itmax = max( 30, 2*kexsh )*max( 10, ( ihi-ilo+1 ) )
463 DO 10 k = kbot, ilo + 1, -1
464 IF( h( k, k-1 ).EQ.zero )
488 nwupbd = min( nh, nwmax )
489 IF( ndfl.LT.kexnw )
THEN
490 nw = min( nwupbd, nwr )
492 nw = min( nwupbd, 2*nw )
494 IF( nw.LT.nwmax )
THEN
495 IF( nw.GE.nh-1 )
THEN
498 kwtop = kbot - nw + 1
499 IF( abs( h( kwtop, kwtop-1 ) ).GT.
500 $ abs( h( kwtop-1, kwtop-2 ) ) )nw = nw + 1
503 IF( ndfl.LT.kexnw )
THEN
505 ELSE IF( ndec.GE.0 .OR. nw.GE.nwupbd )
THEN
525 nho = ( n-nw-1 ) - kt + 1
527 nve = ( n-nw ) - kwv + 1
531 CALL slaqr2( wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz,
532 $ ihiz, z, ldz, ls, ld, wr, wi, h( kv, 1 ), ldh,
533 $ nho, h( kv, kt ), ldh, nve, h( kwv, 1 ), ldh,
550 IF( ( ld.EQ.0 ) .OR. ( ( 100*ld.LE.nw*nibble ) .AND. ( kbot-
551 $ ktop+1.GT.min( nmin, nwmax ) ) ) )
THEN
557 ns = min( nsmax, nsr, max( 2, kbot-ktop ) )
558 ns = ns - mod( ns, 2 )
567 IF( mod( ndfl, kexsh ).EQ.0 )
THEN
569 DO 30 i = kbot, max( ks+1, ktop+2 ), -2
570 ss = abs( h( i, i-1 ) ) + abs( h( i-1, i-2 ) )
571 aa = wilk1*ss + h( i, i )
575 CALL slanv2( aa, bb, cc, dd, wr( i-1 ), wi( i-1 ),
576 $ wr( i ), wi( i ), cs, sn )
578 IF( ks.EQ.ktop )
THEN
579 wr( ks+1 ) = h( ks+1, ks+1 )
581 wr( ks ) = wr( ks+1 )
582 wi( ks ) = wi( ks+1 )
592 IF( kbot-ks+1.LE.ns / 2 )
THEN
595 CALL slacpy(
'A', ns, ns, h( ks, ks ), ldh,
597 CALL slahqr( .false., .false., ns, 1, ns,
598 $ h( kt, 1 ), ldh, wr( ks ), wi( ks ),
599 $ 1, 1, zdum, 1, inf )
606 IF( ks.GE.kbot )
THEN
607 aa = h( kbot-1, kbot-1 )
608 cc = h( kbot, kbot-1 )
609 bb = h( kbot-1, kbot )
611 CALL slanv2( aa, bb, cc, dd, wr( kbot-1 ),
612 $ wi( kbot-1 ), wr( kbot ),
613 $ wi( kbot ), cs, sn )
618 IF( kbot-ks+1.GT.ns )
THEN
625 DO 50 k = kbot, ks + 1, -1
630 IF( abs( wr( i ) )+abs( wi( i ) ).LT.
631 $ abs( wr( i+1 ) )+abs( wi( i+1 ) ) )
THEN
653 DO 70 i = kbot, ks + 2, -2
654 IF( wi( i ).NE.-wi( i-1 ) )
THEN
658 wr( i-1 ) = wr( i-2 )
663 wi( i-1 ) = wi( i-2 )
672 IF( kbot-ks+1.EQ.2 )
THEN
673 IF( wi( kbot ).EQ.zero )
THEN
674 IF( abs( wr( kbot )-h( kbot, kbot ) ).LT.
675 $ abs( wr( kbot-1 )-h( kbot, kbot ) ) )
THEN
676 wr( kbot-1 ) = wr( kbot )
678 wr( kbot ) = wr( kbot-1 )
688 ns = min( ns, kbot-ks+1 )
689 ns = ns - mod( ns, 2 )
706 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
708 nve = n - kdu - kwv + 1
712 CALL slaqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
713 $ wr( ks ), wi( ks ), h, ldh, iloz, ihiz, z,
714 $ ldz, work, 3, h( ku, 1 ), ldh, nve,
715 $ h( kwv, 1 ), ldh, nho, h( ku, kwh ), ldh )
738 work( 1 ) =
REAL( lwkopt )
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, using the double-shift/single-shift QR algorithm.
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 slacpy(UPLO, M, N, A, LDA, B, LDB)
SLACPY copies all or part of one two-dimensional array to another.
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.
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 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...