LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cgelqf.f
Go to the documentation of this file.
1*> \brief \b CGELQF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CGELQF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgelqf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgelqf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgelqf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CGELQF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, LDA, LWORK, M, N
23* ..
24* .. Array Arguments ..
25* COMPLEX A( LDA, * ), TAU( * ), WORK( * )
26* ..
27*
28*
29*> \par Purpose:
30* =============
31*>
32*> \verbatim
33*>
34*> CGELQF computes an LQ factorization of a complex M-by-N matrix A:
35*>
36*> A = ( L 0 ) * Q
37*>
38*> where:
39*>
40*> Q is a N-by-N orthogonal matrix;
41*> L is a lower-triangular M-by-M matrix;
42*> 0 is a M-by-(N-M) zero matrix, if M < N.
43*>
44*> \endverbatim
45*
46* Arguments:
47* ==========
48*
49*> \param[in] M
50*> \verbatim
51*> M is INTEGER
52*> The number of rows of the matrix A. M >= 0.
53*> \endverbatim
54*>
55*> \param[in] N
56*> \verbatim
57*> N is INTEGER
58*> The number of columns of the matrix A. N >= 0.
59*> \endverbatim
60*>
61*> \param[in,out] A
62*> \verbatim
63*> A is COMPLEX array, dimension (LDA,N)
64*> On entry, the M-by-N matrix A.
65*> On exit, the elements on and below the diagonal of the array
66*> contain the m-by-min(m,n) lower trapezoidal matrix L (L is
67*> lower triangular if m <= n); the elements above the diagonal,
68*> with the array TAU, represent the unitary matrix Q as a
69*> product of elementary reflectors (see Further Details).
70*> \endverbatim
71*>
72*> \param[in] LDA
73*> \verbatim
74*> LDA is INTEGER
75*> The leading dimension of the array A. LDA >= max(1,M).
76*> \endverbatim
77*>
78*> \param[out] TAU
79*> \verbatim
80*> TAU is COMPLEX array, dimension (min(M,N))
81*> The scalar factors of the elementary reflectors (see Further
82*> Details).
83*> \endverbatim
84*>
85*> \param[out] WORK
86*> \verbatim
87*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
88*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
89*> \endverbatim
90*>
91*> \param[in] LWORK
92*> \verbatim
93*> LWORK is INTEGER
94*> The dimension of the array WORK.
95*> LWORK >= 1, if MIN(M,N) = 0, and LWORK >= M, otherwise.
96*> For optimum performance LWORK >= M*NB, where NB is the
97*> optimal blocksize.
98*>
99*> If LWORK = -1, then a workspace query is assumed; the routine
100*> only calculates the optimal size of the WORK array, returns
101*> this value as the first entry of the WORK array, and no error
102*> message related to LWORK is issued by XERBLA.
103*> \endverbatim
104*>
105*> \param[out] INFO
106*> \verbatim
107*> INFO is INTEGER
108*> = 0: successful exit
109*> < 0: if INFO = -i, the i-th argument had an illegal value
110*> \endverbatim
111*
112* Authors:
113* ========
114*
115*> \author Univ. of Tennessee
116*> \author Univ. of California Berkeley
117*> \author Univ. of Colorado Denver
118*> \author NAG Ltd.
119*
120*> \ingroup gelqf
121*
122*> \par Further Details:
123* =====================
124*>
125*> \verbatim
126*>
127*> The matrix Q is represented as a product of elementary reflectors
128*>
129*> Q = H(k)**H . . . H(2)**H H(1)**H, where k = min(m,n).
130*>
131*> Each H(i) has the form
132*>
133*> H(i) = I - tau * v * v**H
134*>
135*> where tau is a complex scalar, and v is a complex vector with
136*> v(1:i-1) = 0 and v(i) = 1; conjg(v(i+1:n)) is stored on exit in
137*> A(i,i+1:n), and tau in TAU(i).
138*> \endverbatim
139*>
140* =====================================================================
141 SUBROUTINE cgelqf( M, N, A, LDA, TAU, WORK, LWORK, INFO )
142*
143* -- LAPACK computational routine --
144* -- LAPACK is a software package provided by Univ. of Tennessee, --
145* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
146*
147* .. Scalar Arguments ..
148 INTEGER INFO, LDA, LWORK, M, N
149* ..
150* .. Array Arguments ..
151 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
152* ..
153*
154* =====================================================================
155*
156* .. Local Scalars ..
157 LOGICAL LQUERY
158 INTEGER I, IB, IINFO, IWS, K, LDWORK, LWKOPT, NB,
159 $ NBMIN, NX
160* ..
161* .. External Subroutines ..
162 EXTERNAL cgelq2, clarfb, clarft, xerbla
163* ..
164* .. Intrinsic Functions ..
165 INTRINSIC max, min
166* ..
167* .. External Functions ..
168 INTEGER ILAENV
169 REAL SROUNDUP_LWORK
170 EXTERNAL ilaenv, sroundup_lwork
171* ..
172* .. Executable Statements ..
173*
174* Test the input arguments
175*
176 info = 0
177 k = min( m, n )
178 nb = ilaenv( 1, 'CGELQF', ' ', m, n, -1, -1 )
179 lquery = ( lwork.EQ.-1 )
180 IF( m.LT.0 ) THEN
181 info = -1
182 ELSE IF( n.LT.0 ) THEN
183 info = -2
184 ELSE IF( lda.LT.max( 1, m ) ) THEN
185 info = -4
186 ELSE IF( .NOT.lquery ) THEN
187 IF( lwork.LE.0 .OR. ( n.GT.0 .AND. lwork.LT.max( 1, m ) ) )
188 $ info = -7
189 END IF
190 IF( info.NE.0 ) THEN
191 CALL xerbla( 'CGELQF', -info )
192 RETURN
193 ELSE IF( lquery ) THEN
194 IF( k.EQ.0 ) THEN
195 lwkopt = 1
196 ELSE
197 lwkopt = m*nb
198 END IF
199 work( 1 ) = sroundup_lwork( lwkopt )
200 RETURN
201 END IF
202*
203* Quick return if possible
204*
205 IF( k.EQ.0 ) THEN
206 work( 1 ) = 1
207 RETURN
208 END IF
209*
210 nbmin = 2
211 nx = 0
212 iws = m
213 IF( nb.GT.1 .AND. nb.LT.k ) THEN
214*
215* Determine when to cross over from blocked to unblocked code.
216*
217 nx = max( 0, ilaenv( 3, 'CGELQF', ' ', m, n, -1, -1 ) )
218 IF( nx.LT.k ) THEN
219*
220* Determine if workspace is large enough for blocked code.
221*
222 ldwork = m
223 iws = ldwork*nb
224 IF( lwork.LT.iws ) THEN
225*
226* Not enough workspace to use optimal NB: reduce NB and
227* determine the minimum value of NB.
228*
229 nb = lwork / ldwork
230 nbmin = max( 2, ilaenv( 2, 'CGELQF', ' ', m, n, -1,
231 $ -1 ) )
232 END IF
233 END IF
234 END IF
235*
236 IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
237*
238* Use blocked code initially
239*
240 DO 10 i = 1, k - nx, nb
241 ib = min( k-i+1, nb )
242*
243* Compute the LQ factorization of the current block
244* A(i:i+ib-1,i:n)
245*
246 CALL cgelq2( ib, n-i+1, a( i, i ), lda, tau( i ), work,
247 $ iinfo )
248 IF( i+ib.LE.m ) THEN
249*
250* Form the triangular factor of the block reflector
251* H = H(i) H(i+1) . . . H(i+ib-1)
252*
253 CALL clarft( 'Forward', 'Rowwise', n-i+1, ib, a( i,
254 $ i ),
255 $ lda, tau( i ), work, ldwork )
256*
257* Apply H to A(i+ib:m,i:n) from the right
258*
259 CALL clarfb( 'Right', 'No transpose', 'Forward',
260 $ 'Rowwise', m-i-ib+1, n-i+1, ib, a( i, i ),
261 $ lda, work, ldwork, a( i+ib, i ), lda,
262 $ work( ib+1 ), ldwork )
263 END IF
264 10 CONTINUE
265 ELSE
266 i = 1
267 END IF
268*
269* Use unblocked code to factor the last or only block.
270*
271 IF( i.LE.k )
272 $ CALL cgelq2( m-i+1, n-i+1, a( i, i ), lda, tau( i ), work,
273 $ iinfo )
274*
275 work( 1 ) = sroundup_lwork( iws )
276 RETURN
277*
278* End of CGELQF
279*
280 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgelq2(m, n, a, lda, tau, work, info)
CGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition cgelq2.f:127
subroutine cgelqf(m, n, a, lda, tau, work, lwork, info)
CGELQF
Definition cgelqf.f:142
subroutine clarfb(side, trans, direct, storev, m, n, k, v, ldv, t, ldt, c, ldc, work, ldwork)
CLARFB applies a block reflector or its conjugate-transpose to a general rectangular matrix.
Definition clarfb.f:195
recursive subroutine clarft(direct, storev, n, k, v, ldv, tau, t, ldt)
CLARFT forms the triangular factor T of a block reflector H = I - vtvH
Definition clarft.f:162