LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
slaqps.f
Go to the documentation of this file.
1*> \brief \b SLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by using BLAS level 3.
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download SLAQPS + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaqps.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaqps.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaqps.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE SLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
20* VN2, AUXV, F, LDF )
21*
22* .. Scalar Arguments ..
23* INTEGER KB, LDA, LDF, M, N, NB, OFFSET
24* ..
25* .. Array Arguments ..
26* INTEGER JPVT( * )
27* REAL A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
28* $ VN1( * ), VN2( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> SLAQPS computes a step of QR factorization with column pivoting
38*> of a real M-by-N matrix A by using Blas-3. It tries to factorize
39*> NB columns from A starting from the row OFFSET+1, and updates all
40*> of the matrix with Blas-3 xGEMM.
41*>
42*> In some cases, due to catastrophic cancellations, it cannot
43*> factorize NB columns. Hence, the actual number of factorized
44*> columns is returned in KB.
45*>
46*> Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.
47*> \endverbatim
48*
49* Arguments:
50* ==========
51*
52*> \param[in] M
53*> \verbatim
54*> M is INTEGER
55*> The number of rows of the matrix A. M >= 0.
56*> \endverbatim
57*>
58*> \param[in] N
59*> \verbatim
60*> N is INTEGER
61*> The number of columns of the matrix A. N >= 0
62*> \endverbatim
63*>
64*> \param[in] OFFSET
65*> \verbatim
66*> OFFSET is INTEGER
67*> The number of rows of A that have been factorized in
68*> previous steps.
69*> \endverbatim
70*>
71*> \param[in] NB
72*> \verbatim
73*> NB is INTEGER
74*> The number of columns to factorize.
75*> \endverbatim
76*>
77*> \param[out] KB
78*> \verbatim
79*> KB is INTEGER
80*> The number of columns actually factorized.
81*> \endverbatim
82*>
83*> \param[in,out] A
84*> \verbatim
85*> A is REAL array, dimension (LDA,N)
86*> On entry, the M-by-N matrix A.
87*> On exit, block A(OFFSET+1:M,1:KB) is the triangular
88*> factor obtained and block A(1:OFFSET,1:N) has been
89*> accordingly pivoted, but no factorized.
90*> The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has
91*> been updated.
92*> \endverbatim
93*>
94*> \param[in] LDA
95*> \verbatim
96*> LDA is INTEGER
97*> The leading dimension of the array A. LDA >= max(1,M).
98*> \endverbatim
99*>
100*> \param[in,out] JPVT
101*> \verbatim
102*> JPVT is INTEGER array, dimension (N)
103*> JPVT(I) = K <==> Column K of the full matrix A has been
104*> permuted into position I in AP.
105*> \endverbatim
106*>
107*> \param[out] TAU
108*> \verbatim
109*> TAU is REAL array, dimension (KB)
110*> The scalar factors of the elementary reflectors.
111*> \endverbatim
112*>
113*> \param[in,out] VN1
114*> \verbatim
115*> VN1 is REAL array, dimension (N)
116*> The vector with the partial column norms.
117*> \endverbatim
118*>
119*> \param[in,out] VN2
120*> \verbatim
121*> VN2 is REAL array, dimension (N)
122*> The vector with the exact column norms.
123*> \endverbatim
124*>
125*> \param[in,out] AUXV
126*> \verbatim
127*> AUXV is REAL array, dimension (NB)
128*> Auxiliary vector.
129*> \endverbatim
130*>
131*> \param[in,out] F
132*> \verbatim
133*> F is REAL array, dimension (LDF,NB)
134*> Matrix F**T = L*Y**T*A.
135*> \endverbatim
136*>
137*> \param[in] LDF
138*> \verbatim
139*> LDF is INTEGER
140*> The leading dimension of the array F. LDF >= max(1,N).
141*> \endverbatim
142*
143* Authors:
144* ========
145*
146*> \author Univ. of Tennessee
147*> \author Univ. of California Berkeley
148*> \author Univ. of Colorado Denver
149*> \author NAG Ltd.
150*
151*> \ingroup laqps
152*
153*> \par Contributors:
154* ==================
155*>
156*> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
157*> X. Sun, Computer Science Dept., Duke University, USA
158*>
159*> \n
160*> Partial column norm updating strategy modified on April 2011
161*> Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
162*> University of Zagreb, Croatia.
163*
164*> \par References:
165* ================
166*>
167*> LAPACK Working Note 176
168*
169*> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a>
170*
171* =====================================================================
172 SUBROUTINE slaqps( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU,
173 $ VN1,
174 $ VN2, AUXV, F, LDF )
175*
176* -- LAPACK auxiliary routine --
177* -- LAPACK is a software package provided by Univ. of Tennessee, --
178* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179*
180* .. Scalar Arguments ..
181 INTEGER KB, LDA, LDF, M, N, NB, OFFSET
182* ..
183* .. Array Arguments ..
184 INTEGER JPVT( * )
185 REAL A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
186 $ vn1( * ), vn2( * )
187* ..
188*
189* =====================================================================
190*
191* .. Parameters ..
192 REAL ZERO, ONE
193 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
194* ..
195* .. Local Scalars ..
196 INTEGER ITEMP, J, K, LASTRK, LSTICC, PVT, RK
197 REAL AKK, TEMP, TEMP2, TOL3Z
198* ..
199* .. External Subroutines ..
200 EXTERNAL sgemm, sgemv, slarfg, sswap
201* ..
202* .. Intrinsic Functions ..
203 INTRINSIC abs, max, min, nint, real, sqrt
204* ..
205* .. External Functions ..
206 INTEGER ISAMAX
207 REAL SLAMCH, SNRM2
208 EXTERNAL isamax, slamch, snrm2
209* ..
210* .. Executable Statements ..
211*
212 lastrk = min( m, n+offset )
213 lsticc = 0
214 k = 0
215 tol3z = sqrt(slamch('Epsilon'))
216*
217* Beginning of while loop.
218*
219 10 CONTINUE
220 IF( ( k.LT.nb ) .AND. ( lsticc.EQ.0 ) ) THEN
221 k = k + 1
222 rk = offset + k
223*
224* Determine ith pivot column and swap if necessary
225*
226 pvt = ( k-1 ) + isamax( n-k+1, vn1( k ), 1 )
227 IF( pvt.NE.k ) THEN
228 CALL sswap( m, a( 1, pvt ), 1, a( 1, k ), 1 )
229 CALL sswap( k-1, f( pvt, 1 ), ldf, f( k, 1 ), ldf )
230 itemp = jpvt( pvt )
231 jpvt( pvt ) = jpvt( k )
232 jpvt( k ) = itemp
233 vn1( pvt ) = vn1( k )
234 vn2( pvt ) = vn2( k )
235 END IF
236*
237* Apply previous Householder reflectors to column K:
238* A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)**T.
239*
240 IF( k.GT.1 ) THEN
241 CALL sgemv( 'No transpose', m-rk+1, k-1, -one, a( rk,
242 $ 1 ),
243 $ lda, f( k, 1 ), ldf, one, a( rk, k ), 1 )
244 END IF
245*
246* Generate elementary reflector H(k).
247*
248 IF( rk.LT.m ) THEN
249 CALL slarfg( m-rk+1, a( rk, k ), a( rk+1, k ), 1,
250 $ tau( k ) )
251 ELSE
252 CALL slarfg( 1, a( rk, k ), a( rk, k ), 1, tau( k ) )
253 END IF
254*
255 akk = a( rk, k )
256 a( rk, k ) = one
257*
258* Compute Kth column of F:
259*
260* Compute F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)**T*A(RK:M,K).
261*
262 IF( k.LT.n ) THEN
263 CALL sgemv( 'Transpose', m-rk+1, n-k, tau( k ),
264 $ a( rk, k+1 ), lda, a( rk, k ), 1, zero,
265 $ f( k+1, k ), 1 )
266 END IF
267*
268* Padding F(1:K,K) with zeros.
269*
270 DO 20 j = 1, k
271 f( j, k ) = zero
272 20 CONTINUE
273*
274* Incremental updating of F:
275* F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)**T
276* *A(RK:M,K).
277*
278 IF( k.GT.1 ) THEN
279 CALL sgemv( 'Transpose', m-rk+1, k-1, -tau( k ), a( rk,
280 $ 1 ),
281 $ lda, a( rk, k ), 1, zero, auxv( 1 ), 1 )
282*
283 CALL sgemv( 'No transpose', n, k-1, one, f( 1, 1 ), ldf,
284 $ auxv( 1 ), 1, one, f( 1, k ), 1 )
285 END IF
286*
287* Update the current row of A:
288* A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)**T.
289*
290 IF( k.LT.n ) THEN
291 CALL sgemv( 'No transpose', n-k, k, -one, f( k+1, 1 ),
292 $ ldf,
293 $ a( rk, 1 ), lda, one, a( rk, k+1 ), lda )
294 END IF
295*
296* Update partial column norms.
297*
298 IF( rk.LT.lastrk ) THEN
299 DO 30 j = k + 1, n
300 IF( vn1( j ).NE.zero ) THEN
301*
302* NOTE: The following 4 lines follow from the analysis in
303* Lapack Working Note 176.
304*
305 temp = abs( a( rk, j ) ) / vn1( j )
306 temp = max( zero, ( one+temp )*( one-temp ) )
307 temp2 = temp*( vn1( j ) / vn2( j ) )**2
308 IF( temp2 .LE. tol3z ) THEN
309 vn2( j ) = real( lsticc )
310 lsticc = j
311 ELSE
312 vn1( j ) = vn1( j )*sqrt( temp )
313 END IF
314 END IF
315 30 CONTINUE
316 END IF
317*
318 a( rk, k ) = akk
319*
320* End of while loop.
321*
322 GO TO 10
323 END IF
324 kb = k
325 rk = offset + kb
326*
327* Apply the block reflector to the rest of the matrix:
328* A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -
329* A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)**T.
330*
331 IF( kb.LT.min( n, m-offset ) ) THEN
332 CALL sgemm( 'No transpose', 'Transpose', m-rk, n-kb, kb,
333 $ -one,
334 $ a( rk+1, 1 ), lda, f( kb+1, 1 ), ldf, one,
335 $ a( rk+1, kb+1 ), lda )
336 END IF
337*
338* Recomputation of difficult columns.
339*
340 40 CONTINUE
341 IF( lsticc.GT.0 ) THEN
342 itemp = nint( vn2( lsticc ) )
343 vn1( lsticc ) = snrm2( m-rk, a( rk+1, lsticc ), 1 )
344*
345* NOTE: The computation of VN1( LSTICC ) relies on the fact that
346* SNRM2 does not fail on vectors with norm below the value of
347* SQRT(DLAMCH('S'))
348*
349 vn2( lsticc ) = vn1( lsticc )
350 lsticc = itemp
351 GO TO 40
352 END IF
353*
354 RETURN
355*
356* End of SLAQPS
357*
358 END
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:188
subroutine sgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
SGEMV
Definition sgemv.f:158
subroutine slaqps(m, n, offset, nb, kb, a, lda, jpvt, tau, vn1, vn2, auxv, f, ldf)
SLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by using BL...
Definition slaqps.f:175
subroutine slarfg(n, alpha, x, incx, tau)
SLARFG generates an elementary reflector (Householder matrix).
Definition slarfg.f:104
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
Definition sswap.f:82