LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
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
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] 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 September 2012
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.
145 *>
146 *> DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
147 *>
148 *> V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
149 *> ( v1 1 ) ( 1 v2 v2 v2 )
150 *> ( v1 v2 1 ) ( 1 v3 v3 )
151 *> ( v1 v2 v3 )
152 *> ( v1 v2 v3 )
153 *>
154 *> DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
155 *>
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 )
159 *> ( 1 v3 )
160 *> ( 1 )
161 *> \endverbatim
162 *>
163 * =====================================================================
164  SUBROUTINE zlarft( DIRECT, STOREV, N, K, V, LDV, TAU, T, LDT )
165 *
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..--
169 * September 2012
170 *
171 * .. Scalar Arguments ..
172  CHARACTER direct, storev
173  INTEGER k, ldt, ldv, n
174 * ..
175 * .. Array Arguments ..
176  COMPLEX*16 t( ldt, * ), tau( * ), v( ldv, * )
177 * ..
178 *
179 * =====================================================================
180 *
181 * .. Parameters ..
182  COMPLEX*16 one, zero
183  parameter( one = ( 1.0d+0, 0.0d+0 ),
184  $ zero = ( 0.0d+0, 0.0d+0 ) )
185 * ..
186 * .. Local Scalars ..
187  INTEGER i, j, prevlastv, lastv
188 * ..
189 * .. External Subroutines ..
190  EXTERNAL zgemv, zlacgv, ztrmv
191 * ..
192 * .. External Functions ..
193  LOGICAL lsame
194  EXTERNAL lsame
195 * ..
196 * .. Executable Statements ..
197 *
198 * Quick return if possible
199 *
200  IF( n.EQ.0 )
201  $ return
202 *
203  IF( lsame( direct, 'F' ) ) THEN
204  prevlastv = n
205  DO i = 1, k
206  prevlastv = max( prevlastv, i )
207  IF( tau( i ).EQ.zero ) THEN
208 *
209 * H(i) = I
210 *
211  DO j = 1, i
212  t( j, i ) = zero
213  END DO
214  ELSE
215 *
216 * general case
217 *
218  IF( lsame( storev, 'C' ) ) THEN
219 * Skip any trailing zeros.
220  DO lastv = n, i+1, -1
221  IF( v( lastv, i ).NE.zero ) exit
222  END DO
223  DO j = 1, i-1
224  t( j, i ) = -tau( i ) * conjg( v( i , j ) )
225  END DO
226  j = min( lastv, prevlastv )
227 *
228 * T(1:i-1,i) := - tau(i) * V(i:j,1:i-1)**H * V(i:j,i)
229 *
230  CALL zgemv( 'Conjugate transpose', j-i, i-1,
231  $ -tau( i ), v( i+1, 1 ), ldv,
232  $ v( i+1, i ), 1, one, t( 1, i ), 1 )
233  ELSE
234 * Skip any trailing zeros.
235  DO lastv = n, i+1, -1
236  IF( v( i, lastv ).NE.zero ) exit
237  END DO
238  DO j = 1, i-1
239  t( j, i ) = -tau( i ) * v( j , i )
240  END DO
241  j = min( lastv, prevlastv )
242 *
243 * T(1:i-1,i) := - tau(i) * V(1:i-1,i:j) * V(i,i:j)**H
244 *
245  CALL zgemm( 'N', 'C', i-1, 1, j-i, -tau( i ),
246  $ v( 1, i+1 ), ldv, v( i, i+1 ), ldv,
247  $ one, t( 1, i ), ldt )
248  END IF
249 *
250 * T(1:i-1,i) := T(1:i-1,1:i-1) * T(1:i-1,i)
251 *
252  CALL ztrmv( 'Upper', 'No transpose', 'Non-unit', i-1, t,
253  $ ldt, t( 1, i ), 1 )
254  t( i, i ) = tau( i )
255  IF( i.GT.1 ) THEN
256  prevlastv = max( prevlastv, lastv )
257  ELSE
258  prevlastv = lastv
259  END IF
260  END IF
261  END DO
262  ELSE
263  prevlastv = 1
264  DO i = k, 1, -1
265  IF( tau( i ).EQ.zero ) THEN
266 *
267 * H(i) = I
268 *
269  DO j = i, k
270  t( j, i ) = zero
271  END DO
272  ELSE
273 *
274 * general case
275 *
276  IF( i.LT.k ) THEN
277  IF( lsame( storev, 'C' ) ) THEN
278 * Skip any leading zeros.
279  DO lastv = 1, i-1
280  IF( v( lastv, i ).NE.zero ) exit
281  END DO
282  DO j = i+1, k
283  t( j, i ) = -tau( i ) * conjg( v( n-k+i , j ) )
284  END DO
285  j = max( lastv, prevlastv )
286 *
287 * T(i+1:k,i) = -tau(i) * V(j:n-k+i,i+1:k)**H * V(j:n-k+i,i)
288 *
289  CALL zgemv( 'Conjugate transpose', n-k+i-j, k-i,
290  $ -tau( i ), v( j, i+1 ), ldv, v( j, i ),
291  $ 1, one, t( i+1, i ), 1 )
292  ELSE
293 * Skip any leading zeros.
294  DO lastv = 1, i-1
295  IF( v( i, lastv ).NE.zero ) exit
296  END DO
297  DO j = i+1, k
298  t( j, i ) = -tau( i ) * v( j, n-k+i )
299  END DO
300  j = max( lastv, prevlastv )
301 *
302 * T(i+1:k,i) = -tau(i) * V(i+1:k,j:n-k+i) * V(i,j:n-k+i)**H
303 *
304  CALL zgemm( 'N', 'C', k-i, 1, n-k+i-j, -tau( i ),
305  $ v( i+1, j ), ldv, v( i, j ), ldv,
306  $ one, t( i+1, i ), ldt )
307  END IF
308 *
309 * T(i+1:k,i) := T(i+1:k,i+1:k) * T(i+1:k,i)
310 *
311  CALL ztrmv( 'Lower', 'No transpose', 'Non-unit', k-i,
312  $ t( i+1, i+1 ), ldt, t( i+1, i ), 1 )
313  IF( i.GT.1 ) THEN
314  prevlastv = min( prevlastv, lastv )
315  ELSE
316  prevlastv = lastv
317  END IF
318  END IF
319  t( i, i ) = tau( i )
320  END IF
321  END DO
322  END IF
323  return
324 *
325 * End of ZLARFT
326 *
327  END