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