1: *> \brief \b ZLARFT
2: *
3: * =========== DOCUMENTATION ===========
4: *
5: * Online html documentation available at
6: * http://www.netlib.org/lapack/explore-html/
7: *
8: *> \htmlonly
9: *> Download ZLARFT + dependencies
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
71: *> reflectors are stored (see also Further Details):
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,out] 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: *> \date November 2011
134: *
135: *> \ingroup complex16OTHERauxiliary
136: *
137: *> \par Further Details:
138: * =====================
139: *>
140: *> \verbatim
141: *>
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; the corresponding
145: *> array elements are modified but restored on exit. The rest of the
146: *> array is not used.
147: *>
148: *> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
149: *>
150: *> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
151: *> ( v1 1 ) ( 1 v2 v2 v2 )
152: *> ( v1 v2 1 ) ( 1 v3 v3 )
153: *> ( v1 v2 v3 )
154: *> ( v1 v2 v3 )
155: *>
156: *> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
157: *>
158: *> V = ( v1 v2 v3 ) V = ( v1 v1 1 )
159: *> ( v1 v2 v3 ) ( v2 v2 v2 1 )
160: *> ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
161: *> ( 1 v3 )
162: *> ( 1 )
163: *> \endverbatim
164: *>
165: * =====================================================================
166: SUBROUTINE ZLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
167: *
168: * -- LAPACK auxiliary routine (version 3.4.0) --
169: * -- LAPACK is a software package provided by Univ. of Tennessee, --
170: * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
171: * November 2011
172: *
173: * .. Scalar Arguments ..
174: CHARACTER DIRECT, STOREV
175: INTEGER K, LDT, LDV, N
176: * ..
177: * .. Array Arguments ..
178: COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * )
179: * ..
180: *
181: * =====================================================================
182: *
183: * .. Parameters ..
184: COMPLEX*16 ONE, ZERO
185: PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),
186: $ ZERO = ( 0.0D+0, 0.0D+0 ) )
187: * ..
188: * .. Local Scalars ..
189: INTEGER I, J, PREVLASTV, LASTV
190: COMPLEX*16 VII
191: * ..
192: * .. External Subroutines ..
193: EXTERNAL ZGEMV, ZLACGV, ZTRMV
194: * ..
195: * .. External Functions ..
196: LOGICAL LSAME
197: EXTERNAL LSAME
198: * ..
199: * .. Executable Statements ..
200: *
201: * Quick return if possible
202: *
203: IF( N.EQ.0 )
204: $ RETURN
205: *
206: IF( LSAME( DIRECT, 'F' ) ) THEN
207: PREVLASTV = N
208: DO 20 I = 1, K
209: PREVLASTV = MAX( PREVLASTV, I )
210: IF( TAU( I ).EQ.ZERO ) THEN
211: *
212: * H(i) = I
213: *
214: DO 10 J = 1, I
215: T( J, I ) = ZERO
216: 10 CONTINUE
217: ELSE
218: *
219: * general case
220: *
221: VII = V( I, I )
222: V( I, I ) = ONE
223: IF( LSAME( STOREV, 'C' ) ) THEN
224: ! Skip any trailing zeros.
225: DO LASTV = N, I+1, -1
226: IF( V( LASTV, I ).NE.ZERO ) EXIT
227: END DO
228: J = MIN( LASTV, PREVLASTV )
229: *
230: * T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**H * V(i:j,i)
231: *
232: CALL ZGEMV( 'Conjugate transpose', J-I+1, I-1,
233: $ -TAU( I ), V( I, 1 ), LDV, V( I, I ), 1,
234: $ ZERO, T( 1, I ), 1 )
235: ELSE
236: ! Skip any trailing zeros.
237: DO LASTV = N, I+1, -1
238: IF( V( I, LASTV ).NE.ZERO ) EXIT
239: END DO
240: J = MIN( LASTV, PREVLASTV )
241: *
242: * T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**H
243: *
244: IF( I.LT.J )
245: $ CALL ZLACGV( J-I, V( I, I+1 ), LDV )
246: CALL ZGEMV( 'No transpose', I-1, J-I+1, -TAU( I ),
247: $ V( 1, I ), LDV, V( I, I ), LDV, ZERO,
248: $ T( 1, I ), 1 )
249: IF( I.LT.J )
250: $ CALL ZLACGV( J-I, V( I, I+1 ), LDV )
251: END IF
252: V( I, I ) = VII
253: *
254: * T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
255: *
256: CALL ZTRMV( 'Upper', 'No transpose', 'Non-unit', I-1, T,
257: $ LDT, T( 1, I ), 1 )
258: T( I, I ) = TAU( I )
259: IF( I.GT.1 ) THEN
260: PREVLASTV = MAX( PREVLASTV, LASTV )
261: ELSE
262: PREVLASTV = LASTV
263: END IF
264: END IF
265: 20 CONTINUE
266: ELSE
267: PREVLASTV = 1
268: DO 40 I = K, 1, -1
269: IF( TAU( I ).EQ.ZERO ) THEN
270: *
271: * H(i) = I
272: *
273: DO 30 J = I, K
274: T( J, I ) = ZERO
275: 30 CONTINUE
276: ELSE
277: *
278: * general case
279: *
280: IF( I.LT.K ) THEN
281: IF( LSAME( STOREV, 'C' ) ) THEN
282: VII = V( N-K+I, I )
283: V( N-K+I, I ) = ONE
284: ! Skip any leading zeros.
285: DO LASTV = 1, I-1
286: IF( V( LASTV, I ).NE.ZERO ) EXIT
287: END DO
288: J = MAX( LASTV, PREVLASTV )
289: *
290: * T(i+1:k,i) :=
291: * - tau(i) * V(j:n-k+i,i+1:k)**H * V(j:n-k+i,i)
292: *
293: CALL ZGEMV( 'Conjugate transpose', N-K+I-J+1, K-I,
294: $ -TAU( I ), V( J, I+1 ), LDV, V( J, I ),
295: $ 1, ZERO, T( I+1, I ), 1 )
296: V( N-K+I, I ) = VII
297: ELSE
298: VII = V( I, N-K+I )
299: V( I, N-K+I ) = ONE
300: ! Skip any leading zeros.
301: DO LASTV = 1, I-1
302: IF( V( I, LASTV ).NE.ZERO ) EXIT
303: END DO
304: J = MAX( LASTV, PREVLASTV )
305: *
306: * T(i+1:k,i) :=
307: * - tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**H
308: *
309: CALL ZLACGV( N-K+I-1-J+1, V( I, J ), LDV )
310: CALL ZGEMV( 'No transpose', K-I, N-K+I-J+1,
311: $ -TAU( I ), V( I+1, J ), LDV, V( I, J ), LDV,
312: $ ZERO, T( I+1, I ), 1 )
313: CALL ZLACGV( N-K+I-1-J+1, V( I, J ), LDV )
314: V( I, N-K+I ) = VII
315: END IF
316: *
317: * T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
318: *
319: CALL ZTRMV( 'Lower', 'No transpose', 'Non-unit', K-I,
320: $ T( I+1, I+1 ), LDT, T( I+1, I ), 1 )
321: IF( I.GT.1 ) THEN
322: PREVLASTV = MIN( PREVLASTV, LASTV )
323: ELSE
324: PREVLASTV = LASTV
325: END IF
326: END IF
327: T( I, I ) = TAU( I )
328: END IF
329: 40 CONTINUE
330: END IF
331: RETURN
332: *
333: * End of ZLARFT
334: *
335: END
CVSweb interface <joel.bertrand@systella.fr>