LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zgeqp3.f
Go to the documentation of this file.
1*> \brief \b ZGEQP3
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZGEQP3 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeqp3.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeqp3.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeqp3.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZGEQP3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK,
20* INFO )
21*
22* .. Scalar Arguments ..
23* INTEGER INFO, LDA, LWORK, M, N
24* ..
25* .. Array Arguments ..
26* INTEGER JPVT( * )
27* DOUBLE PRECISION RWORK( * )
28* COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> ZGEQP3 computes a QR factorization with column pivoting of a
38*> matrix A: A*P = Q*R using Level 3 BLAS.
39*> \endverbatim
40*
41* Arguments:
42* ==========
43*
44*> \param[in] M
45*> \verbatim
46*> M is INTEGER
47*> The number of rows of the matrix A. M >= 0.
48*> \endverbatim
49*>
50*> \param[in] N
51*> \verbatim
52*> N is INTEGER
53*> The number of columns of the matrix A. N >= 0.
54*> \endverbatim
55*>
56*> \param[in,out] A
57*> \verbatim
58*> A is COMPLEX*16 array, dimension (LDA,N)
59*> On entry, the M-by-N matrix A.
60*> On exit, the upper triangle of the array contains the
61*> min(M,N)-by-N upper trapezoidal matrix R; the elements below
62*> the diagonal, together with the array TAU, represent the
63*> unitary matrix Q as a product of min(M,N) elementary
64*> reflectors.
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[in,out] JPVT
74*> \verbatim
75*> JPVT is INTEGER array, dimension (N)
76*> On entry, if JPVT(J).ne.0, the J-th column of A is permuted
77*> to the front of A*P (a leading column); if JPVT(J)=0,
78*> the J-th column of A is a free column.
79*> On exit, if JPVT(J)=K, then the J-th column of A*P was the
80*> the K-th column of A.
81*> \endverbatim
82*>
83*> \param[out] TAU
84*> \verbatim
85*> TAU is COMPLEX*16 array, dimension (min(M,N))
86*> The scalar factors of the elementary reflectors.
87*> \endverbatim
88*>
89*> \param[out] WORK
90*> \verbatim
91*> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
92*> On exit, if INFO=0, WORK(1) returns the optimal LWORK.
93*> \endverbatim
94*>
95*> \param[in] LWORK
96*> \verbatim
97*> LWORK is INTEGER
98*> The dimension of the array WORK. LWORK >= N+1.
99*> For optimal performance LWORK >= ( N+1 )*NB, where NB
100*> is the optimal blocksize.
101*>
102*> If LWORK = -1, then a workspace query is assumed; the routine
103*> only calculates the optimal size of the WORK array, returns
104*> this value as the first entry of the WORK array, and no error
105*> message related to LWORK is issued by XERBLA.
106*> \endverbatim
107*>
108*> \param[out] RWORK
109*> \verbatim
110*> RWORK is DOUBLE PRECISION array, dimension (2*N)
111*> \endverbatim
112*>
113*> \param[out] INFO
114*> \verbatim
115*> INFO is INTEGER
116*> = 0: successful exit.
117*> < 0: if INFO = -i, the i-th argument had an illegal value.
118*> \endverbatim
119*
120* Authors:
121* ========
122*
123*> \author Univ. of Tennessee
124*> \author Univ. of California Berkeley
125*> \author Univ. of Colorado Denver
126*> \author NAG Ltd.
127*
128*> \ingroup geqp3
129*
130*> \par Further Details:
131* =====================
132*>
133*> \verbatim
134*>
135*> The matrix Q is represented as a product of elementary reflectors
136*>
137*> Q = H(1) H(2) . . . H(k), where k = min(m,n).
138*>
139*> Each H(i) has the form
140*>
141*> H(i) = I - tau * v * v**H
142*>
143*> where tau is a complex scalar, and v is a real/complex vector
144*> with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in
145*> A(i+1:m,i), and tau in TAU(i).
146*> \endverbatim
147*
148*> \par Contributors:
149* ==================
150*>
151*> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
152*> X. Sun, Computer Science Dept., Duke University, USA
153*>
154* =====================================================================
155 SUBROUTINE zgeqp3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, RWORK,
156 $ INFO )
157*
158* -- LAPACK computational routine --
159* -- LAPACK is a software package provided by Univ. of Tennessee, --
160* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
161*
162* .. Scalar Arguments ..
163 INTEGER INFO, LDA, LWORK, M, N
164* ..
165* .. Array Arguments ..
166 INTEGER JPVT( * )
167 DOUBLE PRECISION RWORK( * )
168 COMPLEX*16 A( LDA, * ), TAU( * ), WORK( * )
169* ..
170*
171* =====================================================================
172*
173* .. Parameters ..
174 INTEGER INB, INBMIN, IXOVER
175 parameter( inb = 1, inbmin = 2, ixover = 3 )
176* ..
177* .. Local Scalars ..
178 LOGICAL LQUERY
179 INTEGER FJB, IWS, J, JB, LWKOPT, MINMN, MINWS, NA, NB,
180 $ nbmin, nfxd, nx, sm, sminmn, sn, topbmn
181* ..
182* .. External Subroutines ..
183 EXTERNAL xerbla, zgeqrf, zlaqp2, zlaqps, zswap,
184 $ zunmqr
185* ..
186* .. External Functions ..
187 INTEGER ILAENV
188 DOUBLE PRECISION DZNRM2
189 EXTERNAL ilaenv, dznrm2
190* ..
191* .. Intrinsic Functions ..
192 INTRINSIC int, max, min
193* ..
194* .. Executable Statements ..
195*
196* Test input arguments
197* ====================
198*
199 info = 0
200 lquery = ( lwork.EQ.-1 )
201 IF( m.LT.0 ) THEN
202 info = -1
203 ELSE IF( n.LT.0 ) THEN
204 info = -2
205 ELSE IF( lda.LT.max( 1, m ) ) THEN
206 info = -4
207 END IF
208*
209 IF( info.EQ.0 ) THEN
210 minmn = min( m, n )
211 IF( minmn.EQ.0 ) THEN
212 iws = 1
213 lwkopt = 1
214 ELSE
215 iws = n + 1
216 nb = ilaenv( inb, 'ZGEQRF', ' ', m, n, -1, -1 )
217 lwkopt = ( n + 1 )*nb
218 END IF
219 work( 1 ) = dcmplx( lwkopt )
220*
221 IF( ( lwork.LT.iws ) .AND. .NOT.lquery ) THEN
222 info = -8
223 END IF
224 END IF
225*
226 IF( info.NE.0 ) THEN
227 CALL xerbla( 'ZGEQP3', -info )
228 RETURN
229 ELSE IF( lquery ) THEN
230 RETURN
231 END IF
232*
233* Move initial columns up front.
234*
235 nfxd = 1
236 DO 10 j = 1, n
237 IF( jpvt( j ).NE.0 ) THEN
238 IF( j.NE.nfxd ) THEN
239 CALL zswap( m, a( 1, j ), 1, a( 1, nfxd ), 1 )
240 jpvt( j ) = jpvt( nfxd )
241 jpvt( nfxd ) = j
242 ELSE
243 jpvt( j ) = j
244 END IF
245 nfxd = nfxd + 1
246 ELSE
247 jpvt( j ) = j
248 END IF
249 10 CONTINUE
250 nfxd = nfxd - 1
251*
252* Factorize fixed columns
253* =======================
254*
255* Compute the QR factorization of fixed columns and update
256* remaining columns.
257*
258 IF( nfxd.GT.0 ) THEN
259 na = min( m, nfxd )
260*CC CALL ZGEQR2( M, NA, A, LDA, TAU, WORK, INFO )
261 CALL zgeqrf( m, na, a, lda, tau, work, lwork, info )
262 iws = max( iws, int( work( 1 ) ) )
263 IF( na.LT.n ) THEN
264*CC CALL ZUNM2R( 'Left', 'Conjugate Transpose', M, N-NA,
265*CC $ NA, A, LDA, TAU, A( 1, NA+1 ), LDA, WORK,
266*CC $ INFO )
267 CALL zunmqr( 'Left', 'Conjugate Transpose', m, n-na, na,
268 $ a,
269 $ lda, tau, a( 1, na+1 ), lda, work, lwork,
270 $ info )
271 iws = max( iws, int( work( 1 ) ) )
272 END IF
273 END IF
274*
275* Factorize free columns
276* ======================
277*
278 IF( nfxd.LT.minmn ) THEN
279*
280 sm = m - nfxd
281 sn = n - nfxd
282 sminmn = minmn - nfxd
283*
284* Determine the block size.
285*
286 nb = ilaenv( inb, 'ZGEQRF', ' ', sm, sn, -1, -1 )
287 nbmin = 2
288 nx = 0
289*
290 IF( ( nb.GT.1 ) .AND. ( nb.LT.sminmn ) ) THEN
291*
292* Determine when to cross over from blocked to unblocked code.
293*
294 nx = max( 0, ilaenv( ixover, 'ZGEQRF', ' ', sm, sn, -1,
295 $ -1 ) )
296*
297*
298 IF( nx.LT.sminmn ) THEN
299*
300* Determine if workspace is large enough for blocked code.
301*
302 minws = ( sn+1 )*nb
303 iws = max( iws, minws )
304 IF( lwork.LT.minws ) THEN
305*
306* Not enough workspace to use optimal NB: Reduce NB and
307* determine the minimum value of NB.
308*
309 nb = lwork / ( sn+1 )
310 nbmin = max( 2, ilaenv( inbmin, 'ZGEQRF', ' ', sm,
311 $ sn,
312 $ -1, -1 ) )
313*
314*
315 END IF
316 END IF
317 END IF
318*
319* Initialize partial column norms. The first N elements of work
320* store the exact column norms.
321*
322 DO 20 j = nfxd + 1, n
323 rwork( j ) = dznrm2( sm, a( nfxd+1, j ), 1 )
324 rwork( n+j ) = rwork( j )
325 20 CONTINUE
326*
327 IF( ( nb.GE.nbmin ) .AND. ( nb.LT.sminmn ) .AND.
328 $ ( nx.LT.sminmn ) ) THEN
329*
330* Use blocked code initially.
331*
332 j = nfxd + 1
333*
334* Compute factorization: while loop.
335*
336*
337 topbmn = minmn - nx
338 30 CONTINUE
339 IF( j.LE.topbmn ) THEN
340 jb = min( nb, topbmn-j+1 )
341*
342* Factorize JB columns among columns J:N.
343*
344 CALL zlaqps( m, n-j+1, j-1, jb, fjb, a( 1, j ), lda,
345 $ jpvt( j ), tau( j ), rwork( j ),
346 $ rwork( n+j ), work( 1 ), work( jb+1 ),
347 $ n-j+1 )
348*
349 j = j + fjb
350 GO TO 30
351 END IF
352 ELSE
353 j = nfxd + 1
354 END IF
355*
356* Use unblocked code to factor the last or only block.
357*
358*
359 IF( j.LE.minmn )
360 $ CALL zlaqp2( m, n-j+1, j-1, a( 1, j ), lda, jpvt( j ),
361 $ tau( j ), rwork( j ), rwork( n+j ), work( 1 ) )
362*
363 END IF
364*
365 work( 1 ) = dcmplx( lwkopt )
366 RETURN
367*
368* End of ZGEQP3
369*
370 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgeqp3(m, n, a, lda, jpvt, tau, work, lwork, rwork, info)
ZGEQP3
Definition zgeqp3.f:157
subroutine zgeqrf(m, n, a, lda, tau, work, lwork, info)
ZGEQRF
Definition zgeqrf.f:144
subroutine zlaqp2(m, n, offset, a, lda, jpvt, tau, vn1, vn2, work)
ZLAQP2 computes a QR factorization with column pivoting of the matrix block.
Definition zlaqp2.f:145
subroutine zlaqps(m, n, offset, nb, kb, a, lda, jpvt, tau, vn1, vn2, auxv, f, ldf)
ZLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by using BL...
Definition zlaqps.f:174
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP
Definition zswap.f:81
subroutine zunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMQR
Definition zunmqr.f:165