LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zgerqf.f
Go to the documentation of this file.
1*> \brief \b ZGERQF
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZGERQF + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgerqf.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgerqf.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgerqf.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZGERQF( 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*16 A( LDA, * ), TAU( * ), WORK( * )
26* ..
27*
28*
29*> \par Purpose:
30* =============
31*>
32*> \verbatim
33*>
34*> ZGERQF 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*16 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*16 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*16 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 zgerqf( 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*16 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 xerbla, zgerq2, zlarfb, zlarft
158* ..
159* .. Intrinsic Functions ..
160 INTRINSIC max, min
161* ..
162* .. External Functions ..
163 INTEGER ILAENV
164 EXTERNAL ilaenv
165* ..
166* .. Executable Statements ..
167*
168* Test the input arguments
169*
170 info = 0
171 lquery = ( lwork.EQ.-1 )
172 IF( m.LT.0 ) THEN
173 info = -1
174 ELSE IF( n.LT.0 ) THEN
175 info = -2
176 ELSE IF( lda.LT.max( 1, m ) ) THEN
177 info = -4
178 END IF
179*
180 IF( info.EQ.0 ) THEN
181 k = min( m, n )
182 IF( k.EQ.0 ) THEN
183 lwkopt = 1
184 ELSE
185 nb = ilaenv( 1, 'ZGERQF', ' ', m, n, -1, -1 )
186 lwkopt = m*nb
187 END IF
188 work( 1 ) = lwkopt
189*
190 IF ( .NOT.lquery ) THEN
191 IF( lwork.LE.0 .OR. ( n.GT.0 .AND. lwork.LT.max( 1, m ) ) )
192 $ info = -7
193 END IF
194 END IF
195*
196 IF( info.NE.0 ) THEN
197 CALL xerbla( 'ZGERQF', -info )
198 RETURN
199 ELSE IF( lquery ) THEN
200 RETURN
201 END IF
202*
203* Quick return if possible
204*
205 IF( k.EQ.0 ) THEN
206 RETURN
207 END IF
208*
209 nbmin = 2
210 nx = 1
211 iws = m
212 IF( nb.GT.1 .AND. nb.LT.k ) THEN
213*
214* Determine when to cross over from blocked to unblocked code.
215*
216 nx = max( 0, ilaenv( 3, 'ZGERQF', ' ', m, n, -1, -1 ) )
217 IF( nx.LT.k ) THEN
218*
219* Determine if workspace is large enough for blocked code.
220*
221 ldwork = m
222 iws = ldwork*nb
223 IF( lwork.LT.iws ) THEN
224*
225* Not enough workspace to use optimal NB: reduce NB and
226* determine the minimum value of NB.
227*
228 nb = lwork / ldwork
229 nbmin = max( 2, ilaenv( 2, 'ZGERQF', ' ', m, n, -1,
230 $ -1 ) )
231 END IF
232 END IF
233 END IF
234*
235 IF( nb.GE.nbmin .AND. nb.LT.k .AND. nx.LT.k ) THEN
236*
237* Use blocked code initially.
238* The last kk rows are handled by the block method.
239*
240 ki = ( ( k-nx-1 ) / nb )*nb
241 kk = min( k, ki+nb )
242*
243 DO 10 i = k - kk + ki + 1, k - kk + 1, -nb
244 ib = min( k-i+1, nb )
245*
246* Compute the RQ factorization of the current block
247* A(m-k+i:m-k+i+ib-1,1:n-k+i+ib-1)
248*
249 CALL zgerq2( ib, n-k+i+ib-1, a( m-k+i, 1 ), lda,
250 $ tau( i ),
251 $ work, iinfo )
252 IF( m-k+i.GT.1 ) THEN
253*
254* Form the triangular factor of the block reflector
255* H = H(i+ib-1) . . . H(i+1) H(i)
256*
257 CALL zlarft( 'Backward', 'Rowwise', n-k+i+ib-1, ib,
258 $ a( m-k+i, 1 ), lda, tau( i ), work, ldwork )
259*
260* Apply H to A(1:m-k+i-1,1:n-k+i+ib-1) from the right
261*
262 CALL zlarfb( 'Right', 'No transpose', 'Backward',
263 $ 'Rowwise', m-k+i-1, n-k+i+ib-1, ib,
264 $ a( m-k+i, 1 ), lda, work, ldwork, a, lda,
265 $ work( ib+1 ), ldwork )
266 END IF
267 10 CONTINUE
268 mu = m - k + i + nb - 1
269 nu = n - k + i + nb - 1
270 ELSE
271 mu = m
272 nu = n
273 END IF
274*
275* Use unblocked code to factor the last or only block
276*
277 IF( mu.GT.0 .AND. nu.GT.0 )
278 $ CALL zgerq2( mu, nu, a, lda, tau, work, iinfo )
279*
280 work( 1 ) = iws
281 RETURN
282*
283* End of ZGERQF
284*
285 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgerq2(m, n, a, lda, tau, work, info)
ZGERQ2 computes the RQ factorization of a general rectangular matrix using an unblocked algorithm.
Definition zgerq2.f:121
subroutine zgerqf(m, n, a, lda, tau, work, lwork, info)
ZGERQF
Definition zgerqf.f:137
subroutine zlarfb(side, trans, direct, storev, m, n, k, v, ldv, t, ldt, c, ldc, work, ldwork)
ZLARFB applies a block reflector or its conjugate-transpose to a general rectangular matrix.
Definition zlarfb.f:195
recursive subroutine zlarft(direct, storev, n, k, v, ldv, tau, t, ldt)
ZLARFT forms the triangular factor T of a block reflector H = I - vtvH
Definition zlarft.f:162