LAPACK 3.3.0
|
00001 SUBROUTINE ZLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1, 00002 $ VN2, AUXV, F, LDF ) 00003 * 00004 * -- LAPACK auxiliary routine (version 3.2.2) -- 00005 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00006 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00007 * June 2010 00008 * 00009 * .. Scalar Arguments .. 00010 INTEGER KB, LDA, LDF, M, N, NB, OFFSET 00011 * .. 00012 * .. Array Arguments .. 00013 INTEGER JPVT( * ) 00014 DOUBLE PRECISION VN1( * ), VN2( * ) 00015 COMPLEX*16 A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ) 00016 * .. 00017 * 00018 * Purpose 00019 * ======= 00020 * 00021 * ZLAQPS computes a step of QR factorization with column pivoting 00022 * of a complex M-by-N matrix A by using Blas-3. It tries to factorize 00023 * NB columns from A starting from the row OFFSET+1, and updates all 00024 * of the matrix with Blas-3 xGEMM. 00025 * 00026 * In some cases, due to catastrophic cancellations, it cannot 00027 * factorize NB columns. Hence, the actual number of factorized 00028 * columns is returned in KB. 00029 * 00030 * Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized. 00031 * 00032 * Arguments 00033 * ========= 00034 * 00035 * M (input) INTEGER 00036 * The number of rows of the matrix A. M >= 0. 00037 * 00038 * N (input) INTEGER 00039 * The number of columns of the matrix A. N >= 0 00040 * 00041 * OFFSET (input) INTEGER 00042 * The number of rows of A that have been factorized in 00043 * previous steps. 00044 * 00045 * NB (input) INTEGER 00046 * The number of columns to factorize. 00047 * 00048 * KB (output) INTEGER 00049 * The number of columns actually factorized. 00050 * 00051 * A (input/output) COMPLEX*16 array, dimension (LDA,N) 00052 * On entry, the M-by-N matrix A. 00053 * On exit, block A(OFFSET+1:M,1:KB) is the triangular 00054 * factor obtained and block A(1:OFFSET,1:N) has been 00055 * accordingly pivoted, but no factorized. 00056 * The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has 00057 * been updated. 00058 * 00059 * LDA (input) INTEGER 00060 * The leading dimension of the array A. LDA >= max(1,M). 00061 * 00062 * JPVT (input/output) INTEGER array, dimension (N) 00063 * JPVT(I) = K <==> Column K of the full matrix A has been 00064 * permuted into position I in AP. 00065 * 00066 * TAU (output) COMPLEX*16 array, dimension (KB) 00067 * The scalar factors of the elementary reflectors. 00068 * 00069 * VN1 (input/output) DOUBLE PRECISION array, dimension (N) 00070 * The vector with the partial column norms. 00071 * 00072 * VN2 (input/output) DOUBLE PRECISION array, dimension (N) 00073 * The vector with the exact column norms. 00074 * 00075 * AUXV (input/output) COMPLEX*16 array, dimension (NB) 00076 * Auxiliar vector. 00077 * 00078 * F (input/output) COMPLEX*16 array, dimension (LDF,NB) 00079 * Matrix F' = L*Y'*A. 00080 * 00081 * LDF (input) INTEGER 00082 * The leading dimension of the array F. LDF >= max(1,N). 00083 * 00084 * Further Details 00085 * =============== 00086 * 00087 * Based on contributions by 00088 * G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain 00089 * X. Sun, Computer Science Dept., Duke University, USA 00090 * 00091 * ===================================================================== 00092 * 00093 * .. Parameters .. 00094 DOUBLE PRECISION ZERO, ONE 00095 COMPLEX*16 CZERO, CONE 00096 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, 00097 $ CZERO = ( 0.0D+0, 0.0D+0 ), 00098 $ CONE = ( 1.0D+0, 0.0D+0 ) ) 00099 * .. 00100 * .. Local Scalars .. 00101 INTEGER ITEMP, J, K, LASTRK, LSTICC, PVT, RK 00102 DOUBLE PRECISION TEMP, TEMP2, TOL3Z 00103 COMPLEX*16 AKK 00104 * .. 00105 * .. External Subroutines .. 00106 EXTERNAL ZGEMM, ZGEMV, ZLARFG, ZSWAP 00107 * .. 00108 * .. Intrinsic Functions .. 00109 INTRINSIC ABS, DBLE, DCONJG, MAX, MIN, NINT, SQRT 00110 * .. 00111 * .. External Functions .. 00112 INTEGER IDAMAX 00113 DOUBLE PRECISION DLAMCH, DZNRM2 00114 EXTERNAL IDAMAX, DLAMCH, DZNRM2 00115 * .. 00116 * .. Executable Statements .. 00117 * 00118 LASTRK = MIN( M, N+OFFSET ) 00119 LSTICC = 0 00120 K = 0 00121 TOL3Z = SQRT(DLAMCH('Epsilon')) 00122 * 00123 * Beginning of while loop. 00124 * 00125 10 CONTINUE 00126 IF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THEN 00127 K = K + 1 00128 RK = OFFSET + K 00129 * 00130 * Determine ith pivot column and swap if necessary 00131 * 00132 PVT = ( K-1 ) + IDAMAX( N-K+1, VN1( K ), 1 ) 00133 IF( PVT.NE.K ) THEN 00134 CALL ZSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 ) 00135 CALL ZSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF ) 00136 ITEMP = JPVT( PVT ) 00137 JPVT( PVT ) = JPVT( K ) 00138 JPVT( K ) = ITEMP 00139 VN1( PVT ) = VN1( K ) 00140 VN2( PVT ) = VN2( K ) 00141 END IF 00142 * 00143 * Apply previous Householder reflectors to column K: 00144 * A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)'. 00145 * 00146 IF( K.GT.1 ) THEN 00147 DO 20 J = 1, K - 1 00148 F( K, J ) = DCONJG( F( K, J ) ) 00149 20 CONTINUE 00150 CALL ZGEMV( 'No transpose', M-RK+1, K-1, -CONE, A( RK, 1 ), 00151 $ LDA, F( K, 1 ), LDF, CONE, A( RK, K ), 1 ) 00152 DO 30 J = 1, K - 1 00153 F( K, J ) = DCONJG( F( K, J ) ) 00154 30 CONTINUE 00155 END IF 00156 * 00157 * Generate elementary reflector H(k). 00158 * 00159 IF( RK.LT.M ) THEN 00160 CALL ZLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) ) 00161 ELSE 00162 CALL ZLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) ) 00163 END IF 00164 * 00165 AKK = A( RK, K ) 00166 A( RK, K ) = CONE 00167 * 00168 * Compute Kth column of F: 00169 * 00170 * Compute F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)'*A(RK:M,K). 00171 * 00172 IF( K.LT.N ) THEN 00173 CALL ZGEMV( 'Conjugate transpose', M-RK+1, N-K, TAU( K ), 00174 $ A( RK, K+1 ), LDA, A( RK, K ), 1, CZERO, 00175 $ F( K+1, K ), 1 ) 00176 END IF 00177 * 00178 * Padding F(1:K,K) with zeros. 00179 * 00180 DO 40 J = 1, K 00181 F( J, K ) = CZERO 00182 40 CONTINUE 00183 * 00184 * Incremental updating of F: 00185 * F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)' 00186 * *A(RK:M,K). 00187 * 00188 IF( K.GT.1 ) THEN 00189 CALL ZGEMV( 'Conjugate transpose', M-RK+1, K-1, -TAU( K ), 00190 $ A( RK, 1 ), LDA, A( RK, K ), 1, CZERO, 00191 $ AUXV( 1 ), 1 ) 00192 * 00193 CALL ZGEMV( 'No transpose', N, K-1, CONE, F( 1, 1 ), LDF, 00194 $ AUXV( 1 ), 1, CONE, F( 1, K ), 1 ) 00195 END IF 00196 * 00197 * Update the current row of A: 00198 * A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)'. 00199 * 00200 IF( K.LT.N ) THEN 00201 CALL ZGEMM( 'No transpose', 'Conjugate transpose', 1, N-K, 00202 $ K, -CONE, A( RK, 1 ), LDA, F( K+1, 1 ), LDF, 00203 $ CONE, A( RK, K+1 ), LDA ) 00204 END IF 00205 * 00206 * Update partial column norms. 00207 * 00208 IF( RK.LT.LASTRK ) THEN 00209 DO 50 J = K + 1, N 00210 IF( VN1( J ).NE.ZERO ) THEN 00211 * 00212 * NOTE: The following 4 lines follow from the analysis in 00213 * Lapack Working Note 176. 00214 * 00215 TEMP = ABS( A( RK, J ) ) / VN1( J ) 00216 TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) ) 00217 TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2 00218 IF( TEMP2 .LE. TOL3Z ) THEN 00219 VN2( J ) = DBLE( LSTICC ) 00220 LSTICC = J 00221 ELSE 00222 VN1( J ) = VN1( J )*SQRT( TEMP ) 00223 END IF 00224 END IF 00225 50 CONTINUE 00226 END IF 00227 * 00228 A( RK, K ) = AKK 00229 * 00230 * End of while loop. 00231 * 00232 GO TO 10 00233 END IF 00234 KB = K 00235 RK = OFFSET + KB 00236 * 00237 * Apply the block reflector to the rest of the matrix: 00238 * A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) - 00239 * A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)'. 00240 * 00241 IF( KB.LT.MIN( N, M-OFFSET ) ) THEN 00242 CALL ZGEMM( 'No transpose', 'Conjugate transpose', M-RK, N-KB, 00243 $ KB, -CONE, A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF, 00244 $ CONE, A( RK+1, KB+1 ), LDA ) 00245 END IF 00246 * 00247 * Recomputation of difficult columns. 00248 * 00249 60 CONTINUE 00250 IF( LSTICC.GT.0 ) THEN 00251 ITEMP = NINT( VN2( LSTICC ) ) 00252 VN1( LSTICC ) = DZNRM2( M-RK, A( RK+1, LSTICC ), 1 ) 00253 * 00254 * NOTE: The computation of VN1( LSTICC ) relies on the fact that 00255 * SNRM2 does not fail on vectors with norm below the value of 00256 * SQRT(DLAMCH('S')) 00257 * 00258 VN2( LSTICC ) = VN1( LSTICC ) 00259 LSTICC = ITEMP 00260 GO TO 60 00261 END IF 00262 * 00263 RETURN 00264 * 00265 * End of ZLAQPS 00266 * 00267 END