LAPACK 3.12.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches
zlarft.f
Go to the documentation of this file.
1*> \brief \b ZLARFT forms the triangular factor T of a block reflector H = I - vtvH
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zlarft.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zlarft.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zlarft.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE ZLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
22*
23* .. Scalar Arguments ..
24* CHARACTER DIRECT, STOREV
25* INTEGER K, LDT, LDV, N
26* ..
27* .. Array Arguments ..
28* COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> ZLARFT 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.
39*>
40*> If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
41*>
42*> If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
43*>
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
46*>
47*> H = I - V * T * V**H
48*>
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
51*>
52*> H = I - V**H * T * V
53*> \endverbatim
54*
55* Arguments:
56* ==========
57*
58*> \param[in] DIRECT
59*> \verbatim
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)
65*> \endverbatim
66*>
67*> \param[in] STOREV
68*> \verbatim
69*> STOREV is CHARACTER*1
70*> Specifies how the vectors which define the elementary
72*> = 'C': columnwise
73*> = 'R': rowwise
74*> \endverbatim
75*>
76*> \param[in] N
77*> \verbatim
78*> N is INTEGER
79*> The order of the block reflector H. N >= 0.
80*> \endverbatim
81*>
82*> \param[in] K
83*> \verbatim
84*> K is INTEGER
85*> The order of the triangular factor T (= the number of
86*> elementary reflectors). K >= 1.
87*> \endverbatim
88*>
89*> \param[in] V
90*> \verbatim
91*> V is COMPLEX*16 array, dimension
92*> (LDV,K) if STOREV = 'C'
93*> (LDV,N) if STOREV = 'R'
94*> The matrix V. See further details.
95*> \endverbatim
96*>
97*> \param[in] LDV
98*> \verbatim
99*> LDV is INTEGER
100*> The leading dimension of the array V.
101*> If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
102*> \endverbatim
103*>
104*> \param[in] TAU
105*> \verbatim
106*> TAU is COMPLEX*16 array, dimension (K)
107*> TAU(i) must contain the scalar factor of the elementary
108*> reflector H(i).
109*> \endverbatim
110*>
111*> \param[out] T
112*> \verbatim
113*> T is COMPLEX*16 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.
117*> \endverbatim
118*>
119*> \param[in] LDT
120*> \verbatim
121*> LDT is INTEGER
122*> The leading dimension of the array T. LDT >= K.
123*> \endverbatim
124*
125* Authors:
126* ========
127*
128*> \author Univ. of Tennessee
129*> \author Univ. of California Berkeley
130*> \author Univ. of Colorado Denver
131*> \author NAG Ltd.
132*
133*> \ingroup larft
134*
135*> \par Further Details:
136* =====================
137*>
138*> \verbatim
139*>
140*> The shape of the matrix V and the storage of the vectors which define
141*> the H(i) is best illustrated by the following example with n = 5 and
142*> k = 3. The elements equal to 1 are not stored.
143*>
144*> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
145*>
146*> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
147*> ( v1 1 ) ( 1 v2 v2 v2 )
148*> ( v1 v2 1 ) ( 1 v3 v3 )
149*> ( v1 v2 v3 )
150*> ( v1 v2 v3 )
151*>
152*> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
153*>
154*> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
155*> ( v1 v2 v3 ) ( v2 v2 v2 1 )
156*> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
157*> ( 1 v3 )
158*> ( 1 )
159*> \endverbatim
160*>
161* =====================================================================
162 SUBROUTINE zlarft( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
163*
164* -- LAPACK auxiliary routine --
165* -- LAPACK is a software package provided by Univ. of Tennessee, --
166* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
167*
168* .. Scalar Arguments ..
169 CHARACTER DIRECT, STOREV
170 INTEGER K, LDT, LDV, N
171* ..
172* .. Array Arguments ..
173 COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * )
174* ..
175*
176* =====================================================================
177*
178* .. Parameters ..
179 COMPLEX*16 ONE, ZERO
180 parameter( one = ( 1.0d+0, 0.0d+0 ),
181 \$ zero = ( 0.0d+0, 0.0d+0 ) )
182* ..
183* .. Local Scalars ..
184 INTEGER I, J, PREVLASTV, LASTV
185* ..
186* .. External Subroutines ..
187 EXTERNAL zgemv, ztrmv, zgemm
188* ..
189* .. External Functions ..
190 LOGICAL LSAME
191 EXTERNAL lsame
192* ..
193* .. Executable Statements ..
194*
195* Quick return if possible
196*
197 IF( n.EQ.0 )
198 \$ RETURN
199*
200 IF( lsame( direct, 'F' ) ) THEN
201 prevlastv = n
202 DO i = 1, k
203 prevlastv = max( prevlastv, i )
204 IF( tau( i ).EQ.zero ) THEN
205*
206* H(i) = I
207*
208 DO j = 1, i
209 t( j, i ) = zero
210 END DO
211 ELSE
212*
213* general case
214*
215 IF( lsame( storev, 'C' ) ) THEN
216* Skip any trailing zeros.
217 DO lastv = n, i+1, -1
218 IF( v( lastv, i ).NE.zero ) EXIT
219 END DO
220 DO j = 1, i-1
221 t( j, i ) = -tau( i ) * conjg( v( i , j ) )
222 END DO
223 j = min( lastv, prevlastv )
224*
225* T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**H * V(i:j,i)
226*
227 CALL zgemv( 'Conjugate transpose', j-i, i-1,
228 \$ -tau( i ), v( i+1, 1 ), ldv,
229 \$ v( i+1, i ), 1, one, t( 1, i ), 1 )
230 ELSE
231* Skip any trailing zeros.
232 DO lastv = n, i+1, -1
233 IF( v( i, lastv ).NE.zero ) EXIT
234 END DO
235 DO j = 1, i-1
236 t( j, i ) = -tau( i ) * v( j , i )
237 END DO
238 j = min( lastv, prevlastv )
239*
240* T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**H
241*
242 CALL zgemm( 'N', 'C', i-1, 1, j-i, -tau( i ),
243 \$ v( 1, i+1 ), ldv, v( i, i+1 ), ldv,
244 \$ one, t( 1, i ), ldt )
245 END IF
246*
247* T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
248*
249 CALL ztrmv( 'Upper', 'No transpose', 'Non-unit', i-1, t,
250 \$ ldt, t( 1, i ), 1 )
251 t( i, i ) = tau( i )
252 IF( i.GT.1 ) THEN
253 prevlastv = max( prevlastv, lastv )
254 ELSE
255 prevlastv = lastv
256 END IF
257 END IF
258 END DO
259 ELSE
260 prevlastv = 1
261 DO i = k, 1, -1
262 IF( tau( i ).EQ.zero ) THEN
263*
264* H(i) = I
265*
266 DO j = i, k
267 t( j, i ) = zero
268 END DO
269 ELSE
270*
271* general case
272*
273 IF( i.LT.k ) THEN
274 IF( lsame( storev, 'C' ) ) THEN
276 DO lastv = 1, i-1
277 IF( v( lastv, i ).NE.zero ) EXIT
278 END DO
279 DO j = i+1, k
280 t( j, i ) = -tau( i ) * conjg( v( n-k+i , j ) )
281 END DO
282 j = max( lastv, prevlastv )
283*
284* T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**H * V(j:n-k+i,i)
285*
286 CALL zgemv( 'Conjugate transpose', n-k+i-j, k-i,
287 \$ -tau( i ), v( j, i+1 ), ldv, v( j, i ),
288 \$ 1, one, t( i+1, i ), 1 )
289 ELSE
291 DO lastv = 1, i-1
292 IF( v( i, lastv ).NE.zero ) EXIT
293 END DO
294 DO j = i+1, k
295 t( j, i ) = -tau( i ) * v( j, n-k+i )
296 END DO
297 j = max( lastv, prevlastv )
298*
299* T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**H
300*
301 CALL zgemm( 'N', 'C', k-i, 1, n-k+i-j, -tau( i ),
302 \$ v( i+1, j ), ldv, v( i, j ), ldv,
303 \$ one, t( i+1, i ), ldt )
304 END IF
305*
306* T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
307*
308 CALL ztrmv( 'Lower', 'No transpose', 'Non-unit', k-i,
309 \$ t( i+1, i+1 ), ldt, t( i+1, i ), 1 )
310 IF( i.GT.1 ) THEN
311 prevlastv = min( prevlastv, lastv )
312 ELSE
313 prevlastv = lastv
314 END IF
315 END IF
316 t( i, i ) = tau( i )
317 END IF
318 END DO
319 END IF
320 RETURN
321*
322* End of ZLARFT
323*
324 END
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
Definition zgemm.f:188
subroutine zgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
ZGEMV
Definition zgemv.f:160
subroutine zlarft(direct, storev, n, k, v, ldv, tau, t, ldt)
ZLARFT forms the triangular factor T of a block reflector H = I - vtvH
Definition zlarft.f:163
subroutine ztrmv(uplo, trans, diag, n, a, lda, x, incx)
ZTRMV
Definition ztrmv.f:147