3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CGEQRFP + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqrfp.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqrfp.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqrfp.f">
21 * SUBROUTINE CGEQRFP( M, N, A, LDA, TAU, WORK, LWORK, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, LWORK, M, N
26 * .. Array Arguments ..
27 * COMPLEX A( LDA, * ), TAU( * ), WORK( * )
36 *> CGEQRFP computes a QR factorization of a complex M-by-N matrix A:
37 *> A = Q * R. The diagonal entries of R are real and nonnegative.
46 *> The number of rows of the matrix A. M >= 0.
52 *> The number of columns of the matrix A. N >= 0.
57 *> A is COMPLEX array, dimension (LDA,N)
58 *> On entry, the M-by-N matrix A.
59 *> On exit, the elements on and above the diagonal of the array
60 *> contain the min(M,N)-by-N upper trapezoidal matrix R (R is
61 *> upper triangular if m >= n). The diagonal entries of R
62 *> are real and nonnegative; the elements below the diagonal,
63 *> with the array TAU, represent the unitary matrix Q as a
64 *> product of min(m,n) elementary reflectors (see Further
71 *> The leading dimension of the array A. LDA >= max(1,M).
76 *> TAU is COMPLEX array, dimension (min(M,N))
77 *> The scalar factors of the elementary reflectors (see Further
83 *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
84 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
90 *> The dimension of the array WORK. LWORK >= max(1,N).
91 *> For optimum performance LWORK >= N*NB, where NB is
92 *> the optimal blocksize.
94 *> If LWORK = -1, then a workspace query is assumed; the routine
95 *> only calculates the optimal size of the WORK array, returns
96 *> this value as the first entry of the WORK array, and no error
97 *> message related to LWORK is issued by XERBLA.
103 *> = 0: successful exit
104 *> < 0: if INFO = -i, the i-th argument had an illegal value
110 *> \author Univ. of Tennessee
111 *> \author Univ. of California Berkeley
112 *> \author Univ. of Colorado Denver
115 *> \date November 2015
117 *> \ingroup complexGEcomputational
119 *> \par Further Details:
120 * =====================
124 *> The matrix Q is represented as a product of elementary reflectors
126 *> Q = H(1) H(2) . . . H(k), where k = min(m,n).
128 *> Each H(i) has the form
130 *> H(i) = I - tau * v * v**H
132 *> where tau is a complex scalar, and v is a complex vector with
133 *> v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
134 *> and tau in TAU(i).
136 *> See Lapack Working Note 203 for details
139 * =====================================================================
140 SUBROUTINE CGEQRFP( M, N, A, LDA, TAU, WORK, LWORK, INFO )
142 * -- LAPACK computational routine (version 3.6.0) --
143 * -- LAPACK is a software package provided by Univ. of Tennessee, --
144 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
147 * .. Scalar Arguments ..
148 INTEGER INFO, LDA, LWORK, M, N
150 * .. Array Arguments ..
151 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
154 * =====================================================================
156 * .. Local Scalars ..
158 INTEGER I, IB, IINFO, IWS, K, LDWORK, LWKOPT, NB,
161 * .. External Subroutines ..
162 EXTERNAL CGEQR2P, CLARFB, CLARFT, XERBLA
164 * .. Intrinsic Functions ..
167 * .. External Functions ..
171 * .. Executable Statements ..
173 * Test the input arguments
176 NB = ILAENV( 1, 'CGEQRF', ' ', M, N, -1, -1 )
179 LQUERY = ( LWORK.EQ.-1 )
182 ELSE IF( N.LT.0 ) THEN
184 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
186 ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
190 CALL XERBLA( 'CGEQRFP', -INFO )
192 ELSE IF( LQUERY ) THEN
196 * Quick return if possible
207 IF( NB.GT.1 .AND. NB.LT.K ) THEN
209 * Determine when to cross over from blocked to unblocked code.
211 NX = MAX( 0, ILAENV( 3, 'CGEQRF', ' ', M, N, -1, -1 ) )
214 * Determine if workspace is large enough for blocked code.
218 IF( LWORK.LT.IWS ) THEN
220 * Not enough workspace to use optimal NB: reduce NB and
221 * determine the minimum value of NB.
224 NBMIN = MAX( 2, ILAENV( 2, 'CGEQRF', ' ', M, N, -1,
230 IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
232 * Use blocked code initially
234 DO 10 I = 1, K - NX, NB
235 IB = MIN( K-I+1, NB )
237 * Compute the QR factorization of the current block
240 CALL CGEQR2P( M-I+1, IB, A( I, I ), LDA, TAU( I ), WORK,
244 * Form the triangular factor of the block reflector
245 * H = H(i) H(i+1) . . . H(i+ib-1)
247 CALL CLARFT( 'Forward', 'Columnwise', M-I+1, IB,
248 $ A( I, I ), LDA, TAU( I ), WORK, LDWORK )
250 * Apply H**H to A(i:m,i+ib:n) from the left
252 CALL CLARFB( 'Left', 'Conjugate transpose', 'Forward',
253 $ 'Columnwise', M-I+1, N-I-IB+1, IB,
254 $ A( I, I ), LDA, WORK, LDWORK, A( I, I+IB ),
255 $ LDA, WORK( IB+1 ), LDWORK )
262 * Use unblocked code to factor the last or only block.
265 $ CALL CGEQR2P( M-I+1, N-I+1, A( I, I ), LDA, TAU( I ), WORK,