File:  [local] / rpl / lapack / lapack / dlaqps.f
Revision 1.21: download - view: text, annotated - select for diffs - revision graph
Mon Aug 7 08:38:55 2023 UTC (8 months, 3 weeks ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_35, rpl-4_1_34, HEAD
Première mise à jour de lapack et blas.

    1: *> \brief \b DLAQPS computes a step of QR factorization with column pivoting of a real m-by-n matrix A by using BLAS level 3.
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at
    6: *            http://www.netlib.org/lapack/explore-html/
    7: *
    8: *> \htmlonly
    9: *> Download DLAQPS + dependencies
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqps.f">
   11: *> [TGZ]</a>
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqps.f">
   13: *> [ZIP]</a>
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqps.f">
   15: *> [TXT]</a>
   16: *> \endhtmlonly
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE DLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
   22: *                          VN2, AUXV, F, LDF )
   23: *
   24: *       .. Scalar Arguments ..
   25: *       INTEGER            KB, LDA, LDF, M, N, NB, OFFSET
   26: *       ..
   27: *       .. Array Arguments ..
   28: *       INTEGER            JPVT( * )
   29: *       DOUBLE PRECISION   A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
   30: *      $                   VN1( * ), VN2( * )
   31: *       ..
   32: *
   33: *
   34: *> \par Purpose:
   35: *  =============
   36: *>
   37: *> \verbatim
   38: *>
   39: *> DLAQPS computes a step of QR factorization with column pivoting
   40: *> of a real M-by-N matrix A by using Blas-3.  It tries to factorize
   41: *> NB columns from A starting from the row OFFSET+1, and updates all
   42: *> of the matrix with Blas-3 xGEMM.
   43: *>
   44: *> In some cases, due to catastrophic cancellations, it cannot
   45: *> factorize NB columns.  Hence, the actual number of factorized
   46: *> columns is returned in KB.
   47: *>
   48: *> Block A(1:OFFSET,1:N) is accordingly pivoted, but not factorized.
   49: *> \endverbatim
   50: *
   51: *  Arguments:
   52: *  ==========
   53: *
   54: *> \param[in] M
   55: *> \verbatim
   56: *>          M is INTEGER
   57: *>          The number of rows of the matrix A. M >= 0.
   58: *> \endverbatim
   59: *>
   60: *> \param[in] N
   61: *> \verbatim
   62: *>          N is INTEGER
   63: *>          The number of columns of the matrix A. N >= 0
   64: *> \endverbatim
   65: *>
   66: *> \param[in] OFFSET
   67: *> \verbatim
   68: *>          OFFSET is INTEGER
   69: *>          The number of rows of A that have been factorized in
   70: *>          previous steps.
   71: *> \endverbatim
   72: *>
   73: *> \param[in] NB
   74: *> \verbatim
   75: *>          NB is INTEGER
   76: *>          The number of columns to factorize.
   77: *> \endverbatim
   78: *>
   79: *> \param[out] KB
   80: *> \verbatim
   81: *>          KB is INTEGER
   82: *>          The number of columns actually factorized.
   83: *> \endverbatim
   84: *>
   85: *> \param[in,out] A
   86: *> \verbatim
   87: *>          A is DOUBLE PRECISION array, dimension (LDA,N)
   88: *>          On entry, the M-by-N matrix A.
   89: *>          On exit, block A(OFFSET+1:M,1:KB) is the triangular
   90: *>          factor obtained and block A(1:OFFSET,1:N) has been
   91: *>          accordingly pivoted, but no factorized.
   92: *>          The rest of the matrix, block A(OFFSET+1:M,KB+1:N) has
   93: *>          been updated.
   94: *> \endverbatim
   95: *>
   96: *> \param[in] LDA
   97: *> \verbatim
   98: *>          LDA is INTEGER
   99: *>          The leading dimension of the array A. LDA >= max(1,M).
  100: *> \endverbatim
  101: *>
  102: *> \param[in,out] JPVT
  103: *> \verbatim
  104: *>          JPVT is INTEGER array, dimension (N)
  105: *>          JPVT(I) = K <==> Column K of the full matrix A has been
  106: *>          permuted into position I in AP.
  107: *> \endverbatim
  108: *>
  109: *> \param[out] TAU
  110: *> \verbatim
  111: *>          TAU is DOUBLE PRECISION array, dimension (KB)
  112: *>          The scalar factors of the elementary reflectors.
  113: *> \endverbatim
  114: *>
  115: *> \param[in,out] VN1
  116: *> \verbatim
  117: *>          VN1 is DOUBLE PRECISION array, dimension (N)
  118: *>          The vector with the partial column norms.
  119: *> \endverbatim
  120: *>
  121: *> \param[in,out] VN2
  122: *> \verbatim
  123: *>          VN2 is DOUBLE PRECISION array, dimension (N)
  124: *>          The vector with the exact column norms.
  125: *> \endverbatim
  126: *>
  127: *> \param[in,out] AUXV
  128: *> \verbatim
  129: *>          AUXV is DOUBLE PRECISION array, dimension (NB)
  130: *>          Auxiliary vector.
  131: *> \endverbatim
  132: *>
  133: *> \param[in,out] F
  134: *> \verbatim
  135: *>          F is DOUBLE PRECISION array, dimension (LDF,NB)
  136: *>          Matrix F**T = L*Y**T*A.
  137: *> \endverbatim
  138: *>
  139: *> \param[in] LDF
  140: *> \verbatim
  141: *>          LDF is INTEGER
  142: *>          The leading dimension of the array F. LDF >= max(1,N).
  143: *> \endverbatim
  144: *
  145: *  Authors:
  146: *  ========
  147: *
  148: *> \author Univ. of Tennessee
  149: *> \author Univ. of California Berkeley
  150: *> \author Univ. of Colorado Denver
  151: *> \author NAG Ltd.
  152: *
  153: *> \ingroup doubleOTHERauxiliary
  154: *
  155: *> \par Contributors:
  156: *  ==================
  157: *>
  158: *>    G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
  159: *>    X. Sun, Computer Science Dept., Duke University, USA
  160: *> \n
  161: *>  Partial column norm updating strategy modified on April 2011
  162: *>    Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
  163: *>    University of Zagreb, Croatia.
  164: *
  165: *> \par References:
  166: *  ================
  167: *>
  168: *> LAPACK Working Note 176
  169: *
  170: *> \htmlonly
  171: *> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">[PDF]</a>
  172: *> \endhtmlonly
  173: *
  174: *  =====================================================================
  175:       SUBROUTINE DLAQPS( M, N, OFFSET, NB, KB, A, LDA, JPVT, TAU, VN1,
  176:      $                   VN2, AUXV, F, LDF )
  177: *
  178: *  -- LAPACK auxiliary routine --
  179: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  180: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  181: *
  182: *     .. Scalar Arguments ..
  183:       INTEGER            KB, LDA, LDF, M, N, NB, OFFSET
  184: *     ..
  185: *     .. Array Arguments ..
  186:       INTEGER            JPVT( * )
  187:       DOUBLE PRECISION   A( LDA, * ), AUXV( * ), F( LDF, * ), TAU( * ),
  188:      $                   VN1( * ), VN2( * )
  189: *     ..
  190: *
  191: *  =====================================================================
  192: *
  193: *     .. Parameters ..
  194:       DOUBLE PRECISION   ZERO, ONE
  195:       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
  196: *     ..
  197: *     .. Local Scalars ..
  198:       INTEGER            ITEMP, J, K, LASTRK, LSTICC, PVT, RK
  199:       DOUBLE PRECISION   AKK, TEMP, TEMP2, TOL3Z
  200: *     ..
  201: *     .. External Subroutines ..
  202:       EXTERNAL           DGEMM, DGEMV, DLARFG, DSWAP
  203: *     ..
  204: *     .. Intrinsic Functions ..
  205:       INTRINSIC          ABS, DBLE, MAX, MIN, NINT, SQRT
  206: *     ..
  207: *     .. External Functions ..
  208:       INTEGER            IDAMAX
  209:       DOUBLE PRECISION   DLAMCH, DNRM2
  210:       EXTERNAL           IDAMAX, DLAMCH, DNRM2
  211: *     ..
  212: *     .. Executable Statements ..
  213: *
  214:       LASTRK = MIN( M, N+OFFSET )
  215:       LSTICC = 0
  216:       K = 0
  217:       TOL3Z = SQRT(DLAMCH('Epsilon'))
  218: *
  219: *     Beginning of while loop.
  220: *
  221:    10 CONTINUE
  222:       IF( ( K.LT.NB ) .AND. ( LSTICC.EQ.0 ) ) THEN
  223:          K = K + 1
  224:          RK = OFFSET + K
  225: *
  226: *        Determine ith pivot column and swap if necessary
  227: *
  228:          PVT = ( K-1 ) + IDAMAX( N-K+1, VN1( K ), 1 )
  229:          IF( PVT.NE.K ) THEN
  230:             CALL DSWAP( M, A( 1, PVT ), 1, A( 1, K ), 1 )
  231:             CALL DSWAP( K-1, F( PVT, 1 ), LDF, F( K, 1 ), LDF )
  232:             ITEMP = JPVT( PVT )
  233:             JPVT( PVT ) = JPVT( K )
  234:             JPVT( K ) = ITEMP
  235:             VN1( PVT ) = VN1( K )
  236:             VN2( PVT ) = VN2( K )
  237:          END IF
  238: *
  239: *        Apply previous Householder reflectors to column K:
  240: *        A(RK:M,K) := A(RK:M,K) - A(RK:M,1:K-1)*F(K,1:K-1)**T.
  241: *
  242:          IF( K.GT.1 ) THEN
  243:             CALL DGEMV( 'No transpose', M-RK+1, K-1, -ONE, A( RK, 1 ),
  244:      $                  LDA, F( K, 1 ), LDF, ONE, A( RK, K ), 1 )
  245:          END IF
  246: *
  247: *        Generate elementary reflector H(k).
  248: *
  249:          IF( RK.LT.M ) THEN
  250:             CALL DLARFG( M-RK+1, A( RK, K ), A( RK+1, K ), 1, TAU( K ) )
  251:          ELSE
  252:             CALL DLARFG( 1, A( RK, K ), A( RK, K ), 1, TAU( K ) )
  253:          END IF
  254: *
  255:          AKK = A( RK, K )
  256:          A( RK, K ) = ONE
  257: *
  258: *        Compute Kth column of F:
  259: *
  260: *        Compute  F(K+1:N,K) := tau(K)*A(RK:M,K+1:N)**T*A(RK:M,K).
  261: *
  262:          IF( K.LT.N ) THEN
  263:             CALL DGEMV( 'Transpose', M-RK+1, N-K, TAU( K ),
  264:      $                  A( RK, K+1 ), LDA, A( RK, K ), 1, ZERO,
  265:      $                  F( K+1, K ), 1 )
  266:          END IF
  267: *
  268: *        Padding F(1:K,K) with zeros.
  269: *
  270:          DO 20 J = 1, K
  271:             F( J, K ) = ZERO
  272:    20    CONTINUE
  273: *
  274: *        Incremental updating of F:
  275: *        F(1:N,K) := F(1:N,K) - tau(K)*F(1:N,1:K-1)*A(RK:M,1:K-1)**T
  276: *                    *A(RK:M,K).
  277: *
  278:          IF( K.GT.1 ) THEN
  279:             CALL DGEMV( 'Transpose', M-RK+1, K-1, -TAU( K ), A( RK, 1 ),
  280:      $                  LDA, A( RK, K ), 1, ZERO, AUXV( 1 ), 1 )
  281: *
  282:             CALL DGEMV( 'No transpose', N, K-1, ONE, F( 1, 1 ), LDF,
  283:      $                  AUXV( 1 ), 1, ONE, F( 1, K ), 1 )
  284:          END IF
  285: *
  286: *        Update the current row of A:
  287: *        A(RK,K+1:N) := A(RK,K+1:N) - A(RK,1:K)*F(K+1:N,1:K)**T.
  288: *
  289:          IF( K.LT.N ) THEN
  290:             CALL DGEMV( 'No transpose', N-K, K, -ONE, F( K+1, 1 ), LDF,
  291:      $                  A( RK, 1 ), LDA, ONE, A( RK, K+1 ), LDA )
  292:          END IF
  293: *
  294: *        Update partial column norms.
  295: *
  296:          IF( RK.LT.LASTRK ) THEN
  297:             DO 30 J = K + 1, N
  298:                IF( VN1( J ).NE.ZERO ) THEN
  299: *
  300: *                 NOTE: The following 4 lines follow from the analysis in
  301: *                 Lapack Working Note 176.
  302: *
  303:                   TEMP = ABS( A( RK, J ) ) / VN1( J )
  304:                   TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )
  305:                   TEMP2 = TEMP*( VN1( J ) / VN2( J ) )**2
  306:                   IF( TEMP2 .LE. TOL3Z ) THEN
  307:                      VN2( J ) = DBLE( LSTICC )
  308:                      LSTICC = J
  309:                   ELSE
  310:                      VN1( J ) = VN1( J )*SQRT( TEMP )
  311:                   END IF
  312:                END IF
  313:    30       CONTINUE
  314:          END IF
  315: *
  316:          A( RK, K ) = AKK
  317: *
  318: *        End of while loop.
  319: *
  320:          GO TO 10
  321:       END IF
  322:       KB = K
  323:       RK = OFFSET + KB
  324: *
  325: *     Apply the block reflector to the rest of the matrix:
  326: *     A(OFFSET+KB+1:M,KB+1:N) := A(OFFSET+KB+1:M,KB+1:N) -
  327: *                         A(OFFSET+KB+1:M,1:KB)*F(KB+1:N,1:KB)**T.
  328: *
  329:       IF( KB.LT.MIN( N, M-OFFSET ) ) THEN
  330:          CALL DGEMM( 'No transpose', 'Transpose', M-RK, N-KB, KB, -ONE,
  331:      $               A( RK+1, 1 ), LDA, F( KB+1, 1 ), LDF, ONE,
  332:      $               A( RK+1, KB+1 ), LDA )
  333:       END IF
  334: *
  335: *     Recomputation of difficult columns.
  336: *
  337:    40 CONTINUE
  338:       IF( LSTICC.GT.0 ) THEN
  339:          ITEMP = NINT( VN2( LSTICC ) )
  340:          VN1( LSTICC ) = DNRM2( M-RK, A( RK+1, LSTICC ), 1 )
  341: *
  342: *        NOTE: The computation of VN1( LSTICC ) relies on the fact that
  343: *        SNRM2 does not fail on vectors with norm below the value of
  344: *        SQRT(DLAMCH('S'))
  345: *
  346:          VN2( LSTICC ) = VN1( LSTICC )
  347:          LSTICC = ITEMP
  348:          GO TO 40
  349:       END IF
  350: *
  351:       RETURN
  352: *
  353: *     End of DLAQPS
  354: *
  355:       END

CVSweb interface <joel.bertrand@systella.fr>