260 SUBROUTINE dlaqr5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS,
261 $ SR, SI, H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U,
262 $ LDU, NV, WV, LDWV, NH, WH, LDWH )
270 INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,
271 $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV
275 DOUBLE PRECISION H( LDH, * ), SI( * ), SR( * ), U( LDU, * ),
276 $ V( LDV, * ), WH( LDWH, * ), WV( LDWV, * ),
282 DOUBLE PRECISION ZERO, ONE
283 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
286 DOUBLE PRECISION ALPHA, BETA, H11, H12, H21, H22, REFSUM,
287 $ SAFMAX, SAFMIN, SCL, SMLNUM, SWAP, T1, T2,
288 $ t3, tst1, tst2, ulp
289 INTEGER I, I2, I4, INCOL, J, JBOT, JCOL, JLEN,
290 $ JROW, JTOP, K, K1, KDU, KMS, KRCOL,
291 $ m, m22, mbot, mtop, nbmps, ndcol,
296 DOUBLE PRECISION DLAMCH
301 INTRINSIC abs, dble, max, min, mod
304 DOUBLE PRECISION VT( 3 )
328 DO 10 i = 1, nshfts - 2, 2
329 IF( si( i ).NE.-si( i+1 ) )
THEN
333 sr( i+1 ) = sr( i+2 )
338 si( i+1 ) = si( i+2 )
348 ns = nshfts - mod( nshfts, 2 )
352 safmin = dlamch(
'SAFE MINIMUM' )
353 safmax = one / safmin
354 ulp = dlamch(
'PRECISION' )
355 smlnum = safmin*( dble( n ) / ulp )
360 accum = ( kacc22.EQ.1 ) .OR. ( kacc22.EQ.2 )
365 $ h( ktop+2, ktop ) = zero
377 DO 180 incol = ktop - 2*nbmps + 1, kbot - 2, 2*nbmps
382 jtop = max( ktop, incol )
383 ELSE IF( wantt )
THEN
391 $
CALL dlaset(
'ALL', kdu, kdu, zero, one, u, ldu )
405 DO 145 krcol = incol, min( incol+2*nbmps-1, kbot-2 )
414 mtop = max( 1, ( ktop-krcol ) / 2+1 )
415 mbot = min( nbmps, ( kbot-krcol-1 ) / 2 )
417 bmp22 = ( mbot.LT.nbmps ) .AND. ( krcol+2*( m22-1 ) ).EQ.
428 k = krcol + 2*( m22-1 )
429 IF( k.EQ.ktop-1 )
THEN
430 CALL dlaqr1( 2, h( k+1, k+1 ), ldh, sr( 2*m22-1 ),
431 $ si( 2*m22-1 ), sr( 2*m22 ), si( 2*m22 ),
434 CALL dlarfg( 2, beta, v( 2, m22 ), 1, v( 1, m22 ) )
437 v( 2, m22 ) = h( k+2, k )
438 CALL dlarfg( 2, beta, v( 2, m22 ), 1, v( 1, m22 ) )
449 DO 30 j = jtop, min( kbot, k+3 )
450 refsum = h( j, k+1 ) + v( 2, m22 )*h( j, k+2 )
451 h( j, k+1 ) = h( j, k+1 ) - refsum*t1
452 h( j, k+2 ) = h( j, k+2 ) - refsum*t2
459 jbot = min( ndcol, kbot )
460 ELSE IF( wantt )
THEN
468 refsum = h( k+1, j ) + v( 2, m22 )*h( k+2, j )
469 h( k+1, j ) = h( k+1, j ) - refsum*t1
470 h( k+2, j ) = h( k+2, j ) - refsum*t2
483 IF( h( k+1, k ).NE.zero )
THEN
484 tst1 = abs( h( k, k ) ) + abs( h( k+1, k+1 ) )
485 IF( tst1.EQ.zero )
THEN
487 $ tst1 = tst1 + abs( h( k, k-1 ) )
489 $ tst1 = tst1 + abs( h( k, k-2 ) )
491 $ tst1 = tst1 + abs( h( k, k-3 ) )
493 $ tst1 = tst1 + abs( h( k+2, k+1 ) )
495 $ tst1 = tst1 + abs( h( k+3, k+1 ) )
497 $ tst1 = tst1 + abs( h( k+4, k+1 ) )
499 IF( abs( h( k+1, k ) )
500 $ .LE.max( smlnum, ulp*tst1 ) )
THEN
501 h12 = max( abs( h( k+1, k ) ),
502 $ abs( h( k, k+1 ) ) )
503 h21 = min( abs( h( k+1, k ) ),
504 $ abs( h( k, k+1 ) ) )
505 h11 = max( abs( h( k+1, k+1 ) ),
506 $ abs( h( k, k )-h( k+1, k+1 ) ) )
507 h22 = min( abs( h( k+1, k+1 ) ),
508 $ abs( h( k, k )-h( k+1, k+1 ) ) )
510 tst2 = h22*( h11 / scl )
512 IF( tst2.EQ.zero .OR. h21*( h12 / scl ).LE.
513 $ max( smlnum, ulp*tst2 ) )
THEN
526 DO 50 j = max( 1, ktop-incol ), kdu
527 refsum = u( j, kms+1 ) + v( 2, m22 )*u( j, kms+2 )
528 u( j, kms+1 ) = u( j, kms+1 ) - refsum*t1
529 u( j, kms+2 ) = u( j, kms+2 ) - refsum*t2
531 ELSE IF( wantz )
THEN
535 refsum = z( j, k+1 )+v( 2, m22 )*z( j, k+2 )
536 z( j, k+1 ) = z( j, k+1 ) - refsum*t1
537 z( j, k+2 ) = z( j, k+2 ) - refsum*t2
544 DO 80 m = mbot, mtop, -1
545 k = krcol + 2*( m-1 )
546 IF( k.EQ.ktop-1 )
THEN
547 CALL dlaqr1( 3, h( ktop, ktop ), ldh, sr( 2*m-1 ),
548 $ si( 2*m-1 ), sr( 2*m ), si( 2*m ),
551 CALL dlarfg( 3, alpha, v( 2, m ), 1, v( 1, m ) )
561 refsum = v( 3, m )*h( k+3, k+2 )
562 h( k+3, k ) = -refsum*t1
563 h( k+3, k+1 ) = -refsum*t2
564 h( k+3, k+2 ) = h( k+3, k+2 ) - refsum*t3
570 v( 2, m ) = h( k+2, k )
571 v( 3, m ) = h( k+3, k )
572 CALL dlarfg( 3, beta, v( 2, m ), 1, v( 1, m ) )
579 IF( h( k+3, k ).NE.zero .OR. h( k+3, k+1 ).NE.
580 $ zero .OR. h( k+3, k+2 ).EQ.zero )
THEN
595 CALL dlaqr1( 3, h( k+1, k+1 ), ldh, sr( 2*m-1 ),
596 $ si( 2*m-1 ), sr( 2*m ), si( 2*m ),
599 CALL dlarfg( 3, alpha, vt( 2 ), 1, vt( 1 ) )
603 refsum = h( k+1, k ) + vt( 2 )*h( k+2, k )
605 IF( abs( h( k+2, k )-refsum*t2 )+
606 $ abs( refsum*t3 ).GT.ulp*
607 $ ( abs( h( k, k ) )+abs( h( k+1,
608 $ k+1 ) )+abs( h( k+2, k+2 ) ) ) )
THEN
624 h( k+1, k ) = h( k+1, k ) - refsum*t1
643 DO 70 j = jtop, min( kbot, k+3 )
644 refsum = h( j, k+1 ) + v( 2, m )*h( j, k+2 )
645 $ + v( 3, m )*h( j, k+3 )
646 h( j, k+1 ) = h( j, k+1 ) - refsum*t1
647 h( j, k+2 ) = h( j, k+2 ) - refsum*t2
648 h( j, k+3 ) = h( j, k+3 ) - refsum*t3
654 refsum = h( k+1, k+1 ) + v( 2, m )*h( k+2, k+1 )
655 $ + v( 3, m )*h( k+3, k+1 )
656 h( k+1, k+1 ) = h( k+1, k+1 ) - refsum*t1
657 h( k+2, k+1 ) = h( k+2, k+1 ) - refsum*t2
658 h( k+3, k+1 ) = h( k+3, k+1 ) - refsum*t3
671 IF( h( k+1, k ).NE.zero )
THEN
672 tst1 = abs( h( k, k ) ) + abs( h( k+1, k+1 ) )
673 IF( tst1.EQ.zero )
THEN
675 $ tst1 = tst1 + abs( h( k, k-1 ) )
677 $ tst1 = tst1 + abs( h( k, k-2 ) )
679 $ tst1 = tst1 + abs( h( k, k-3 ) )
681 $ tst1 = tst1 + abs( h( k+2, k+1 ) )
683 $ tst1 = tst1 + abs( h( k+3, k+1 ) )
685 $ tst1 = tst1 + abs( h( k+4, k+1 ) )
687 IF( abs( h( k+1, k ) ).LE.max( smlnum, ulp*tst1 ) )
689 h12 = max( abs( h( k+1, k ) ), abs( h( k, k+1 ) ) )
690 h21 = min( abs( h( k+1, k ) ), abs( h( k, k+1 ) ) )
691 h11 = max( abs( h( k+1, k+1 ) ),
692 $ abs( h( k, k )-h( k+1, k+1 ) ) )
693 h22 = min( abs( h( k+1, k+1 ) ),
694 $ abs( h( k, k )-h( k+1, k+1 ) ) )
696 tst2 = h22*( h11 / scl )
698 IF( tst2.EQ.zero .OR. h21*( h12 / scl ).LE.
699 $ max( smlnum, ulp*tst2 ) )
THEN
709 jbot = min( ndcol, kbot )
710 ELSE IF( wantt )
THEN
716 DO 100 m = mbot, mtop, -1
717 k = krcol + 2*( m-1 )
721 DO 90 j = max( ktop, krcol + 2*m ), jbot
722 refsum = h( k+1, j ) + v( 2, m )*h( k+2, j )
723 $ + v( 3, m )*h( k+3, j )
724 h( k+1, j ) = h( k+1, j ) - refsum*t1
725 h( k+2, j ) = h( k+2, j ) - refsum*t2
726 h( k+3, j ) = h( k+3, j ) - refsum*t3
738 DO 120 m = mbot, mtop, -1
739 k = krcol + 2*( m-1 )
741 i2 = max( 1, ktop-incol )
742 i2 = max( i2, kms-(krcol-incol)+1 )
743 i4 = min( kdu, krcol + 2*( mbot-1 ) - incol + 5 )
748 refsum = u( j, kms+1 ) + v( 2, m )*u( j, kms+2 )
749 $ + v( 3, m )*u( j, kms+3 )
750 u( j, kms+1 ) = u( j, kms+1 ) - refsum*t1
751 u( j, kms+2 ) = u( j, kms+2 ) - refsum*t2
752 u( j, kms+3 ) = u( j, kms+3 ) - refsum*t3
755 ELSE IF( wantz )
THEN
761 DO 140 m = mbot, mtop, -1
762 k = krcol + 2*( m-1 )
766 DO 130 j = iloz, ihiz
767 refsum = z( j, k+1 ) + v( 2, m )*z( j, k+2 )
768 $ + v( 3, m )*z( j, k+3 )
769 z( j, k+1 ) = z( j, k+1 ) - refsum*t1
770 z( j, k+2 ) = z( j, k+2 ) - refsum*t2
771 z( j, k+3 ) = z( j, k+3 ) - refsum*t3
792 k1 = max( 1, ktop-incol )
793 nu = ( kdu-max( 0, ndcol-kbot ) ) - k1 + 1
797 DO 150 jcol = min( ndcol, kbot ) + 1, jbot, nh
798 jlen = min( nh, jbot-jcol+1 )
799 CALL dgemm(
'C',
'N', nu, jlen, nu, one, u( k1, k1 ),
800 $ ldu, h( incol+k1, jcol ), ldh, zero, wh,
802 CALL dlacpy(
'ALL', nu, jlen, wh, ldwh,
803 $ h( incol+k1, jcol ), ldh )
808 DO 160 jrow = jtop, max( ktop, incol ) - 1, nv
809 jlen = min( nv, max( ktop, incol )-jrow )
810 CALL dgemm(
'N',
'N', jlen, nu, nu, one,
811 $ h( jrow, incol+k1 ), ldh, u( k1, k1 ),
812 $ ldu, zero, wv, ldwv )
813 CALL dlacpy(
'ALL', jlen, nu, wv, ldwv,
814 $ h( jrow, incol+k1 ), ldh )
820 DO 170 jrow = iloz, ihiz, nv
821 jlen = min( nv, ihiz-jrow+1 )
822 CALL dgemm(
'N',
'N', jlen, nu, nu, one,
823 $ z( jrow, incol+k1 ), ldz, u( k1, k1 ),
824 $ ldu, zero, wv, ldwv )
825 CALL dlacpy(
'ALL', jlen, nu, wv, ldwv,
826 $ z( jrow, incol+k1 ), ldz )