LAPACK  3.8.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 )
Purpose:
CGEQR computes a QR factorization of an M-by-N matrix A.
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```
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 unlikely not 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 162 of file cgeqr.f.

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