254 SUBROUTINE slaqr0( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
255 $ ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO )
262 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
266 REAL H( LDH, * ), WI( * ), WORK( * ), WR( * ),
277 parameter( ntiny = 15 )
283 parameter( kexnw = 5 )
289 parameter( kexsh = 6 )
294 parameter( wilk1 = 0.75e0, wilk2 = -0.4375e0 )
296 parameter( zero = 0.0e0, one = 1.0e0 )
299 REAL AA, BB, CC, CS, DD, SN, SS, SWAP
300 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
301 $ kt, ktop, ku, kv, kwh, kwtop, kwv, ld, ls,
302 $ lwkopt, ndec, ndfl, nh, nho, nibble, nmin, ns,
303 $ nsmax, nsr, nve, nw, nwmax, nwr, nwupbd
318 INTRINSIC abs, int, max, min, mod, real
330 IF( n.LE.ntiny )
THEN
336 $
CALL slahqr( wantt, wantz, n, ilo, ihi, h, ldh, wr, wi,
337 $ iloz, ihiz, z, ldz, info )
366 nwr = ilaenv( 13,
'SLAQR0', jbcmpz, n, ilo, ihi, lwork )
368 nwr = min( ihi-ilo+1, ( n-1 ) / 3, nwr )
375 nsr = ilaenv( 15,
'SLAQR0', jbcmpz, n, ilo, ihi, lwork )
376 nsr = min( nsr, ( n-3 ) / 6, ihi-ilo )
377 nsr = max( 2, nsr-mod( nsr, 2 ) )
383 CALL slaqr3( wantt, wantz, n, ilo, ihi, nwr+1, h, ldh, iloz,
384 $ ihiz, z, ldz, ls, ld, wr, wi, h, ldh, n, h, ldh,
385 $ n, h, ldh, work, -1 )
389 lwkopt = max( 3*nsr / 2, int( work( 1 ) ) )
393 IF( lwork.EQ.-1 )
THEN
394 work( 1 ) = real( lwkopt )
400 nmin = ilaenv( 12,
'SLAQR0', jbcmpz, n, ilo, ihi, lwork )
401 nmin = max( ntiny, nmin )
405 nibble = ilaenv( 14,
'SLAQR0', jbcmpz, n, ilo, ihi, lwork )
406 nibble = max( 0, nibble )
411 kacc22 = ilaenv( 16,
'SLAQR0', 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( abs( h( kwtop, kwtop-1 ) ).GT.
487 $ abs( 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 slaqr3( wantt, wantz, n, ktop, kbot, nw, h, ldh, iloz,
519 $ ihiz, z, ldz, ls, ld, wr, wi, h( kv, 1 ), ldh,
520 $ nho, h( kv, kt ), ldh, nve, h( kwv, 1 ), ldh,
537 IF( ( ld.EQ.0 ) .OR. ( ( 100*ld.LE.nw*nibble ) .AND. ( kbot-
538 $ ktop+1.GT.min( nmin, nwmax ) ) ) )
THEN
544 ns = min( nsmax, nsr, max( 2, kbot-ktop ) )
545 ns = ns - mod( ns, 2 )
554 IF( mod( ndfl, kexsh ).EQ.0 )
THEN
556 DO 30 i = kbot, max( ks+1, ktop+2 ), -2
557 ss = abs( h( i, i-1 ) ) + abs( h( i-1, i-2 ) )
558 aa = wilk1*ss + h( i, i )
562 CALL slanv2( aa, bb, cc, dd, wr( i-1 ), wi( i-1 ),
563 $ wr( i ), wi( i ), cs, sn )
565 IF( ks.EQ.ktop )
THEN
566 wr( ks+1 ) = h( ks+1, ks+1 )
568 wr( ks ) = wr( ks+1 )
569 wi( ks ) = wi( ks+1 )
579 IF( kbot-ks+1.LE.ns / 2 )
THEN
582 CALL slacpy(
'A', ns, ns, h( ks, ks ), ldh,
584 IF( ns.GT.nmin )
THEN
585 CALL slaqr4( .false., .false., ns, 1, ns,
586 $ h( kt, 1 ), ldh, wr( ks ),
587 $ wi( ks ), 1, 1, zdum, 1, work,
590 CALL slahqr( .false., .false., ns, 1, ns,
591 $ h( kt, 1 ), ldh, wr( ks ),
592 $ wi( ks ), 1, 1, zdum, 1, inf )
600 IF( ks.GE.kbot )
THEN
601 aa = h( kbot-1, kbot-1 )
602 cc = h( kbot, kbot-1 )
603 bb = h( kbot-1, kbot )
605 CALL slanv2( aa, bb, cc, dd, wr( kbot-1 ),
606 $ wi( kbot-1 ), wr( kbot ),
607 $ wi( kbot ), cs, sn )
612 IF( kbot-ks+1.GT.ns )
THEN
619 DO 50 k = kbot, ks + 1, -1
624 IF( abs( wr( i ) )+abs( wi( i ) ).LT.
625 $ abs( wr( i+1 ) )+abs( wi( i+1 ) ) )
THEN
647 DO 70 i = kbot, ks + 2, -2
648 IF( wi( i ).NE.-wi( i-1 ) )
THEN
652 wr( i-1 ) = wr( i-2 )
657 wi( i-1 ) = wi( i-2 )
666 IF( kbot-ks+1.EQ.2 )
THEN
667 IF( wi( kbot ).EQ.zero )
THEN
668 IF( abs( wr( kbot )-h( kbot, kbot ) ).LT.
669 $ abs( wr( kbot-1 )-h( kbot, kbot ) ) )
THEN
670 wr( kbot-1 ) = wr( kbot )
672 wr( kbot ) = wr( kbot-1 )
682 ns = min( ns, kbot-ks+1 )
683 ns = ns - mod( ns, 2 )
700 nho = ( n-kdu+1-4 ) - ( kdu+1 ) + 1
702 nve = n - kdu - kwv + 1
706 CALL slaqr5( wantt, wantz, kacc22, n, ktop, kbot, ns,
707 $ wr( ks ), wi( ks ), h, ldh, iloz, ihiz, z,
708 $ ldz, work, 3, h( ku, 1 ), ldh, nve,
709 $ h( kwv, 1 ), ldh, nho, h( ku, kwh ), ldh )
732 work( 1 ) = real( 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 slaqr0(wantt, wantz, n, ilo, ihi, h, ldh, wr, wi, iloz, ihiz, z, ldz, work, lwork, info)
SLAQR0 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur de...
subroutine slaqr3(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)
SLAQR3 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.