LAPACK 3.3.0

claqps.f

Go to the documentation of this file.
00001       SUBROUTINE CLAQPS( 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       REAL               VN1( * ), VN2( * )
00015       COMPLEX            A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  CLAQPS 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 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 array, dimension (KB)
00067 *          The scalar factors of the elementary reflectors.
00068 *
00069 *  VN1     (input/output) REAL array, dimension (N)
00070 *          The vector with the partial column norms.
00071 *
00072 *  VN2     (input/output) REAL array, dimension (N)
00073 *          The vector with the exact column norms.
00074 *
00075 *  AUXV    (input/output) COMPLEX array, dimension (NB)
00076 *          Auxiliar vector.
00077 *
00078 *  F       (input/output) COMPLEX 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 *  Partial column norm updating strategy modified by
00092 *    Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
00093 *    University of Zagreb, Croatia.
00094 *     June 2010
00095 *  For more details see LAPACK Working Note 176.
00096 *  =====================================================================
00097 *
00098 *     .. Parameters ..
00099       REAL               ZERO, ONE
00100       COMPLEX            CZERO, CONE
00101       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0,
00102      $                   CZERO = ( 0.0E+0, 0.0E+0 ),
00103      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00104 *     ..
00105 *     .. Local Scalars ..
00106       INTEGER            ITEMP, J, K, LASTRK, LSTICC, PVT, RK
00107       REAL               TEMP, TEMP2, TOL3Z
00108       COMPLEX            AKK
00109 *     ..
00110 *     .. External Subroutines ..
00111       EXTERNAL           CGEMM, CGEMV, CLARFG, CSWAP
00112 *     ..
00113 *     .. Intrinsic Functions ..
00114       INTRINSIC          ABS, CONJG, MAX, MIN, NINT, REAL, SQRT
00115 *     ..
00116 *     .. External Functions ..
00117       INTEGER            ISAMAX
00118       REAL               SCNRM2, SLAMCH
00119       EXTERNAL           ISAMAX, SCNRM2, SLAMCH
00120 *     ..
00121 *     .. Executable Statements ..
00122 *
00123       LASTRK = MIN( M, N+OFFSET )
00124       LSTICC = 0
00125       K = 0
00126       TOL3Z = SQRT(SLAMCH('Epsilon'))
00127 *
00128 *     Beginning of while loop.
00129 *
00130    10 CONTINUE
00131       IF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THEN
00132          K = K + 1
00133          RK = OFFSET + K
00134 *
00135 *        Determine ith pivot column and swap if necessary
00136 *
00137          PVT = ( K-1 ) + ISAMAX( N-K+1, VN1( K ), 1 )
00138          IF( PVT.NE.K ) THEN
00139             CALL CSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 )
00140             CALL CSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF )
00141             ITEMP = JPVT( PVT )
00142             JPVT( PVT ) = JPVT( K )
00143             JPVT( K ) = ITEMP
00144             VN1( PVT ) = VN1( K )
00145             VN2( PVT ) = VN2( K )
00146          END IF
00147 *
00148 *        Apply previous Householder reflectors to column K:
00149 *        A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)'.
00150 *
00151          IF( K.GT.1 ) THEN
00152             DO 20 J = 1, K - 1
00153                F( K, J ) = CONJG( F( K, J ) )
00154    20       CONTINUE
00155             CALL CGEMV( 'No transpose', M-RK+1, K-1, -CONE, A( RK, 1 ),
00156      $                  LDA, F( K, 1 ), LDF, CONE, A( RK, K ), 1 )
00157             DO 30 J = 1, K - 1
00158                F( K, J ) = CONJG( F( K, J ) )
00159    30       CONTINUE
00160          END IF
00161 *
00162 *        Generate elementary reflector H(k).
00163 *
00164          IF( RK.LT.M ) THEN
00165             CALL CLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) )
00166          ELSE
00167             CALL CLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) )
00168          END IF
00169 *
00170          AKK = A( RK, K )
00171          A( RK, K ) = CONE
00172 *
00173 *        Compute Kth column of F:
00174 *
00175 *        Compute  F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)'*A(RK:M,K).
00176 *
00177          IF( K.LT.N ) THEN
00178             CALL CGEMV( 'Conjugate transpose', M-RK+1, N-K, TAU( K ),
00179      $                  A( RK, K+1 ), LDA, A( RK, K ), 1, CZERO,
00180      $                  F( K+1, K ), 1 )
00181          END IF
00182 *
00183 *        Padding F(1:K,K) with zeros.
00184 *
00185          DO 40 J = 1, K
00186             F( J, K ) = CZERO
00187    40    CONTINUE
00188 *
00189 *        Incremental updating of F:
00190 *        F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)'
00191 *                    *A(RK:M,K).
00192 *
00193          IF( K.GT.1 ) THEN
00194             CALL CGEMV( 'Conjugate transpose', M-RK+1, K-1, -TAU( K ),
00195      $                  A( RK, 1 ), LDA, A( RK, K ), 1, CZERO,
00196      $                  AUXV( 1 ), 1 )
00197 *
00198             CALL CGEMV( 'No transpose', N, K-1, CONE, F( 1, 1 ), LDF,
00199      $                  AUXV( 1 ), 1, CONE, F( 1, K ), 1 )
00200          END IF
00201 *
00202 *        Update the current row of A:
00203 *        A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)'.
00204 *
00205          IF( K.LT.N ) THEN
00206             CALL CGEMM( 'No transpose', 'Conjugate transpose', 1, N-K,
00207      $                  K, -CONE, A( RK, 1 ), LDA, F( K+1, 1 ), LDF,
00208      $                  CONE, A( RK, K+1 ), LDA )
00209          END IF
00210 *
00211 *        Update partial column norms.
00212 *
00213          IF( RK.LT.LASTRK ) THEN
00214             DO 50 J = K + 1, N
00215                IF( VN1( J ).NE.ZERO ) THEN
00216 *
00217 *                 NOTE: The following 4 lines follow from the analysis in
00218 *                 Lapack Working Note 176.
00219 *
00220                   TEMP = ABS( A( RK, J ) ) / VN1( J )
00221                   TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )
00222                   TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
00223                   IF( TEMP2 .LE. TOL3Z ) THEN
00224                      VN2( J ) = REAL( LSTICC )
00225                      LSTICC = J
00226                   ELSE
00227                      VN1( J ) = VN1( J )*SQRT( TEMP )
00228                   END IF
00229                END IF
00230    50       CONTINUE
00231          END IF
00232 *
00233          A( RK, K ) = AKK
00234 *
00235 *        End of while loop.
00236 *
00237          GO TO 10
00238       END IF
00239       KB = K
00240       RK = OFFSET + KB
00241 *
00242 *     Apply the block reflector to the rest of the matrix:
00243 *     A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -
00244 *                         A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)'.
00245 *
00246       IF( KB.LT.MIN( N, M-OFFSET ) ) THEN
00247          CALL CGEMM( 'No transpose', 'Conjugate transpose', M-RK, N-KB,
00248      $               KB, -CONE, A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF,
00249      $               CONE, A( RK+1, KB+1 ), LDA )
00250       END IF
00251 *
00252 *     Recomputation of difficult columns.
00253 *
00254    60 CONTINUE
00255       IF( LSTICC.GT.0 ) THEN
00256          ITEMP = NINT( VN2( LSTICC ) )
00257          VN1( LSTICC ) = SCNRM2( M-RK, A( RK+1, LSTICC ), 1 )
00258 *
00259 *        NOTE: The computation of VN1( LSTICC ) relies on the fact that 
00260 *        SNRM2 does not fail on vectors with norm below the value of
00261 *        SQRT(DLAMCH('S')) 
00262 *
00263          VN2( LSTICC ) = VN1( LSTICC )
00264          LSTICC = ITEMP
00265          GO TO 60
00266       END IF
00267 *
00268       RETURN
00269 *
00270 *     End of CLAQPS
00271 *
00272       END
 All Files Functions