3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZGEQLF + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeqlf.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeqlf.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeqlf.f">
21 * SUBROUTINE ZGEQLF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, LWORK, M, N
26 * .. Array Arguments ..
27 * COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
36 *> ZGEQLF computes a QL factorization of a complex M-by-N matrix A:
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*16 array, dimension (LDA,N)
58 *> On entry, the M-by-N matrix A.
60 *> if m >= n, the lower triangle of the subarray
61 *> A(m-n+1:m,1:n) contains the N-by-N lower triangular matrix L;
62 *> if m <= n, the elements on and below the (n-m)-th
63 *> superdiagonal contain the M-by-N lower trapezoidal matrix L;
64 *> the remaining elements, with the array TAU, represent the
65 *> unitary matrix Q as a product of elementary reflectors
66 *> (see Further Details).
72 *> The leading dimension of the array A. LDA >= max(1,M).
77 *> TAU is COMPLEX*16 array, dimension (min(M,N))
78 *> The scalar factors of the elementary reflectors (see Further
84 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
85 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
91 *> The dimension of the array WORK. LWORK >= max(1,N).
92 *> For optimum performance LWORK >= N*NB, where NB is
93 *> the optimal blocksize.
95 *> If LWORK = -1, then a workspace query is assumed; the routine
96 *> only calculates the optimal size of the WORK array, returns
97 *> this value as the first entry of the WORK array, and no error
98 *> message related to LWORK is issued by XERBLA.
104 *> = 0: successful exit
105 *> < 0: if INFO = -i, the i-th argument had an illegal value
111 *> \author Univ. of Tennessee
112 *> \author Univ. of California Berkeley
113 *> \author Univ. of Colorado Denver
116 *> \date November 2011
118 *> \ingroup complex16GEcomputational
120 *> \par Further Details:
121 * =====================
125 *> The matrix Q is represented as a product of elementary reflectors
127 *> Q = H(k) . . . H(2) H(1), where k = min(m,n).
129 *> Each H(i) has the form
131 *> H(i) = I - tau * v * v**H
133 *> where tau is a complex scalar, and v is a complex vector with
134 *> v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in
135 *> A(1:m-k+i-1,n-k+i), and tau in TAU(i).
138 * =====================================================================
139 SUBROUTINE ZGEQLF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
141 * -- LAPACK computational routine (version 3.4.0) --
142 * -- LAPACK is a software package provided by Univ. of Tennessee, --
143 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
146 * .. Scalar Arguments ..
147 INTEGER INFO, LDA, LWORK, M, N
149 * .. Array Arguments ..
150 COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
153 * =====================================================================
155 * .. Local Scalars ..
157 INTEGER I, IB, IINFO, IWS, K, KI, KK, LDWORK, LWKOPT,
158 $ MU, NB, NBMIN, NU, NX
160 * .. External Subroutines ..
161 EXTERNAL XERBLA, ZGEQL2, ZLARFB, ZLARFT
163 * .. Intrinsic Functions ..
166 * .. External Functions ..
170 * .. Executable Statements ..
172 * Test the input arguments
175 LQUERY = ( LWORK.EQ.-1 )
178 ELSE IF( N.LT.0 ) THEN
180 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
189 NB = ILAENV( 1, 'ZGEQLF', ' ', M, N, -1, -1 )
194 IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
200 CALL XERBLA( 'ZGEQLF', -INFO )
202 ELSE IF( LQUERY ) THEN
206 * Quick return if possible
215 IF( NB.GT.1 .AND. NB.LT.K ) THEN
217 * Determine when to cross over from blocked to unblocked code.
219 NX = MAX( 0, ILAENV( 3, 'ZGEQLF', ' ', M, N, -1, -1 ) )
222 * Determine if workspace is large enough for blocked code.
226 IF( LWORK.LT.IWS ) THEN
228 * Not enough workspace to use optimal NB: reduce NB and
229 * determine the minimum value of NB.
232 NBMIN = MAX( 2, ILAENV( 2, 'ZGEQLF', ' ', M, N, -1,
238 IF( NB.GE.NBMIN .AND. NB.LT.K .AND. NX.LT.K ) THEN
240 * Use blocked code initially.
241 * The last kk columns are handled by the block method.
243 KI = ( ( K-NX-1 ) / NB )*NB
246 DO 10 I = K - KK + KI + 1, K - KK + 1, -NB
247 IB = MIN( K-I+1, NB )
249 * Compute the QL factorization of the current block
250 * A(1:m-k+i+ib-1,n-k+i:n-k+i+ib-1)
252 CALL ZGEQL2( M-K+I+IB-1, IB, A( 1, N-K+I ), LDA, TAU( I ),
254 IF( N-K+I.GT.1 ) THEN
256 * Form the triangular factor of the block reflector
257 * H = H(i+ib-1) . . . H(i+1) H(i)
259 CALL ZLARFT( 'Backward', 'Columnwise', M-K+I+IB-1, IB,
260 $ A( 1, N-K+I ), LDA, TAU( I ), WORK, LDWORK )
262 * Apply H**H to A(1:m-k+i+ib-1,1:n-k+i-1) from the left
264 CALL ZLARFB( 'Left', 'Conjugate transpose', 'Backward',
265 $ 'Columnwise', M-K+I+IB-1, N-K+I-1, IB,
266 $ A( 1, N-K+I ), LDA, WORK, LDWORK, A, LDA,
267 $ WORK( IB+1 ), LDWORK )
270 MU = M - K + I + NB - 1
271 NU = N - K + I + NB - 1
277 * Use unblocked code to factor the last or only block
279 IF( MU.GT.0 .AND. NU.GT.0 )
280 $ CALL ZGEQL2( MU, NU, A, LDA, TAU, WORK, IINFO )