Debian Codegraph @

Modules/ThirdParty/VNL/src/vxl/v3p/netlib/lapack/complex16/zlarft.f

raw
1 SUBROUTINE ZLARFT( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * September 30, 1994
7 *
8 * .. Scalar Arguments ..
9 CHARACTER DIRECT, STOREV
10 INTEGER K, LDT, LDV, N
11 * ..
12 * .. Array Arguments ..
13 COMPLEX*16 T( LDT, * ), TAU( * ), V( LDV, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZLARFT forms the triangular factor T of a complex block reflector H
20 * of order n, which is defined as a product of k elementary reflectors.
21 *
22 * If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
23 *
24 * If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
25 *
26 * If STOREV = 'C', the vector which defines the elementary reflector
27 * H(i) is stored in the i-th column of the array V, and
28 *
29 * H = I - V * T * V'
30 *
31 * If STOREV = 'R', the vector which defines the elementary reflector
32 * H(i) is stored in the i-th row of the array V, and
33 *
34 * H = I - V' * T * V
35 *
36 * Arguments
37 * =========
38 *
39 * DIRECT (input) CHARACTER*1
40 * Specifies the order in which the elementary reflectors are
41 * multiplied to form the block reflector:
42 * = 'F': H = H(1) H(2) . . . H(k) (Forward)
43 * = 'B': H = H(k) . . . H(2) H(1) (Backward)
44 *
45 * STOREV (input) CHARACTER*1
46 * Specifies how the vectors which define the elementary
47 * reflectors are stored (see also Further Details):
48 * = 'C': columnwise
49 * = 'R': rowwise
50 *
51 * N (input) INTEGER
52 * The order of the block reflector H. N >= 0.
53 *
54 * K (input) INTEGER
55 * The order of the triangular factor T (= the number of
56 * elementary reflectors). K >= 1.
57 *
58 * V (input/output) COMPLEX*16 array, dimension
59 * (LDV,K) if STOREV = 'C'
60 * (LDV,N) if STOREV = 'R'
61 * The matrix V. See further details.
62 *
63 * LDV (input) INTEGER
64 * The leading dimension of the array V.
65 * If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
66 *
67 * TAU (input) COMPLEX*16 array, dimension (K)
68 * TAU(i) must contain the scalar factor of the elementary
69 * reflector H(i).
70 *
71 * T (output) COMPLEX*16 array, dimension (LDT,K)
72 * The k by k triangular factor T of the block reflector.
73 * If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is
74 * lower triangular. The rest of the array is not used.
75 *
76 * LDT (input) INTEGER
77 * The leading dimension of the array T. LDT >= K.
78 *
79 * Further Details
80 * ===============
81 *
82 * The shape of the matrix V and the storage of the vectors which define
83 * the H(i) is best illustrated by the following example with n = 5 and
84 * k = 3. The elements equal to 1 are not stored; the corresponding
85 * array elements are modified but restored on exit. The rest of the
86 * array is not used.
87 *
88 * DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
89 *
90 * V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
91 * ( v1 1 ) ( 1 v2 v2 v2 )
92 * ( v1 v2 1 ) ( 1 v3 v3 )
93 * ( v1 v2 v3 )
94 * ( v1 v2 v3 )
95 *
96 * DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
97 *
98 * V = ( v1 v2 v3 ) V = ( v1 v1 1 )
99 * ( v1 v2 v3 ) ( v2 v2 v2 1 )
100 * ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
101 * ( 1 v3 )
102 * ( 1 )
103 *
104 * =====================================================================
105 *
106 * .. Parameters ..
107 COMPLEX*16 ONE, ZERO
108 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),
109 $ ZERO = ( 0.0D+0, 0.0D+0 ) )
110 * ..
111 * .. Local Scalars ..
112 INTEGER I, J
113 COMPLEX*16 VII
114 * ..
115 * .. External Subroutines ..
116 EXTERNAL ZGEMV, ZLACGV, ZTRMV
117 * ..
118 * .. External Functions ..
119 LOGICAL LSAME
120 EXTERNAL LSAME
121 * ..
122 * .. Executable Statements ..
123 *
124 * Quick return if possible
125 *
126 IF( N.EQ.0 )
127 $ RETURN
128 *
129 IF( LSAME( DIRECT, 'F' ) ) THEN
130 DO 20 I = 1, K
131 IF( TAU( I ).EQ.ZERO ) THEN
132 *
133 * H(i) = I
134 *
135 DO 10 J = 1, I
136 T( J, I ) = ZERO
137 10 CONTINUE
138 ELSE
139 *
140 * general case
141 *
142 VII = V( I, I )
143 V( I, I ) = ONE
144 IF( LSAME( STOREV, 'C' ) ) THEN
145 *
146 * T(1:i-1,i) := - tau(i) * V(i:n,1:i-1)' * V(i:n,i)
147 *
148 CALL ZGEMV( 'Conjugate transpose', N-I+1, I-1,
149 $ -TAU( I ), V( I, 1 ), LDV, V( I, I ), 1,
150 $ ZERO, T( 1, I ), 1 )
151 ELSE
152 *
153 * T(1:i-1,i) := - tau(i) * V(1:i-1,i:n) * V(i,i:n)'
154 *
155 IF( I.LT.N )
156 $ CALL ZLACGV( N-I, V( I, I+1 ), LDV )
157 CALL ZGEMV( 'No transpose', I-1, N-I+1, -TAU( I ),
158 $ V( 1, I ), LDV, V( I, I ), LDV, ZERO,
159 $ T( 1, I ), 1 )
160 IF( I.LT.N )
161 $ CALL ZLACGV( N-I, V( I, I+1 ), LDV )
162 END IF
163 V( I, I ) = VII
164 *
165 * T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
166 *
167 CALL ZTRMV( 'Upper', 'No transpose', 'Non-unit', I-1, T,
168 $ LDT, T( 1, I ), 1 )
169 T( I, I ) = TAU( I )
170 END IF
171 20 CONTINUE
172 ELSE
173 DO 40 I = K, 1, -1
174 IF( TAU( I ).EQ.ZERO ) THEN
175 *
176 * H(i) = I
177 *
178 DO 30 J = I, K
179 T( J, I ) = ZERO
180 30 CONTINUE
181 ELSE
182 *
183 * general case
184 *
185 IF( I.LT.K ) THEN
186 IF( LSAME( STOREV, 'C' ) ) THEN
187 VII = V( N-K+I, I )
188 V( N-K+I, I ) = ONE
189 *
190 * T(i+1:k,i) :=
191 * - tau(i) * V(1:n-k+i,i+1:k)' * V(1:n-k+i,i)
192 *
193 CALL ZGEMV( 'Conjugate transpose', N-K+I, K-I,
194 $ -TAU( I ), V( 1, I+1 ), LDV, V( 1, I ),
195 $ 1, ZERO, T( I+1, I ), 1 )
196 V( N-K+I, I ) = VII
197 ELSE
198 VII = V( I, N-K+I )
199 V( I, N-K+I ) = ONE
200 *
201 * T(i+1:k,i) :=
202 * - tau(i) * V(i+1:k,1:n-k+i) * V(i,1:n-k+i)'
203 *
204 CALL ZLACGV( N-K+I-1, V( I, 1 ), LDV )
205 CALL ZGEMV( 'No transpose', K-I, N-K+I, -TAU( I ),
206 $ V( I+1, 1 ), LDV, V( I, 1 ), LDV, ZERO,
207 $ T( I+1, I ), 1 )
208 CALL ZLACGV( N-K+I-1, V( I, 1 ), LDV )
209 V( I, N-K+I ) = VII
210 END IF
211 *
212 * T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
213 *
214 CALL ZTRMV( 'Lower', 'No transpose', 'Non-unit', K-I,
215 $ T( I+1, I+1 ), LDT, T( I+1, I ), 1 )
216 END IF
217 T( I, I ) = TAU( I )
218 END IF
219 40 CONTINUE
220 END IF
221 RETURN
222 *
223 * End of ZLARFT
224 *
225 END