1 *> \brief \b ZLAQR5 performs a single small-bulge multi-shift QR sweep.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZLAQR5 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlaqr5.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlaqr5.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlaqr5.f">
21 * SUBROUTINE ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, S,
22 * H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, LDU, NV,
23 * WV, LDWV, NH, WH, LDWH )
25 * .. Scalar Arguments ..
26 * INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,
27 * $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV
28 * LOGICAL WANTT, WANTZ
30 * .. Array Arguments ..
31 * COMPLEX*16 H( LDH, * ), S( * ), U( LDU, * ), V( LDV, * ),
32 * $ WH( LDWH, * ), WV( LDWV, * ), Z( LDZ, * )
41 *> ZLAQR5, called by ZLAQR0, performs a
42 *> single small-bulge multi-shift QR sweep.
50 *> WANTT is logical scalar
51 *> WANTT = .true. if the triangular Schur factor
52 *> is being computed. WANTT is set to .false. otherwise.
57 *> WANTZ is logical scalar
58 *> WANTZ = .true. if the unitary Schur factor is being
59 *> computed. WANTZ is set to .false. otherwise.
64 *> KACC22 is integer with value 0, 1, or 2.
65 *> Specifies the computation mode of far-from-diagonal
66 *> orthogonal updates.
67 *> = 0: ZLAQR5 does not accumulate reflections and does not
68 *> use matrix-matrix multiply to update far-from-diagonal
70 *> = 1: ZLAQR5 accumulates reflections and uses matrix-matrix
71 *> multiply to update the far-from-diagonal matrix entries.
72 *> = 2: ZLAQR5 accumulates reflections, uses matrix-matrix
73 *> multiply to update the far-from-diagonal matrix entries,
74 *> and takes advantage of 2-by-2 block structure during
80 *> N is integer scalar
81 *> N is the order of the Hessenberg matrix H upon which this
82 *> subroutine operates.
87 *> KTOP is integer scalar
92 *> KBOT is integer scalar
93 *> These are the first and last rows and columns of an
94 *> isolated diagonal block upon which the QR sweep is to be
95 *> applied. It is assumed without a check that
96 *> either KTOP = 1 or H(KTOP,KTOP-1) = 0
98 *> either KBOT = N or H(KBOT+1,KBOT) = 0.
103 *> NSHFTS is integer scalar
104 *> NSHFTS gives the number of simultaneous shifts. NSHFTS
105 *> must be positive and even.
110 *> S is COMPLEX*16 array of size (NSHFTS)
111 *> S contains the shifts of origin that define the multi-
112 *> shift QR sweep. On output S may be reordered.
117 *> H is COMPLEX*16 array of size (LDH,N)
118 *> On input H contains a Hessenberg matrix. On output a
119 *> multi-shift QR sweep with shifts SR(J)+i*SI(J) is applied
120 *> to the isolated diagonal block in rows and columns KTOP
126 *> LDH is integer scalar
127 *> LDH is the leading dimension of H just as declared in the
128 *> calling procedure. LDH.GE.MAX(1,N).
139 *> Specify the rows of Z to which transformations must be
140 *> applied if WANTZ is .TRUE.. 1 .LE. ILOZ .LE. IHIZ .LE. N
145 *> Z is COMPLEX*16 array of size (LDZ,IHIZ)
146 *> If WANTZ = .TRUE., then the QR Sweep unitary
147 *> similarity transformation is accumulated into
148 *> Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right.
149 *> If WANTZ = .FALSE., then Z is unreferenced.
154 *> LDZ is integer scalar
155 *> LDA is the leading dimension of Z just as declared in
156 *> the calling procedure. LDZ.GE.N.
161 *> V is COMPLEX*16 array of size (LDV,NSHFTS/2)
166 *> LDV is integer scalar
167 *> LDV is the leading dimension of V as declared in the
168 *> calling procedure. LDV.GE.3.
173 *> U is COMPLEX*16 array of size
179 *> LDU is integer scalar
180 *> LDU is the leading dimension of U just as declared in the
181 *> in the calling subroutine. LDU.GE.3*NSHFTS-3.
186 *> NH is integer scalar
187 *> NH is the number of columns in array WH available for
188 *> workspace. NH.GE.1.
193 *> WH is COMPLEX*16 array of size (LDWH,NH)
198 *> LDWH is integer scalar
199 *> Leading dimension of WH just as declared in the
200 *> calling procedure. LDWH.GE.3*NSHFTS-3.
205 *> NV is integer scalar
206 *> NV is the number of rows in WV agailable for workspace.
212 *> WV is COMPLEX*16 array of size
218 *> LDWV is integer scalar
219 *> LDWV is the leading dimension of WV as declared in the
220 *> in the calling subroutine. LDWV.GE.NV.
226 *> \author Univ. of Tennessee
227 *> \author Univ. of California Berkeley
228 *> \author Univ. of Colorado Denver
233 *> \ingroup complex16OTHERauxiliary
235 *> \par Contributors:
238 *> Karen Braman and Ralph Byers, Department of Mathematics,
239 *> University of Kansas, USA
244 *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
245 *> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3
246 *> Performance, SIAM Journal of Matrix Analysis, volume 23, pages
249 * =====================================================================
250 SUBROUTINE ZLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, S,
251 $ H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, LDU, NV,
252 $ WV, LDWV, NH, WH, LDWH )
254 * -- LAPACK auxiliary routine (version 3.6.1) --
255 * -- LAPACK is a software package provided by Univ. of Tennessee, --
256 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
259 * .. Scalar Arguments ..
260 INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV,
261 $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV
264 * .. Array Arguments ..
265 COMPLEX*16 H( LDH, * ), S( * ), U( LDU, * ), V( LDV, * ),
266 $ WH( LDWH, * ), WV( LDWV, * ), Z( LDZ, * )
269 * ================================================================
272 PARAMETER ( ZERO = ( 0.0d0, 0.0d0 ),
273 $ ONE = ( 1.0d0, 0.0d0 ) )
274 DOUBLE PRECISION RZERO, RONE
275 PARAMETER ( RZERO = 0.0d0, RONE = 1.0d0 )
277 * .. Local Scalars ..
278 COMPLEX*16 ALPHA, BETA, CDUM, REFSUM
279 DOUBLE PRECISION H11, H12, H21, H22, SAFMAX, SAFMIN, SCL,
280 $ SMLNUM, TST1, TST2, ULP
281 INTEGER I2, I4, INCOL, J, J2, J4, JBOT, JCOL, JLEN,
282 $ JROW, JTOP, K, K1, KDU, KMS, KNZ, KRCOL, KZS,
283 $ M, M22, MBOT, MEND, MSTART, MTOP, NBMPS, NDCOL,
285 LOGICAL ACCUM, BLK22, BMP22
287 * .. External Functions ..
288 DOUBLE PRECISION DLAMCH
291 * .. Intrinsic Functions ..
293 INTRINSIC ABS, DBLE, DCONJG, DIMAG, MAX, MIN, MOD
298 * .. External Subroutines ..
299 EXTERNAL DLABAD, ZGEMM, ZLACPY, ZLAQR1, ZLARFG, ZLASET,
302 * .. Statement Functions ..
303 DOUBLE PRECISION CABS1
305 * .. Statement Function definitions ..
306 CABS1( CDUM ) = ABS( DBLE( CDUM ) ) + ABS( DIMAG( CDUM ) )
308 * .. Executable Statements ..
310 * ==== If there are no shifts, then there is nothing to do. ====
315 * ==== If the active block is empty or 1-by-1, then there
316 * . is nothing to do. ====
321 * ==== NSHFTS is supposed to be even, but if it is odd,
322 * . then simply reduce it by one. ====
324 NS = NSHFTS - MOD( NSHFTS, 2 )
326 * ==== Machine constants for deflation ====
328 SAFMIN = DLAMCH( 'SAFE MINIMUM' )
329 SAFMAX = RONE / SAFMIN
330 CALL DLABAD( SAFMIN, SAFMAX )
331 ULP = DLAMCH( 'PRECISION' )
332 SMLNUM = SAFMIN*( DBLE( N ) / ULP )
334 * ==== Use accumulated reflections to update far-from-diagonal
337 ACCUM = ( KACC22.EQ.1 ) .OR. ( KACC22.EQ.2 )
339 * ==== If so, exploit the 2-by-2 block structure? ====
341 BLK22 = ( NS.GT.2 ) .AND. ( KACC22.EQ.2 )
343 * ==== clear trash ====
346 $ H( KTOP+2, KTOP ) = ZERO
348 * ==== NBMPS = number of 2-shift bulges in the chain ====
352 * ==== KDU = width of slab ====
356 * ==== Create and chase chains of NBMPS bulges ====
358 DO 210 INCOL = 3*( 1-NBMPS ) + KTOP - 1, KBOT - 2, 3*NBMPS - 2
361 $ CALL ZLASET( 'ALL', KDU, KDU, ZERO, ONE, U, LDU )
363 * ==== Near-the-diagonal bulge chase. The following loop
364 * . performs the near-the-diagonal part of a small bulge
365 * . multi-shift QR sweep. Each 6*NBMPS-2 column diagonal
366 * . chunk extends from column INCOL to column NDCOL
367 * . (including both column INCOL and column NDCOL). The
368 * . following loop chases a 3*NBMPS column long chain of
369 * . NBMPS bulges 3*NBMPS-2 columns to the right. (INCOL
370 * . may be less than KTOP and and NDCOL may be greater than
371 * . KBOT indicating phantom columns from which to chase
372 * . bulges before they are actually introduced or to which
373 * . to chase bulges beyond column KBOT.) ====
375 DO 140 KRCOL = INCOL, MIN( INCOL+3*NBMPS-3, KBOT-2 )
377 * ==== Bulges number MTOP to MBOT are active double implicit
378 * . shift bulges. There may or may not also be small
379 * . 2-by-2 bulge, if there is room. The inactive bulges
380 * . (if any) must wait until the active bulges have moved
381 * . down the diagonal to make room. The phantom matrix
382 * . paradigm described above helps keep track. ====
384 MTOP = MAX( 1, ( ( KTOP-1 )-KRCOL+2 ) / 3+1 )
385 MBOT = MIN( NBMPS, ( KBOT-KRCOL ) / 3 )
387 BMP22 = ( MBOT.LT.NBMPS ) .AND. ( KRCOL+3*( M22-1 ) ).EQ.
390 * ==== Generate reflections to chase the chain right
391 * . one column. (The minimum value of K is KTOP-1.) ====
394 K = KRCOL + 3*( M-1 )
395 IF( K.EQ.KTOP-1 ) THEN
396 CALL ZLAQR1( 3, H( KTOP, KTOP ), LDH, S( 2*M-1 ),
397 $ S( 2*M ), V( 1, M ) )
399 CALL ZLARFG( 3, ALPHA, V( 2, M ), 1, V( 1, M ) )
402 V( 2, M ) = H( K+2, K )
403 V( 3, M ) = H( K+3, K )
404 CALL ZLARFG( 3, BETA, V( 2, M ), 1, V( 1, M ) )
406 * ==== A Bulge may collapse because of vigilant
407 * . deflation or destructive underflow. In the
408 * . underflow case, try the two-small-subdiagonals
409 * . trick to try to reinflate the bulge. ====
411 IF( H( K+3, K ).NE.ZERO .OR. H( K+3, K+1 ).NE.
412 $ ZERO .OR. H( K+3, K+2 ).EQ.ZERO ) THEN
414 * ==== Typical case: not collapsed (yet). ====
421 * ==== Atypical case: collapsed. Attempt to
422 * . reintroduce ignoring H(K+1,K) and H(K+2,K).
423 * . If the fill resulting from the new
424 * . reflector is too large, then abandon it.
425 * . Otherwise, use the new one. ====
427 CALL ZLAQR1( 3, H( K+1, K+1 ), LDH, S( 2*M-1 ),
430 CALL ZLARFG( 3, ALPHA, VT( 2 ), 1, VT( 1 ) )
431 REFSUM = DCONJG( VT( 1 ) )*
432 $ ( H( K+1, K )+DCONJG( VT( 2 ) )*
435 IF( CABS1( H( K+2, K )-REFSUM*VT( 2 ) )+
436 $ CABS1( REFSUM*VT( 3 ) ).GT.ULP*
437 $ ( CABS1( H( K, K ) )+CABS1( H( K+1,
438 $ K+1 ) )+CABS1( H( K+2, K+2 ) ) ) ) THEN
440 * ==== Starting a new bulge here would
441 * . create non-negligible fill. Use
442 * . the old one with trepidation. ====
449 * ==== Stating a new bulge here would
450 * . create only negligible fill.
451 * . Replace the old reflector with
452 * . the new one. ====
454 H( K+1, K ) = H( K+1, K ) - REFSUM
465 * ==== Generate a 2-by-2 reflection, if needed. ====
467 K = KRCOL + 3*( M22-1 )
469 IF( K.EQ.KTOP-1 ) THEN
470 CALL ZLAQR1( 2, H( K+1, K+1 ), LDH, S( 2*M22-1 ),
471 $ S( 2*M22 ), V( 1, M22 ) )
473 CALL ZLARFG( 2, BETA, V( 2, M22 ), 1, V( 1, M22 ) )
476 V( 2, M22 ) = H( K+2, K )
477 CALL ZLARFG( 2, BETA, V( 2, M22 ), 1, V( 1, M22 ) )
483 * ==== Multiply H by reflections from the left ====
486 JBOT = MIN( NDCOL, KBOT )
487 ELSE IF( WANTT ) THEN
492 DO 30 J = MAX( KTOP, KRCOL ), JBOT
493 MEND = MIN( MBOT, ( J-KRCOL+2 ) / 3 )
495 K = KRCOL + 3*( M-1 )
496 REFSUM = DCONJG( V( 1, M ) )*
497 $ ( H( K+1, J )+DCONJG( V( 2, M ) )*
498 $ H( K+2, J )+DCONJG( V( 3, M ) )*H( K+3, J ) )
499 H( K+1, J ) = H( K+1, J ) - REFSUM
500 H( K+2, J ) = H( K+2, J ) - REFSUM*V( 2, M )
501 H( K+3, J ) = H( K+3, J ) - REFSUM*V( 3, M )
505 K = KRCOL + 3*( M22-1 )
506 DO 40 J = MAX( K+1, KTOP ), JBOT
507 REFSUM = DCONJG( V( 1, M22 ) )*
508 $ ( H( K+1, J )+DCONJG( V( 2, M22 ) )*
510 H( K+1, J ) = H( K+1, J ) - REFSUM
511 H( K+2, J ) = H( K+2, J ) - REFSUM*V( 2, M22 )
515 * ==== Multiply H by reflections from the right.
516 * . Delay filling in the last row until the
517 * . vigilant deflation check is complete. ====
520 JTOP = MAX( KTOP, INCOL )
521 ELSE IF( WANTT ) THEN
527 IF( V( 1, M ).NE.ZERO ) THEN
528 K = KRCOL + 3*( M-1 )
529 DO 50 J = JTOP, MIN( KBOT, K+3 )
530 REFSUM = V( 1, M )*( H( J, K+1 )+V( 2, M )*
531 $ H( J, K+2 )+V( 3, M )*H( J, K+3 ) )
532 H( J, K+1 ) = H( J, K+1 ) - REFSUM
533 H( J, K+2 ) = H( J, K+2 ) -
534 $ REFSUM*DCONJG( V( 2, M ) )
535 H( J, K+3 ) = H( J, K+3 ) -
536 $ REFSUM*DCONJG( V( 3, M ) )
541 * ==== Accumulate U. (If necessary, update Z later
542 * . with with an efficient matrix-matrix
546 DO 60 J = MAX( 1, KTOP-INCOL ), KDU
547 REFSUM = V( 1, M )*( U( J, KMS+1 )+V( 2, M )*
548 $ U( J, KMS+2 )+V( 3, M )*U( J, KMS+3 ) )
549 U( J, KMS+1 ) = U( J, KMS+1 ) - REFSUM
550 U( J, KMS+2 ) = U( J, KMS+2 ) -
551 $ REFSUM*DCONJG( V( 2, M ) )
552 U( J, KMS+3 ) = U( J, KMS+3 ) -
553 $ REFSUM*DCONJG( V( 3, M ) )
555 ELSE IF( WANTZ ) THEN
557 * ==== U is not accumulated, so update Z
558 * . now by multiplying by reflections
559 * . from the right. ====
562 REFSUM = V( 1, M )*( Z( J, K+1 )+V( 2, M )*
563 $ Z( J, K+2 )+V( 3, M )*Z( J, K+3 ) )
564 Z( J, K+1 ) = Z( J, K+1 ) - REFSUM
565 Z( J, K+2 ) = Z( J, K+2 ) -
566 $ REFSUM*DCONJG( V( 2, M ) )
567 Z( J, K+3 ) = Z( J, K+3 ) -
568 $ REFSUM*DCONJG( V( 3, M ) )
574 * ==== Special case: 2-by-2 reflection (if needed) ====
576 K = KRCOL + 3*( M22-1 )
578 IF ( V( 1, M22 ).NE.ZERO ) THEN
579 DO 90 J = JTOP, MIN( KBOT, K+3 )
580 REFSUM = V( 1, M22 )*( H( J, K+1 )+V( 2, M22 )*
582 H( J, K+1 ) = H( J, K+1 ) - REFSUM
583 H( J, K+2 ) = H( J, K+2 ) -
584 $ REFSUM*DCONJG( V( 2, M22 ) )
589 DO 100 J = MAX( 1, KTOP-INCOL ), KDU
590 REFSUM = V( 1, M22 )*( U( J, KMS+1 )+
591 $ V( 2, M22 )*U( J, KMS+2 ) )
592 U( J, KMS+1 ) = U( J, KMS+1 ) - REFSUM
593 U( J, KMS+2 ) = U( J, KMS+2 ) -
594 $ REFSUM*DCONJG( V( 2, M22 ) )
596 ELSE IF( WANTZ ) THEN
597 DO 110 J = ILOZ, IHIZ
598 REFSUM = V( 1, M22 )*( Z( J, K+1 )+V( 2, M22 )*
600 Z( J, K+1 ) = Z( J, K+1 ) - REFSUM
601 Z( J, K+2 ) = Z( J, K+2 ) -
602 $ REFSUM*DCONJG( V( 2, M22 ) )
608 * ==== Vigilant deflation check ====
611 IF( KRCOL+3*( MSTART-1 ).LT.KTOP )
612 $ MSTART = MSTART + 1
616 IF( KRCOL.EQ.KBOT-2 )
618 DO 120 M = MSTART, MEND
619 K = MIN( KBOT-1, KRCOL+3*( M-1 ) )
621 * ==== The following convergence test requires that
622 * . the tradition small-compared-to-nearby-diagonals
623 * . criterion and the Ahues & Tisseur (LAWN 122, 1997)
624 * . criteria both be satisfied. The latter improves
625 * . accuracy in some examples. Falling back on an
626 * . alternate convergence criterion when TST1 or TST2
627 * . is zero (as done here) is traditional but probably
628 * . unnecessary. ====
630 IF( H( K+1, K ).NE.ZERO ) THEN
631 TST1 = CABS1( H( K, K ) ) + CABS1( H( K+1, K+1 ) )
632 IF( TST1.EQ.RZERO ) THEN
634 $ TST1 = TST1 + CABS1( H( K, K-1 ) )
636 $ TST1 = TST1 + CABS1( H( K, K-2 ) )
638 $ TST1 = TST1 + CABS1( H( K, K-3 ) )
640 $ TST1 = TST1 + CABS1( H( K+2, K+1 ) )
642 $ TST1 = TST1 + CABS1( H( K+3, K+1 ) )
644 $ TST1 = TST1 + CABS1( H( K+4, K+1 ) )
646 IF( CABS1( H( K+1, K ) ).LE.MAX( SMLNUM, ULP*TST1 ) )
648 H12 = MAX( CABS1( H( K+1, K ) ),
649 $ CABS1( H( K, K+1 ) ) )
650 H21 = MIN( CABS1( H( K+1, K ) ),
651 $ CABS1( H( K, K+1 ) ) )
652 H11 = MAX( CABS1( H( K+1, K+1 ) ),
653 $ CABS1( H( K, K )-H( K+1, K+1 ) ) )
654 H22 = MIN( CABS1( H( K+1, K+1 ) ),
655 $ CABS1( H( K, K )-H( K+1, K+1 ) ) )
657 TST2 = H22*( H11 / SCL )
659 IF( TST2.EQ.RZERO .OR. H21*( H12 / SCL ).LE.
660 $ MAX( SMLNUM, ULP*TST2 ) )H( K+1, K ) = ZERO
665 * ==== Fill in the last row of each bulge. ====
667 MEND = MIN( NBMPS, ( KBOT-KRCOL-1 ) / 3 )
668 DO 130 M = MTOP, MEND
669 K = KRCOL + 3*( M-1 )
670 REFSUM = V( 1, M )*V( 3, M )*H( K+4, K+3 )
671 H( K+4, K+1 ) = -REFSUM
672 H( K+4, K+2 ) = -REFSUM*DCONJG( V( 2, M ) )
673 H( K+4, K+3 ) = H( K+4, K+3 ) -
674 $ REFSUM*DCONJG( V( 3, M ) )
677 * ==== End of near-the-diagonal bulge chase. ====
681 * ==== Use U (if accumulated) to update far-from-diagonal
682 * . entries in H. If required, use U to update Z as
693 IF( ( .NOT.BLK22 ) .OR. ( INCOL.LT.KTOP ) .OR.
694 $ ( NDCOL.GT.KBOT ) .OR. ( NS.LE.2 ) ) THEN
696 * ==== Updates not exploiting the 2-by-2 block
697 * . structure of U. K1 and NU keep track of
698 * . the location and size of U in the special
699 * . cases of introducing bulges and chasing
700 * . bulges off the bottom. In these special
701 * . cases and in case the number of shifts
702 * . is NS = 2, there is no 2-by-2 block
703 * . structure to exploit. ====
705 K1 = MAX( 1, KTOP-INCOL )
706 NU = ( KDU-MAX( 0, NDCOL-KBOT ) ) - K1 + 1
708 * ==== Horizontal Multiply ====
710 DO 150 JCOL = MIN( NDCOL, KBOT ) + 1, JBOT, NH
711 JLEN = MIN( NH, JBOT-JCOL+1 )
712 CALL ZGEMM( 'C', 'N', NU, JLEN, NU, ONE, U( K1, K1 ),
713 $ LDU, H( INCOL+K1, JCOL ), LDH, ZERO, WH,
715 CALL ZLACPY( 'ALL', NU, JLEN, WH, LDWH,
716 $ H( INCOL+K1, JCOL ), LDH )
719 * ==== Vertical multiply ====
721 DO 160 JROW = JTOP, MAX( KTOP, INCOL ) - 1, NV
722 JLEN = MIN( NV, MAX( KTOP, INCOL )-JROW )
723 CALL ZGEMM( 'N', 'N', JLEN, NU, NU, ONE,
724 $ H( JROW, INCOL+K1 ), LDH, U( K1, K1 ),
725 $ LDU, ZERO, WV, LDWV )
726 CALL ZLACPY( 'ALL', JLEN, NU, WV, LDWV,
727 $ H( JROW, INCOL+K1 ), LDH )
730 * ==== Z multiply (also vertical) ====
733 DO 170 JROW = ILOZ, IHIZ, NV
734 JLEN = MIN( NV, IHIZ-JROW+1 )
735 CALL ZGEMM( 'N', 'N', JLEN, NU, NU, ONE,
736 $ Z( JROW, INCOL+K1 ), LDZ, U( K1, K1 ),
737 $ LDU, ZERO, WV, LDWV )
738 CALL ZLACPY( 'ALL', JLEN, NU, WV, LDWV,
739 $ Z( JROW, INCOL+K1 ), LDZ )
744 * ==== Updates exploiting U's 2-by-2 block structure.
745 * . (I2, I4, J2, J4 are the last rows and columns
746 * . of the blocks.) ====
753 * ==== KZS and KNZ deal with the band of zeros
754 * . along the diagonal of one of the triangular
757 KZS = ( J4-J2 ) - ( NS+1 )
760 * ==== Horizontal multiply ====
762 DO 180 JCOL = MIN( NDCOL, KBOT ) + 1, JBOT, NH
763 JLEN = MIN( NH, JBOT-JCOL+1 )
765 * ==== Copy bottom of H to top+KZS of scratch ====
766 * (The first KZS rows get multiplied by zero.) ====
768 CALL ZLACPY( 'ALL', KNZ, JLEN, H( INCOL+1+J2, JCOL ),
769 $ LDH, WH( KZS+1, 1 ), LDWH )
771 * ==== Multiply by U21**H ====
773 CALL ZLASET( 'ALL', KZS, JLEN, ZERO, ZERO, WH, LDWH )
774 CALL ZTRMM( 'L', 'U', 'C', 'N', KNZ, JLEN, ONE,
775 $ U( J2+1, 1+KZS ), LDU, WH( KZS+1, 1 ),
778 * ==== Multiply top of H by U11**H ====
780 CALL ZGEMM( 'C', 'N', I2, JLEN, J2, ONE, U, LDU,
781 $ H( INCOL+1, JCOL ), LDH, ONE, WH, LDWH )
783 * ==== Copy top of H to bottom of WH ====
785 CALL ZLACPY( 'ALL', J2, JLEN, H( INCOL+1, JCOL ), LDH,
786 $ WH( I2+1, 1 ), LDWH )
788 * ==== Multiply by U21**H ====
790 CALL ZTRMM( 'L', 'L', 'C', 'N', J2, JLEN, ONE,
791 $ U( 1, I2+1 ), LDU, WH( I2+1, 1 ), LDWH )
793 * ==== Multiply by U22 ====
795 CALL ZGEMM( 'C', 'N', I4-I2, JLEN, J4-J2, ONE,
796 $ U( J2+1, I2+1 ), LDU,
797 $ H( INCOL+1+J2, JCOL ), LDH, ONE,
798 $ WH( I2+1, 1 ), LDWH )
800 * ==== Copy it back ====
802 CALL ZLACPY( 'ALL', KDU, JLEN, WH, LDWH,
803 $ H( INCOL+1, JCOL ), LDH )
806 * ==== Vertical multiply ====
808 DO 190 JROW = JTOP, MAX( INCOL, KTOP ) - 1, NV
809 JLEN = MIN( NV, MAX( INCOL, KTOP )-JROW )
811 * ==== Copy right of H to scratch (the first KZS
812 * . columns get multiplied by zero) ====
814 CALL ZLACPY( 'ALL', JLEN, KNZ, H( JROW, INCOL+1+J2 ),
815 $ LDH, WV( 1, 1+KZS ), LDWV )
817 * ==== Multiply by U21 ====
819 CALL ZLASET( 'ALL', JLEN, KZS, ZERO, ZERO, WV, LDWV )
820 CALL ZTRMM( 'R', 'U', 'N', 'N', JLEN, KNZ, ONE,
821 $ U( J2+1, 1+KZS ), LDU, WV( 1, 1+KZS ),
824 * ==== Multiply by U11 ====
826 CALL ZGEMM( 'N', 'N', JLEN, I2, J2, ONE,
827 $ H( JROW, INCOL+1 ), LDH, U, LDU, ONE, WV,
830 * ==== Copy left of H to right of scratch ====
832 CALL ZLACPY( 'ALL', JLEN, J2, H( JROW, INCOL+1 ), LDH,
833 $ WV( 1, 1+I2 ), LDWV )
835 * ==== Multiply by U21 ====
837 CALL ZTRMM( 'R', 'L', 'N', 'N', JLEN, I4-I2, ONE,
838 $ U( 1, I2+1 ), LDU, WV( 1, 1+I2 ), LDWV )
840 * ==== Multiply by U22 ====
842 CALL ZGEMM( 'N', 'N', JLEN, I4-I2, J4-J2, ONE,
843 $ H( JROW, INCOL+1+J2 ), LDH,
844 $ U( J2+1, I2+1 ), LDU, ONE, WV( 1, 1+I2 ),
847 * ==== Copy it back ====
849 CALL ZLACPY( 'ALL', JLEN, KDU, WV, LDWV,
850 $ H( JROW, INCOL+1 ), LDH )
853 * ==== Multiply Z (also vertical) ====
856 DO 200 JROW = ILOZ, IHIZ, NV
857 JLEN = MIN( NV, IHIZ-JROW+1 )
859 * ==== Copy right of Z to left of scratch (first
860 * . KZS columns get multiplied by zero) ====
862 CALL ZLACPY( 'ALL', JLEN, KNZ,
863 $ Z( JROW, INCOL+1+J2 ), LDZ,
864 $ WV( 1, 1+KZS ), LDWV )
866 * ==== Multiply by U12 ====
868 CALL ZLASET( 'ALL', JLEN, KZS, ZERO, ZERO, WV,
870 CALL ZTRMM( 'R', 'U', 'N', 'N', JLEN, KNZ, ONE,
871 $ U( J2+1, 1+KZS ), LDU, WV( 1, 1+KZS ),
874 * ==== Multiply by U11 ====
876 CALL ZGEMM( 'N', 'N', JLEN, I2, J2, ONE,
877 $ Z( JROW, INCOL+1 ), LDZ, U, LDU, ONE,
880 * ==== Copy left of Z to right of scratch ====
882 CALL ZLACPY( 'ALL', JLEN, J2, Z( JROW, INCOL+1 ),
883 $ LDZ, WV( 1, 1+I2 ), LDWV )
885 * ==== Multiply by U21 ====
887 CALL ZTRMM( 'R', 'L', 'N', 'N', JLEN, I4-I2, ONE,
888 $ U( 1, I2+1 ), LDU, WV( 1, 1+I2 ),
891 * ==== Multiply by U22 ====
893 CALL ZGEMM( 'N', 'N', JLEN, I4-I2, J4-J2, ONE,
894 $ Z( JROW, INCOL+1+J2 ), LDZ,
895 $ U( J2+1, I2+1 ), LDU, ONE,
896 $ WV( 1, 1+I2 ), LDWV )
898 * ==== Copy the result back to Z ====
900 CALL ZLACPY( 'ALL', JLEN, KDU, WV, LDWV,
901 $ Z( JROW, INCOL+1 ), LDZ )
908 * ==== End of ZLAQR5 ====