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