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

◆ sgerqf()

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

SGERQF

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

Purpose:
!>
!> SGERQF computes an RQ factorization of a real M-by-N matrix A:
!> A = R * Q.
!> 
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,
!>          if m <= n, the upper triangle of the subarray
!>          A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R;
!>          if m >= n, the elements on and above the (m-n)-th subdiagonal
!>          contain the M-by-N upper trapezoidal matrix R;
!>          the remaining elements, with the array TAU, represent the
!>          orthogonal matrix Q as a product of min(m,n) 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(1) H(2) . . . H(k), 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(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
!>  A(m-k+i,1:n-k+i-1), and tau in TAU(i).
!> 

Definition at line 136 of file sgerqf.f.

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 sgerq2, 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, 'SGERQF', ' ', m, n, -1, -1 )
187 lwkopt = m*nb
188 END IF
189 work( 1 ) = sroundup_lwork(lwkopt)
190*
191 IF ( .NOT.lquery ) THEN
192 IF( lwork.LE.0 .OR. ( n.GT.0 .AND. lwork.LT.max( 1, m ) ) )
193 $ info = -7
194 END IF
195 END IF
196*
197 IF( info.NE.0 ) THEN
198 CALL xerbla( 'SGERQF', -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 = 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, 'SGERQF', ' ', 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, 'SGERQF', ' ', 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 rows 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 RQ factorization of the current block
248* A(m-k+i:m-k+i+ib-1,1:n-k+i+ib-1)
249*
250 CALL sgerq2( ib, n-k+i+ib-1, a( m-k+i, 1 ), lda,
251 $ tau( i ),
252 $ work, iinfo )
253 IF( m-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', 'Rowwise', n-k+i+ib-1, ib,
259 $ a( m-k+i, 1 ), lda, tau( i ), work, ldwork )
260*
261* Apply H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right
262*
263 CALL slarfb( 'Right', 'No transpose', 'Backward',
264 $ 'Rowwise', m-k+i-1, n-k+i+ib-1, ib,
265 $ a( m-k+i, 1 ), 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 sgerq2( mu, nu, a, lda, tau, work, iinfo )
280*
281 work( 1 ) = sroundup_lwork(iws)
282 RETURN
283*
284* End of SGERQF
285*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgerq2(m, n, a, lda, tau, work, info)
SGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition sgerq2.f:121
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: