1 *> \brief \b CTPRFB applies a real or complex "triangular-pentagonal" blocked reflector to a real or complex matrix, which is composed of two blocks.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CTPRFB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctprfb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctprfb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctprfb.f">
21 * SUBROUTINE CTPRFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, L,
22 * V, LDV, T, LDT, A, LDA, B, LDB, WORK, LDWORK )
24 * .. Scalar Arguments ..
25 * CHARACTER DIRECT, SIDE, STOREV, TRANS
26 * INTEGER K, L, LDA, LDB, LDT, LDV, LDWORK, M, N
28 * .. Array Arguments ..
29 * COMPLEX A( LDA, * ), B( LDB, * ), T( LDT, * ),
30 * $ V( LDV, * ), WORK( LDWORK, * )
39 *> CTPRFB applies a complex "triangular-pentagonal" block reflector H or its
40 *> conjugate transpose H**H to a complex matrix C, which is composed of two
41 *> blocks A and B, either from the left or right.
50 *> SIDE is CHARACTER*1
51 *> = 'L': apply H or H**H from the Left
52 *> = 'R': apply H or H**H from the Right
57 *> TRANS is CHARACTER*1
58 *> = 'N': apply H (No transpose)
59 *> = 'C': apply H**H (Conjugate transpose)
64 *> DIRECT is CHARACTER*1
65 *> Indicates how H is formed from a product of elementary
67 *> = 'F': H = H(1) H(2) . . . H(k) (Forward)
68 *> = 'B': H = H(k) . . . H(2) H(1) (Backward)
73 *> STOREV is CHARACTER*1
74 *> Indicates how the vectors which define the elementary
75 *> reflectors are stored:
83 *> The number of rows of the matrix B.
90 *> The number of columns of the matrix B.
97 *> The order of the matrix T, i.e. the number of elementary
98 *> reflectors whose product defines the block reflector.
105 *> The order of the trapezoidal part of V.
106 *> K >= L >= 0. See Further Details.
111 *> V is COMPLEX array, dimension
112 *> (LDV,K) if STOREV = 'C'
113 *> (LDV,M) if STOREV = 'R' and SIDE = 'L'
114 *> (LDV,N) if STOREV = 'R' and SIDE = 'R'
115 *> The pentagonal matrix V, which contains the elementary reflectors
116 *> H(1), H(2), ..., H(K). See Further Details.
122 *> The leading dimension of the array V.
123 *> If STOREV = 'C' and SIDE = 'L', LDV >= max(1,M);
124 *> if STOREV = 'C' and SIDE = 'R', LDV >= max(1,N);
125 *> if STOREV = 'R', LDV >= K.
130 *> T is COMPLEX array, dimension (LDT,K)
131 *> The triangular K-by-K matrix T in the representation of the
138 *> The leading dimension of the array T.
144 *> A is COMPLEX array, dimension
145 *> (LDA,N) if SIDE = 'L' or (LDA,K) if SIDE = 'R'
146 *> On entry, the K-by-N or M-by-K matrix A.
147 *> On exit, A is overwritten by the corresponding block of
148 *> H*C or H**H*C or C*H or C*H**H. See Further Details.
154 *> The leading dimension of the array A.
155 *> If SIDE = 'L', LDC >= max(1,K);
156 *> If SIDE = 'R', LDC >= max(1,M).
161 *> B is COMPLEX array, dimension (LDB,N)
162 *> On entry, the M-by-N matrix B.
163 *> On exit, B is overwritten by the corresponding block of
164 *> H*C or H**H*C or C*H or C*H**H. See Further Details.
170 *> The leading dimension of the array B.
176 *> WORK is COMPLEX array, dimension
177 *> (LDWORK,N) if SIDE = 'L',
178 *> (LDWORK,K) if SIDE = 'R'.
184 *> The leading dimension of the array WORK.
185 *> If SIDE = 'L', LDWORK >= K;
186 *> if SIDE = 'R', LDWORK >= M.
192 *> \author Univ. of Tennessee
193 *> \author Univ. of California Berkeley
194 *> \author Univ. of Colorado Denver
197 *> \date September 2012
199 *> \ingroup complexOTHERauxiliary
201 *> \par Further Details:
202 * =====================
206 *> The matrix C is a composite matrix formed from blocks A and B.
207 *> The block B is of size M-by-N; if SIDE = 'R', A is of size M-by-K,
208 *> and if SIDE = 'L', A is of size K-by-N.
210 *> If SIDE = 'R' and DIRECT = 'F', C = [A B].
212 *> If SIDE = 'L' and DIRECT = 'F', C = [A]
215 *> If SIDE = 'R' and DIRECT = 'B', C = [B A].
217 *> If SIDE = 'L' and DIRECT = 'B', C = [B]
220 *> The pentagonal matrix V is composed of a rectangular block V1 and a
221 *> trapezoidal block V2. The size of the trapezoidal block is determined by
222 *> the parameter L, where 0<=L<=K. If L=K, the V2 block of V is triangular;
223 *> if L=0, there is no trapezoidal block, thus V = V1 is rectangular.
225 *> If DIRECT = 'F' and STOREV = 'C': V = [V1]
227 *> - V2 is upper trapezoidal (first L rows of K-by-K upper triangular)
229 *> If DIRECT = 'F' and STOREV = 'R': V = [V1 V2]
231 *> - V2 is lower trapezoidal (first L columns of K-by-K lower triangular)
233 *> If DIRECT = 'B' and STOREV = 'C': V = [V2]
235 *> - V2 is lower trapezoidal (last L rows of K-by-K lower triangular)
237 *> If DIRECT = 'B' and STOREV = 'R': V = [V2 V1]
239 *> - V2 is upper trapezoidal (last L columns of K-by-K upper triangular)
241 *> If STOREV = 'C' and SIDE = 'L', V is M-by-K with V2 L-by-K.
243 *> If STOREV = 'C' and SIDE = 'R', V is N-by-K with V2 L-by-K.
245 *> If STOREV = 'R' and SIDE = 'L', V is K-by-M with V2 K-by-L.
247 *> If STOREV = 'R' and SIDE = 'R', V is K-by-N with V2 K-by-L.
250 * =====================================================================
251 SUBROUTINE CTPRFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, L,
252 $ V, LDV, T, LDT, A, LDA, B, LDB, WORK, LDWORK )
254 * -- LAPACK auxiliary routine (version 3.4.2) --
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 CHARACTER DIRECT, SIDE, STOREV, TRANS
261 INTEGER K, L, LDA, LDB, LDT, LDV, LDWORK, M, N
263 * .. Array Arguments ..
264 COMPLEX A( LDA, * ), B( LDB, * ), T( LDT, * ),
265 $ V( LDV, * ), WORK( LDWORK, * )
268 * ==========================================================================
272 PARAMETER ( ONE = (1.0,0.0), ZERO = (0.0,0.0) )
274 * .. Local Scalars ..
275 INTEGER I, J, MP, NP, KP
276 LOGICAL LEFT, FORWARD, COLUMN, RIGHT, BACKWARD, ROW
278 * .. External Functions ..
282 * .. External Subroutines ..
283 EXTERNAL CGEMM, CTRMM
285 * .. Intrinsic Functions ..
288 * .. Executable Statements ..
290 * Quick return if possible
292 IF( M.LE.0 .OR. N.LE.0 .OR. K.LE.0 .OR. L.LT.0 ) RETURN
294 IF( LSAME( STOREV, 'C' ) ) THEN
297 ELSE IF ( LSAME( STOREV, 'R' ) ) THEN
305 IF( LSAME( SIDE, 'L' ) ) THEN
308 ELSE IF( LSAME( SIDE, 'R' ) ) THEN
316 IF( LSAME( DIRECT, 'F' ) ) THEN
319 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
327 * ---------------------------------------------------------------------------
329 IF( COLUMN .AND. FORWARD .AND. LEFT ) THEN
331 * ---------------------------------------------------------------------------
333 * Let W = [ I ] (K-by-K)
336 * Form H C or H**H C where C = [ A ] (K-by-N)
339 * H = I - W T W**H or H**H = I - W T**H W**H
341 * A = A - T (A + V**H B) or A = A - T**H (A + V**H B)
342 * B = B - V T (A + V**H B) or B = B - V T**H (A + V**H B)
344 * ---------------------------------------------------------------------------
351 WORK( I, J ) = B( M-L+I, J )
354 CALL CTRMM( 'L', 'U', 'C', 'N', L, N, ONE, V( MP, 1 ), LDV,
356 CALL CGEMM( 'C', 'N', L, N, M-L, ONE, V, LDV, B, LDB,
357 $ ONE, WORK, LDWORK )
358 CALL CGEMM( 'C', 'N', K-L, N, M, ONE, V( 1, KP ), LDV,
359 $ B, LDB, ZERO, WORK( KP, 1 ), LDWORK )
363 WORK( I, J ) = WORK( I, J ) + A( I, J )
367 CALL CTRMM( 'L', 'U', TRANS, 'N', K, N, ONE, T, LDT,
372 A( I, J ) = A( I, J ) - WORK( I, J )
376 CALL CGEMM( 'N', 'N', M-L, N, K, -ONE, V, LDV, WORK, LDWORK,
378 CALL CGEMM( 'N', 'N', L, N, K-L, -ONE, V( MP, KP ), LDV,
379 $ WORK( KP, 1 ), LDWORK, ONE, B( MP, 1 ), LDB )
380 CALL CTRMM( 'L', 'U', 'N', 'N', L, N, ONE, V( MP, 1 ), LDV,
384 B( M-L+I, J ) = B( M-L+I, J ) - WORK( I, J )
388 * ---------------------------------------------------------------------------
390 ELSE IF( COLUMN .AND. FORWARD .AND. RIGHT ) THEN
392 * ---------------------------------------------------------------------------
394 * Let W = [ I ] (K-by-K)
397 * Form C H or C H**H where C = [ A B ] (A is M-by-K, B is M-by-N)
399 * H = I - W T W**H or H**H = I - W T**H W**H
401 * A = A - (A + B V) T or A = A - (A + B V) T**H
402 * B = B - (A + B V) T V**H or B = B - (A + B V) T**H V**H
404 * ---------------------------------------------------------------------------
411 WORK( I, J ) = B( I, N-L+J )
414 CALL CTRMM( 'R', 'U', 'N', 'N', M, L, ONE, V( NP, 1 ), LDV,
416 CALL CGEMM( 'N', 'N', M, L, N-L, ONE, B, LDB,
417 $ V, LDV, ONE, WORK, LDWORK )
418 CALL CGEMM( 'N', 'N', M, K-L, N, ONE, B, LDB,
419 $ V( 1, KP ), LDV, ZERO, WORK( 1, KP ), LDWORK )
423 WORK( I, J ) = WORK( I, J ) + A( I, J )
427 CALL CTRMM( 'R', 'U', TRANS, 'N', M, K, ONE, T, LDT,
432 A( I, J ) = A( I, J ) - WORK( I, J )
436 CALL CGEMM( 'N', 'C', M, N-L, K, -ONE, WORK, LDWORK,
437 $ V, LDV, ONE, B, LDB )
438 CALL CGEMM( 'N', 'C', M, L, K-L, -ONE, WORK( 1, KP ), LDWORK,
439 $ V( NP, KP ), LDV, ONE, B( 1, NP ), LDB )
440 CALL CTRMM( 'R', 'U', 'C', 'N', M, L, ONE, V( NP, 1 ), LDV,
444 B( I, N-L+J ) = B( I, N-L+J ) - WORK( I, J )
448 * ---------------------------------------------------------------------------
450 ELSE IF( COLUMN .AND. BACKWARD .AND. LEFT ) THEN
452 * ---------------------------------------------------------------------------
454 * Let W = [ V ] (M-by-K)
457 * Form H C or H**H C where C = [ B ] (M-by-N)
460 * H = I - W T W**H or H**H = I - W T**H W**H
462 * A = A - T (A + V**H B) or A = A - T**H (A + V**H B)
463 * B = B - V T (A + V**H B) or B = B - V T**H (A + V**H B)
465 * ---------------------------------------------------------------------------
472 WORK( K-L+I, J ) = B( I, J )
476 CALL CTRMM( 'L', 'L', 'C', 'N', L, N, ONE, V( 1, KP ), LDV,
477 $ WORK( KP, 1 ), LDWORK )
478 CALL CGEMM( 'C', 'N', L, N, M-L, ONE, V( MP, KP ), LDV,
479 $ B( MP, 1 ), LDB, ONE, WORK( KP, 1 ), LDWORK )
480 CALL CGEMM( 'C', 'N', K-L, N, M, ONE, V, LDV,
481 $ B, LDB, ZERO, WORK, LDWORK )
485 WORK( I, J ) = WORK( I, J ) + A( I, J )
489 CALL CTRMM( 'L', 'L', TRANS, 'N', K, N, ONE, T, LDT,
494 A( I, J ) = A( I, J ) - WORK( I, J )
498 CALL CGEMM( 'N', 'N', M-L, N, K, -ONE, V( MP, 1 ), LDV,
499 $ WORK, LDWORK, ONE, B( MP, 1 ), LDB )
500 CALL CGEMM( 'N', 'N', L, N, K-L, -ONE, V, LDV,
501 $ WORK, LDWORK, ONE, B, LDB )
502 CALL CTRMM( 'L', 'L', 'N', 'N', L, N, ONE, V( 1, KP ), LDV,
503 $ WORK( KP, 1 ), LDWORK )
506 B( I, J ) = B( I, J ) - WORK( K-L+I, J )
510 * ---------------------------------------------------------------------------
512 ELSE IF( COLUMN .AND. BACKWARD .AND. RIGHT ) THEN
514 * ---------------------------------------------------------------------------
516 * Let W = [ V ] (N-by-K)
519 * Form C H or C H**H where C = [ B A ] (B is M-by-N, A is M-by-K)
521 * H = I - W T W**H or H**H = I - W T**H W**H
523 * A = A - (A + B V) T or A = A - (A + B V) T**H
524 * B = B - (A + B V) T V**H or B = B - (A + B V) T**H V**H
526 * ---------------------------------------------------------------------------
533 WORK( I, K-L+J ) = B( I, J )
536 CALL CTRMM( 'R', 'L', 'N', 'N', M, L, ONE, V( 1, KP ), LDV,
537 $ WORK( 1, KP ), LDWORK )
538 CALL CGEMM( 'N', 'N', M, L, N-L, ONE, B( 1, NP ), LDB,
539 $ V( NP, KP ), LDV, ONE, WORK( 1, KP ), LDWORK )
540 CALL CGEMM( 'N', 'N', M, K-L, N, ONE, B, LDB,
541 $ V, LDV, ZERO, WORK, LDWORK )
545 WORK( I, J ) = WORK( I, J ) + A( I, J )
549 CALL CTRMM( 'R', 'L', TRANS, 'N', M, K, ONE, T, LDT,
554 A( I, J ) = A( I, J ) - WORK( I, J )
558 CALL CGEMM( 'N', 'C', M, N-L, K, -ONE, WORK, LDWORK,
559 $ V( NP, 1 ), LDV, ONE, B( 1, NP ), LDB )
560 CALL CGEMM( 'N', 'C', M, L, K-L, -ONE, WORK, LDWORK,
561 $ V, LDV, ONE, B, LDB )
562 CALL CTRMM( 'R', 'L', 'C', 'N', M, L, ONE, V( 1, KP ), LDV,
563 $ WORK( 1, KP ), LDWORK )
566 B( I, J ) = B( I, J ) - WORK( I, K-L+J )
570 * ---------------------------------------------------------------------------
572 ELSE IF( ROW .AND. FORWARD .AND. LEFT ) THEN
574 * ---------------------------------------------------------------------------
576 * Let W = [ I V ] ( I is K-by-K, V is K-by-M )
578 * Form H C or H**H C where C = [ A ] (K-by-N)
581 * H = I - W**H T W or H**H = I - W**H T**H W
583 * A = A - T (A + V B) or A = A - T**H (A + V B)
584 * B = B - V**H T (A + V B) or B = B - V**H T**H (A + V B)
586 * ---------------------------------------------------------------------------
593 WORK( I, J ) = B( M-L+I, J )
596 CALL CTRMM( 'L', 'L', 'N', 'N', L, N, ONE, V( 1, MP ), LDV,
598 CALL CGEMM( 'N', 'N', L, N, M-L, ONE, V, LDV,B, LDB,
599 $ ONE, WORK, LDWORK )
600 CALL CGEMM( 'N', 'N', K-L, N, M, ONE, V( KP, 1 ), LDV,
601 $ B, LDB, ZERO, WORK( KP, 1 ), LDWORK )
605 WORK( I, J ) = WORK( I, J ) + A( I, J )
609 CALL CTRMM( 'L', 'U', TRANS, 'N', K, N, ONE, T, LDT,
614 A( I, J ) = A( I, J ) - WORK( I, J )
618 CALL CGEMM( 'C', 'N', M-L, N, K, -ONE, V, LDV, WORK, LDWORK,
620 CALL CGEMM( 'C', 'N', L, N, K-L, -ONE, V( KP, MP ), LDV,
621 $ WORK( KP, 1 ), LDWORK, ONE, B( MP, 1 ), LDB )
622 CALL CTRMM( 'L', 'L', 'C', 'N', L, N, ONE, V( 1, MP ), LDV,
626 B( M-L+I, J ) = B( M-L+I, J ) - WORK( I, J )
630 * ---------------------------------------------------------------------------
632 ELSE IF( ROW .AND. FORWARD .AND. RIGHT ) THEN
634 * ---------------------------------------------------------------------------
636 * Let W = [ I V ] ( I is K-by-K, V is K-by-N )
638 * Form C H or C H**H where C = [ A B ] (A is M-by-K, B is M-by-N)
640 * H = I - W**H T W or H**H = I - W**H T**H W
642 * A = A - (A + B V**H) T or A = A - (A + B V**H) T**H
643 * B = B - (A + B V**H) T V or B = B - (A + B V**H) T**H V
645 * ---------------------------------------------------------------------------
652 WORK( I, J ) = B( I, N-L+J )
655 CALL CTRMM( 'R', 'L', 'C', 'N', M, L, ONE, V( 1, NP ), LDV,
657 CALL CGEMM( 'N', 'C', M, L, N-L, ONE, B, LDB, V, LDV,
658 $ ONE, WORK, LDWORK )
659 CALL CGEMM( 'N', 'C', M, K-L, N, ONE, B, LDB,
660 $ V( KP, 1 ), LDV, ZERO, WORK( 1, KP ), LDWORK )
664 WORK( I, J ) = WORK( I, J ) + A( I, J )
668 CALL CTRMM( 'R', 'U', TRANS, 'N', M, K, ONE, T, LDT,
673 A( I, J ) = A( I, J ) - WORK( I, J )
677 CALL CGEMM( 'N', 'N', M, N-L, K, -ONE, WORK, LDWORK,
678 $ V, LDV, ONE, B, LDB )
679 CALL CGEMM( 'N', 'N', M, L, K-L, -ONE, WORK( 1, KP ), LDWORK,
680 $ V( KP, NP ), LDV, ONE, B( 1, NP ), LDB )
681 CALL CTRMM( 'R', 'L', 'N', 'N', M, L, ONE, V( 1, NP ), LDV,
685 B( I, N-L+J ) = B( I, N-L+J ) - WORK( I, J )
689 * ---------------------------------------------------------------------------
691 ELSE IF( ROW .AND. BACKWARD .AND. LEFT ) THEN
693 * ---------------------------------------------------------------------------
695 * Let W = [ V I ] ( I is K-by-K, V is K-by-M )
697 * Form H C or H**H C where C = [ B ] (M-by-N)
700 * H = I - W**H T W or H**H = I - W**H T**H W
702 * A = A - T (A + V B) or A = A - T**H (A + V B)
703 * B = B - V**H T (A + V B) or B = B - V**H T**H (A + V B)
705 * ---------------------------------------------------------------------------
712 WORK( K-L+I, J ) = B( I, J )
715 CALL CTRMM( 'L', 'U', 'N', 'N', L, N, ONE, V( KP, 1 ), LDV,
716 $ WORK( KP, 1 ), LDWORK )
717 CALL CGEMM( 'N', 'N', L, N, M-L, ONE, V( KP, MP ), LDV,
718 $ B( MP, 1 ), LDB, ONE, WORK( KP, 1 ), LDWORK )
719 CALL CGEMM( 'N', 'N', K-L, N, M, ONE, V, LDV, B, LDB,
720 $ ZERO, WORK, LDWORK )
724 WORK( I, J ) = WORK( I, J ) + A( I, J )
728 CALL CTRMM( 'L', 'L ', TRANS, 'N', K, N, ONE, T, LDT,
733 A( I, J ) = A( I, J ) - WORK( I, J )
737 CALL CGEMM( 'C', 'N', M-L, N, K, -ONE, V( 1, MP ), LDV,
738 $ WORK, LDWORK, ONE, B( MP, 1 ), LDB )
739 CALL CGEMM( 'C', 'N', L, N, K-L, -ONE, V, LDV,
740 $ WORK, LDWORK, ONE, B, LDB )
741 CALL CTRMM( 'L', 'U', 'C', 'N', L, N, ONE, V( KP, 1 ), LDV,
742 $ WORK( KP, 1 ), LDWORK )
745 B( I, J ) = B( I, J ) - WORK( K-L+I, J )
749 * ---------------------------------------------------------------------------
751 ELSE IF( ROW .AND. BACKWARD .AND. RIGHT ) THEN
753 * ---------------------------------------------------------------------------
755 * Let W = [ V I ] ( I is K-by-K, V is K-by-N )
757 * Form C H or C H**H where C = [ B A ] (A is M-by-K, B is M-by-N)
759 * H = I - W**H T W or H**H = I - W**H T**H W
761 * A = A - (A + B V**H) T or A = A - (A + B V**H) T**H
762 * B = B - (A + B V**H) T V or B = B - (A + B V**H) T**H V
764 * ---------------------------------------------------------------------------
771 WORK( I, K-L+J ) = B( I, J )
774 CALL CTRMM( 'R', 'U', 'C', 'N', M, L, ONE, V( KP, 1 ), LDV,
775 $ WORK( 1, KP ), LDWORK )
776 CALL CGEMM( 'N', 'C', M, L, N-L, ONE, B( 1, NP ), LDB,
777 $ V( KP, NP ), LDV, ONE, WORK( 1, KP ), LDWORK )
778 CALL CGEMM( 'N', 'C', M, K-L, N, ONE, B, LDB, V, LDV,
779 $ ZERO, WORK, LDWORK )
783 WORK( I, J ) = WORK( I, J ) + A( I, J )
787 CALL CTRMM( 'R', 'L', TRANS, 'N', M, K, ONE, T, LDT,
792 A( I, J ) = A( I, J ) - WORK( I, J )
796 CALL CGEMM( 'N', 'N', M, N-L, K, -ONE, WORK, LDWORK,
797 $ V( 1, NP ), LDV, ONE, B( 1, NP ), LDB )
798 CALL CGEMM( 'N', 'N', M, L, K-L , -ONE, WORK, LDWORK,
799 $ V, LDV, ONE, B, LDB )
800 CALL CTRMM( 'R', 'U', 'N', 'N', M, L, ONE, V( KP, 1 ), LDV,
801 $ WORK( 1, KP ), LDWORK )
804 B( I, J ) = B( I, J ) - WORK( I, K-L+J )