1 SUBROUTINE dlaqr6( JOB, WANTT, WANTZ, KACC22, N, KTOP, KBOT,
2 $ NSHFTS, SR, SI, H, LDH, ILOZ, IHIZ, Z, LDZ,
3 $ V, LDV, U, LDU, NV, WV, LDWV, NH, WH, LDWH )
16 INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,
17 $ ldwh, ldwv, ldz, n, nh, nshfts, nv
21 DOUBLE PRECISION H( LDH, * ), SI( * ), SR( * ), U( LDU, * ),
22 $ V( LDV, * ), WH( LDWH, * ), WV( LDWV, * ),
169 DOUBLE PRECISION ZERO, ONE
170 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
173 DOUBLE PRECISION ALPHA, BETA, H11, H12, H21, H22, REFSUM,
174 $ SAFMAX, SAFMIN, SCL, SMLNUM, SWAP, TST1, TST2,
176 INTEGER I, I2, I4, INCOL, J, J2, J4, JBOT, JCOL, JLEN,
177 $ JROW, JTOP, K, K1, KDU, KMS, KNZ, KRCOL, KZS,
178 $ m, m22, mbot, mend, mstart, mtop, nbmps, ndcol,
179 $ ns, nu, sincol, eincol, uincol, iphv, chunk,
180 $ threads, jlen2, jcol2, gchunk, jrow2, maxchunk
181 LOGICAL ACCUM, BLK22, BMP22, INTRO, CHASE, OFF, ALL
186 DOUBLE PRECISION DLAMCH
187 EXTERNAL lsame, dlamch, pilaenvx
191 INTRINSIC abs, dble,
max,
min, mod
194 DOUBLE PRECISION VT( 3 )
197 EXTERNAL dgemm, dlabad, dlamov, dlaqr1, dlarfg, dlaset,
219 DO 10 i = 1, nshfts - 2, 2
220 IF( si( i ).NE.-si( i+1 ) )
THEN
224 sr( i+1 ) = sr( i+2 )
229 si( i+1 ) = si( i+2 )
239 ns = nshfts - mod( nshfts, 2 )
243 safmin = dlamch(
'SAFE MINIMUM' )
244 safmax = one / safmin
245 CALL dlabad( safmin, safmax )
246 ulp = dlamch(
'PRECISION' )
247 smlnum = safmin*( dble( n ) / ulp )
253 accum = ( kacc22.EQ.1 ) .OR. ( kacc22.EQ.2 )
254 accum = accum .AND. nh.GE.1 .AND. nv.GE.1
258 blk22 = ( ns.GT.2 ) .AND. ( kacc22.EQ.2 )
262 all = lsame( job,
'A' )
264 $ intro = lsame( job,
'I' )
265 IF( .NOT. all .AND. .NOT. intro )
266 $ chase = lsame( job,
'C' )
267 IF( .NOT. all .AND. .NOT. intro .AND. .NOT. chase )
THEN
268 off = lsame( job,
'O' )
275 IF( intro.OR.all .AND. ktop+2.LE.kbot )
276 $ h( ktop+2, ktop ) = zero
289 sincol = 3*( 1-nbmps ) + ktop - 1
293 sincol = 3*( 1-nbmps ) + ktop - 1
294 eincol = kbot - 3*nbmps - 1
298 eincol = kbot - 3*nbmps - 1
309 DO 220 incol = sincol, eincol, uincol
310 ndcol =
min( incol + kdu, eincol )
312 $
CALL dlaset(
'ALL', kdu, kdu, zero, one, u, ldu )
326 DO 150 krcol = incol,
min( eincol, incol+3*nbmps-3, kbot-2 )
335 mtop =
max( 1, ( ( ktop-1 )-krcol+2 ) / 3+1 )
336 mbot =
min( nbmps, ( kbot-krcol ) / 3 )
338 bmp22 = ( mbot.LT.nbmps ) .AND. ( krcol+3*( m22-1 ) ).EQ.
345 k = krcol + 3*( m-1 )
346 IF( k.EQ.ktop-1 )
THEN
347 CALL dlaqr1( 3, h( ktop, ktop ), ldh, sr( 2*m-1 ),
348 $ si( 2*m-1 ), sr( 2*m ), si( 2*m ),
351 CALL dlarfg( 3, alpha, v( 2, m ), 1, v( 1, m ) )
354 v( 2, m ) = h( k+2, k )
355 v( 3, m ) = h( k+3, k )
356 CALL dlarfg( 3, beta, v( 2, m ), 1, v( 1, m ) )
363 IF( h( k+3, k ).NE.zero .OR. h( k+3, k+1 ).NE.
364 $ zero .OR. h( k+3, k+2 ).EQ.zero )
THEN
379 CALL dlaqr1( 3, h( k+1, k+1 ), ldh, sr( 2*m-1 ),
380 $ si( 2*m-1 ), sr( 2*m ), si( 2*m ),
383 CALL dlarfg( 3, alpha, vt( 2 ), 1, vt( 1 ) )
384 refsum = vt( 1 )*( h( k+1, k )+vt( 2 )*
387 IF( abs( h( k+2, k )-refsum*vt( 2 ) )+
388 $ abs( refsum*vt( 3 ) ).GT.ulp*
389 $ ( abs( h( k, k ) )+abs( h( k+1,
390 $ k+1 ) )+abs( h( k+2, k+2 ) ) ) )
THEN
406 h( k+1, k ) = h( k+1, k ) - refsum
419 k = krcol + 3*( m22-1 )
421 IF( k.EQ.ktop-1 )
THEN
422 CALL dlaqr1( 2, h( k+1, k+1 ), ldh, sr( 2*m22-1 ),
423 $ si( 2*m22-1 ), sr( 2*m22 ), si( 2*m22 ),
426 CALL dlarfg( 2, beta, v( 2, m22 ), 1, v( 1, m22 ) )
429 v( 2, m22 ) = h( k+2, k )
430 CALL dlarfg( 2, beta, v( 2, m22 ), 1, v( 1, m22 ) )
445 jbot =
min(
max(incol+kdu,ndcol), kbot )
446 ELSE IF( wantt )
THEN
451 DO 40 j =
max( ktop, krcol ), jbot
452 mend =
min( mbot, ( j-krcol+2 ) / 3 )
454 k = krcol + 3*( m-1 )
455 refsum = v( 1, m )*( h( k+1, j )+v( 2, m )*
456 $ h( k+2, j )+v( 3, m )*h( k+3, j ) )
457 h( k+1, j ) = h( k+1, j ) - refsum
458 h( k+2, j ) = h( k+2, j ) - refsum*v( 2, m )
459 h( k+3, j ) = h( k+3, j ) - refsum*v( 3, m )
463 k = krcol + 3*( m22-1 )
464 DO 50 j =
max( k+1, ktop ), jbot
465 refsum = v( 1, m22 )*( h( k+1, j )+v( 2, m22 )*
467 h( k+1, j ) = h( k+1, j ) - refsum
468 h( k+2, j ) = h( k+2, j ) - refsum*v( 2, m22 )
477 jtop =
max( ktop, incol )
478 ELSE IF( wantt )
THEN
484 IF( v( 1, m ).NE.zero )
THEN
485 k = krcol + 3*( m-1 )
486 DO 60 j = jtop,
min( kbot, k+3 )
487 refsum = v( 1, m )*( h( j, k+1 )+v( 2, m )*
488 $ h( j, k+2 )+v( 3, m )*h( j, k+3 ) )
489 h( j, k+1 ) = h( j, k+1 ) - refsum
490 h( j, k+2 ) = h( j, k+2 ) - refsum*v( 2, m )
491 h( j, k+3 ) = h( j, k+3 ) - refsum*v( 3, m )
501 DO 70 j =
max( 1, ktop-incol ), kdu
502 refsum = v( 1, m )*( u( j, kms+1 )+v( 2, m )*
503 $ u( j, kms+2 )+v( 3, m )*u( j, kms+3 ) )
504 u( j, kms+1 ) = u( j, kms+1 ) - refsum
505 u( j, kms+2 ) = u( j, kms+2 ) - refsum*v( 2, m )
506 u( j, kms+3 ) = u( j, kms+3 ) - refsum*v( 3, m )
508 ELSE IF( wantz )
THEN
515 refsum = v( 1, m )*( z( j, k+1 )+v( 2, m )*
516 $ z( j, k+2 )+v( 3, m )*z( j, k+3 ) )
517 z( j, k+1 ) = z( j, k+1 ) - refsum
518 z( j, k+2 ) = z( j, k+2 ) - refsum*v( 2, m )
519 z( j, k+3 ) = z( j, k+3 ) - refsum*v( 3, m )
527 k = krcol + 3*( m22-1 )
529 IF( v( 1, m22 ).NE.zero )
THEN
530 DO 100 j = jtop,
min( kbot, k+3 )
531 refsum = v( 1, m22 )*( h( j, k+1 )+v( 2, m22 )*
533 h( j, k+1 ) = h( j, k+1 ) - refsum
534 h( j, k+2 ) = h( j, k+2 ) - refsum*v( 2, m22 )
539 DO 110 j =
max( 1, ktop-incol ), kdu
540 refsum = v( 1, m22 )*( u( j, kms+1 ) +
541 $ v( 2, m22 )*u( j, kms+2 ) )
542 u( j, kms+1 ) = u( j, kms+1 ) - refsum
543 u( j, kms+2 ) = u( j, kms+2 ) -
546 ELSE IF( wantz )
THEN
547 DO 120 j = iloz, ihiz
548 refsum = v( 1, m22 )*( z( j, k+1 )+v( 2, m22 )*
550 z( j, k+1 ) = z( j, k+1 ) - refsum
551 z( j, k+2 ) = z( j, k+2 ) - refsum*v( 2, m22 )
560 IF( krcol+3*( mstart-1 ).LT.ktop )
561 $ mstart = mstart + 1
565 IF( krcol.EQ.kbot-2 )
567 DO 130 m = mstart, mend
568 k =
min( kbot-1, krcol+3*( m-1 ) )
579 IF( h( k+1, k ).NE.zero )
THEN
580 tst1 = abs( h( k, k ) ) + abs( h( k+1, k+1 ) )
581 IF( tst1.EQ.zero )
THEN
583 $ tst1 = tst1 + abs( h( k, k-1 ) )
585 $ tst1 = tst1 + abs( h( k, k-2 ) )
587 $ tst1 = tst1 + abs( h( k, k-3 ) )
589 $ tst1 = tst1 + abs( h( k+2, k+1 ) )
591 $ tst1 = tst1 + abs( h( k+3, k+1 ) )
593 $ tst1 = tst1 + abs( h( k+4, k+1 ) )
595 IF( abs( h( k+1, k ) ).LE.
max( smlnum, ulp*tst1 ) )
597 h12 =
max( abs( h( k+1, k ) ), abs( h( k, k+1 ) ) )
598 h21 =
min( abs( h( k+1, k ) ), abs( h( k, k+1 ) ) )
599 h11 =
max( abs( h( k+1, k+1 ) ),
600 $ abs( h( k, k )-h( k+1, k+1 ) ) )
601 h22 =
min( abs( h( k+1, k+1 ) ),
602 $ abs( h( k, k )-h( k+1, k+1 ) ) )
604 tst2 = h22*( h11 / scl )
606 IF( tst2.EQ.zero .OR. h21*( h12 / scl ).LE.
607 $
max( smlnum, ulp*tst2 ) )h( k+1, k ) = zero
614 mend =
min( nbmps, ( kbot-krcol-1 ) / 3 )
615 DO 140 m = mtop, mend
616 k = krcol + 3*( m-1 )
617 refsum = v( 1, m )*v( 3, m )*h( k+4, k+3 )
618 h( k+4, k+1 ) = -refsum
619 h( k+4, k+2 ) = -refsum*v( 2, m )
620 h( k+4, k+3 ) = h( k+4, k+3 ) - refsum*v( 3, m )
639 k1 =
max( 1, ktop-incol )
640 nu = ( kdu-
max( 0,
max(incol+kdu,ndcol)-kbot ) ) - k1 + 1
641 IF( ( .NOT.blk22 ) .OR. ( incol.LT.ktop ) .OR.
642 $ ( ndcol.GT.kbot ) .OR. ( ns.LE.2 ) .OR.
656 DO 160 jcol =
min(
max(incol+kdu,ndcol),kbot)+ 1, jbot, nh
657 jlen =
min( nh, jbot-jcol+1 )
658 CALL dgemm(
'C',
'N', nu, jlen, nu, one, u( k1, k1 ),
659 $ ldu, h( incol+k1, jcol ), ldh, zero, wh,
661 CALL dlamov(
'ALL', nu, jlen, wh, ldwh,
662 $ h( incol+k1, jcol ), ldh )
667 DO 170 jrow = jtop,
max( ktop, incol ) - 1, nv
668 jlen =
min( nv,
max( ktop, incol )-jrow )
669 CALL dgemm(
'N',
'N', jlen, nu, nu, one,
670 $ h( jrow, incol+k1 ), ldh, u( k1, k1 ),
671 $ ldu, zero, wv, ldwv )
672 CALL dlamov(
'ALL', jlen, nu, wv, ldwv,
673 $ h( jrow, incol+k1 ), ldh )
679 DO 180 jrow = iloz, ihiz, nv
680 jlen =
min( nv, ihiz-jrow+1 )
681 CALL dgemm(
'N',
'N', jlen, nu, nu, one,
682 $ z( jrow, incol+k1 ), ldz, u( k1, k1 ),
683 $ ldu, zero, wv, ldwv )
684 CALL dlamov(
'ALL', jlen, nu, wv, ldwv,
685 $ z( jrow, incol+k1 ), ldz )
703 kzs = ( j4-j2 ) - ( ns+1 )
708 DO 190 jcol =
min(
max(incol+kdu,ndcol),kbot)+ 1, jbot, nh
709 jlen =
min( nh, jbot-jcol+1 )
714 CALL dlamov(
'ALL', knz, jlen, h( incol+1+j2, jcol ),
715 $ ldh, wh( kzs+1, 1 ), ldwh )
716 CALL dlaset(
'ALL', kzs, jlen, zero, zero, wh, ldwh )
720 CALL dtrmm(
'L',
'U',
'C',
'N', knz, jlen, one,
721 $ u( j2+1, 1+kzs ), ldu, wh( kzs+1, 1 ),
726 CALL dgemm(
'C',
'N', i2, jlen, j2, one, u, ldu,
727 $ h( incol+1, jcol ), ldh, one, wh, ldwh )
731 CALL dlamov(
'ALL', j2, jlen, h( incol+1, jcol ), ldh,
732 $ wh( i2+1, 1 ), ldwh )
736 CALL dtrmm(
'L',
'L',
'C',
'N', j2, jlen, one,
737 $ u( 1, i2+1 ), ldu, wh( i2+1, 1 ), ldwh )
741 CALL dgemm(
'C',
'N', i4-i2, jlen, j4-j2, one,
742 $ u( j2+1, i2+1 ), ldu,
743 $ h( incol+1+j2, jcol ), ldh, one,
744 $ wh( i2+1, 1 ), ldwh )
748 CALL dlamov(
'ALL', kdu, jlen, wh, ldwh,
749 $ h( incol+1, jcol ), ldh )
754 DO 200 jrow = jtop,
max( incol, ktop ) - 1, nv
755 jlen =
min( nv,
max( incol, ktop )-jrow )
760 CALL dlamov(
'ALL', jlen, knz, h( jrow, incol+1+j2 ),
761 $ ldh, wv( 1, 1+kzs ), ldwv )
762 CALL dlaset(
'ALL', jlen, kzs, zero, zero, wv, ldwv )
766 CALL dtrmm(
'R',
'U',
'N',
'N', jlen, knz, one,
767 $ u( j2+1, 1+kzs ), ldu, wv( 1, 1+kzs ),
772 CALL dgemm(
'N',
'N', jlen, i2, j2, one,
773 $ h( jrow, incol+1 ), ldh, u, ldu, one, wv,
778 CALL dlamov(
'ALL', jlen, j2, h( jrow, incol+1 ), ldh,
779 $ wv( 1, 1+i2 ), ldwv )
783 CALL dtrmm(
'R',
'L',
'N',
'N', jlen, i4-i2, one,
784 $ u( 1, i2+1 ), ldu, wv( 1, 1+i2 ), ldwv )
788 CALL dgemm(
'N',
'N', jlen, i4-i2, j4-j2, one,
789 $ h( jrow, incol+1+j2 ), ldh,
790 $ u( j2+1, i2+1 ), ldu, one, wv( 1, 1+i2 ),
795 CALL dlamov(
'ALL', jlen, kdu, wv, ldwv,
796 $ h( jrow, incol+1 ), ldh )
802 DO 210 jrow = iloz, ihiz, nv
803 jlen =
min( nv, ihiz-jrow+1 )
808 CALL dlamov(
'ALL', jlen, knz,
809 $ z( jrow, incol+1+j2 ), ldz,
810 $ wv( 1, 1+kzs ), ldwv )
814 CALL dlaset(
'ALL', jlen, kzs, zero, zero, wv,
816 CALL dtrmm(
'R',
'U',
'N',
'N', jlen, knz, one,
817 $ u( j2+1, 1+kzs ), ldu, wv( 1, 1+kzs ),
822 CALL dgemm(
'N',
'N', jlen, i2, j2, one,
823 $ z( jrow, incol+1 ), ldz, u, ldu, one,
828 CALL dlamov(
'ALL', jlen, j2, z( jrow, incol+1 ),
829 $ ldz, wv( 1, 1+i2 ), ldwv )
833 CALL dtrmm(
'R',
'L',
'N',
'N', jlen, i4-i2, one,
834 $ u( 1, i2+1 ), ldu, wv( 1, 1+i2 ),
839 CALL dgemm(
'N',
'N', jlen, i4-i2, j4-j2, one,
840 $ z( jrow, incol+1+j2 ), ldz,
841 $ u( j2+1, i2+1 ), ldu, one,
842 $ wv( 1, 1+i2 ), ldwv )
846 CALL dlamov(
'ALL', jlen, kdu, wv, ldwv,
847 $ z( jrow, incol+1 ), ldz )
857 $
CALL dlaset(
'Lower', n-4, n-4, zero, zero, h(5,1), ldh )