1 *> \brief \b STPRFB 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 STPRFB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/stprfb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/stprfb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/stprfb.f">
21 * SUBROUTINE STPRFB( 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 * REAL A( LDA, * ), B( LDB, * ), T( LDT, * ),
30 * $ V( LDV, * ), WORK( LDWORK, * )
39 *> STPRFB applies a real "triangular-pentagonal" block reflector H or its
40 *> conjugate transpose H^H to a real 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 realOTHERauxiliary
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 STPRFB( 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 REAL A( LDA, * ), B( LDB, * ), T( LDT, * ),
265 $ V( LDV, * ), WORK( LDWORK, * )
268 * ==========================================================================
272 PARAMETER ( ONE = 1.0, ZERO = 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 SGEMM, STRMM
285 * .. Executable Statements ..
287 * Quick return if possible
289 IF( M.LE.0 .OR. N.LE.0 .OR. K.LE.0 .OR. L.LT.0 ) RETURN
291 IF( LSAME( STOREV, 'C' ) ) THEN
294 ELSE IF ( LSAME( STOREV, 'R' ) ) THEN
302 IF( LSAME( SIDE, 'L' ) ) THEN
305 ELSE IF( LSAME( SIDE, 'R' ) ) THEN
313 IF( LSAME( DIRECT, 'F' ) ) THEN
316 ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
324 * ---------------------------------------------------------------------------
326 IF( COLUMN .AND. FORWARD .AND. LEFT ) THEN
328 * ---------------------------------------------------------------------------
330 * Let W = [ I ] (K-by-K)
333 * Form H C or H^H C where C = [ A ] (K-by-N)
336 * H = I - W T W^H or H^H = I - W T^H W^H
338 * A = A - T (A + V^H B) or A = A - T^H (A + V^H B)
339 * B = B - V T (A + V^H B) or B = B - V T^H (A + V^H B)
341 * ---------------------------------------------------------------------------
348 WORK( I, J ) = B( M-L+I, J )
351 CALL STRMM( 'L', 'U', 'T', 'N', L, N, ONE, V( MP, 1 ), LDV,
353 CALL SGEMM( 'T', 'N', L, N, M-L, ONE, V, LDV, B, LDB,
354 $ ONE, WORK, LDWORK )
355 CALL SGEMM( 'T', 'N', K-L, N, M, ONE, V( 1, KP ), LDV,
356 $ B, LDB, ZERO, WORK( KP, 1 ), LDWORK )
360 WORK( I, J ) = WORK( I, J ) + A( I, J )
364 CALL STRMM( 'L', 'U', TRANS, 'N', K, N, ONE, T, LDT,
369 A( I, J ) = A( I, J ) - WORK( I, J )
373 CALL SGEMM( 'N', 'N', M-L, N, K, -ONE, V, LDV, WORK, LDWORK,
375 CALL SGEMM( 'N', 'N', L, N, K-L, -ONE, V( MP, KP ), LDV,
376 $ WORK( KP, 1 ), LDWORK, ONE, B( MP, 1 ), LDB )
377 CALL STRMM( 'L', 'U', 'N', 'N', L, N, ONE, V( MP, 1 ), LDV,
381 B( M-L+I, J ) = B( M-L+I, J ) - WORK( I, J )
385 * ---------------------------------------------------------------------------
387 ELSE IF( COLUMN .AND. FORWARD .AND. RIGHT ) THEN
389 * ---------------------------------------------------------------------------
391 * Let W = [ I ] (K-by-K)
394 * Form C H or C H^H where C = [ A B ] (A is M-by-K, B is M-by-N)
396 * H = I - W T W^H or H^H = I - W T^H W^H
398 * A = A - (A + B V) T or A = A - (A + B V) T^H
399 * B = B - (A + B V) T V^H or B = B - (A + B V) T^H V^H
401 * ---------------------------------------------------------------------------
408 WORK( I, J ) = B( I, N-L+J )
411 CALL STRMM( 'R', 'U', 'N', 'N', M, L, ONE, V( NP, 1 ), LDV,
413 CALL SGEMM( 'N', 'N', M, L, N-L, ONE, B, LDB,
414 $ V, LDV, ONE, WORK, LDWORK )
415 CALL SGEMM( 'N', 'N', M, K-L, N, ONE, B, LDB,
416 $ V( 1, KP ), LDV, ZERO, WORK( 1, KP ), LDWORK )
420 WORK( I, J ) = WORK( I, J ) + A( I, J )
424 CALL STRMM( 'R', 'U', TRANS, 'N', M, K, ONE, T, LDT,
429 A( I, J ) = A( I, J ) - WORK( I, J )
433 CALL SGEMM( 'N', 'T', M, N-L, K, -ONE, WORK, LDWORK,
434 $ V, LDV, ONE, B, LDB )
435 CALL SGEMM( 'N', 'T', M, L, K-L, -ONE, WORK( 1, KP ), LDWORK,
436 $ V( NP, KP ), LDV, ONE, B( 1, NP ), LDB )
437 CALL STRMM( 'R', 'U', 'T', 'N', M, L, ONE, V( NP, 1 ), LDV,
441 B( I, N-L+J ) = B( I, N-L+J ) - WORK( I, J )
445 * ---------------------------------------------------------------------------
447 ELSE IF( COLUMN .AND. BACKWARD .AND. LEFT ) THEN
449 * ---------------------------------------------------------------------------
451 * Let W = [ V ] (M-by-K)
454 * Form H C or H^H C where C = [ B ] (M-by-N)
457 * H = I - W T W^H or H^H = I - W T^H W^H
459 * A = A - T (A + V^H B) or A = A - T^H (A + V^H B)
460 * B = B - V T (A + V^H B) or B = B - V T^H (A + V^H B)
462 * ---------------------------------------------------------------------------
469 WORK( K-L+I, J ) = B( I, J )
473 CALL STRMM( 'L', 'L', 'T', 'N', L, N, ONE, V( 1, KP ), LDV,
474 $ WORK( KP, 1 ), LDWORK )
475 CALL SGEMM( 'T', 'N', L, N, M-L, ONE, V( MP, KP ), LDV,
476 $ B( MP, 1 ), LDB, ONE, WORK( KP, 1 ), LDWORK )
477 CALL SGEMM( 'T', 'N', K-L, N, M, ONE, V, LDV,
478 $ B, LDB, ZERO, WORK, LDWORK )
482 WORK( I, J ) = WORK( I, J ) + A( I, J )
486 CALL STRMM( 'L', 'L', TRANS, 'N', K, N, ONE, T, LDT,
491 A( I, J ) = A( I, J ) - WORK( I, J )
495 CALL SGEMM( 'N', 'N', M-L, N, K, -ONE, V( MP, 1 ), LDV,
496 $ WORK, LDWORK, ONE, B( MP, 1 ), LDB )
497 CALL SGEMM( 'N', 'N', L, N, K-L, -ONE, V, LDV,
498 $ WORK, LDWORK, ONE, B, LDB )
499 CALL STRMM( 'L', 'L', 'N', 'N', L, N, ONE, V( 1, KP ), LDV,
500 $ WORK( KP, 1 ), LDWORK )
503 B( I, J ) = B( I, J ) - WORK( K-L+I, J )
507 * ---------------------------------------------------------------------------
509 ELSE IF( COLUMN .AND. BACKWARD .AND. RIGHT ) THEN
511 * ---------------------------------------------------------------------------
513 * Let W = [ V ] (N-by-K)
516 * Form C H or C H^H where C = [ B A ] (B is M-by-N, A is M-by-K)
518 * H = I - W T W^H or H^H = I - W T^H W^H
520 * A = A - (A + B V) T or A = A - (A + B V) T^H
521 * B = B - (A + B V) T V^H or B = B - (A + B V) T^H V^H
523 * ---------------------------------------------------------------------------
530 WORK( I, K-L+J ) = B( I, J )
533 CALL STRMM( 'R', 'L', 'N', 'N', M, L, ONE, V( 1, KP ), LDV,
534 $ WORK( 1, KP ), LDWORK )
535 CALL SGEMM( 'N', 'N', M, L, N-L, ONE, B( 1, NP ), LDB,
536 $ V( NP, KP ), LDV, ONE, WORK( 1, KP ), LDWORK )
537 CALL SGEMM( 'N', 'N', M, K-L, N, ONE, B, LDB,
538 $ V, LDV, ZERO, WORK, LDWORK )
542 WORK( I, J ) = WORK( I, J ) + A( I, J )
546 CALL STRMM( 'R', 'L', TRANS, 'N', M, K, ONE, T, LDT,
551 A( I, J ) = A( I, J ) - WORK( I, J )
555 CALL SGEMM( 'N', 'T', M, N-L, K, -ONE, WORK, LDWORK,
556 $ V( NP, 1 ), LDV, ONE, B( 1, NP ), LDB )
557 CALL SGEMM( 'N', 'T', M, L, K-L, -ONE, WORK, LDWORK,
558 $ V, LDV, ONE, B, LDB )
559 CALL STRMM( 'R', 'L', 'T', 'N', M, L, ONE, V( 1, KP ), LDV,
560 $ WORK( 1, KP ), LDWORK )
563 B( I, J ) = B( I, J ) - WORK( I, K-L+J )
567 * ---------------------------------------------------------------------------
569 ELSE IF( ROW .AND. FORWARD .AND. LEFT ) THEN
571 * ---------------------------------------------------------------------------
573 * Let W = [ I V ] ( I is K-by-K, V is K-by-M )
575 * Form H C or H^H C where C = [ A ] (K-by-N)
578 * H = I - W^H T W or H^H = I - W^H T^H W
580 * A = A - T (A + V B) or A = A - T^H (A + V B)
581 * B = B - V^H T (A + V B) or B = B - V^H T^H (A + V B)
583 * ---------------------------------------------------------------------------
590 WORK( I, J ) = B( M-L+I, J )
593 CALL STRMM( 'L', 'L', 'N', 'N', L, N, ONE, V( 1, MP ), LDV,
595 CALL SGEMM( 'N', 'N', L, N, M-L, ONE, V, LDV,B, LDB,
596 $ ONE, WORK, LDWORK )
597 CALL SGEMM( 'N', 'N', K-L, N, M, ONE, V( KP, 1 ), LDV,
598 $ B, LDB, ZERO, WORK( KP, 1 ), LDWORK )
602 WORK( I, J ) = WORK( I, J ) + A( I, J )
606 CALL STRMM( 'L', 'U', TRANS, 'N', K, N, ONE, T, LDT,
611 A( I, J ) = A( I, J ) - WORK( I, J )
615 CALL SGEMM( 'T', 'N', M-L, N, K, -ONE, V, LDV, WORK, LDWORK,
617 CALL SGEMM( 'T', 'N', L, N, K-L, -ONE, V( KP, MP ), LDV,
618 $ WORK( KP, 1 ), LDWORK, ONE, B( MP, 1 ), LDB )
619 CALL STRMM( 'L', 'L', 'T', 'N', L, N, ONE, V( 1, MP ), LDV,
623 B( M-L+I, J ) = B( M-L+I, J ) - WORK( I, J )
627 * ---------------------------------------------------------------------------
629 ELSE IF( ROW .AND. FORWARD .AND. RIGHT ) THEN
631 * ---------------------------------------------------------------------------
633 * Let W = [ I V ] ( I is K-by-K, V is K-by-N )
635 * Form C H or C H^H where C = [ A B ] (A is M-by-K, B is M-by-N)
637 * H = I - W^H T W or H^H = I - W^H T^H W
639 * A = A - (A + B V^H) T or A = A - (A + B V^H) T^H
640 * B = B - (A + B V^H) T V or B = B - (A + B V^H) T^H V
642 * ---------------------------------------------------------------------------
649 WORK( I, J ) = B( I, N-L+J )
652 CALL STRMM( 'R', 'L', 'T', 'N', M, L, ONE, V( 1, NP ), LDV,
654 CALL SGEMM( 'N', 'T', M, L, N-L, ONE, B, LDB, V, LDV,
655 $ ONE, WORK, LDWORK )
656 CALL SGEMM( 'N', 'T', M, K-L, N, ONE, B, LDB,
657 $ V( KP, 1 ), LDV, ZERO, WORK( 1, KP ), LDWORK )
661 WORK( I, J ) = WORK( I, J ) + A( I, J )
665 CALL STRMM( 'R', 'U', TRANS, 'N', M, K, ONE, T, LDT,
670 A( I, J ) = A( I, J ) - WORK( I, J )
674 CALL SGEMM( 'N', 'N', M, N-L, K, -ONE, WORK, LDWORK,
675 $ V, LDV, ONE, B, LDB )
676 CALL SGEMM( 'N', 'N', M, L, K-L, -ONE, WORK( 1, KP ), LDWORK,
677 $ V( KP, NP ), LDV, ONE, B( 1, NP ), LDB )
678 CALL STRMM( 'R', 'L', 'N', 'N', M, L, ONE, V( 1, NP ), LDV,
682 B( I, N-L+J ) = B( I, N-L+J ) - WORK( I, J )
686 * ---------------------------------------------------------------------------
688 ELSE IF( ROW .AND. BACKWARD .AND. LEFT ) THEN
690 * ---------------------------------------------------------------------------
692 * Let W = [ V I ] ( I is K-by-K, V is K-by-M )
694 * Form H C or H^H C where C = [ B ] (M-by-N)
697 * H = I - W^H T W or H^H = I - W^H T^H W
699 * A = A - T (A + V B) or A = A - T^H (A + V B)
700 * B = B - V^H T (A + V B) or B = B - V^H T^H (A + V B)
702 * ---------------------------------------------------------------------------
709 WORK( K-L+I, J ) = B( I, J )
712 CALL STRMM( 'L', 'U', 'N', 'N', L, N, ONE, V( KP, 1 ), LDV,
713 $ WORK( KP, 1 ), LDWORK )
714 CALL SGEMM( 'N', 'N', L, N, M-L, ONE, V( KP, MP ), LDV,
715 $ B( MP, 1 ), LDB, ONE, WORK( KP, 1 ), LDWORK )
716 CALL SGEMM( 'N', 'N', K-L, N, M, ONE, V, LDV, B, LDB,
717 $ ZERO, WORK, LDWORK )
721 WORK( I, J ) = WORK( I, J ) + A( I, J )
725 CALL STRMM( 'L', 'L ', TRANS, 'N', K, N, ONE, T, LDT,
730 A( I, J ) = A( I, J ) - WORK( I, J )
734 CALL SGEMM( 'T', 'N', M-L, N, K, -ONE, V( 1, MP ), LDV,
735 $ WORK, LDWORK, ONE, B( MP, 1 ), LDB )
736 CALL SGEMM( 'T', 'N', L, N, K-L, -ONE, V, LDV,
737 $ WORK, LDWORK, ONE, B, LDB )
738 CALL STRMM( 'L', 'U', 'T', 'N', L, N, ONE, V( KP, 1 ), LDV,
739 $ WORK( KP, 1 ), LDWORK )
742 B( I, J ) = B( I, J ) - WORK( K-L+I, J )
746 * ---------------------------------------------------------------------------
748 ELSE IF( ROW .AND. BACKWARD .AND. RIGHT ) THEN
750 * ---------------------------------------------------------------------------
752 * Let W = [ V I ] ( I is K-by-K, V is K-by-N )
754 * Form C H or C H^H where C = [ B A ] (A is M-by-K, B is M-by-N)
756 * H = I - W^H T W or H^H = I - W^H T^H W
758 * A = A - (A + B V^H) T or A = A - (A + B V^H) T^H
759 * B = B - (A + B V^H) T V or B = B - (A + B V^H) T^H V
761 * ---------------------------------------------------------------------------
768 WORK( I, K-L+J ) = B( I, J )
771 CALL STRMM( 'R', 'U', 'T', 'N', M, L, ONE, V( KP, 1 ), LDV,
772 $ WORK( 1, KP ), LDWORK )
773 CALL SGEMM( 'N', 'T', M, L, N-L, ONE, B( 1, NP ), LDB,
774 $ V( KP, NP ), LDV, ONE, WORK( 1, KP ), LDWORK )
775 CALL SGEMM( 'N', 'T', M, K-L, N, ONE, B, LDB, V, LDV,
776 $ ZERO, WORK, LDWORK )
780 WORK( I, J ) = WORK( I, J ) + A( I, J )
784 CALL STRMM( 'R', 'L', TRANS, 'N', M, K, ONE, T, LDT,
789 A( I, J ) = A( I, J ) - WORK( I, J )
793 CALL SGEMM( 'N', 'N', M, N-L, K, -ONE, WORK, LDWORK,
794 $ V( 1, NP ), LDV, ONE, B( 1, NP ), LDB )
795 CALL SGEMM( 'N', 'N', M, L, K-L , -ONE, WORK, LDWORK,
796 $ V, LDV, ONE, B, LDB )
797 CALL STRMM( 'R', 'U', 'N', 'N', M, L, ONE, V( KP, 1 ), LDV,
798 $ WORK( 1, KP ), LDWORK )
801 B( I, J ) = B( I, J ) - WORK( I, K-L+J )