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

◆ 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. LWORK >= 1.
!>          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.

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