LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sgelqf()

subroutine sgelqf ( integer m,
integer n,
real, dimension( lda, * ) a,
integer lda,
real, dimension( * ) tau,
real, dimension( * ) work,
integer lwork,
integer info )

SGELQF

Download SGELQF + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGELQF computes an LQ factorization of a real M-by-N matrix A:
!>
!>    A = ( L 0 ) *  Q
!>
!> where:
!>
!>    Q is a N-by-N orthogonal matrix;
!>    L is a lower-triangular M-by-M matrix;
!>    0 is a M-by-(N-M) zero matrix, if M < N.
!>
!> 
Parameters
[in]M
!>          M is INTEGER
!>          The number of rows of the matrix A.  M >= 0.
!> 
[in]N
!>          N is INTEGER
!>          The number of columns of the matrix A.  N >= 0.
!> 
[in,out]A
!>          A is REAL array, dimension (LDA,N)
!>          On entry, the M-by-N matrix A.
!>          On exit, the elements on and below the diagonal of the array
!>          contain the m-by-min(m,n) lower trapezoidal matrix L (L is
!>          lower triangular if m <= n); the elements above the diagonal,
!>          with the array TAU, represent the orthogonal matrix Q as a
!>          product of elementary reflectors (see Further Details).
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,M).
!> 
[out]TAU
!>          TAU is REAL array, dimension (min(M,N))
!>          The scalar factors of the elementary reflectors (see Further
!>          Details).
!> 
[out]WORK
!>          WORK is REAL array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.
!>          LWORK >= 1, if MIN(M,N) = 0, and LWORK >= M, otherwise.
!>          For optimum performance LWORK >= M*NB, where NB is the
!>          optimal blocksize.
!>
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the optimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!>
!>  The matrix Q is represented as a product of elementary reflectors
!>
!>     Q = H(k) . . . H(2) H(1), where k = min(m,n).
!>
!>  Each H(i) has the form
!>
!>     H(i) = I - tau * v * v**T
!>
!>  where tau is a real scalar, and v is a real vector with
!>  v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n),
!>  and tau in TAU(i).
!> 

Definition at line 141 of file sgelqf.f.

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 REAL 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 sgelq2, slarfb, slarft, 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, 'SGELQF', ' ', 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( 'SGELQF', -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, 'SGELQF', ' ', 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, 'SGELQF', ' ', 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 sgelq2( 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 slarft( '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 slarfb( '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 sgelq2( 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 SGELQF
279*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgelq2(m, n, a, lda, tau, work, info)
SGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition sgelq2.f:127
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
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
real function sroundup_lwork(lwork)
SROUNDUP_LWORK
Here is the call graph for this function:
Here is the caller graph for this function: