3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CGGHD3 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgghd3.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgghd3.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgghd3.f">
21 * SUBROUTINE CGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,
22 * $ LDQ, Z, LDZ, WORK, LWORK, INFO )
24 * .. Scalar Arguments ..
25 * CHARACTER COMPQ, COMPZ
26 * INTEGER IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, N, LWORK
28 * .. Array Arguments ..
29 * COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
30 * $ Z( LDZ, * ), WORK( * )
40 *> CGGHD3 reduces a pair of complex matrices (A,B) to generalized upper
41 *> Hessenberg form using unitary transformations, where A is a
42 *> general matrix and B is upper triangular. The form of the
43 *> generalized eigenvalue problem is
45 *> and B is typically made upper triangular by computing its QR
46 *> factorization and moving the unitary matrix Q to the left side
49 *> This subroutine simultaneously reduces A to a Hessenberg matrix H:
51 *> and transforms B to another upper triangular matrix T:
53 *> in order to reduce the problem to its standard form
57 *> The unitary matrices Q and Z are determined as products of Givens
58 *> rotations. They may either be formed explicitly, or they may be
59 *> postmultiplied into input matrices Q1 and Z1, so that
61 *> Q1 * A * Z1**H = (Q1*Q) * H * (Z1*Z)**H
63 *> Q1 * B * Z1**H = (Q1*Q) * T * (Z1*Z)**H
65 *> If Q1 is the unitary matrix from the QR factorization of B in the
66 *> original equation A*x = lambda*B*x, then CGGHD3 reduces the original
67 *> problem to generalized Hessenberg form.
69 *> This is a blocked variant of CGGHRD, using matrix-matrix
70 *> multiplications for parts of the computation to enhance performance.
78 *> COMPQ is CHARACTER*1
79 *> = 'N': do not compute Q;
80 *> = 'I': Q is initialized to the unit matrix, and the
81 *> unitary matrix Q is returned;
82 *> = 'V': Q must contain a unitary matrix Q1 on entry,
83 *> and the product Q1*Q is returned.
88 *> COMPZ is CHARACTER*1
89 *> = 'N': do not compute Z;
90 *> = 'I': Z is initialized to the unit matrix, and the
91 *> unitary matrix Z is returned;
92 *> = 'V': Z must contain a unitary matrix Z1 on entry,
93 *> and the product Z1*Z is returned.
99 *> The order of the matrices A and B. N >= 0.
111 *> ILO and IHI mark the rows and columns of A which are to be
112 *> reduced. It is assumed that A is already upper triangular
113 *> in rows and columns 1:ILO-1 and IHI+1:N. ILO and IHI are
114 *> normally set by a previous call to CGGBAL; otherwise they
115 *> should be set to 1 and N respectively.
116 *> 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
121 *> A is COMPLEX array, dimension (LDA, N)
122 *> On entry, the N-by-N general matrix to be reduced.
123 *> On exit, the upper triangle and the first subdiagonal of A
124 *> are overwritten with the upper Hessenberg matrix H, and the
125 *> rest is set to zero.
131 *> The leading dimension of the array A. LDA >= max(1,N).
136 *> B is COMPLEX array, dimension (LDB, N)
137 *> On entry, the N-by-N upper triangular matrix B.
138 *> On exit, the upper triangular matrix T = Q**H B Z. The
139 *> elements below the diagonal are set to zero.
145 *> The leading dimension of the array B. LDB >= max(1,N).
150 *> Q is COMPLEX array, dimension (LDQ, N)
151 *> On entry, if COMPQ = 'V', the unitary matrix Q1, typically
152 *> from the QR factorization of B.
153 *> On exit, if COMPQ='I', the unitary matrix Q, and if
154 *> COMPQ = 'V', the product Q1*Q.
155 *> Not referenced if COMPQ='N'.
161 *> The leading dimension of the array Q.
162 *> LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.
167 *> Z is COMPLEX array, dimension (LDZ, N)
168 *> On entry, if COMPZ = 'V', the unitary matrix Z1.
169 *> On exit, if COMPZ='I', the unitary matrix Z, and if
170 *> COMPZ = 'V', the product Z1*Z.
171 *> Not referenced if COMPZ='N'.
177 *> The leading dimension of the array Z.
178 *> LDZ >= N if COMPZ='V' or 'I'; LDZ >= 1 otherwise.
183 *> WORK is COMPLEX array, dimension (LWORK)
184 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
190 *> The length of the array WORK. LWORK >= 1.
191 *> For optimum performance LWORK >= 6*N*NB, where NB is the
192 *> optimal blocksize.
194 *> If LWORK = -1, then a workspace query is assumed; the routine
195 *> only calculates the optimal size of the WORK array, returns
196 *> this value as the first entry of the WORK array, and no error
197 *> message related to LWORK is issued by XERBLA.
203 *> = 0: successful exit.
204 *> < 0: if INFO = -i, the i-th argument had an illegal value.
210 *> \author Univ. of Tennessee
211 *> \author Univ. of California Berkeley
212 *> \author Univ. of Colorado Denver
215 *> \date January 2015
217 *> \ingroup complexOTHERcomputational
219 *> \par Further Details:
220 * =====================
224 *> This routine reduces A to Hessenberg form and maintains B in
225 *> using a blocked variant of Moler and Stewart's original algorithm,
226 *> as described by Kagstrom, Kressner, Quintana-Orti, and Quintana-Orti
230 * =====================================================================
231 SUBROUTINE CGGHD3( COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q,
232 $ LDQ, Z, LDZ, WORK, LWORK, INFO )
234 * -- LAPACK computational routine (version 3.6.1) --
235 * -- LAPACK is a software package provided by Univ. of Tennessee, --
236 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
242 * .. Scalar Arguments ..
243 CHARACTER COMPQ, COMPZ
244 INTEGER IHI, ILO, INFO, LDA, LDB, LDQ, LDZ, N, LWORK
246 * .. Array Arguments ..
247 COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
248 $ Z( LDZ, * ), WORK( * )
251 * =====================================================================
255 PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ),
256 $ CZERO = ( 0.0E+0, 0.0E+0 ) )
258 * .. Local Scalars ..
259 LOGICAL BLK22, INITQ, INITZ, LQUERY, WANTQ, WANTZ
260 CHARACTER*1 COMPQ2, COMPZ2
261 INTEGER COLA, I, IERR, J, J0, JCOL, JJ, JROW, K,
262 $ KACC22, LEN, LWKOPT, N2NB, NB, NBLST, NBMIN,
263 $ NH, NNB, NX, PPW, PPWO, PW, TOP, TOPQ
265 COMPLEX C1, C2, CTEMP, S, S1, S2, TEMP, TEMP1, TEMP2,
268 * .. External Functions ..
271 EXTERNAL ILAENV, LSAME
273 * .. External Subroutines ..
274 EXTERNAL CGGHRD, CLARTG, CLASET, CUNM22, CROT, XERBLA
276 * .. Intrinsic Functions ..
277 INTRINSIC REAL, CMPLX, CONJG, MAX
279 * .. Executable Statements ..
281 * Decode and test the input parameters.
284 NB = ILAENV( 1, 'CGGHD3', ' ', N, ILO, IHI, -1 )
285 LWKOPT = MAX( 6*N*NB, 1 )
286 WORK( 1 ) = CMPLX( LWKOPT )
287 INITQ = LSAME( COMPQ, 'I' )
288 WANTQ = INITQ .OR. LSAME( COMPQ, 'V' )
289 INITZ = LSAME( COMPZ, 'I' )
290 WANTZ = INITZ .OR. LSAME( COMPZ, 'V' )
291 LQUERY = ( LWORK.EQ.-1 )
293 IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THEN
295 ELSE IF( .NOT.LSAME( COMPZ, 'N' ) .AND. .NOT.WANTZ ) THEN
297 ELSE IF( N.LT.0 ) THEN
299 ELSE IF( ILO.LT.1 ) THEN
301 ELSE IF( IHI.GT.N .OR. IHI.LT.ILO-1 ) THEN
303 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
305 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
307 ELSE IF( ( WANTQ .AND. LDQ.LT.N ) .OR. LDQ.LT.1 ) THEN
309 ELSE IF( ( WANTZ .AND. LDZ.LT.N ) .OR. LDZ.LT.1 ) THEN
311 ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN
315 CALL XERBLA( 'CGGHD3', -INFO )
317 ELSE IF( LQUERY ) THEN
321 * Initialize Q and Z if desired.
324 $ CALL CLASET( 'All', N, N, CZERO, CONE, Q, LDQ )
326 $ CALL CLASET( 'All', N, N, CZERO, CONE, Z, LDZ )
328 * Zero out lower triangle of B.
331 $ CALL CLASET( 'Lower', N-1, N-1, CZERO, CZERO, B(2, 1), LDB )
333 * Quick return if possible
341 * Determine the blocksize.
343 NBMIN = ILAENV( 2, 'CGGHD3', ' ', N, ILO, IHI, -1 )
344 IF( NB.GT.1 .AND. NB.LT.NH ) THEN
346 * Determine when to use unblocked instead of blocked code.
348 NX = MAX( NB, ILAENV( 3, 'CGGHD3', ' ', N, ILO, IHI, -1 ) )
351 * Determine if workspace is large enough for blocked code.
353 IF( LWORK.LT.LWKOPT ) THEN
355 * Not enough workspace to use optimal NB: determine the
356 * minimum value of NB, and reduce NB or force use of
359 NBMIN = MAX( 2, ILAENV( 2, 'CGGHD3', ' ', N, ILO, IHI,
361 IF( LWORK.GE.6*N*NBMIN ) THEN
370 IF( NB.LT.NBMIN .OR. NB.GE.NH ) THEN
372 * Use unblocked code below
380 KACC22 = ILAENV( 16, 'CGGHD3', ' ', N, ILO, IHI, -1 )
382 DO JCOL = ILO, IHI-2, NB
383 NNB = MIN( NB, IHI-JCOL-1 )
385 * Initialize small unitary factors that will hold the
386 * accumulated Givens rotations in workspace.
387 * N2NB denotes the number of 2*NNB-by-2*NNB factors
388 * NBLST denotes the (possibly smaller) order of the last
391 N2NB = ( IHI-JCOL-1 ) / NNB - 1
392 NBLST = IHI - JCOL - N2NB*NNB
393 CALL CLASET( 'All', NBLST, NBLST, CZERO, CONE, WORK, NBLST )
394 PW = NBLST * NBLST + 1
396 CALL CLASET( 'All', 2*NNB, 2*NNB, CZERO, CONE,
397 $ WORK( PW ), 2*NNB )
401 * Reduce columns JCOL:JCOL+NNB-1 of A to Hessenberg form.
403 DO J = JCOL, JCOL+NNB-1
405 * Reduce Jth column of A. Store cosines and sines in Jth
406 * column of A and B, respectively.
410 CALL CLARTG( TEMP, A( I, J ), C, S, A( I-1, J ) )
411 A( I, J ) = CMPLX( C )
415 * Accumulate Givens rotations into workspace array.
417 PPW = ( NBLST + 1 )*( NBLST - 2 ) - J + JCOL + 1
419 JROW = J + N2NB*NNB + 2
423 DO JJ = PPW, PPW+LEN-1
424 TEMP = WORK( JJ + NBLST )
425 WORK( JJ + NBLST ) = CTEMP*TEMP - S*WORK( JJ )
426 WORK( JJ ) = CONJG( S )*TEMP + CTEMP*WORK( JJ )
429 PPW = PPW - NBLST - 1
432 PPWO = NBLST*NBLST + ( NNB+J-JCOL-1 )*2*NNB + NNB
434 DO JROW = J0, J+2, -NNB
437 DO I = JROW+NNB-1, JROW, -1
440 DO JJ = PPW, PPW+LEN-1
441 TEMP = WORK( JJ + 2*NNB )
442 WORK( JJ + 2*NNB ) = CTEMP*TEMP - S*WORK( JJ )
443 WORK( JJ ) = CONJG( S )*TEMP + CTEMP*WORK( JJ )
446 PPW = PPW - 2*NNB - 1
448 PPWO = PPWO + 4*NNB*NNB
451 * TOP denotes the number of top rows in A and B that will
452 * not be updated during the next steps.
460 * Propagate transformations through B and replace stored
461 * left sines/cosines by right sines/cosines.
465 * Update JJth column of B.
467 DO I = MIN( JJ+1, IHI ), J+2, -1
471 B( I, JJ ) = CTEMP*TEMP - CONJG( S )*B( I-1, JJ )
472 B( I-1, JJ ) = S*TEMP + CTEMP*B( I-1, JJ )
475 * Annihilate B( JJ+1, JJ ).
478 TEMP = B( JJ+1, JJ+1 )
479 CALL CLARTG( TEMP, B( JJ+1, JJ ), C, S,
481 B( JJ+1, JJ ) = CZERO
482 CALL CROT( JJ-TOP, B( TOP+1, JJ+1 ), 1,
483 $ B( TOP+1, JJ ), 1, C, S )
484 A( JJ+1, J ) = CMPLX( C )
485 B( JJ+1, J ) = -CONJG( S )
489 * Update A by transformations from right.
491 JJ = MOD( IHI-J-1, 3 )
492 DO I = IHI-J-3, JJ+1, -3
493 CTEMP = A( J+1+I, J )
502 TEMP1 = A( K, J+I+1 )
503 TEMP2 = A( K, J+I+2 )
504 TEMP3 = A( K, J+I+3 )
505 A( K, J+I+3 ) = C2*TEMP3 + CONJG( S2 )*TEMP2
506 TEMP2 = -S2*TEMP3 + C2*TEMP2
507 A( K, J+I+2 ) = C1*TEMP2 + CONJG( S1 )*TEMP1
508 TEMP1 = -S1*TEMP2 + C1*TEMP1
509 A( K, J+I+1 ) = CTEMP*TEMP1 + CONJG( S )*TEMP
510 A( K, J+I ) = -S*TEMP1 + CTEMP*TEMP
516 C = DBLE( A( J+1+I, J ) )
517 CALL CROT( IHI-TOP, A( TOP+1, J+I+1 ), 1,
518 $ A( TOP+1, J+I ), 1, C,
519 $ -CONJG( B( J+1+I, J ) ) )
523 * Update (J+1)th column of A by transformations from left.
525 IF ( J .LT. JCOL + NNB - 1 ) THEN
528 * Multiply with the trailing accumulated unitary
529 * matrix, which takes the form
535 * where U21 is a LEN-by-LEN matrix and U12 is lower
538 JROW = IHI - NBLST + 1
539 CALL CGEMV( 'Conjugate', NBLST, LEN, CONE, WORK,
540 $ NBLST, A( JROW, J+1 ), 1, CZERO,
543 DO I = JROW, JROW+NBLST-LEN-1
544 WORK( PPW ) = A( I, J+1 )
547 CALL CTRMV( 'Lower', 'Conjugate', 'Non-unit',
548 $ NBLST-LEN, WORK( LEN*NBLST + 1 ), NBLST,
549 $ WORK( PW+LEN ), 1 )
550 CALL CGEMV( 'Conjugate', LEN, NBLST-LEN, CONE,
551 $ WORK( (LEN+1)*NBLST - LEN + 1 ), NBLST,
552 $ A( JROW+NBLST-LEN, J+1 ), 1, CONE,
553 $ WORK( PW+LEN ), 1 )
555 DO I = JROW, JROW+NBLST-1
556 A( I, J+1 ) = WORK( PPW )
560 * Multiply with the other accumulated unitary
561 * matrices, which take the form
569 * where I denotes the (NNB-LEN)-by-(NNB-LEN) identity
570 * matrix, U21 is a LEN-by-LEN upper triangular matrix
571 * and U12 is an NNB-by-NNB lower triangular matrix.
573 PPWO = 1 + NBLST*NBLST
575 DO JROW = J0, JCOL+1, -NNB
577 DO I = JROW, JROW+NNB-1
578 WORK( PPW ) = A( I, J+1 )
582 DO I = JROW+NNB, JROW+NNB+LEN-1
583 WORK( PPW ) = A( I, J+1 )
586 CALL CTRMV( 'Upper', 'Conjugate', 'Non-unit', LEN,
587 $ WORK( PPWO + NNB ), 2*NNB, WORK( PW ),
589 CALL CTRMV( 'Lower', 'Conjugate', 'Non-unit', NNB,
590 $ WORK( PPWO + 2*LEN*NNB ),
591 $ 2*NNB, WORK( PW + LEN ), 1 )
592 CALL CGEMV( 'Conjugate', NNB, LEN, CONE,
593 $ WORK( PPWO ), 2*NNB, A( JROW, J+1 ), 1,
594 $ CONE, WORK( PW ), 1 )
595 CALL CGEMV( 'Conjugate', LEN, NNB, CONE,
596 $ WORK( PPWO + 2*LEN*NNB + NNB ), 2*NNB,
597 $ A( JROW+NNB, J+1 ), 1, CONE,
598 $ WORK( PW+LEN ), 1 )
600 DO I = JROW, JROW+LEN+NNB-1
601 A( I, J+1 ) = WORK( PPW )
604 PPWO = PPWO + 4*NNB*NNB
609 * Apply accumulated unitary matrices to A.
611 COLA = N - JCOL - NNB + 1
613 CALL CGEMM( 'Conjugate', 'No Transpose', NBLST,
614 $ COLA, NBLST, CONE, WORK, NBLST,
615 $ A( J, JCOL+NNB ), LDA, CZERO, WORK( PW ),
617 CALL CLACPY( 'All', NBLST, COLA, WORK( PW ), NBLST,
618 $ A( J, JCOL+NNB ), LDA )
619 PPWO = NBLST*NBLST + 1
621 DO J = J0, JCOL+1, -NNB
624 * Exploit the structure of
630 * where all blocks are NNB-by-NNB, U21 is upper
631 * triangular and U12 is lower triangular.
633 CALL CUNM22( 'Left', 'Conjugate', 2*NNB, COLA, NNB,
634 $ NNB, WORK( PPWO ), 2*NNB,
635 $ A( J, JCOL+NNB ), LDA, WORK( PW ),
639 * Ignore the structure of U.
641 CALL CGEMM( 'Conjugate', 'No Transpose', 2*NNB,
642 $ COLA, 2*NNB, CONE, WORK( PPWO ), 2*NNB,
643 $ A( J, JCOL+NNB ), LDA, CZERO, WORK( PW ),
645 CALL CLACPY( 'All', 2*NNB, COLA, WORK( PW ), 2*NNB,
646 $ A( J, JCOL+NNB ), LDA )
648 PPWO = PPWO + 4*NNB*NNB
651 * Apply accumulated unitary matrices to Q.
656 TOPQ = MAX( 2, J - JCOL + 1 )
662 CALL CGEMM( 'No Transpose', 'No Transpose', NH,
663 $ NBLST, NBLST, CONE, Q( TOPQ, J ), LDQ,
664 $ WORK, NBLST, CZERO, WORK( PW ), NH )
665 CALL CLACPY( 'All', NH, NBLST, WORK( PW ), NH,
666 $ Q( TOPQ, J ), LDQ )
667 PPWO = NBLST*NBLST + 1
669 DO J = J0, JCOL+1, -NNB
671 TOPQ = MAX( 2, J - JCOL + 1 )
676 * Exploit the structure of U.
678 CALL CUNM22( 'Right', 'No Transpose', NH, 2*NNB,
679 $ NNB, NNB, WORK( PPWO ), 2*NNB,
680 $ Q( TOPQ, J ), LDQ, WORK( PW ),
684 * Ignore the structure of U.
686 CALL CGEMM( 'No Transpose', 'No Transpose', NH,
687 $ 2*NNB, 2*NNB, CONE, Q( TOPQ, J ), LDQ,
688 $ WORK( PPWO ), 2*NNB, CZERO, WORK( PW ),
690 CALL CLACPY( 'All', NH, 2*NNB, WORK( PW ), NH,
691 $ Q( TOPQ, J ), LDQ )
693 PPWO = PPWO + 4*NNB*NNB
697 * Accumulate right Givens rotations if required.
699 IF ( WANTZ .OR. TOP.GT.0 ) THEN
701 * Initialize small unitary factors that will hold the
702 * accumulated Givens rotations in workspace.
704 CALL CLASET( 'All', NBLST, NBLST, CZERO, CONE, WORK,
706 PW = NBLST * NBLST + 1
708 CALL CLASET( 'All', 2*NNB, 2*NNB, CZERO, CONE,
709 $ WORK( PW ), 2*NNB )
713 * Accumulate Givens rotations into workspace array.
715 DO J = JCOL, JCOL+NNB-1
716 PPW = ( NBLST + 1 )*( NBLST - 2 ) - J + JCOL + 1
718 JROW = J + N2NB*NNB + 2
724 DO JJ = PPW, PPW+LEN-1
725 TEMP = WORK( JJ + NBLST )
726 WORK( JJ + NBLST ) = CTEMP*TEMP -
727 $ CONJG( S )*WORK( JJ )
728 WORK( JJ ) = S*TEMP + CTEMP*WORK( JJ )
731 PPW = PPW - NBLST - 1
734 PPWO = NBLST*NBLST + ( NNB+J-JCOL-1 )*2*NNB + NNB
736 DO JROW = J0, J+2, -NNB
739 DO I = JROW+NNB-1, JROW, -1
744 DO JJ = PPW, PPW+LEN-1
745 TEMP = WORK( JJ + 2*NNB )
746 WORK( JJ + 2*NNB ) = CTEMP*TEMP -
747 $ CONJG( S )*WORK( JJ )
748 WORK( JJ ) = S*TEMP + CTEMP*WORK( JJ )
751 PPW = PPW - 2*NNB - 1
753 PPWO = PPWO + 4*NNB*NNB
758 CALL CLASET( 'Lower', IHI - JCOL - 1, NNB, CZERO, CZERO,
759 $ A( JCOL + 2, JCOL ), LDA )
760 CALL CLASET( 'Lower', IHI - JCOL - 1, NNB, CZERO, CZERO,
761 $ B( JCOL + 2, JCOL ), LDB )
764 * Apply accumulated unitary matrices to A and B.
768 CALL CGEMM( 'No Transpose', 'No Transpose', TOP,
769 $ NBLST, NBLST, CONE, A( 1, J ), LDA,
770 $ WORK, NBLST, CZERO, WORK( PW ), TOP )
771 CALL CLACPY( 'All', TOP, NBLST, WORK( PW ), TOP,
773 PPWO = NBLST*NBLST + 1
775 DO J = J0, JCOL+1, -NNB
778 * Exploit the structure of U.
780 CALL CUNM22( 'Right', 'No Transpose', TOP, 2*NNB,
781 $ NNB, NNB, WORK( PPWO ), 2*NNB,
782 $ A( 1, J ), LDA, WORK( PW ),
786 * Ignore the structure of U.
788 CALL CGEMM( 'No Transpose', 'No Transpose', TOP,
789 $ 2*NNB, 2*NNB, CONE, A( 1, J ), LDA,
790 $ WORK( PPWO ), 2*NNB, CZERO,
792 CALL CLACPY( 'All', TOP, 2*NNB, WORK( PW ), TOP,
795 PPWO = PPWO + 4*NNB*NNB
799 CALL CGEMM( 'No Transpose', 'No Transpose', TOP,
800 $ NBLST, NBLST, CONE, B( 1, J ), LDB,
801 $ WORK, NBLST, CZERO, WORK( PW ), TOP )
802 CALL CLACPY( 'All', TOP, NBLST, WORK( PW ), TOP,
804 PPWO = NBLST*NBLST + 1
806 DO J = J0, JCOL+1, -NNB
809 * Exploit the structure of U.
811 CALL CUNM22( 'Right', 'No Transpose', TOP, 2*NNB,
812 $ NNB, NNB, WORK( PPWO ), 2*NNB,
813 $ B( 1, J ), LDB, WORK( PW ),
817 * Ignore the structure of U.
819 CALL CGEMM( 'No Transpose', 'No Transpose', TOP,
820 $ 2*NNB, 2*NNB, CONE, B( 1, J ), LDB,
821 $ WORK( PPWO ), 2*NNB, CZERO,
823 CALL CLACPY( 'All', TOP, 2*NNB, WORK( PW ), TOP,
826 PPWO = PPWO + 4*NNB*NNB
830 * Apply accumulated unitary matrices to Z.
835 TOPQ = MAX( 2, J - JCOL + 1 )
841 CALL CGEMM( 'No Transpose', 'No Transpose', NH,
842 $ NBLST, NBLST, CONE, Z( TOPQ, J ), LDZ,
843 $ WORK, NBLST, CZERO, WORK( PW ), NH )
844 CALL CLACPY( 'All', NH, NBLST, WORK( PW ), NH,
845 $ Z( TOPQ, J ), LDZ )
846 PPWO = NBLST*NBLST + 1
848 DO J = J0, JCOL+1, -NNB
850 TOPQ = MAX( 2, J - JCOL + 1 )
855 * Exploit the structure of U.
857 CALL CUNM22( 'Right', 'No Transpose', NH, 2*NNB,
858 $ NNB, NNB, WORK( PPWO ), 2*NNB,
859 $ Z( TOPQ, J ), LDZ, WORK( PW ),
863 * Ignore the structure of U.
865 CALL CGEMM( 'No Transpose', 'No Transpose', NH,
866 $ 2*NNB, 2*NNB, CONE, Z( TOPQ, J ), LDZ,
867 $ WORK( PPWO ), 2*NNB, CZERO, WORK( PW ),
869 CALL CLACPY( 'All', NH, 2*NNB, WORK( PW ), NH,
870 $ Z( TOPQ, J ), LDZ )
872 PPWO = PPWO + 4*NNB*NNB
878 * Use unblocked code to reduce the rest of the matrix
879 * Avoid re-initialization of modified Q and Z.
883 IF ( JCOL.NE.ILO ) THEN
891 $ CALL CGGHRD( COMPQ2, COMPZ2, N, JCOL, IHI, A, LDA, B, LDB, Q,
892 $ LDQ, Z, LDZ, IERR )
893 WORK( 1 ) = CMPLX( LWKOPT )