LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cgerqf.f
Go to the documentation of this file.
1*> \brief \b CGERQF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CGERQF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgerqf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgerqf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgerqf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CGERQF( M, N, A, LDA, TAU, WORK, LWORK, INFO )
20*
21* .. Scalar Arguments ..
22* INTEGER INFO, LDA, LWORK, M, N
23* ..
24* .. Array Arguments ..
25* COMPLEX A( LDA, * ), TAU( * ), WORK( * )
26* ..
27*
28*
29*> \par Purpose:
30* =============
31*>
32*> \verbatim
33*>
34*> CGERQF computes an RQ factorization of a complex M-by-N matrix A:
35*> A = R * Q.
36*> \endverbatim
37*
38* Arguments:
39* ==========
40*
41*> \param[in] M
42*> \verbatim
43*> M is INTEGER
44*> The number of rows of the matrix A. M >= 0.
45*> \endverbatim
46*>
47*> \param[in] N
48*> \verbatim
49*> N is INTEGER
50*> The number of columns of the matrix A. N >= 0.
51*> \endverbatim
52*>
53*> \param[in,out] A
54*> \verbatim
55*> A is COMPLEX array, dimension (LDA,N)
56*> On entry, the M-by-N matrix A.
57*> On exit,
58*> if m <= n, the upper triangle of the subarray
59*> A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R;
60*> if m >= n, the elements on and above the (m-n)-th subdiagonal
61*> contain the M-by-N upper trapezoidal matrix R;
62*> the remaining elements, with the array TAU, represent the
63*> unitary matrix Q as a product of min(m,n) elementary
64*> reflectors (see Further Details).
65*> \endverbatim
66*>
67*> \param[in] LDA
68*> \verbatim
69*> LDA is INTEGER
70*> The leading dimension of the array A. LDA >= max(1,M).
71*> \endverbatim
72*>
73*> \param[out] TAU
74*> \verbatim
75*> TAU is COMPLEX array, dimension (min(M,N))
76*> The scalar factors of the elementary reflectors (see Further
77*> Details).
78*> \endverbatim
79*>
80*> \param[out] WORK
81*> \verbatim
82*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
83*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
84*> \endverbatim
85*>
86*> \param[in] LWORK
87*> \verbatim
88*> LWORK is INTEGER
89*> The dimension of the array WORK.
90*> LWORK >= 1, if MIN(M,N) = 0, and LWORK >= M, otherwise.
91*> For optimum performance LWORK >= M*NB, where NB is
92*> the optimal blocksize.
93*>
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.
98*> \endverbatim
99*>
100*> \param[out] INFO
101*> \verbatim
102*> INFO is INTEGER
103*> = 0: successful exit
104*> < 0: if INFO = -i, the i-th argument had an illegal value
105*> \endverbatim
106*
107* Authors:
108* ========
109*
110*> \author Univ. of Tennessee
111*> \author Univ. of California Berkeley
112*> \author Univ. of Colorado Denver
113*> \author NAG Ltd.
114*
115*> \ingroup gerqf
116*
117*> \par Further Details:
118* =====================
119*>
120*> \verbatim
121*>
122*> The matrix Q is represented as a product of elementary reflectors
123*>
124*> Q = H(1)**H H(2)**H . . . H(k)**H, where k = min(m,n).
125*>
126*> Each H(i) has the form
127*>
128*> H(i) = I - tau * v * v**H
129*>
130*> where tau is a complex scalar, and v is a complex vector with
131*> v(n-k+i+1:n) = 0 and v(n-k+i) = 1; conjg(v(1:n-k+i-1)) is stored on
132*> exit in A(m-k+i,1:n-k+i-1), and tau in TAU(i).
133*> \endverbatim
134*>
135* =====================================================================
136 SUBROUTINE cgerqf( M, N, A, LDA, TAU, WORK, LWORK, INFO )
137*
138* -- LAPACK computational routine --
139* -- LAPACK is a software package provided by Univ. of Tennessee, --
140* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
141*
142* .. Scalar Arguments ..
143 INTEGER INFO, LDA, LWORK, M, N
144* ..
145* .. Array Arguments ..
146 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
147* ..
148*
149* =====================================================================
150*
151* .. Local Scalars ..
152 LOGICAL LQUERY
153 INTEGER I, IB, IINFO, IWS, K, KI, KK, LDWORK, LWKOPT,
154 $ MU, NB, NBMIN, NU, NX
155* ..
156* .. External Subroutines ..
157 EXTERNAL cgerq2, clarfb, clarft, xerbla
158* ..
159* .. Intrinsic Functions ..
160 INTRINSIC max, min
161* ..
162* .. External Functions ..
163 INTEGER ILAENV
164 REAL SROUNDUP_LWORK
165 EXTERNAL ilaenv, sroundup_lwork
166* ..
167* .. Executable Statements ..
168*
169* Test the input arguments
170*
171 info = 0
172 lquery = ( lwork.EQ.-1 )
173 IF( m.LT.0 ) THEN
174 info = -1
175 ELSE IF( n.LT.0 ) THEN
176 info = -2
177 ELSE IF( lda.LT.max( 1, m ) ) THEN
178 info = -4
179 END IF
180*
181 IF( info.EQ.0 ) THEN
182 k = min( m, n )
183 IF( k.EQ.0 ) THEN
184 lwkopt = 1
185 ELSE
186 nb = ilaenv( 1, 'CGERQF', ' ', m, n, -1, -1 )
187 lwkopt = m*nb
188 END IF
189 work( 1 ) = sroundup_lwork(lwkopt)
190*
191 IF ( .NOT.lquery ) THEN
192 IF( lwork.LE.0 .OR. ( n.GT.0 .AND. lwork.LT.max( 1, m ) ) )
193 $ info = -7
194 END IF
195 END IF
196*
197 IF( info.NE.0 ) THEN
198 CALL xerbla( 'CGERQF', -info )
199 RETURN
200 ELSE IF( lquery ) THEN
201 RETURN
202 END IF
203*
204* Quick return if possible
205*
206 IF( k.EQ.0 ) THEN
207 RETURN
208 END IF
209*
210 nbmin = 2
211 nx = 1
212 iws = m
213 IF( nb.GT.1 .AND. nb.LT.k ) THEN
214*
215* Determine when to cross over from blocked to unblocked code.
216*
217 nx = max( 0, ilaenv( 3, 'CGERQF', ' ', m, n, -1, -1 ) )
218 IF( nx.LT.k ) THEN
219*
220* Determine if workspace is large enough for blocked code.
221*
222 ldwork = m
223 iws = ldwork*nb
224 IF( lwork.LT.iws ) THEN
225*
226* Not enough workspace to use optimal NB: reduce NB and
227* determine the minimum value of NB.
228*
229 nb = lwork / ldwork
230 nbmin = max( 2, ilaenv( 2, 'CGERQF', ' ', m, n, -1,
231 $ -1 ) )
232 END IF
233 END IF
234 END IF
235*
236 IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
237*
238* Use blocked code initially.
239* The last kk rows are handled by the block method.
240*
241 ki = ( ( k-nx-1 ) / nb )*nb
242 kk = min( k, ki+nb )
243*
244 DO 10 i = k - kk + ki + 1, k - kk + 1, -nb
245 ib = min( k-i+1, nb )
246*
247* Compute the RQ factorization of the current block
248* A(m-k+i:m-k+i+ib-1,1:n-k+i+ib-1)
249*
250 CALL cgerq2( ib, n-k+i+ib-1, a( m-k+i, 1 ), lda,
251 $ tau( i ),
252 $ work, iinfo )
253 IF( m-k+i.GT.1 ) THEN
254*
255* Form the triangular factor of the block reflector
256* H = H(i+ib-1) . . . H(i+1) H(i)
257*
258 CALL clarft( 'Backward', 'Rowwise', n-k+i+ib-1, ib,
259 $ a( m-k+i, 1 ), lda, tau( i ), work, ldwork )
260*
261* Apply H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right
262*
263 CALL clarfb( 'Right', 'No transpose', 'Backward',
264 $ 'Rowwise', m-k+i-1, n-k+i+ib-1, ib,
265 $ a( m-k+i, 1 ), lda, work, ldwork, a, lda,
266 $ work( ib+1 ), ldwork )
267 END IF
268 10 CONTINUE
269 mu = m - k + i + nb - 1
270 nu = n - k + i + nb - 1
271 ELSE
272 mu = m
273 nu = n
274 END IF
275*
276* Use unblocked code to factor the last or only block
277*
278 IF( mu.GT.0 .AND. nu.GT.0 )
279 $ CALL cgerq2( mu, nu, a, lda, tau, work, iinfo )
280*
281 work( 1 ) = sroundup_lwork(iws)
282 RETURN
283*
284* End of CGERQF
285*
286 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgerq2(m, n, a, lda, tau, work, info)
CGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition cgerq2.f:121
subroutine cgerqf(m, n, a, lda, tau, work, lwork, info)
CGERQF
Definition cgerqf.f:137
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