LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dlaqps.f
Go to the documentation of this file.
00001 *> \brief \b DLAQPS
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DLAQPS + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqps.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqps.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqps.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DLAQPS( 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 *       DOUBLE PRECISION   A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
00030 *      $                   VN1( * ), VN2( * )
00031 *       ..
00032 *  
00033 *
00034 *> \par Purpose:
00035 *  =============
00036 *>
00037 *> \verbatim
00038 *>
00039 *> DLAQPS computes a step of QR factorization with column pivoting
00040 *> of a real 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 DOUBLE PRECISION 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 DOUBLE PRECISION array, dimension (KB)
00112 *>          The scalar factors of the elementary reflectors.
00113 *> \endverbatim
00114 *>
00115 *> \param[in,out] VN1
00116 *> \verbatim
00117 *>          VN1 is DOUBLE PRECISION array, dimension (N)
00118 *>          The vector with the partial column norms.
00119 *> \endverbatim
00120 *>
00121 *> \param[in,out] VN2
00122 *> \verbatim
00123 *>          VN2 is DOUBLE PRECISION array, dimension (N)
00124 *>          The vector with the exact column norms.
00125 *> \endverbatim
00126 *>
00127 *> \param[in,out] AUXV
00128 *> \verbatim
00129 *>          AUXV is DOUBLE PRECISION array, dimension (NB)
00130 *>          Auxiliar vector.
00131 *> \endverbatim
00132 *>
00133 *> \param[in,out] F
00134 *> \verbatim
00135 *>          F is DOUBLE PRECISION array, dimension (LDF,NB)
00136 *>          Matrix F**T = L*Y**T*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 doubleOTHERauxiliary
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 *> \n
00163 *>  Partial column norm updating strategy modified on April 2011
00164 *>    Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
00165 *>    University of Zagreb, Croatia.
00166 *
00167 *> \par References:
00168 *  ================
00169 *>
00170 *> LAPACK Working Note 176
00171 *
00172 *> \htmlonly
00173 *> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a> 
00174 *> \endhtmlonly 
00175 *
00176 *  =====================================================================
00177       SUBROUTINE DLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
00178      $                   VN2, AUXV, F, LDF )
00179 *
00180 *  -- LAPACK auxiliary routine (version 3.4.0) --
00181 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00182 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00183 *     November 2011
00184 *
00185 *     .. Scalar Arguments ..
00186       INTEGER            KB, LDA, LDF, M, N, NB, OFFSET
00187 *     ..
00188 *     .. Array Arguments ..
00189       INTEGER            JPVT( * )
00190       DOUBLE PRECISION   A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
00191      $                   VN1( * ), VN2( * )
00192 *     ..
00193 *
00194 *  =====================================================================
00195 *
00196 *     .. Parameters ..
00197       DOUBLE PRECISION   ZERO, ONE
00198       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00199 *     ..
00200 *     .. Local Scalars ..
00201       INTEGER            ITEMP, J, K, LASTRK, LSTICC, PVT, RK
00202       DOUBLE PRECISION   AKK, TEMP, TEMP2, TOL3Z
00203 *     ..
00204 *     .. External Subroutines ..
00205       EXTERNAL           DGEMM, DGEMV, DLARFG, DSWAP
00206 *     ..
00207 *     .. Intrinsic Functions ..
00208       INTRINSIC          ABS, DBLE, MAX, MIN, NINT, SQRT
00209 *     ..
00210 *     .. External Functions ..
00211       INTEGER            IDAMAX
00212       DOUBLE PRECISION   DLAMCH, DNRM2
00213       EXTERNAL           IDAMAX, DLAMCH, DNRM2
00214 *     ..
00215 *     .. Executable Statements ..
00216 *
00217       LASTRK = MIN( M, N+OFFSET )
00218       LSTICC = 0
00219       K = 0
00220       TOL3Z = SQRT(DLAMCH('Epsilon'))
00221 *
00222 *     Beginning of while loop.
00223 *
00224    10 CONTINUE
00225       IF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THEN
00226          K = K + 1
00227          RK = OFFSET + K
00228 *
00229 *        Determine ith pivot column and swap if necessary
00230 *
00231          PVT = ( K-1 ) + IDAMAX( N-K+1, VN1( K ), 1 )
00232          IF( PVT.NE.K ) THEN
00233             CALL DSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 )
00234             CALL DSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF )
00235             ITEMP = JPVT( PVT )
00236             JPVT( PVT ) = JPVT( K )
00237             JPVT( K ) = ITEMP
00238             VN1( PVT ) = VN1( K )
00239             VN2( PVT ) = VN2( K )
00240          END IF
00241 *
00242 *        Apply previous Householder reflectors to column K:
00243 *        A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)**T.
00244 *
00245          IF( K.GT.1 ) THEN
00246             CALL DGEMV( 'No transpose', M-RK+1, K-1, -ONE, A( RK, 1 ),
00247      $                  LDA, F( K, 1 ), LDF, ONE, A( RK, K ), 1 )
00248          END IF
00249 *
00250 *        Generate elementary reflector H(k).
00251 *
00252          IF( RK.LT.M ) THEN
00253             CALL DLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) )
00254          ELSE
00255             CALL DLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) )
00256          END IF
00257 *
00258          AKK = A( RK, K )
00259          A( RK, K ) = ONE
00260 *
00261 *        Compute Kth column of F:
00262 *
00263 *        Compute  F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)**T*A(RK:M,K).
00264 *
00265          IF( K.LT.N ) THEN
00266             CALL DGEMV( 'Transpose', M-RK+1, N-K, TAU( K ),
00267      $                  A( RK, K+1 ), LDA, A( RK, K ), 1, ZERO,
00268      $                  F( K+1, K ), 1 )
00269          END IF
00270 *
00271 *        Padding F(1:K,K) with zeros.
00272 *
00273          DO 20 J = 1, K
00274             F( J, K ) = ZERO
00275    20    CONTINUE
00276 *
00277 *        Incremental updating of F:
00278 *        F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)**T
00279 *                    *A(RK:M,K).
00280 *
00281          IF( K.GT.1 ) THEN
00282             CALL DGEMV( 'Transpose', M-RK+1, K-1, -TAU( K ), A( RK, 1 ),
00283      $                  LDA, A( RK, K ), 1, ZERO, AUXV( 1 ), 1 )
00284 *
00285             CALL DGEMV( 'No transpose', N, K-1, ONE, F( 1, 1 ), LDF,
00286      $                  AUXV( 1 ), 1, ONE, F( 1, K ), 1 )
00287          END IF
00288 *
00289 *        Update the current row of A:
00290 *        A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)**T.
00291 *
00292          IF( K.LT.N ) THEN
00293             CALL DGEMV( 'No transpose', N-K, K, -ONE, F( K+1, 1 ), LDF,
00294      $                  A( RK, 1 ), LDA, ONE, A( RK, K+1 ), LDA )
00295          END IF
00296 *
00297 *        Update partial column norms.
00298 *
00299          IF( RK.LT.LASTRK ) THEN
00300             DO 30 J = K + 1, N
00301                IF( VN1( J ).NE.ZERO ) THEN
00302 *
00303 *                 NOTE: The following 4 lines follow from the analysis in
00304 *                 Lapack Working Note 176.
00305 *
00306                   TEMP = ABS( A( RK, J ) ) / VN1( J )
00307                   TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )
00308                   TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
00309                   IF( TEMP2 .LE. TOL3Z ) THEN
00310                      VN2( J ) = DBLE( LSTICC )
00311                      LSTICC = J
00312                   ELSE
00313                      VN1( J ) = VN1( J )*SQRT( TEMP )
00314                   END IF
00315                END IF
00316    30       CONTINUE
00317          END IF
00318 *
00319          A( RK, K ) = AKK
00320 *
00321 *        End of while loop.
00322 *
00323          GO TO 10
00324       END IF
00325       KB = K
00326       RK = OFFSET + KB
00327 *
00328 *     Apply the block reflector to the rest of the matrix:
00329 *     A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -
00330 *                         A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)**T.
00331 *
00332       IF( KB.LT.MIN( N, M-OFFSET ) ) THEN
00333          CALL DGEMM( 'No transpose', 'Transpose', M-RK, N-KB, KB, -ONE,
00334      $               A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF, ONE,
00335      $               A( RK+1, KB+1 ), LDA )
00336       END IF
00337 *
00338 *     Recomputation of difficult columns.
00339 *
00340    40 CONTINUE
00341       IF( LSTICC.GT.0 ) THEN
00342          ITEMP = NINT( VN2( LSTICC ) )
00343          VN1( LSTICC ) = DNRM2( M-RK, A( RK+1, LSTICC ), 1 )
00344 *
00345 *        NOTE: The computation of VN1( LSTICC ) relies on the fact that 
00346 *        SNRM2 does not fail on vectors with norm below the value of
00347 *        SQRT(DLAMCH('S')) 
00348 *
00349          VN2( LSTICC ) = VN1( LSTICC )
00350          LSTICC = ITEMP
00351          GO TO 40
00352       END IF
00353 *
00354       RETURN
00355 *
00356 *     End of DLAQPS
00357 *
00358       END
 All Files Functions