1
*> \brief \b CLARFT forms the triangular factor T of a block reflector H = I - vtvH
3
* =========== DOCUMENTATION ===========
5
* Online html documentation available at
6
* http://www.netlib.org/lapack/explore-html/
9
*> Download CLARFT + dependencies
10
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clarft.f">
12
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clarft.f">
14
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clarft.f">
21
* SUBROUTINE CLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
23
* .. Scalar Arguments ..
24
* CHARACTER DIRECT, STOREV
25
* INTEGER K, LDT, LDV, N
27
* .. Array Arguments ..
28
* COMPLEX T( LDT, * ), TAU( * ), V( LDV, * )
37
*> CLARFT forms the triangular factor T of a complex block reflector H
38
*> of order n, which is defined as a product of k elementary reflectors.
40
*> If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
42
*> If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
44
*> If STOREV = 'C', the vector which defines the elementary reflector
45
*> H(i) is stored in the i-th column of the array V, and
47
*> H = I - V * T * V**H
49
*> If STOREV = 'R', the vector which defines the elementary reflector
50
*> H(i) is stored in the i-th row of the array V, and
52
*> H = I - V**H * T * V
60
*> DIRECT is CHARACTER*1
61
*> Specifies the order in which the elementary reflectors are
62
*> multiplied to form the block reflector:
63
*> = 'F': H = H(1) H(2) . . . H(k) (Forward)
64
*> = 'B': H = H(k) . . . H(2) H(1) (Backward)
69
*> STOREV is CHARACTER*1
70
*> Specifies how the vectors which define the elementary
71
*> reflectors are stored (see also Further Details):
79
*> The order of the block reflector H. N >= 0.
85
*> The order of the triangular factor T (= the number of
86
*> elementary reflectors). K >= 1.
91
*> V is COMPLEX array, dimension
92
*> (LDV,K) if STOREV = 'C'
93
*> (LDV,N) if STOREV = 'R'
94
*> The matrix V. See further details.
100
*> The leading dimension of the array V.
101
*> If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
106
*> TAU is COMPLEX array, dimension (K)
107
*> TAU(i) must contain the scalar factor of the elementary
113
*> T is COMPLEX array, dimension (LDT,K)
114
*> The k by k triangular factor T of the block reflector.
115
*> If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is
116
*> lower triangular. The rest of the array is not used.
122
*> The leading dimension of the array T. LDT >= K.
128
*> \author Univ. of Tennessee
129
*> \author Univ. of California Berkeley
130
*> \author Univ. of Colorado Denver
133
*> \date September 2012
135
*> \ingroup complexOTHERauxiliary
137
*> \par Further Details:
138
* =====================
142
*> The shape of the matrix V and the storage of the vectors which define
143
*> the H(i) is best illustrated by the following example with n = 5 and
144
*> k = 3. The elements equal to 1 are not stored.
146
*> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
148
*> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
149
*> ( v1 1 ) ( 1 v2 v2 v2 )
150
*> ( v1 v2 1 ) ( 1 v3 v3 )
154
*> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
156
*> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
157
*> ( v1 v2 v3 ) ( v2 v2 v2 1 )
158
*> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
163
* =====================================================================
1
164
SUBROUTINE CLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
3
* -- LAPACK auxiliary routine (version 2.0) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
166
* -- LAPACK auxiliary routine (version 3.4.2) --
167
* -- LAPACK is a software package provided by Univ. of Tennessee, --
168
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
8
171
* .. Scalar Arguments ..
9
172
CHARACTER DIRECT, STOREV
13
176
COMPLEX T( LDT, * ), TAU( * ), V( LDV, * )
17
* $Id: clarft.f 19697 2010-10-29 16:57:34Z d3y133 $
22
* CLARFT forms the triangular factor T of a complex block reflector H
23
* of order n, which is defined as a product of k elementary reflectors.
25
* If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
27
* If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
29
* If STOREV = 'C', the vector which defines the elementary reflector
30
* H(i) is stored in the i-th column of the array V, and
34
* If STOREV = 'R', the vector which defines the elementary reflector
35
* H(i) is stored in the i-th row of the array V, and
42
* DIRECT (input) CHARACTER*1
43
* Specifies the order in which the elementary reflectors are
44
* multiplied to form the block reflector:
45
* = 'F': H = H(1) H(2) . . . H(k) (Forward)
46
* = 'B': H = H(k) . . . H(2) H(1) (Backward)
48
* STOREV (input) CHARACTER*1
49
* Specifies how the vectors which define the elementary
50
* reflectors are stored (see also Further Details):
55
* The order of the block reflector H. N >= 0.
58
* The order of the triangular factor T (= the number of
59
* elementary reflectors). K >= 1.
61
* V (input/output) COMPLEX array, dimension
62
* (LDV,K) if STOREV = 'C'
63
* (LDV,N) if STOREV = 'R'
64
* The matrix V. See further details.
67
* The leading dimension of the array V.
68
* If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
70
* TAU (input) COMPLEX array, dimension (K)
71
* TAU(i) must contain the scalar factor of the elementary
74
* T (output) COMPLEX array, dimension (LDT,K)
75
* The k by k triangular factor T of the block reflector.
76
* If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is
77
* lower triangular. The rest of the array is not used.
80
* The leading dimension of the array T. LDT >= K.
85
* The shape of the matrix V and the storage of the vectors which define
86
* the H(i) is best illustrated by the following example with n = 5 and
87
* k = 3. The elements equal to 1 are not stored; the corresponding
88
* array elements are modified but restored on exit. The rest of the
91
* DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
93
* V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
94
* ( v1 1 ) ( 1 v2 v2 v2 )
95
* ( v1 v2 1 ) ( 1 v3 v3 )
99
* DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
101
* V = ( v1 v2 v3 ) V = ( v1 v1 1 )
102
* ( v1 v2 v3 ) ( v2 v2 v2 1 )
103
* ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
107
179
* =====================================================================
109
181
* .. Parameters ..
132
203
IF( LSAME( DIRECT, 'F' ) ) THEN
206
PREVLASTV = MAX( PREVLASTV, I )
134
207
IF( TAU( I ).EQ.ZERO ) THEN
147
218
IF( LSAME( STOREV, 'C' ) ) THEN
149
* T(1:i-1,i) := - tau(i) * V(i:n,1:i-1)' * V(i:n,i)
151
CALL CGEMV( 'Conjugate transpose', N-I+1, I-1,
152
$ -TAU( I ), V( I, 1 ), LDV, V( I, I ), 1,
153
$ ZERO, T( 1, I ), 1 )
219
* Skip any trailing zeros.
220
DO LASTV = N, I+1, -1
221
IF( V( LASTV, I ).NE.ZERO ) EXIT
224
T( J, I ) = -TAU( I ) * CONJG( V( I , J ) )
226
J = MIN( LASTV, PREVLASTV )
228
* T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**H * V(i:j,i)
230
CALL CGEMV( 'Conjugate transpose', J-I, I-1,
231
$ -TAU( I ), V( I+1, 1 ), LDV,
233
$ ONE, T( 1, I ), 1 )
156
* T(1:i-1,i) := - tau(i) * V(1:i-1,i:n) * V(i,i:n)'
159
$ CALL CLACGV( N-I, V( I, I+1 ), LDV )
160
CALL CGEMV( 'No transpose', I-1, N-I+1, -TAU( I ),
161
$ V( 1, I ), LDV, V( I, I ), LDV, ZERO,
164
$ CALL CLACGV( N-I, V( I, I+1 ), LDV )
235
* Skip any trailing zeros.
236
DO LASTV = N, I+1, -1
237
IF( V( I, LASTV ).NE.ZERO ) EXIT
240
T( J, I ) = -TAU( I ) * V( J , I )
242
J = MIN( LASTV, PREVLASTV )
244
* T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**H
246
CALL CGEMM( 'N', 'C', I-1, 1, J-I, -TAU( I ),
247
$ V( 1, I+1 ), LDV, V( I, I+1 ), LDV,
248
$ ONE, T( 1, I ), LDT )
168
251
* T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
170
253
CALL CTRMV( 'Upper', 'No transpose', 'Non-unit', I-1, T,
171
254
$ LDT, T( 1, I ), 1 )
172
255
T( I, I ) = TAU( I )
257
PREVLASTV = MAX( PREVLASTV, LASTV )
177
266
IF( TAU( I ).EQ.ZERO ) THEN
188
277
IF( I.LT.K ) THEN
189
278
IF( LSAME( STOREV, 'C' ) ) THEN
194
* - tau(i) * V(1:n-k+i,i+1:k)' * V(1:n-k+i,i)
196
CALL CGEMV( 'Conjugate transpose', N-K+I, K-I,
197
$ -TAU( I ), V( 1, I+1 ), LDV, V( 1, I ),
198
$ 1, ZERO, T( I+1, I ), 1 )
279
* Skip any leading zeros.
281
IF( V( LASTV, I ).NE.ZERO ) EXIT
284
T( J, I ) = -TAU( I ) * CONJG( V( N-K+I , J ) )
286
J = MAX( LASTV, PREVLASTV )
288
* T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**H * V(j:n-k+i,i)
290
CALL CGEMV( 'Conjugate transpose', N-K+I-J, K-I,
291
$ -TAU( I ), V( J, I+1 ), LDV, V( J, I ),
292
$ 1, ONE, T( I+1, I ), 1 )
205
* - tau(i) * V(i+1:k,1:n-k+i) * V(i,1:n-k+i)'
207
CALL CLACGV( N-K+I-1, V( I, 1 ), LDV )
208
CALL CGEMV( 'No transpose', K-I, N-K+I, -TAU( I ),
209
$ V( I+1, 1 ), LDV, V( I, 1 ), LDV, ZERO,
211
CALL CLACGV( N-K+I-1, V( I, 1 ), LDV )
294
* Skip any leading zeros.
296
IF( V( I, LASTV ).NE.ZERO ) EXIT
299
T( J, I ) = -TAU( I ) * V( J, N-K+I )
301
J = MAX( LASTV, PREVLASTV )
303
* T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**H
305
CALL CGEMM( 'N', 'C', K-I, 1, N-K+I-J, -TAU( I ),
306
$ V( I+1, J ), LDV, V( I, J ), LDV,
307
$ ONE, T( I+1, I ), LDT )
215
310
* T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
217
312
CALL CTRMV( 'Lower', 'No transpose', 'Non-unit', K-I,
218
313
$ T( I+1, I+1 ), LDT, T( I+1, I ), 1 )
315
PREVLASTV = MIN( PREVLASTV, LASTV )
220
320
T( I, I ) = TAU( I )