LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ 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 >= max(1,M).
          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.
Date
December 2016
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 140 of file sgerqf.f.

140 *
141 * -- LAPACK computational routine (version 3.7.0) --
142 * -- LAPACK is a software package provided by Univ. of Tennessee, --
143 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
144 * December 2016
145 *
146 * .. Scalar Arguments ..
147  INTEGER info, lda, lwork, m, n
148 * ..
149 * .. Array Arguments ..
150  REAL a( lda, * ), tau( * ), work( * )
151 * ..
152 *
153 * =====================================================================
154 *
155 * .. Local Scalars ..
156  LOGICAL lquery
157  INTEGER i, ib, iinfo, iws, k, ki, kk, ldwork, lwkopt,
158  $ mu, nb, nbmin, nu, nx
159 * ..
160 * .. External Subroutines ..
161  EXTERNAL sgerq2, slarfb, slarft, xerbla
162 * ..
163 * .. Intrinsic Functions ..
164  INTRINSIC max, min
165 * ..
166 * .. External Functions ..
167  INTEGER ilaenv
168  EXTERNAL ilaenv
169 * ..
170 * .. Executable Statements ..
171 *
172 * Test the input arguments
173 *
174  info = 0
175  lquery = ( lwork.EQ.-1 )
176  IF( m.LT.0 ) THEN
177  info = -1
178  ELSE IF( n.LT.0 ) THEN
179  info = -2
180  ELSE IF( lda.LT.max( 1, m ) ) THEN
181  info = -4
182  ELSE IF( lwork.LT.max( 1, m ) .AND. .NOT.lquery ) THEN
183  info = -7
184  END IF
185 *
186  IF( info.EQ.0 ) THEN
187  k = min( m, n )
188  IF( k.EQ.0 ) THEN
189  lwkopt = 1
190  ELSE
191  nb = ilaenv( 1, 'SGERQF', ' ', m, n, -1, -1 )
192  lwkopt = m*nb
193  work( 1 ) = lwkopt
194  END IF
195  work( 1 ) = lwkopt
196 *
197  IF( lwork.LT.max( 1, m ) .AND. .NOT.lquery ) THEN
198  info = -7
199  END IF
200  END IF
201 *
202  IF( info.NE.0 ) THEN
203  CALL xerbla( 'SGERQF', -info )
204  RETURN
205  ELSE IF( lquery ) THEN
206  RETURN
207  END IF
208 *
209 * Quick return if possible
210 *
211  IF( k.EQ.0 ) THEN
212  RETURN
213  END IF
214 *
215  nbmin = 2
216  nx = 1
217  iws = m
218  IF( nb.GT.1 .AND. nb.LT.k ) THEN
219 *
220 * Determine when to cross over from blocked to unblocked code.
221 *
222  nx = max( 0, ilaenv( 3, 'SGERQF', ' ', m, n, -1, -1 ) )
223  IF( nx.LT.k ) THEN
224 *
225 * Determine if workspace is large enough for blocked code.
226 *
227  ldwork = m
228  iws = ldwork*nb
229  IF( lwork.LT.iws ) THEN
230 *
231 * Not enough workspace to use optimal NB: reduce NB and
232 * determine the minimum value of NB.
233 *
234  nb = lwork / ldwork
235  nbmin = max( 2, ilaenv( 2, 'SGERQF', ' ', m, n, -1,
236  $ -1 ) )
237  END IF
238  END IF
239  END IF
240 *
241  IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
242 *
243 * Use blocked code initially.
244 * The last kk rows are handled by the block method.
245 *
246  ki = ( ( k-nx-1 ) / nb )*nb
247  kk = min( k, ki+nb )
248 *
249  DO 10 i = k - kk + ki + 1, k - kk + 1, -nb
250  ib = min( k-i+1, nb )
251 *
252 * Compute the RQ factorization of the current block
253 * A(m-k+i:m-k+i+ib-1,1:n-k+i+ib-1)
254 *
255  CALL sgerq2( ib, n-k+i+ib-1, a( m-k+i, 1 ), lda, tau( i ),
256  $ work, iinfo )
257  IF( m-k+i.GT.1 ) THEN
258 *
259 * Form the triangular factor of the block reflector
260 * H = H(i+ib-1) . . . H(i+1) H(i)
261 *
262  CALL slarft( 'Backward', 'Rowwise', n-k+i+ib-1, ib,
263  $ a( m-k+i, 1 ), lda, tau( i ), work, ldwork )
264 *
265 * Apply H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right
266 *
267  CALL slarfb( 'Right', 'No transpose', 'Backward',
268  $ 'Rowwise', m-k+i-1, n-k+i+ib-1, ib,
269  $ a( m-k+i, 1 ), lda, work, ldwork, a, lda,
270  $ work( ib+1 ), ldwork )
271  END IF
272  10 CONTINUE
273  mu = m - k + i + nb - 1
274  nu = n - k + i + nb - 1
275  ELSE
276  mu = m
277  nu = n
278  END IF
279 *
280 * Use unblocked code to factor the last or only block
281 *
282  IF( mu.GT.0 .AND. nu.GT.0 )
283  $ CALL sgerq2( mu, nu, a, lda, tau, work, iinfo )
284 *
285  work( 1 ) = iws
286  RETURN
287 *
288 * End of SGERQF
289 *
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:197
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:165
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
ILAENV
Definition: tstiee.f:83
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
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:125
Here is the call graph for this function:
Here is the caller graph for this function: