OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
dgeqp3.f
Go to the documentation of this file.
1*> \brief \b DGEQP3
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download DGEQP3 + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgeqp3.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgeqp3.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgeqp3.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE DGEQP3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, INFO )
22*
23* .. Scalar Arguments ..
24* INTEGER INFO, LDA, LWORK, M, N
25* ..
26* .. Array Arguments ..
27* INTEGER JPVT( * )
28* DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> DGEQP3 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 DOUBLE PRECISION 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*> orthogonal 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 >= 3*N+1.
99*> For optimal performance LWORK >= 2*N+( 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] INFO
109*> \verbatim
110*> INFO is INTEGER
111*> = 0: successful exit.
112*> < 0: if INFO = -i, the i-th argument had an illegal value.
113*> \endverbatim
114*
115* Authors:
116* ========
117*
118*> \author Univ. of Tennessee
119*> \author Univ. of California Berkeley
120*> \author Univ. of Colorado Denver
121*> \author NAG Ltd.
122*
123*> \ingroup doubleGEcomputational
124*
125*> \par Further Details:
126* =====================
127*>
128*> \verbatim
129*>
130*> The matrix Q is represented as a product of elementary reflectors
131*>
132*> Q = H(1) H(2) . . . H(k), where k = min(m,n).
133*>
134*> Each H(i) has the form
135*>
136*> H(i) = I - tau * v * v**T
137*>
138*> where tau is a real scalar, and v is a real/complex vector
139*> with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in
140*> A(i+1:m,i), and tau in TAU(i).
141*> \endverbatim
142*
143*> \par Contributors:
144* ==================
145*>
146*> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
147*> X. Sun, Computer Science Dept., Duke University, USA
148*>
149* =====================================================================
150 SUBROUTINE dgeqp3( M, N, A, LDA, JPVT, TAU, WORK, LWORK, INFO )
151*
152* -- LAPACK computational routine --
153* -- LAPACK is a software package provided by Univ. of Tennessee, --
154* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
155*
156* .. Scalar Arguments ..
157 INTEGER INFO, LDA, LWORK, M, N
158* ..
159* .. Array Arguments ..
160 INTEGER JPVT( * )
161 DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
162* ..
163*
164* =====================================================================
165*
166* .. Parameters ..
167 INTEGER INB, INBMIN, IXOVER
168 parameter( inb = 1, inbmin = 2, ixover = 3 )
169* ..
170* .. Local Scalars ..
171 LOGICAL LQUERY
172 INTEGER FJB, IWS, J, JB, LWKOPT, MINMN, MINWS, NA, NB,
173 $ NBMIN, NFXD, NX, SM, SMINMN, SN, TOPBMN
174* ..
175* .. External Subroutines ..
176 EXTERNAL dgeqrf, dlaqp2, dlaqps, dormqr, dswap, xerbla
177* ..
178* .. External Functions ..
179 INTEGER ILAENV
180 DOUBLE PRECISION DNRM2
181 EXTERNAL ilaenv, dnrm2
182* ..
183* .. Intrinsic Functions ..
184 INTRINSIC int, max, min
185* ..
186* .. Executable Statements ..
187*
188* Test input arguments
189* ====================
190*
191 info = 0
192 lquery = ( lwork.EQ.-1 )
193 IF( m.LT.0 ) THEN
194 info = -1
195 ELSE IF( n.LT.0 ) THEN
196 info = -2
197 ELSE IF( lda.LT.max( 1, m ) ) THEN
198 info = -4
199 END IF
200*
201 IF( info.EQ.0 ) THEN
202 minmn = min( m, n )
203 IF( minmn.EQ.0 ) THEN
204 iws = 1
205 lwkopt = 1
206 ELSE
207 iws = 3*n + 1
208 nb = ilaenv( inb, 'DGEQRF', ' ', M, N, -1, -1 )
209 LWKOPT = 2*N + ( N + 1 )*NB
210 END IF
211 WORK( 1 ) = LWKOPT
212*
213.LT..AND..NOT. IF( ( LWORKIWS ) LQUERY ) THEN
214 INFO = -8
215 END IF
216 END IF
217*
218.NE. IF( INFO0 ) THEN
219 CALL XERBLA( 'dgeqp3', -INFO )
220 RETURN
221 ELSE IF( LQUERY ) THEN
222 RETURN
223 END IF
224*
225* Move initial columns up front.
226*
227 NFXD = 1
228 DO 10 J = 1, N
229.NE. IF( JPVT( J )0 ) THEN
230.NE. IF( JNFXD ) THEN
231 CALL DSWAP( M, A( 1, J ), 1, A( 1, NFXD ), 1 )
232 JPVT( J ) = JPVT( NFXD )
233 JPVT( NFXD ) = J
234 ELSE
235 JPVT( J ) = J
236 END IF
237 NFXD = NFXD + 1
238 ELSE
239 JPVT( J ) = J
240 END IF
241 10 CONTINUE
242 NFXD = NFXD - 1
243*
244* Factorize fixed columns
245* =======================
246*
247* Compute the QR factorization of fixed columns and update
248* remaining columns.
249*
250.GT. IF( NFXD0 ) THEN
251 NA = MIN( M, NFXD )
252*CC CALL DGEQR2( M, NA, A, LDA, TAU, WORK, INFO )
253 CALL DGEQRF( M, NA, A, LDA, TAU, WORK, LWORK, INFO )
254 IWS = MAX( IWS, INT( WORK( 1 ) ) )
255.LT. IF( NAN ) THEN
256*CC CALL DORM2R( 'Left', 'Transpose', M, N-NA, NA, A, LDA,
257*CC $ TAU, A( 1, NA+1 ), LDA, WORK, INFO )
258 CALL DORMQR( 'left', 'transpose', M, N-NA, NA, A, LDA, TAU,
259 $ A( 1, NA+1 ), LDA, WORK, LWORK, INFO )
260 IWS = MAX( IWS, INT( WORK( 1 ) ) )
261 END IF
262 END IF
263*
264* Factorize free columns
265* ======================
266*
267.LT. IF( NFXDMINMN ) THEN
268*
269 SM = M - NFXD
270 SN = N - NFXD
271 SMINMN = MINMN - NFXD
272*
273* Determine the block size.
274*
275 NB = ILAENV( INB, 'dgeqrf', ' ', SM, SN, -1, -1 )
276 NBMIN = 2
277 NX = 0
278*
279.GT..AND..LT. IF( ( NB1 ) ( NBSMINMN ) ) THEN
280*
281* Determine when to cross over from blocked to unblocked code.
282*
283 NX = MAX( 0, ILAENV( IXOVER, 'dgeqrf', ' ', SM, SN, -1,
284 $ -1 ) )
285*
286*
287.LT. IF( NXSMINMN ) THEN
288*
289* Determine if workspace is large enough for blocked code.
290*
291 MINWS = 2*SN + ( SN+1 )*NB
292 IWS = MAX( IWS, MINWS )
293.LT. IF( LWORKMINWS ) THEN
294*
295* Not enough workspace to use optimal NB: Reduce NB and
296* determine the minimum value of NB.
297*
298 NB = ( LWORK-2*SN ) / ( SN+1 )
299 NBMIN = MAX( 2, ILAENV( INBMIN, 'dgeqrf', ' ', SM, SN,
300 $ -1, -1 ) )
301*
302*
303 END IF
304 END IF
305 END IF
306*
307* Initialize partial column norms. The first N elements of work
308* store the exact column norms.
309*
310 DO 20 J = NFXD + 1, N
311 WORK( J ) = DNRM2( SM, A( NFXD+1, J ), 1 )
312 WORK( N+J ) = WORK( J )
313 20 CONTINUE
314*
315.GE..AND..LT..AND. IF( ( NBNBMIN ) ( NBSMINMN )
316.LT. $ ( NXSMINMN ) ) THEN
317*
318* Use blocked code initially.
319*
320 J = NFXD + 1
321*
322* Compute factorization: while loop.
323*
324*
325 TOPBMN = MINMN - NX
326 30 CONTINUE
327.LE. IF( JTOPBMN ) THEN
328 JB = MIN( NB, TOPBMN-J+1 )
329*
330* Factorize JB columns among columns J:N.
331*
332 CALL DLAQPS( M, N-J+1, J-1, JB, FJB, A( 1, J ), LDA,
333 $ JPVT( J ), TAU( J ), WORK( J ), WORK( N+J ),
334 $ WORK( 2*N+1 ), WORK( 2*N+JB+1 ), N-J+1 )
335*
336 J = J + FJB
337 GO TO 30
338 END IF
339 ELSE
340 J = NFXD + 1
341 END IF
342*
343* Use unblocked code to factor the last or only block.
344*
345*
346.LE. IF( JMINMN )
347 $ CALL DLAQP2( M, N-J+1, J-1, A( 1, J ), LDA, JPVT( J ),
348 $ TAU( J ), WORK( J ), WORK( N+J ),
349 $ WORK( 2*N+1 ) )
350*
351 END IF
352*
353 WORK( 1 ) = IWS
354 RETURN
355*
356* End of DGEQP3
357*
358 END
subroutine xerbla(srname, info)
XERBLA
Definition xerbla.f:60
subroutine dgeqrf(m, n, a, lda, tau, work, lwork, info)
DGEQRF
Definition dgeqrf.f:146
subroutine dgeqp3(m, n, a, lda, jpvt, tau, work, lwork, info)
DGEQP3
Definition dgeqp3.f:151
subroutine dlaqps(m, n, offset, nb, kb, a, lda, jpvt, tau, vn1, vn2, auxv, f, ldf)
DLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by using BL...
Definition dlaqps.f:177
subroutine dlaqp2(m, n, offset, a, lda, jpvt, tau, vn1, vn2, work)
DLAQP2 computes a QR factorization with column pivoting of the matrix block.
Definition dlaqp2.f:149
subroutine dormqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
DORMQR
Definition dormqr.f:167
subroutine dswap(n, dx, incx, dy, incy)
DSWAP
Definition dswap.f:82
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21