254 SUBROUTINE zlaqr5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, S,
255 $ H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, LDU, NV,
256 $ WV, LDWV, NH, WH, LDWH )
264 INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,
265 $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV
269 COMPLEX*16 H( LDH, * ), S( * ), U( LDU, * ), V( LDV, * ),
270 $ WH( LDWH, * ), WV( LDWV, * ), Z( LDZ, * )
276 PARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),
277 $ one = ( 1.0d0, 0.0d0 ) )
278 DOUBLE PRECISION RZERO, RONE
279 PARAMETER ( RZERO = 0.0d0, rone = 1.0d0 )
282 COMPLEX*16 ALPHA, BETA, CDUM, REFSUM, T1, T2, T3
283 DOUBLE PRECISION H11, H12, H21, H22, SAFMAX, SAFMIN, SCL,
284 $ smlnum, tst1, tst2, ulp
285 INTEGER I2, I4, INCOL, J, JBOT, JCOL, JLEN,
286 $ JROW, JTOP, K, K1, KDU, KMS, KRCOL,
287 $ m, m22, mbot, mtop, nbmps, ndcol,
292 DOUBLE PRECISION DLAMCH
297 INTRINSIC abs, dble, dconjg, dimag, max, min, mod
306 DOUBLE PRECISION CABS1
309 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
327 ns = nshfts - mod( nshfts, 2 )
331 safmin = dlamch(
'SAFE MINIMUM' )
332 safmax = rone / safmin
333 ulp = dlamch(
'PRECISION' )
334 smlnum = safmin*( dble( n ) / ulp )
339 accum = ( kacc22.EQ.1 ) .OR. ( kacc22.EQ.2 )
344 $ h( ktop+2, ktop ) = zero
356 DO 180 incol = ktop - 2*nbmps + 1, kbot - 2, 2*nbmps
361 jtop = max( ktop, incol )
362 ELSE IF( wantt )
THEN
370 $
CALL zlaset(
'ALL', kdu, kdu, zero, one, u, ldu )
384 DO 145 krcol = incol, min( incol+2*nbmps-1, kbot-2 )
393 mtop = max( 1, ( ktop-krcol ) / 2+1 )
394 mbot = min( nbmps, ( kbot-krcol-1 ) / 2 )
396 bmp22 = ( mbot.LT.nbmps ) .AND. ( krcol+2*( m22-1 ) ).EQ.
407 k = krcol + 2*( m22-1 )
408 IF( k.EQ.ktop-1 )
THEN
409 CALL zlaqr1( 2, h( k+1, k+1 ), ldh, s( 2*m22-1 ),
410 $ s( 2*m22 ), v( 1, m22 ) )
412 CALL zlarfg( 2, beta, v( 2, m22 ), 1, v( 1, m22 ) )
415 v( 2, m22 ) = h( k+2, k )
416 CALL zlarfg( 2, beta, v( 2, m22 ), 1, v( 1, m22 ) )
426 t2 = t1*dconjg( v( 2, m22 ) )
427 DO 30 j = jtop, min( kbot, k+3 )
428 refsum = h( j, k+1 ) + v( 2, m22 )*h( j, k+2 )
429 h( j, k+1 ) = h( j, k+1 ) - refsum*t1
430 h( j, k+2 ) = h( j, k+2 ) - refsum*t2
437 jbot = min( ndcol, kbot )
438 ELSE IF( wantt )
THEN
443 t1 = dconjg( v( 1, m22 ) )
446 refsum = h( k+1, j ) +
447 $ dconjg( v( 2, m22 ) )*h( k+2, j )
448 h( k+1, j ) = h( k+1, j ) - refsum*t1
449 h( k+2, j ) = h( k+2, j ) - refsum*t2
462 IF( h( k+1, k ).NE.zero )
THEN
463 tst1 = cabs1( h( k, k ) ) + cabs1( h( k+1, k+1 ) )
464 IF( tst1.EQ.rzero )
THEN
466 $ tst1 = tst1 + cabs1( h( k, k-1 ) )
468 $ tst1 = tst1 + cabs1( h( k, k-2 ) )
470 $ tst1 = tst1 + cabs1( h( k, k-3 ) )
472 $ tst1 = tst1 + cabs1( h( k+2, k+1 ) )
474 $ tst1 = tst1 + cabs1( h( k+3, k+1 ) )
476 $ tst1 = tst1 + cabs1( h( k+4, k+1 ) )
478 IF( cabs1( h( k+1, k ) )
479 $ .LE.max( smlnum, ulp*tst1 ) )
THEN
480 h12 = max( cabs1( h( k+1, k ) ),
481 $ cabs1( h( k, k+1 ) ) )
482 h21 = min( cabs1( h( k+1, k ) ),
483 $ cabs1( h( k, k+1 ) ) )
484 h11 = max( cabs1( h( k+1, k+1 ) ),
485 $ cabs1( h( k, k )-h( k+1, k+1 ) ) )
486 h22 = min( cabs1( h( k+1, k+1 ) ),
487 $ cabs1( h( k, k )-h( k+1, k+1 ) ) )
489 tst2 = h22*( h11 / scl )
491 IF( tst2.EQ.rzero .OR. h21*( h12 / scl ).LE.
492 $ max( smlnum, ulp*tst2 ) )h( k+1, k ) = zero
501 DO 50 j = max( 1, ktop-incol ), kdu
502 refsum = v( 1, m22 )*( u( j, kms+1 )+
503 $ v( 2, m22 )*u( j, kms+2 ) )
504 u( j, kms+1 ) = u( j, kms+1 ) - refsum
505 u( j, kms+2 ) = u( j, kms+2 ) -
506 $ refsum*dconjg( v( 2, m22 ) )
508 ELSE IF( wantz )
THEN
510 refsum = v( 1, m22 )*( z( j, k+1 )+v( 2, m22 )*
512 z( j, k+1 ) = z( j, k+1 ) - refsum
513 z( j, k+2 ) = z( j, k+2 ) -
514 $ refsum*dconjg( v( 2, m22 ) )
521 DO 80 m = mbot, mtop, -1
522 k = krcol + 2*( m-1 )
523 IF( k.EQ.ktop-1 )
THEN
524 CALL zlaqr1( 3, h( ktop, ktop ), ldh, s( 2*m-1 ),
525 $ s( 2*m ), v( 1, m ) )
527 CALL zlarfg( 3, alpha, v( 2, m ), 1, v( 1, m ) )
535 t2 = t1*dconjg( v( 2, m ) )
536 t3 = t1*dconjg( v( 3, m ) )
537 refsum = v( 3, m )*h( k+3, k+2 )
538 h( k+3, k ) = -refsum*t1
539 h( k+3, k+1 ) = -refsum*t2
540 h( k+3, k+2 ) = h( k+3, k+2 ) - refsum*t3
546 v( 2, m ) = h( k+2, k )
547 v( 3, m ) = h( k+3, k )
548 CALL zlarfg( 3, beta, v( 2, m ), 1, v( 1, m ) )
555 IF( h( k+3, k ).NE.zero .OR. h( k+3, k+1 ).NE.
556 $ zero .OR. h( k+3, k+2 ).EQ.zero )
THEN
571 CALL zlaqr1( 3, h( k+1, k+1 ), ldh, s( 2*m-1 ),
574 CALL zlarfg( 3, alpha, vt( 2 ), 1, vt( 1 ) )
575 t1 = dconjg( vt( 1 ) )
578 refsum = h( k+1, k )+dconjg( vt( 2 ) )*h( k+2, k )
580 IF( cabs1( h( k+2, k )-refsum*t2 )+
581 $ cabs1( refsum*t3 ).GT.ulp*
582 $ ( cabs1( h( k, k ) )+cabs1( h( k+1,
583 $ k+1 ) )+cabs1( h( k+2, k+2 ) ) ) )
THEN
599 h( k+1, k ) = h( k+1, k ) - refsum*t1
616 t2 = t1*dconjg( v( 2, m ) )
617 t3 = t1*dconjg( v( 3, m ) )
618 DO 70 j = jtop, min( kbot, k+3 )
619 refsum = h( j, k+1 ) + v( 2, m )*h( j, k+2 )
620 $ + v( 3, m )*h( j, k+3 )
621 h( j, k+1 ) = h( j, k+1 ) - refsum*t1
622 h( j, k+2 ) = h( j, k+2 ) - refsum*t2
623 h( j, k+3 ) = h( j, k+3 ) - refsum*t3
629 t1 = dconjg( v( 1, m ) )
632 refsum = h( k+1, k+1 )
633 $ + dconjg( v( 2, m ) )*h( k+2, k+1 )
634 $ + dconjg( v( 3, m ) )*h( k+3, k+1 )
635 h( k+1, k+1 ) = h( k+1, k+1 ) - refsum*t1
636 h( k+2, k+1 ) = h( k+2, k+1 ) - refsum*t2
637 h( k+3, k+1 ) = h( k+3, k+1 ) - refsum*t3
650 IF( h( k+1, k ).NE.zero )
THEN
651 tst1 = cabs1( h( k, k ) ) + cabs1( h( k+1, k+1 ) )
652 IF( tst1.EQ.rzero )
THEN
654 $ tst1 = tst1 + cabs1( h( k, k-1 ) )
656 $ tst1 = tst1 + cabs1( h( k, k-2 ) )
658 $ tst1 = tst1 + cabs1( h( k, k-3 ) )
660 $ tst1 = tst1 + cabs1( h( k+2, k+1 ) )
662 $ tst1 = tst1 + cabs1( h( k+3, k+1 ) )
664 $ tst1 = tst1 + cabs1( h( k+4, k+1 ) )
666 IF( cabs1( h( k+1, k ) ).LE.max( smlnum, ulp*tst1 ) )
668 h12 = max( cabs1( h( k+1, k ) ),
669 $ cabs1( h( k, k+1 ) ) )
670 h21 = min( cabs1( h( k+1, k ) ),
671 $ cabs1( h( k, k+1 ) ) )
672 h11 = max( cabs1( h( k+1, k+1 ) ),
673 $ cabs1( h( k, k )-h( k+1, k+1 ) ) )
674 h22 = min( cabs1( h( k+1, k+1 ) ),
675 $ cabs1( h( k, k )-h( k+1, k+1 ) ) )
677 tst2 = h22*( h11 / scl )
679 IF( tst2.EQ.rzero .OR. h21*( h12 / scl ).LE.
680 $ max( smlnum, ulp*tst2 ) )h( k+1, k ) = zero
688 jbot = min( ndcol, kbot )
689 ELSE IF( wantt )
THEN
695 DO 100 m = mbot, mtop, -1
696 k = krcol + 2*( m-1 )
697 t1 = dconjg( v( 1, m ) )
700 DO 90 j = max( ktop, krcol + 2*m ), jbot
701 refsum = h( k+1, j ) + dconjg( v( 2, m ) )*h( k+2, j )
702 $ + dconjg( v( 3, m ) )*h( k+3, j )
703 h( k+1, j ) = h( k+1, j ) - refsum*t1
704 h( k+2, j ) = h( k+2, j ) - refsum*t2
705 h( k+3, j ) = h( k+3, j ) - refsum*t3
717 DO 120 m = mbot, mtop, -1
718 k = krcol + 2*( m-1 )
720 i2 = max( 1, ktop-incol )
721 i2 = max( i2, kms-(krcol-incol)+1 )
722 i4 = min( kdu, krcol + 2*( mbot-1 ) - incol + 5 )
724 t2 = t1*dconjg( v( 2, m ) )
725 t3 = t1*dconjg( v( 3, m ) )
727 refsum = u( j, kms+1 ) + v( 2, m )*u( j, kms+2 )
728 $ + v( 3, m )*u( j, kms+3 )
729 u( j, kms+1 ) = u( j, kms+1 ) - refsum*t1
730 u( j, kms+2 ) = u( j, kms+2 ) - refsum*t2
731 u( j, kms+3 ) = u( j, kms+3 ) - refsum*t3
734 ELSE IF( wantz )
THEN
740 DO 140 m = mbot, mtop, -1
741 k = krcol + 2*( m-1 )
743 t2 = t1*dconjg( v( 2, m ) )
744 t3 = t1*dconjg( v( 3, m ) )
745 DO 130 j = iloz, ihiz
746 refsum = z( j, k+1 ) + v( 2, m )*z( j, k+2 )
747 $ + v( 3, m )*z( j, k+3 )
748 z( j, k+1 ) = z( j, k+1 ) - refsum*t1
749 z( j, k+2 ) = z( j, k+2 ) - refsum*t2
750 z( j, k+3 ) = z( j, k+3 ) - refsum*t3
771 k1 = max( 1, ktop-incol )
772 nu = ( kdu-max( 0, ndcol-kbot ) ) - k1 + 1
776 DO 150 jcol = min( ndcol, kbot ) + 1, jbot, nh
777 jlen = min( nh, jbot-jcol+1 )
778 CALL zgemm(
'C',
'N', nu, jlen, nu, one, u( k1, k1 ),
779 $ ldu, h( incol+k1, jcol ), ldh, zero, wh,
781 CALL zlacpy(
'ALL', nu, jlen, wh, ldwh,
782 $ h( incol+k1, jcol ), ldh )
787 DO 160 jrow = jtop, max( ktop, incol ) - 1, nv
788 jlen = min( nv, max( ktop, incol )-jrow )
789 CALL zgemm(
'N',
'N', jlen, nu, nu, one,
790 $ h( jrow, incol+k1 ), ldh, u( k1, k1 ),
791 $ ldu, zero, wv, ldwv )
792 CALL zlacpy(
'ALL', jlen, nu, wv, ldwv,
793 $ h( jrow, incol+k1 ), ldh )
799 DO 170 jrow = iloz, ihiz, nv
800 jlen = min( nv, ihiz-jrow+1 )
801 CALL zgemm(
'N',
'N', jlen, nu, nu, one,
802 $ z( jrow, incol+k1 ), ldz, u( k1, k1 ),
803 $ ldu, zero, wv, ldwv )
804 CALL zlacpy(
'ALL', jlen, nu, wv, ldwv,
805 $ z( jrow, incol+k1 ), ldz )
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlaqr1(n, h, ldh, s1, s2, v)
ZLAQR1 sets a scalar multiple of the first column of the product of 2-by-2 or 3-by-3 matrix H and spe...
subroutine zlaqr5(wantt, wantz, kacc22, n, ktop, kbot, nshfts, s, h, ldh, iloz, ihiz, z, ldz, v, ldv, u, ldu, nv, wv, ldwv, nh, wh, ldwh)
ZLAQR5 performs a single small-bulge multi-shift QR sweep.
subroutine zlarfg(n, alpha, x, incx, tau)
ZLARFG generates an elementary reflector (Householder matrix).
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine ztrmm(side, uplo, transa, diag, m, n, alpha, a, lda, b, ldb)
ZTRMM