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

◆ dgelqf()

subroutine dgelqf ( integer m,
integer n,
double precision, dimension( lda, * ) a,
integer lda,
double precision, dimension( * ) tau,
double precision, dimension( * ) work,
integer lwork,
integer info )

DGELQF

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

Purpose:
!>
!> DGELQF 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 DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (min(M,N))
!>          The scalar factors of the elementary reflectors (see Further
!>          Details).
!> 
[out]WORK
!>          WORK is DOUBLE PRECISION 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 dgelqf.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 DOUBLE PRECISION 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 dgelq2, dlarfb, dlarft, xerbla
163* ..
164* .. Intrinsic Functions ..
165 INTRINSIC max, min
166* ..
167* .. External Functions ..
168 INTEGER ILAENV
169 EXTERNAL ilaenv
170* ..
171* .. Executable Statements ..
172*
173* Test the input arguments
174*
175 info = 0
176 k = min( m, n )
177 nb = ilaenv( 1, 'DGELQF', ' ', m, n, -1, -1 )
178 lquery = ( lwork.EQ.-1 )
179 IF( m.LT.0 ) THEN
180 info = -1
181 ELSE IF( n.LT.0 ) THEN
182 info = -2
183 ELSE IF( lda.LT.max( 1, m ) ) THEN
184 info = -4
185 ELSE IF( .NOT.lquery ) THEN
186 IF( lwork.LE.0 .OR. ( n.GT.0 .AND. lwork.LT.max( 1, m ) ) )
187 $ info = -7
188 END IF
189 IF( info.NE.0 ) THEN
190 CALL xerbla( 'DGELQF', -info )
191 RETURN
192 ELSE IF( lquery ) THEN
193 IF( k.EQ.0 ) THEN
194 lwkopt = 1
195 ELSE
196 lwkopt = m*nb
197 END IF
198 work( 1 ) = lwkopt
199 RETURN
200 END IF
201*
202* Quick return if possible
203*
204 IF( k.EQ.0 ) THEN
205 work( 1 ) = 1
206 RETURN
207 END IF
208*
209 nbmin = 2
210 nx = 0
211 iws = m
212 IF( nb.GT.1 .AND. nb.LT.k ) THEN
213*
214* Determine when to cross over from blocked to unblocked code.
215*
216 nx = max( 0, ilaenv( 3, 'DGELQF', ' ', m, n, -1, -1 ) )
217 IF( nx.LT.k ) THEN
218*
219* Determine if workspace is large enough for blocked code.
220*
221 ldwork = m
222 iws = ldwork*nb
223 IF( lwork.LT.iws ) THEN
224*
225* Not enough workspace to use optimal NB: reduce NB and
226* determine the minimum value of NB.
227*
228 nb = lwork / ldwork
229 nbmin = max( 2, ilaenv( 2, 'DGELQF', ' ', m, n, -1,
230 $ -1 ) )
231 END IF
232 END IF
233 END IF
234*
235 IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
236*
237* Use blocked code initially
238*
239 DO 10 i = 1, k - nx, nb
240 ib = min( k-i+1, nb )
241*
242* Compute the LQ factorization of the current block
243* A(i:i+ib-1,i:n)
244*
245 CALL dgelq2( ib, n-i+1, a( i, i ), lda, tau( i ), work,
246 $ iinfo )
247 IF( i+ib.LE.m ) THEN
248*
249* Form the triangular factor of the block reflector
250* H = H(i) H(i+1) . . . H(i+ib-1)
251*
252 CALL dlarft( 'Forward', 'Rowwise', n-i+1, ib, a( i,
253 $ i ),
254 $ lda, tau( i ), work, ldwork )
255*
256* Apply H to A(i+ib:m,i:n) from the right
257*
258 CALL dlarfb( 'Right', 'No transpose', 'Forward',
259 $ 'Rowwise', m-i-ib+1, n-i+1, ib, a( i, i ),
260 $ lda, work, ldwork, a( i+ib, i ), lda,
261 $ work( ib+1 ), ldwork )
262 END IF
263 10 CONTINUE
264 ELSE
265 i = 1
266 END IF
267*
268* Use unblocked code to factor the last or only block.
269*
270 IF( i.LE.k )
271 $ CALL dgelq2( m-i+1, n-i+1, a( i, i ), lda, tau( i ), work,
272 $ iinfo )
273*
274 work( 1 ) = iws
275 RETURN
276*
277* End of DGELQF
278*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dgelq2(m, n, a, lda, tau, work, info)
DGELQ2 computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition dgelq2.f:127
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
subroutine dlarfb(side, trans, direct, storev, m, n, k, v, ldv, t, ldt, c, ldc, work, ldwork)
DLARFB applies a block reflector or its transpose to a general rectangular matrix.
Definition dlarfb.f:195
recursive subroutine dlarft(direct, storev, n, k, v, ldv, tau, t, ldt)
DLARFT forms the triangular factor T of a block reflector H = I - vtvH
Definition dlarft.f:162
Here is the call graph for this function:
Here is the caller graph for this function: