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

◆ cgeqrfp()

subroutine cgeqrfp ( integer m,
integer n,
complex, dimension( lda, * ) a,
integer lda,
complex, dimension( * ) tau,
complex, dimension( * ) work,
integer lwork,
integer info )

CGEQRFP

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

Purpose:
!>
!> CGEQR2P 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 with nonnegative diagonal
!>    entries;
!>    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 diagonal entries of R
!>          are real and nonnegative; the elements below the diagonal,
!>          with the array TAU, represent the unitary 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 COMPLEX array, dimension (min(M,N))
!>          The scalar factors of the elementary reflectors (see Further
!>          Details).
!> 
[out]WORK
!>          WORK is COMPLEX 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 >= N, otherwise.
!>          For optimum performance LWORK >= N*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**H
!>
!>  where tau is a complex scalar, and v is a complex vector with
!>  v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
!>  and tau in TAU(i).
!>
!> See Lapack Working Note 203 for details
!> 

Definition at line 147 of file cgeqrfp.f.

148*
149* -- LAPACK computational routine --
150* -- LAPACK is a software package provided by Univ. of Tennessee, --
151* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
152*
153* .. Scalar Arguments ..
154 INTEGER INFO, LDA, LWORK, M, N
155* ..
156* .. Array Arguments ..
157 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
158* ..
159*
160* =====================================================================
161*
162* .. Local Scalars ..
163 LOGICAL LQUERY
164 INTEGER I, IB, IINFO, IWS, K, LDWORK, LWKMIN, LWKOPT,
165 $ NB, NBMIN, NX
166* ..
167* .. External Subroutines ..
168 EXTERNAL cgeqr2p, clarfb, clarft, xerbla
169* ..
170* .. Intrinsic Functions ..
171 INTRINSIC max, min
172* ..
173* .. External Functions ..
174 INTEGER ILAENV
175 REAL SROUNDUP_LWORK
176 EXTERNAL ilaenv, sroundup_lwork
177* ..
178* .. Executable Statements ..
179*
180* Test the input arguments
181*
182 info = 0
183 nb = ilaenv( 1, 'CGEQRF', ' ', m, n, -1, -1 )
184 k = min( m, n )
185 IF( k.EQ.0 ) THEN
186 lwkmin = 1
187 lwkopt = 1
188 ELSE
189 lwkmin = n
190 lwkopt = n*nb
191 END IF
192 work( 1 ) = sroundup_lwork( lwkopt )
193*
194 lquery = ( lwork.EQ.-1 )
195 IF( m.LT.0 ) THEN
196 info = -1
197 ELSE IF( n.LT.0 ) THEN
198 info = -2
199 ELSE IF( lda.LT.max( 1, m ) ) THEN
200 info = -4
201 ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery ) THEN
202 info = -7
203 END IF
204 IF( info.NE.0 ) THEN
205 CALL xerbla( 'CGEQRFP', -info )
206 RETURN
207 ELSE IF( lquery ) THEN
208 RETURN
209 END IF
210*
211* Quick return if possible
212*
213 IF( k.EQ.0 ) THEN
214 work( 1 ) = 1
215 RETURN
216 END IF
217*
218 nbmin = 2
219 nx = 0
220 iws = lwkmin
221 IF( nb.GT.1 .AND. nb.LT.k ) THEN
222*
223* Determine when to cross over from blocked to unblocked code.
224*
225 nx = max( 0, ilaenv( 3, 'CGEQRF', ' ', m, n, -1, -1 ) )
226 IF( nx.LT.k ) THEN
227*
228* Determine if workspace is large enough for blocked code.
229*
230 ldwork = n
231 iws = ldwork*nb
232 IF( lwork.LT.iws ) THEN
233*
234* Not enough workspace to use optimal NB: reduce NB and
235* determine the minimum value of NB.
236*
237 nb = lwork / ldwork
238 nbmin = max( 2, ilaenv( 2, 'CGEQRF', ' ', m, n, -1,
239 $ -1 ) )
240 END IF
241 END IF
242 END IF
243*
244 IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
245*
246* Use blocked code initially
247*
248 DO 10 i = 1, k - nx, nb
249 ib = min( k-i+1, nb )
250*
251* Compute the QR factorization of the current block
252* A(i:m,i:i+ib-1)
253*
254 CALL cgeqr2p( m-i+1, ib, a( i, i ), lda, tau( i ), work,
255 $ iinfo )
256 IF( i+ib.LE.n ) THEN
257*
258* Form the triangular factor of the block reflector
259* H = H(i) H(i+1) . . . H(i+ib-1)
260*
261 CALL clarft( 'Forward', 'Columnwise', m-i+1, ib,
262 $ a( i, i ), lda, tau( i ), work, ldwork )
263*
264* Apply H**H to A(i:m,i+ib:n) from the left
265*
266 CALL clarfb( 'Left', 'Conjugate transpose', 'Forward',
267 $ 'Columnwise', m-i+1, n-i-ib+1, ib,
268 $ a( i, i ), lda, work, ldwork, a( i, i+ib ),
269 $ lda, work( ib+1 ), ldwork )
270 END IF
271 10 CONTINUE
272 ELSE
273 i = 1
274 END IF
275*
276* Use unblocked code to factor the last or only block.
277*
278 IF( i.LE.k )
279 $ CALL cgeqr2p( m-i+1, n-i+1, a( i, i ), lda, tau( i ), work,
280 $ iinfo )
281*
282 work( 1 ) = sroundup_lwork( iws )
283 RETURN
284*
285* End of CGEQRFP
286*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgeqr2p(m, n, a, lda, tau, work, info)
CGEQR2P computes the QR factorization of a general rectangular matrix with non-negative diagonal elem...
Definition cgeqr2p.f:132
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:160
subroutine clarfb(side, trans, direct, storev, m, n, k, v, ldv, t, ldt, c, ldc, work, ldwork)
CLARFB applies a block reflector or its conjugate-transpose to a general rectangular matrix.
Definition clarfb.f:195
recursive subroutine clarft(direct, storev, n, k, v, ldv, tau, t, ldt)
CLARFT forms the triangular factor T of a block reflector H = I - vtvH
Definition clarft.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: