1 SUBROUTINE ZLARFB
( SIDE
, TRANS
, DIRECT
, STOREV
, M
, N
, K
, V
, LDV
,
2 $ T
, LDT
, C
, LDC
, WORK
, LDWORK
)
4 * -- LAPACK auxiliary routine
(version
3.1) --
5 * Univ
. of Tennessee
, Univ
. of California Berkeley and NAG Ltd
..
8 * .. Scalar Arguments
..
9 CHARACTER DIRECT
, SIDE
, STOREV
, TRANS
10 INTEGER K
, LDC
, LDT
, LDV
, LDWORK
, M
, N
12 * .. Array Arguments
..
13 COMPLEX*16 C
( LDC
, * ), T
( LDT
, * ), V
( LDV
, * ),
20 * ZLARFB applies a
complex block reflector H or its transpose H
' to a
21 * complex M-by-N matrix C, from either the left or the right.
26 * SIDE (input) CHARACTER*1
27 * = 'L
': apply H or H' from the Left
28 * = 'R': apply H or H
' from the Right
30 * TRANS (input) CHARACTER*1
31 * = 'N
': apply H (No transpose)
32 * = 'C
': apply H' (Conjugate transpose
)
34 * DIRECT
(input
) CHARACTER*1
35 * Indicates how H is formed from a product of elementary
37 * = 'F': H
= H
(1) H
(2) . . . H
(k
) (Forward
)
38 * = 'B': H
= H
(k
) . . . H
(2) H
(1) (Backward
)
40 * STOREV
(input
) CHARACTER*1
41 * Indicates how the vectors which define the elementary
42 * reflectors are stored
:
47 * The number of rows of the matrix C
.
50 * The number of columns of the matrix C
.
53 * The order of the matrix T
(= the number of elementary
54 * reflectors whose product defines the block reflector
).
56 * V
(input
) COMPLEX*16 array
, dimension
57 * (LDV
,K
) if STOREV
= 'C'
58 * (LDV
,M
) if STOREV
= 'R' and SIDE
= 'L'
59 * (LDV
,N
) if STOREV
= 'R' and SIDE
= 'R'
60 * The matrix V
. See further details
.
63 * The leading
dimension of the array V
.
64 * If STOREV
= 'C' and SIDE
= 'L', LDV
>= max
(1,M
);
65 * if STOREV
= 'C' and SIDE
= 'R', LDV
>= max
(1,N
);
66 * if STOREV
= 'R', LDV
>= K
.
68 * T
(input
) COMPLEX*16 array
, dimension (LDT
,K
)
69 * The triangular K
-by
-K matrix T in the representation of the
73 * The leading
dimension of the array T
. LDT
>= K
.
75 * C
(input
/output
) COMPLEX*16 array
, dimension (LDC
,N
)
76 * On entry
, the M
-by
-N matrix C
.
77 * On exit
, C is overwritten by H*C or H
'*C or C*H or C*H'.
80 * The leading
dimension of the array C
. LDC
>= max
(1,M
).
82 * WORK
(workspace
) COMPLEX*16 array
, dimension (LDWORK
,K
)
84 * LDWORK
(input
) INTEGER
85 * The leading
dimension of the array WORK
.
86 * If SIDE
= 'L', LDWORK
>= max
(1,N
);
87 * if SIDE
= 'R', LDWORK
>= max
(1,M
).
89 * =====================================================================
93 PARAMETER ( ONE
= ( 1.0D
+0, 0.0D
+0 ) )
99 * .. External Functions
..
103 * .. External Subroutines
..
104 EXTERNAL ZCOPY
, ZGEMM
, ZLACGV
, ZTRMM
106 * .. Intrinsic Functions
..
109 * .. Executable Statements
..
111 * Quick
return if possible
113 IF( M
.LE
.0 .OR
. N
.LE
.0 )
116 IF( LSAME
( TRANS
, 'N' ) ) THEN
122 IF( LSAME
( STOREV
, 'C' ) ) THEN
124 IF( LSAME
( DIRECT
, 'F' ) ) THEN
126 * Let V
= ( V1
) (first K rows
)
128 * where V1 is unit lower triangular
.
130 IF( LSAME
( SIDE
, 'L' ) ) THEN
132 * Form H
* C or H
' * C where C = ( C1 )
135 * W := C' * V
= (C1
'*V1 + C2'*V2
) (stored in WORK
)
140 CALL ZCOPY( N, C( J, 1 ), LDC, WORK( 1, J ), 1 )
141 CALL ZLACGV( N, WORK( 1, J ), 1 )
146 CALL ZTRMM( 'Right
', 'Lower
', 'No transpose
', 'Unit
', N,
147 $ K, ONE, V, LDV, WORK, LDWORK )
152 CALL ZGEMM
( 'Conjugate transpose', 'No transpose', N
,
153 $ K
, M
-K
, ONE
, C
( K
+1, 1 ), LDC
,
154 $ V
( K
+1, 1 ), LDV
, ONE
, WORK
, LDWORK
)
157 * W
:= W
* T
' or W * T
159 CALL ZTRMM( 'Right
', 'Upper
', TRANST, 'Non
-unit
', N, K,
160 $ ONE, T, LDT, WORK, LDWORK )
168 CALL ZGEMM( 'No transpose
', 'Conjugate transpose
',
169 $ M-K, N, K, -ONE, V( K+1, 1 ), LDV, WORK,
170 $ LDWORK, ONE, C( K+1, 1 ), LDC )
175 CALL ZTRMM
( 'Right', 'Lower', 'Conjugate transpose',
176 $
'Unit', N
, K
, ONE
, V
, LDV
, WORK
, LDWORK
)
182 C( J, I ) = C( J, I ) - DCONJG( WORK( I, J ) )
186 ELSE IF( LSAME( SIDE, 'R
' ) ) THEN
188 * Form C * H or C * H' where C
= ( C1 C2
)
190 * W
:= C
* V
= (C1*V1
+ C2*V2
) (stored in WORK
)
195 CALL ZCOPY
( M
, C
( 1, J
), 1, WORK
( 1, J
), 1 )
200 CALL ZTRMM
( 'Right', 'Lower', 'No transpose', 'Unit', M
,
201 $ K
, ONE
, V
, LDV
, WORK
, LDWORK
)
206 CALL ZGEMM
( 'No transpose', 'No transpose', M
, K
, N
-K
,
207 $ ONE
, C
( 1, K
+1 ), LDC
, V
( K
+1, 1 ), LDV
,
208 $ ONE
, WORK
, LDWORK
)
211 * W
:= W
* T or W
* T
'
213 CALL ZTRMM( 'Right
', 'Upper
', TRANS, 'Non
-unit
', M, K,
214 $ ONE, T, LDT, WORK, LDWORK )
222 CALL ZGEMM( 'No transpose
', 'Conjugate transpose
', M,
223 $ N-K, K, -ONE, WORK, LDWORK, V( K+1, 1 ),
224 $ LDV, ONE, C( 1, K+1 ), LDC )
229 CALL ZTRMM
( 'Right', 'Lower', 'Conjugate transpose',
230 $
'Unit', M
, K
, ONE
, V
, LDV
, WORK
, LDWORK
)
236 C
( I
, J
) = C
( I
, J
) - WORK
( I
, J
)
244 * ( V2
) (last K rows
)
245 * where V2 is unit upper triangular
.
247 IF( LSAME
( SIDE
, 'L' ) ) THEN
249 * Form H
* C or H
' * C where C = ( C1 )
252 * W := C' * V
= (C1
'*V1 + C2'*V2
) (stored in WORK
)
257 CALL ZCOPY( N, C( M-K+J, 1 ), LDC, WORK( 1, J ), 1 )
258 CALL ZLACGV( N, WORK( 1, J ), 1 )
263 CALL ZTRMM( 'Right
', 'Upper
', 'No transpose
', 'Unit
', N,
264 $ K, ONE, V( M-K+1, 1 ), LDV, WORK, LDWORK )
269 CALL ZGEMM
( 'Conjugate transpose', 'No transpose', N
,
270 $ K
, M
-K
, ONE
, C
, LDC
, V
, LDV
, ONE
, WORK
,
274 * W
:= W
* T
' or W * T
276 CALL ZTRMM( 'Right
', 'Lower
', TRANST, 'Non
-unit
', N, K,
277 $ ONE, T, LDT, WORK, LDWORK )
285 CALL ZGEMM( 'No transpose
', 'Conjugate transpose
',
286 $ M-K, N, K, -ONE, V, LDV, WORK, LDWORK,
292 CALL ZTRMM
( 'Right', 'Upper', 'Conjugate transpose',
293 $
'Unit', N
, K
, ONE
, V
( M
-K
+1, 1 ), LDV
, WORK
,
300 C( M-K+J, I ) = C( M-K+J, I ) -
301 $ DCONJG( WORK( I, J ) )
305 ELSE IF( LSAME( SIDE, 'R
' ) ) THEN
307 * Form C * H or C * H' where C
= ( C1 C2
)
309 * W
:= C
* V
= (C1*V1
+ C2*V2
) (stored in WORK
)
314 CALL ZCOPY
( M
, C
( 1, N
-K
+J
), 1, WORK
( 1, J
), 1 )
319 CALL ZTRMM
( 'Right', 'Upper', 'No transpose', 'Unit', M
,
320 $ K
, ONE
, V
( N
-K
+1, 1 ), LDV
, WORK
, LDWORK
)
325 CALL ZGEMM
( 'No transpose', 'No transpose', M
, K
, N
-K
,
326 $ ONE
, C
, LDC
, V
, LDV
, ONE
, WORK
, LDWORK
)
329 * W
:= W
* T or W
* T
'
331 CALL ZTRMM( 'Right
', 'Lower
', TRANS, 'Non
-unit
', M, K,
332 $ ONE, T, LDT, WORK, LDWORK )
340 CALL ZGEMM( 'No transpose
', 'Conjugate transpose
', M,
341 $ N-K, K, -ONE, WORK, LDWORK, V, LDV, ONE,
347 CALL ZTRMM
( 'Right', 'Upper', 'Conjugate transpose',
348 $
'Unit', M
, K
, ONE
, V
( N
-K
+1, 1 ), LDV
, WORK
,
355 C
( I
, N
-K
+J
) = C
( I
, N
-K
+J
) - WORK
( I
, J
)
361 ELSE IF( LSAME
( STOREV
, 'R' ) ) THEN
363 IF( LSAME
( DIRECT
, 'F' ) ) THEN
365 * Let V
= ( V1 V2
) (V1
: first K columns
)
366 * where V1 is unit upper triangular
.
368 IF( LSAME
( SIDE
, 'L' ) ) THEN
370 * Form H
* C or H
' * C where C = ( C1 )
373 * W := C' * V
' = (C1'*V1
' + C2'*V2
') (stored in WORK)
378 CALL ZCOPY
( N
, C
( J
, 1 ), LDC
, WORK
( 1, J
), 1 )
379 CALL ZLACGV
( N
, WORK
( 1, J
), 1 )
384 CALL ZTRMM( 'Right
', 'Upper
', 'Conjugate transpose
',
385 $ 'Unit
', N, K, ONE, V, LDV, WORK, LDWORK )
390 CALL ZGEMM( 'Conjugate transpose
',
391 $ 'Conjugate transpose
', N, K, M-K, ONE,
392 $ C( K+1, 1 ), LDC, V( 1, K+1 ), LDV, ONE,
396 * W := W * T' or W
* T
398 CALL ZTRMM
( 'Right', 'Upper', TRANST
, 'Non-unit', N
, K
,
399 $ ONE
, T
, LDT
, WORK
, LDWORK
)
405 * C2
:= C2
- V2
' * W'
407 CALL ZGEMM
( 'Conjugate transpose',
408 $
'Conjugate transpose', M
-K
, N
, K
, -ONE
,
409 $ V
( 1, K
+1 ), LDV
, WORK
, LDWORK
, ONE
,
415 CALL ZTRMM
( 'Right', 'Upper', 'No transpose', 'Unit', N
,
416 $ K
, ONE
, V
, LDV
, WORK
, LDWORK
)
422 C( J, I ) = C( J, I ) - DCONJG( WORK( I, J ) )
426 ELSE IF( LSAME( SIDE, 'R
' ) ) THEN
428 * Form C * H or C * H' where C
= ( C1 C2
)
430 * W
:= C
* V
' = (C1*V1' + C2*V2
') (stored in WORK)
435 CALL ZCOPY( M, C( 1, J ), 1, WORK( 1, J ), 1 )
440 CALL ZTRMM
( 'Right', 'Upper', 'Conjugate transpose',
441 $
'Unit', M
, K
, ONE
, V
, LDV
, WORK
, LDWORK
)
446 CALL ZGEMM( 'No transpose
', 'Conjugate transpose
', M,
447 $ K, N-K, ONE, C( 1, K+1 ), LDC,
448 $ V( 1, K+1 ), LDV, ONE, WORK, LDWORK )
451 * W := W * T or W * T'
453 CALL ZTRMM
( 'Right', 'Upper', TRANS
, 'Non-unit', M
, K
,
454 $ ONE
, T
, LDT
, WORK
, LDWORK
)
462 CALL ZGEMM
( 'No transpose', 'No transpose', M
, N
-K
, K
,
463 $
-ONE
, WORK
, LDWORK
, V
( 1, K
+1 ), LDV
, ONE
,
469 CALL ZTRMM
( 'Right', 'Upper', 'No transpose', 'Unit', M
,
470 $ K
, ONE
, V
, LDV
, WORK
, LDWORK
)
476 C
( I
, J
) = C
( I
, J
) - WORK
( I
, J
)
484 * Let V
= ( V1 V2
) (V2
: last K columns
)
485 * where V2 is unit lower triangular
.
487 IF( LSAME
( SIDE
, 'L' ) ) THEN
489 * Form H
* C or H
' * C where C = ( C1 )
492 * W := C' * V
' = (C1'*V1
' + C2'*V2
') (stored in WORK)
497 CALL ZCOPY
( N
, C
( M
-K
+J
, 1 ), LDC
, WORK
( 1, J
), 1 )
498 CALL ZLACGV
( N
, WORK
( 1, J
), 1 )
503 CALL ZTRMM( 'Right
', 'Lower
', 'Conjugate transpose
',
504 $ 'Unit
', N, K, ONE, V( 1, M-K+1 ), LDV, WORK,
510 CALL ZGEMM( 'Conjugate transpose
',
511 $ 'Conjugate transpose
', N, K, M-K, ONE, C,
512 $ LDC, V, LDV, ONE, WORK, LDWORK )
515 * W := W * T' or W
* T
517 CALL ZTRMM
( 'Right', 'Lower', TRANST
, 'Non-unit', N
, K
,
518 $ ONE
, T
, LDT
, WORK
, LDWORK
)
524 * C1
:= C1
- V1
' * W'
526 CALL ZGEMM
( 'Conjugate transpose',
527 $
'Conjugate transpose', M
-K
, N
, K
, -ONE
, V
,
528 $ LDV
, WORK
, LDWORK
, ONE
, C
, LDC
)
533 CALL ZTRMM
( 'Right', 'Lower', 'No transpose', 'Unit', N
,
534 $ K
, ONE
, V
( 1, M
-K
+1 ), LDV
, WORK
, LDWORK
)
540 C( M-K+J, I ) = C( M-K+J, I ) -
541 $ DCONJG( WORK( I, J ) )
545 ELSE IF( LSAME( SIDE, 'R
' ) ) THEN
547 * Form C * H or C * H' where C
= ( C1 C2
)
549 * W
:= C
* V
' = (C1*V1' + C2*V2
') (stored in WORK)
554 CALL ZCOPY( M, C( 1, N-K+J ), 1, WORK( 1, J ), 1 )
559 CALL ZTRMM
( 'Right', 'Lower', 'Conjugate transpose',
560 $
'Unit', M
, K
, ONE
, V
( 1, N
-K
+1 ), LDV
, WORK
,
566 CALL ZGEMM( 'No transpose
', 'Conjugate transpose
', M,
567 $ K, N-K, ONE, C, LDC, V, LDV, ONE, WORK,
571 * W := W * T or W * T'
573 CALL ZTRMM
( 'Right', 'Lower', TRANS
, 'Non-unit', M
, K
,
574 $ ONE
, T
, LDT
, WORK
, LDWORK
)
582 CALL ZGEMM
( 'No transpose', 'No transpose', M
, N
-K
, K
,
583 $
-ONE
, WORK
, LDWORK
, V
, LDV
, ONE
, C
, LDC
)
588 CALL ZTRMM
( 'Right', 'Lower', 'No transpose', 'Unit', M
,
589 $ K
, ONE
, V
( 1, N
-K
+1 ), LDV
, WORK
, LDWORK
)
595 C
( I
, N
-K
+J
) = C
( I
, N
-K
+J
) - WORK
( I
, J
)