LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
claqps.f
Go to the documentation of this file.
00001 *> \brief \b CLAQPS
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CLAQPS + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/claqps.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/claqps.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/claqps.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE CLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
00022 *                          VN2, AUXV, F, LDF )
00023 * 
00024 *       .. Scalar Arguments ..
00025 *       INTEGER            KB, LDA, LDF, M, N, NB, OFFSET
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       INTEGER            JPVT( * )
00029 *       REAL               VN1( * ), VN2( * )
00030 *       COMPLEX            A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * )
00031 *       ..
00032 *  
00033 *
00034 *> \par Purpose:
00035 *  =============
00036 *>
00037 *> \verbatim
00038 *>
00039 *> CLAQPS computes a step of QR factorization with column pivoting
00040 *> of a complex M-by-N matrix A by using Blas-3.  It tries to factorize
00041 *> NB columns from A starting from the row OFFSET+1, and updates all
00042 *> of the matrix with Blas-3 xGEMM.
00043 *>
00044 *> In some cases, due to catastrophic cancellations, it cannot
00045 *> factorize NB columns.  Hence, the actual number of factorized
00046 *> columns is returned in KB.
00047 *>
00048 *> Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.
00049 *> \endverbatim
00050 *
00051 *  Arguments:
00052 *  ==========
00053 *
00054 *> \param[in] M
00055 *> \verbatim
00056 *>          M is INTEGER
00057 *>          The number of rows of the matrix A. M >= 0.
00058 *> \endverbatim
00059 *>
00060 *> \param[in] N
00061 *> \verbatim
00062 *>          N is INTEGER
00063 *>          The number of columns of the matrix A. N >= 0
00064 *> \endverbatim
00065 *>
00066 *> \param[in] OFFSET
00067 *> \verbatim
00068 *>          OFFSET is INTEGER
00069 *>          The number of rows of A that have been factorized in
00070 *>          previous steps.
00071 *> \endverbatim
00072 *>
00073 *> \param[in] NB
00074 *> \verbatim
00075 *>          NB is INTEGER
00076 *>          The number of columns to factorize.
00077 *> \endverbatim
00078 *>
00079 *> \param[out] KB
00080 *> \verbatim
00081 *>          KB is INTEGER
00082 *>          The number of columns actually factorized.
00083 *> \endverbatim
00084 *>
00085 *> \param[in,out] A
00086 *> \verbatim
00087 *>          A is COMPLEX array, dimension (LDA,N)
00088 *>          On entry, the M-by-N matrix A.
00089 *>          On exit, block A(OFFSET+1:M,1:KB) is the triangular
00090 *>          factor obtained and block A(1:OFFSET,1:N) has been
00091 *>          accordingly pivoted, but no factorized.
00092 *>          The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has
00093 *>          been updated.
00094 *> \endverbatim
00095 *>
00096 *> \param[in] LDA
00097 *> \verbatim
00098 *>          LDA is INTEGER
00099 *>          The leading dimension of the array A. LDA >= max(1,M).
00100 *> \endverbatim
00101 *>
00102 *> \param[in,out] JPVT
00103 *> \verbatim
00104 *>          JPVT is INTEGER array, dimension (N)
00105 *>          JPVT(I) = K <==> Column K of the full matrix A has been
00106 *>          permuted into position I in AP.
00107 *> \endverbatim
00108 *>
00109 *> \param[out] TAU
00110 *> \verbatim
00111 *>          TAU is COMPLEX array, dimension (KB)
00112 *>          The scalar factors of the elementary reflectors.
00113 *> \endverbatim
00114 *>
00115 *> \param[in,out] VN1
00116 *> \verbatim
00117 *>          VN1 is REAL array, dimension (N)
00118 *>          The vector with the partial column norms.
00119 *> \endverbatim
00120 *>
00121 *> \param[in,out] VN2
00122 *> \verbatim
00123 *>          VN2 is REAL array, dimension (N)
00124 *>          The vector with the exact column norms.
00125 *> \endverbatim
00126 *>
00127 *> \param[in,out] AUXV
00128 *> \verbatim
00129 *>          AUXV is COMPLEX array, dimension (NB)
00130 *>          Auxiliar vector.
00131 *> \endverbatim
00132 *>
00133 *> \param[in,out] F
00134 *> \verbatim
00135 *>          F is COMPLEX array, dimension (LDF,NB)
00136 *>          Matrix  F**H = L * Y**H * A.
00137 *> \endverbatim
00138 *>
00139 *> \param[in] LDF
00140 *> \verbatim
00141 *>          LDF is INTEGER
00142 *>          The leading dimension of the array F. LDF >= max(1,N).
00143 *> \endverbatim
00144 *
00145 *  Authors:
00146 *  ========
00147 *
00148 *> \author Univ. of Tennessee 
00149 *> \author Univ. of California Berkeley 
00150 *> \author Univ. of Colorado Denver 
00151 *> \author NAG Ltd. 
00152 *
00153 *> \date November 2011
00154 *
00155 *> \ingroup complexOTHERauxiliary
00156 *
00157 *> \par Contributors:
00158 *  ==================
00159 *>
00160 *>    G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
00161 *>    X. Sun, Computer Science Dept., Duke University, USA
00162 *>
00163 *> \n
00164 *>  Partial column norm updating strategy modified on April 2011
00165 *>    Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
00166 *>    University of Zagreb, Croatia.
00167 *
00168 *> \par References:
00169 *  ================
00170 *>
00171 *> LAPACK Working Note 176
00172 *
00173 *> \htmlonly
00174 *> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a> 
00175 *> \endhtmlonly 
00176 *
00177 *  =====================================================================
00178       SUBROUTINE CLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
00179      $                   VN2, AUXV, F, LDF )
00180 *
00181 *  -- LAPACK auxiliary routine (version 3.4.0) --
00182 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00183 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00184 *     November 2011
00185 *
00186 *     .. Scalar Arguments ..
00187       INTEGER            KB, LDA, LDF, M, N, NB, OFFSET
00188 *     ..
00189 *     .. Array Arguments ..
00190       INTEGER            JPVT( * )
00191       REAL               VN1( * ), VN2( * )
00192       COMPLEX            A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * )
00193 *     ..
00194 *
00195 *  =====================================================================
00196 *
00197 *     .. Parameters ..
00198       REAL               ZERO, ONE
00199       COMPLEX            CZERO, CONE
00200       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0,
00201      $                   CZERO = ( 0.0E+0, 0.0E+0 ),
00202      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00203 *     ..
00204 *     .. Local Scalars ..
00205       INTEGER            ITEMP, J, K, LASTRK, LSTICC, PVT, RK
00206       REAL               TEMP, TEMP2, TOL3Z
00207       COMPLEX            AKK
00208 *     ..
00209 *     .. External Subroutines ..
00210       EXTERNAL           CGEMM, CGEMV, CLARFG, CSWAP
00211 *     ..
00212 *     .. Intrinsic Functions ..
00213       INTRINSIC          ABS, CONJG, MAX, MIN, NINT, REAL, SQRT
00214 *     ..
00215 *     .. External Functions ..
00216       INTEGER            ISAMAX
00217       REAL               SCNRM2, SLAMCH
00218       EXTERNAL           ISAMAX, SCNRM2, SLAMCH
00219 *     ..
00220 *     .. Executable Statements ..
00221 *
00222       LASTRK = MIN( M, N+OFFSET )
00223       LSTICC = 0
00224       K = 0
00225       TOL3Z = SQRT(SLAMCH('Epsilon'))
00226 *
00227 *     Beginning of while loop.
00228 *
00229    10 CONTINUE
00230       IF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THEN
00231          K = K + 1
00232          RK = OFFSET + K
00233 *
00234 *        Determine ith pivot column and swap if necessary
00235 *
00236          PVT = ( K-1 ) + ISAMAX( N-K+1, VN1( K ), 1 )
00237          IF( PVT.NE.K ) THEN
00238             CALL CSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 )
00239             CALL CSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF )
00240             ITEMP = JPVT( PVT )
00241             JPVT( PVT ) = JPVT( K )
00242             JPVT( K ) = ITEMP
00243             VN1( PVT ) = VN1( K )
00244             VN2( PVT ) = VN2( K )
00245          END IF
00246 *
00247 *        Apply previous Householder reflectors to column K:
00248 *        A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)**H.
00249 *
00250          IF( K.GT.1 ) THEN
00251             DO 20 J = 1, K - 1
00252                F( K, J ) = CONJG( F( K, J ) )
00253    20       CONTINUE
00254             CALL CGEMV( 'No transpose', M-RK+1, K-1, -CONE, A( RK, 1 ),
00255      $                  LDA, F( K, 1 ), LDF, CONE, A( RK, K ), 1 )
00256             DO 30 J = 1, K - 1
00257                F( K, J ) = CONJG( F( K, J ) )
00258    30       CONTINUE
00259          END IF
00260 *
00261 *        Generate elementary reflector H(k).
00262 *
00263          IF( RK.LT.M ) THEN
00264             CALL CLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) )
00265          ELSE
00266             CALL CLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) )
00267          END IF
00268 *
00269          AKK = A( RK, K )
00270          A( RK, K ) = CONE
00271 *
00272 *        Compute Kth column of F:
00273 *
00274 *        Compute  F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)**H*A(RK:M,K).
00275 *
00276          IF( K.LT.N ) THEN
00277             CALL CGEMV( 'Conjugate transpose', M-RK+1, N-K, TAU( K ),
00278      $                  A( RK, K+1 ), LDA, A( RK, K ), 1, CZERO,
00279      $                  F( K+1, K ), 1 )
00280          END IF
00281 *
00282 *        Padding F(1:K,K) with zeros.
00283 *
00284          DO 40 J = 1, K
00285             F( J, K ) = CZERO
00286    40    CONTINUE
00287 *
00288 *        Incremental updating of F:
00289 *        F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)**H
00290 *                    *A(RK:M,K).
00291 *
00292          IF( K.GT.1 ) THEN
00293             CALL CGEMV( 'Conjugate transpose', M-RK+1, K-1, -TAU( K ),
00294      $                  A( RK, 1 ), LDA, A( RK, K ), 1, CZERO,
00295      $                  AUXV( 1 ), 1 )
00296 *
00297             CALL CGEMV( 'No transpose', N, K-1, CONE, F( 1, 1 ), LDF,
00298      $                  AUXV( 1 ), 1, CONE, F( 1, K ), 1 )
00299          END IF
00300 *
00301 *        Update the current row of A:
00302 *        A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)**H.
00303 *
00304          IF( K.LT.N ) THEN
00305             CALL CGEMM( 'No transpose', 'Conjugate transpose', 1, N-K,
00306      $                  K, -CONE, A( RK, 1 ), LDA, F( K+1, 1 ), LDF,
00307      $                  CONE, A( RK, K+1 ), LDA )
00308          END IF
00309 *
00310 *        Update partial column norms.
00311 *
00312          IF( RK.LT.LASTRK ) THEN
00313             DO 50 J = K + 1, N
00314                IF( VN1( J ).NE.ZERO ) THEN
00315 *
00316 *                 NOTE: The following 4 lines follow from the analysis in
00317 *                 Lapack Working Note 176.
00318 *
00319                   TEMP = ABS( A( RK, J ) ) / VN1( J )
00320                   TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )
00321                   TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
00322                   IF( TEMP2 .LE. TOL3Z ) THEN
00323                      VN2( J ) = REAL( LSTICC )
00324                      LSTICC = J
00325                   ELSE
00326                      VN1( J ) = VN1( J )*SQRT( TEMP )
00327                   END IF
00328                END IF
00329    50       CONTINUE
00330          END IF
00331 *
00332          A( RK, K ) = AKK
00333 *
00334 *        End of while loop.
00335 *
00336          GO TO 10
00337       END IF
00338       KB = K
00339       RK = OFFSET + KB
00340 *
00341 *     Apply the block reflector to the rest of the matrix:
00342 *     A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -
00343 *                         A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)**H.
00344 *
00345       IF( KB.LT.MIN( N, M-OFFSET ) ) THEN
00346          CALL CGEMM( 'No transpose', 'Conjugate transpose', M-RK, N-KB,
00347      $               KB, -CONE, A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF,
00348      $               CONE, A( RK+1, KB+1 ), LDA )
00349       END IF
00350 *
00351 *     Recomputation of difficult columns.
00352 *
00353    60 CONTINUE
00354       IF( LSTICC.GT.0 ) THEN
00355          ITEMP = NINT( VN2( LSTICC ) )
00356          VN1( LSTICC ) = SCNRM2( M-RK, A( RK+1, LSTICC ), 1 )
00357 *
00358 *        NOTE: The computation of VN1( LSTICC ) relies on the fact that 
00359 *        SNRM2 does not fail on vectors with norm below the value of
00360 *        SQRT(DLAMCH('S')) 
00361 *
00362          VN2( LSTICC ) = VN1( LSTICC )
00363          LSTICC = ITEMP
00364          GO TO 60
00365       END IF
00366 *
00367       RETURN
00368 *
00369 *     End of CLAQPS
00370 *
00371       END
 All Files Functions