1 *> \brief \b CLAQP2 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 CLAQP2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/claqp2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/claqp2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/claqp2.f">
21 * SUBROUTINE CLAQP2( M, N, OFFSET, A, LDA, JPVT, TAU, VN1, VN2,
24 * .. Scalar Arguments ..
25 * INTEGER LDA, M, N, OFFSET
27 * .. Array Arguments ..
29 * REAL VN1( * ), VN2( * )
30 * COMPLEX A( LDA, * ), TAU( * ), WORK( * )
39 *> CLAQP2 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 COMPLEX 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 COMPLEX 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 COMPLEX 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 complexOTHERauxiliary
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 CLAQP2( 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 VN1( * ), VN2( * )
163 COMPLEX A( LDA, * ), TAU( * ), WORK( * )
166 * =====================================================================
171 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0,
172 $ CONE = ( 1.0E+0, 0.0E+0 ) )
174 * .. Local Scalars ..
175 INTEGER I, ITEMP, J, MN, OFFPI, PVT
176 REAL TEMP, TEMP2, TOL3Z
179 * .. External Subroutines ..
180 EXTERNAL CLARF, CLARFG, CSWAP
182 * .. Intrinsic Functions ..
183 INTRINSIC ABS, CONJG, MAX, MIN, SQRT
185 * .. External Functions ..
188 EXTERNAL ISAMAX, SCNRM2, SLAMCH
190 * .. Executable Statements ..
192 MN = MIN( M-OFFSET, N )
193 TOL3Z = SQRT(SLAMCH('Epsilon'))
195 * Compute factorization.
201 * Determine ith pivot column and swap if necessary.
203 PVT = ( I-1 ) + ISAMAX( N-I+1, VN1( I ), 1 )
206 CALL CSWAP( M, A( 1, PVT ), 1, A( 1, I ), 1 )
208 JPVT( PVT ) = JPVT( I )
210 VN1( PVT ) = VN1( I )
211 VN2( PVT ) = VN2( I )
214 * Generate elementary reflector H(i).
216 IF( OFFPI.LT.M ) THEN
217 CALL CLARFG( M-OFFPI+1, A( OFFPI, I ), A( OFFPI+1, I ), 1,
220 CALL CLARFG( 1, A( M, I ), A( M, I ), 1, TAU( I ) )
225 * Apply H(i)**H to A(offset+i:m,i+1:n) from the left.
229 CALL CLARF( 'Left', M-OFFPI+1, N-I, A( OFFPI, I ), 1,
230 $ CONJG( TAU( I ) ), A( OFFPI, I+1 ), LDA,
235 * Update partial column norms.
238 IF( VN1( J ).NE.ZERO ) THEN
240 * NOTE: The following 4 lines follow from the analysis in
241 * Lapack Working Note 176.
243 TEMP = ONE - ( ABS( A( OFFPI, J ) ) / VN1( J ) )**2
244 TEMP = MAX( TEMP, ZERO )
245 TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
246 IF( TEMP2 .LE. TOL3Z ) THEN
247 IF( OFFPI.LT.M ) THEN
248 VN1( J ) = SCNRM2( M-OFFPI, A( OFFPI+1, J ), 1 )
255 VN1( J ) = VN1( J )*SQRT( TEMP )