LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ cgeqr()

subroutine cgeqr ( integer  M,
integer  N,
complex, dimension( lda, * )  A,
integer  LDA,
complex, dimension( * )  T,
integer  TSIZE,
complex, dimension( * )  WORK,
integer  LWORK,
integer  INFO 
)

CGEQR

Purpose:
 CGEQR computes a QR factorization of a complex M-by-N matrix A:

    A = Q * ( R ),
            ( 0 )

 where:

    Q is a M-by-M orthogonal matrix;
    R is an upper-triangular N-by-N matrix;
    0 is a (M-N)-by-N 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 COMPLEX array, dimension (LDA,N)
          On entry, the M-by-N matrix A.
          On exit, the elements on and above the diagonal of the array
          contain the min(M,N)-by-N upper trapezoidal matrix R
          (R is upper triangular if M >= N);
          the elements below the diagonal are used to store part of the 
          data structure to represent Q.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,M).
[out]T
          T is COMPLEX array, dimension (MAX(5,TSIZE))
          On exit, if INFO = 0, T(1) returns optimal (or either minimal 
          or optimal, if query is assumed) TSIZE. See TSIZE for details.
          Remaining T contains part of the data structure used to represent Q.
          If one wants to apply or construct Q, then one needs to keep T 
          (in addition to A) and pass it to further subroutines.
[in]TSIZE
          TSIZE is INTEGER
          If TSIZE >= 5, the dimension of the array T.
          If TSIZE = -1 or -2, then a workspace query is assumed. The routine
          only calculates the sizes of the T and WORK arrays, returns these
          values as the first entries of the T and WORK arrays, and no error
          message related to T or WORK is issued by XERBLA.
          If TSIZE = -1, the routine calculates optimal size of T for the 
          optimum performance and returns this value in T(1).
          If TSIZE = -2, the routine calculates minimal size of T and 
          returns this value in T(1).
[out]WORK
          (workspace) COMPLEX array, dimension (MAX(1,LWORK))
          On exit, if INFO = 0, WORK(1) contains optimal (or either minimal
          or optimal, if query was assumed) LWORK.
          See LWORK for details.
[in]LWORK
          LWORK is INTEGER
          The dimension of the array WORK.
          If LWORK = -1 or -2, then a workspace query is assumed. The routine
          only calculates the sizes of the T and WORK arrays, returns these
          values as the first entries of the T and WORK arrays, and no error
          message related to T or WORK is issued by XERBLA.
          If LWORK = -1, the routine calculates optimal size of WORK for the
          optimal performance and returns this value in WORK(1).
          If LWORK = -2, the routine calculates minimal size of WORK and 
          returns this value in WORK(1).
[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 goal of the interface is to give maximum freedom to the developers for
 creating any QR factorization algorithm they wish. The triangular 
 (trapezoidal) R has to be stored in the upper part of A. The lower part of A
 and the array T can be used to store any relevant information for applying or
 constructing the Q factor. The WORK array can safely be discarded after exit.

 Caution: One should not expect the sizes of T and WORK to be the same from one 
 LAPACK implementation to the other, or even from one execution to the other.
 A workspace query (for T and WORK) is needed at each execution. However, 
 for a given execution, the size of T and WORK are fixed and will not change 
 from one query to the next.
Further Details particular to this LAPACK implementation:
 These details are particular for this LAPACK implementation. Users should not 
 take them for granted. These details may change in the future, and are not likely
 true for another LAPACK implementation. These details are relevant if one wants
 to try to understand the code. They are not part of the interface.

 In this version,

          T(2): row block size (MB)
          T(3): column block size (NB)
          T(6:TSIZE): data structure needed for Q, computed by
                           CLATSQR or CGEQRT

  Depending on the matrix dimensions M and N, and row and column
  block sizes MB and NB returned by ILAENV, CGEQR will use either
  CLATSQR (if the matrix is tall-and-skinny) or CGEQRT to compute
  the QR factorization.

Definition at line 174 of file cgeqr.f.

174 *
175 * -- LAPACK computational routine (version 3.9.0) --
176 * -- LAPACK is a software package provided by Univ. of Tennessee, --
177 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd. --
178 * November 2019
179 *
180 * .. Scalar Arguments ..
181  INTEGER INFO, LDA, M, N, TSIZE, LWORK
182 * ..
183 * .. Array Arguments ..
184  COMPLEX A( LDA, * ), T( * ), WORK( * )
185 * ..
186 *
187 * =====================================================================
188 *
189 * ..
190 * .. Local Scalars ..
191  LOGICAL LQUERY, LMINWS, MINT, MINW
192  INTEGER MB, NB, MINTSZ, NBLCKS
193 * ..
194 * .. External Functions ..
195  LOGICAL LSAME
196  EXTERNAL lsame
197 * ..
198 * .. External Subroutines ..
199  EXTERNAL clatsqr, cgeqrt, xerbla
200 * ..
201 * .. Intrinsic Functions ..
202  INTRINSIC max, min, mod
203 * ..
204 * .. External Functions ..
205  INTEGER ILAENV
206  EXTERNAL ilaenv
207 * ..
208 * .. Executable Statements ..
209 *
210 * Test the input arguments
211 *
212  info = 0
213 *
214  lquery = ( tsize.EQ.-1 .OR. tsize.EQ.-2 .OR.
215  $ lwork.EQ.-1 .OR. lwork.EQ.-2 )
216 *
217  mint = .false.
218  minw = .false.
219  IF( tsize.EQ.-2 .OR. lwork.EQ.-2 ) THEN
220  IF( tsize.NE.-1 ) mint = .true.
221  IF( lwork.NE.-1 ) minw = .true.
222  END IF
223 *
224 * Determine the block size
225 *
226  IF( min( m, n ).GT.0 ) THEN
227  mb = ilaenv( 1, 'CGEQR ', ' ', m, n, 1, -1 )
228  nb = ilaenv( 1, 'CGEQR ', ' ', m, n, 2, -1 )
229  ELSE
230  mb = m
231  nb = 1
232  END IF
233  IF( mb.GT.m .OR. mb.LE.n ) mb = m
234  IF( nb.GT.min( m, n ) .OR. nb.LT.1 ) nb = 1
235  mintsz = n + 5
236  IF( mb.GT.n .AND. m.GT.n ) THEN
237  IF( mod( m - n, mb - n ).EQ.0 ) THEN
238  nblcks = ( m - n ) / ( mb - n )
239  ELSE
240  nblcks = ( m - n ) / ( mb - n ) + 1
241  END IF
242  ELSE
243  nblcks = 1
244  END IF
245 *
246 * Determine if the workspace size satisfies minimal size
247 *
248  lminws = .false.
249  IF( ( tsize.LT.max( 1, nb*n*nblcks + 5 ) .OR. lwork.LT.nb*n )
250  $ .AND. ( lwork.GE.n ) .AND. ( tsize.GE.mintsz )
251  $ .AND. ( .NOT.lquery ) ) THEN
252  IF( tsize.LT.max( 1, nb*n*nblcks + 5 ) ) THEN
253  lminws = .true.
254  nb = 1
255  mb = m
256  END IF
257  IF( lwork.LT.nb*n ) THEN
258  lminws = .true.
259  nb = 1
260  END IF
261  END IF
262 *
263  IF( m.LT.0 ) THEN
264  info = -1
265  ELSE IF( n.LT.0 ) THEN
266  info = -2
267  ELSE IF( lda.LT.max( 1, m ) ) THEN
268  info = -4
269  ELSE IF( tsize.LT.max( 1, nb*n*nblcks + 5 )
270  $ .AND. ( .NOT.lquery ) .AND. ( .NOT.lminws ) ) THEN
271  info = -6
272  ELSE IF( ( lwork.LT.max( 1, n*nb ) ) .AND. ( .NOT.lquery )
273  $ .AND. ( .NOT.lminws ) ) THEN
274  info = -8
275  END IF
276 *
277  IF( info.EQ.0 ) THEN
278  IF( mint ) THEN
279  t( 1 ) = mintsz
280  ELSE
281  t( 1 ) = nb*n*nblcks + 5
282  END IF
283  t( 2 ) = mb
284  t( 3 ) = nb
285  IF( minw ) THEN
286  work( 1 ) = max( 1, n )
287  ELSE
288  work( 1 ) = max( 1, nb*n )
289  END IF
290  END IF
291  IF( info.NE.0 ) THEN
292  CALL xerbla( 'CGEQR', -info )
293  RETURN
294  ELSE IF( lquery ) THEN
295  RETURN
296  END IF
297 *
298 * Quick return if possible
299 *
300  IF( min( m, n ).EQ.0 ) THEN
301  RETURN
302  END IF
303 *
304 * The QR Decomposition
305 *
306  IF( ( m.LE.n ) .OR. ( mb.LE.n ) .OR. ( mb.GE.m ) ) THEN
307  CALL cgeqrt( m, n, nb, a, lda, t( 6 ), nb, work, info )
308  ELSE
309  CALL clatsqr( m, n, mb, nb, a, lda, t( 6 ), nb, work,
310  $ lwork, info )
311  END IF
312 *
313  work( 1 ) = max( 1, nb*n )
314 *
315  RETURN
316 *
317 * End of CGEQR
318 *
Here is the call graph for this function:
Here is the caller graph for this function:
clatsqr
subroutine clatsqr(M, N, MB, NB, A, LDA, T, LDT, WORK, LWORK, INFO)
CLATSQR
Definition: clatsqr.f:166
cgeqrt
subroutine cgeqrt(M, N, NB, A, LDA, T, LDT, WORK, INFO)
CGEQRT
Definition: cgeqrt.f:143
xerbla
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
lsame
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
ilaenv
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
ILAENV
Definition: tstiee.f:83