1 *> \brief \b SLAQP2 computes a QR factorization with column pivoting of the matrix block.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SLAQP2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaqp2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaqp2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaqp2.f">
21 * SUBROUTINE SLAQP2( M, N, OFFSET, A, LDA, JPVT, TAU, VN1, VN2,
24 * .. Scalar Arguments ..
25 * INTEGER LDA, M, N, OFFSET
27 * .. Array Arguments ..
29 * REAL A( LDA, * ), TAU( * ), VN1( * ), VN2( * ),
39 *> SLAQP2 computes a QR factorization with column pivoting of
40 *> the block A(OFFSET+1:M,1:N).
41 *> The block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.
50 *> The number of rows of the matrix A. M >= 0.
56 *> The number of columns of the matrix A. N >= 0.
62 *> The number of rows of the matrix A that must be pivoted
63 *> but no factorized. OFFSET >= 0.
68 *> A is REAL array, dimension (LDA,N)
69 *> On entry, the M-by-N matrix A.
70 *> On exit, the upper triangle of block A(OFFSET+1:M,1:N) is
71 *> the triangular factor obtained; the elements in block
72 *> A(OFFSET+1:M,1:N) below the diagonal, together with the
73 *> array TAU, represent the orthogonal matrix Q as a product of
74 *> elementary reflectors. Block A(1:OFFSET,1:N) has been
75 *> accordingly pivoted, but no factorized.
81 *> The leading dimension of the array A. LDA >= max(1,M).
84 *> \param[in,out] JPVT
86 *> JPVT is INTEGER array, dimension (N)
87 *> On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted
88 *> to the front of A*P (a leading column); if JPVT(i) = 0,
89 *> the i-th column of A is a free column.
90 *> On exit, if JPVT(i) = k, then the i-th column of A*P
91 *> was the k-th column of A.
96 *> TAU is REAL array, dimension (min(M,N))
97 *> The scalar factors of the elementary reflectors.
100 *> \param[in,out] VN1
102 *> VN1 is REAL array, dimension (N)
103 *> The vector with the partial column norms.
106 *> \param[in,out] VN2
108 *> VN2 is REAL array, dimension (N)
109 *> The vector with the exact column norms.
114 *> WORK is REAL array, dimension (N)
120 *> \author Univ. of Tennessee
121 *> \author Univ. of California Berkeley
122 *> \author Univ. of Colorado Denver
125 *> \date September 2012
127 *> \ingroup realOTHERauxiliary
129 *> \par Contributors:
132 *> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
133 *> X. Sun, Computer Science Dept., Duke University, USA
135 *> Partial column norm updating strategy modified on April 2011
136 *> Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
137 *> University of Zagreb, Croatia.
142 *> LAPACK Working Note 176
145 *> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a>
148 * =====================================================================
149 SUBROUTINE SLAQP2( M, N, OFFSET, A, LDA, JPVT, TAU, VN1, VN2,
152 * -- LAPACK auxiliary routine (version 3.4.2) --
153 * -- LAPACK is a software package provided by Univ. of Tennessee, --
154 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
157 * .. Scalar Arguments ..
158 INTEGER LDA, M, N, OFFSET
160 * .. Array Arguments ..
162 REAL A( LDA, * ), TAU( * ), VN1( * ), VN2( * ),
166 * =====================================================================
170 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
172 * .. Local Scalars ..
173 INTEGER I, ITEMP, J, MN, OFFPI, PVT
174 REAL AII, TEMP, TEMP2, TOL3Z
176 * .. External Subroutines ..
177 EXTERNAL SLARF, SLARFG, SSWAP
179 * .. Intrinsic Functions ..
180 INTRINSIC ABS, MAX, MIN, SQRT
182 * .. External Functions ..
185 EXTERNAL ISAMAX, SLAMCH, SNRM2
187 * .. Executable Statements ..
189 MN = MIN( M-OFFSET, N )
190 TOL3Z = SQRT(SLAMCH('Epsilon'))
192 * Compute factorization.
198 * Determine ith pivot column and swap if necessary.
200 PVT = ( I-1 ) + ISAMAX( N-I+1, VN1( I ), 1 )
203 CALL SSWAP( M, A( 1, PVT ), 1, A( 1, I ), 1 )
205 JPVT( PVT ) = JPVT( I )
207 VN1( PVT ) = VN1( I )
208 VN2( PVT ) = VN2( I )
211 * Generate elementary reflector H(i).
213 IF( OFFPI.LT.M ) THEN
214 CALL SLARFG( M-OFFPI+1, A( OFFPI, I ), A( OFFPI+1, I ), 1,
217 CALL SLARFG( 1, A( M, I ), A( M, I ), 1, TAU( I ) )
222 * Apply H(i)**T to A(offset+i:m,i+1:n) from the left.
226 CALL SLARF( 'Left', M-OFFPI+1, N-I, A( OFFPI, I ), 1,
227 $ TAU( I ), A( OFFPI, I+1 ), LDA, WORK( 1 ) )
231 * Update partial column norms.
234 IF( VN1( J ).NE.ZERO ) THEN
236 * NOTE: The following 4 lines follow from the analysis in
237 * Lapack Working Note 176.
239 TEMP = ONE - ( ABS( A( OFFPI, J ) ) / VN1( J ) )**2
240 TEMP = MAX( TEMP, ZERO )
241 TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
242 IF( TEMP2 .LE. TOL3Z ) THEN
243 IF( OFFPI.LT.M ) THEN
244 VN1( J ) = SNRM2( M-OFFPI, A( OFFPI+1, J ), 1 )
251 VN1( J ) = VN1( J )*SQRT( TEMP )