File:  [local] / rpl / lapack / lapack / dgeqpf.f
Revision 1.19: download - view: text, annotated - select for diffs - revision graph
Mon Aug 7 08:38:49 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 DGEQPF
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at
    6: *            http://www.netlib.org/lapack/explore-html/
    7: *
    8: *> \htmlonly
    9: *> Download DGEQPF + dependencies
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgeqpf.f">
   11: *> [TGZ]</a>
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgeqpf.f">
   13: *> [ZIP]</a>
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgeqpf.f">
   15: *> [TXT]</a>
   16: *> \endhtmlonly
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE DGEQPF( M, N, A, LDA, JPVT, TAU, WORK, INFO )
   22: *
   23: *       .. Scalar Arguments ..
   24: *       INTEGER            INFO, LDA, M, N
   25: *       ..
   26: *       .. Array Arguments ..
   27: *       INTEGER            JPVT( * )
   28: *       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
   29: *       ..
   30: *
   31: *
   32: *> \par Purpose:
   33: *  =============
   34: *>
   35: *> \verbatim
   36: *>
   37: *> This routine is deprecated and has been replaced by routine DGEQP3.
   38: *>
   39: *> DGEQPF computes a QR factorization with column pivoting of a
   40: *> real M-by-N matrix A: A*P = Q*R.
   41: *> \endverbatim
   42: *
   43: *  Arguments:
   44: *  ==========
   45: *
   46: *> \param[in] M
   47: *> \verbatim
   48: *>          M is INTEGER
   49: *>          The number of rows of the matrix A. M >= 0.
   50: *> \endverbatim
   51: *>
   52: *> \param[in] N
   53: *> \verbatim
   54: *>          N is INTEGER
   55: *>          The number of columns of the matrix A. N >= 0
   56: *> \endverbatim
   57: *>
   58: *> \param[in,out] A
   59: *> \verbatim
   60: *>          A is DOUBLE PRECISION array, dimension (LDA,N)
   61: *>          On entry, the M-by-N matrix A.
   62: *>          On exit, the upper triangle of the array contains the
   63: *>          min(M,N)-by-N upper triangular matrix R; the elements
   64: *>          below the diagonal, together with the array TAU,
   65: *>          represent the orthogonal matrix Q as a product of
   66: *>          min(m,n) elementary reflectors.
   67: *> \endverbatim
   68: *>
   69: *> \param[in] LDA
   70: *> \verbatim
   71: *>          LDA is INTEGER
   72: *>          The leading dimension of the array A. LDA >= max(1,M).
   73: *> \endverbatim
   74: *>
   75: *> \param[in,out] JPVT
   76: *> \verbatim
   77: *>          JPVT is INTEGER array, dimension (N)
   78: *>          On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted
   79: *>          to the front of A*P (a leading column); if JPVT(i) = 0,
   80: *>          the i-th column of A is a free column.
   81: *>          On exit, if JPVT(i) = k, then the i-th column of A*P
   82: *>          was the k-th column of A.
   83: *> \endverbatim
   84: *>
   85: *> \param[out] TAU
   86: *> \verbatim
   87: *>          TAU is DOUBLE PRECISION array, dimension (min(M,N))
   88: *>          The scalar factors of the elementary reflectors.
   89: *> \endverbatim
   90: *>
   91: *> \param[out] WORK
   92: *> \verbatim
   93: *>          WORK is DOUBLE PRECISION array, dimension (3*N)
   94: *> \endverbatim
   95: *>
   96: *> \param[out] INFO
   97: *> \verbatim
   98: *>          INFO is INTEGER
   99: *>          = 0:  successful exit
  100: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
  101: *> \endverbatim
  102: *
  103: *  Authors:
  104: *  ========
  105: *
  106: *> \author Univ. of Tennessee
  107: *> \author Univ. of California Berkeley
  108: *> \author Univ. of Colorado Denver
  109: *> \author NAG Ltd.
  110: *
  111: *> \ingroup doubleGEcomputational
  112: *
  113: *> \par Further Details:
  114: *  =====================
  115: *>
  116: *> \verbatim
  117: *>
  118: *>  The matrix Q is represented as a product of elementary reflectors
  119: *>
  120: *>     Q = H(1) H(2) . . . H(n)
  121: *>
  122: *>  Each H(i) has the form
  123: *>
  124: *>     H = I - tau * v * v**T
  125: *>
  126: *>  where tau is a real scalar, and v is a real vector with
  127: *>  v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i).
  128: *>
  129: *>  The matrix P is represented in jpvt as follows: If
  130: *>     jpvt(j) = i
  131: *>  then the jth column of P is the ith canonical unit vector.
  132: *>
  133: *>  Partial column norm updating strategy modified by
  134: *>    Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
  135: *>    University of Zagreb, Croatia.
  136: *>  -- April 2011                                                      --
  137: *>  For more details see LAPACK Working Note 176.
  138: *> \endverbatim
  139: *>
  140: *  =====================================================================
  141:       SUBROUTINE DGEQPF( M, N, A, LDA, JPVT, TAU, WORK, INFO )
  142: *
  143: *  -- LAPACK computational routine --
  144: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  145: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  146: *
  147: *     .. Scalar Arguments ..
  148:       INTEGER            INFO, LDA, M, N
  149: *     ..
  150: *     .. Array Arguments ..
  151:       INTEGER            JPVT( * )
  152:       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
  153: *     ..
  154: *
  155: *  =====================================================================
  156: *
  157: *     .. Parameters ..
  158:       DOUBLE PRECISION   ZERO, ONE
  159:       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
  160: *     ..
  161: *     .. Local Scalars ..
  162:       INTEGER            I, ITEMP, J, MA, MN, PVT
  163:       DOUBLE PRECISION   AII, TEMP, TEMP2, TOL3Z
  164: *     ..
  165: *     .. External Subroutines ..
  166:       EXTERNAL           DGEQR2, DLARF, DLARFG, DORM2R, DSWAP, XERBLA
  167: *     ..
  168: *     .. Intrinsic Functions ..
  169:       INTRINSIC          ABS, MAX, MIN, SQRT
  170: *     ..
  171: *     .. External Functions ..
  172:       INTEGER            IDAMAX
  173:       DOUBLE PRECISION   DLAMCH, DNRM2
  174:       EXTERNAL           IDAMAX, DLAMCH, DNRM2
  175: *     ..
  176: *     .. Executable Statements ..
  177: *
  178: *     Test the input arguments
  179: *
  180:       INFO = 0
  181:       IF( M.LT.0 ) THEN
  182:          INFO = -1
  183:       ELSE IF( N.LT.0 ) THEN
  184:          INFO = -2
  185:       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  186:          INFO = -4
  187:       END IF
  188:       IF( INFO.NE.0 ) THEN
  189:          CALL XERBLA( 'DGEQPF', -INFO )
  190:          RETURN
  191:       END IF
  192: *
  193:       MN = MIN( M, N )
  194:       TOL3Z = SQRT(DLAMCH('Epsilon'))
  195: *
  196: *     Move initial columns up front
  197: *
  198:       ITEMP = 1
  199:       DO 10 I = 1, N
  200:          IF( JPVT( I ).NE.0 ) THEN
  201:             IF( I.NE.ITEMP ) THEN
  202:                CALL DSWAP( M, A( 1, I ), 1, A( 1, ITEMP ), 1 )
  203:                JPVT( I ) = JPVT( ITEMP )
  204:                JPVT( ITEMP ) = I
  205:             ELSE
  206:                JPVT( I ) = I
  207:             END IF
  208:             ITEMP = ITEMP + 1
  209:          ELSE
  210:             JPVT( I ) = I
  211:          END IF
  212:    10 CONTINUE
  213:       ITEMP = ITEMP - 1
  214: *
  215: *     Compute the QR factorization and update remaining columns
  216: *
  217:       IF( ITEMP.GT.0 ) THEN
  218:          MA = MIN( ITEMP, M )
  219:          CALL DGEQR2( M, MA, A, LDA, TAU, WORK, INFO )
  220:          IF( MA.LT.N ) THEN
  221:             CALL DORM2R( 'Left', 'Transpose', M, N-MA, MA, A, LDA, TAU,
  222:      $                   A( 1, MA+1 ), LDA, WORK, INFO )
  223:          END IF
  224:       END IF
  225: *
  226:       IF( ITEMP.LT.MN ) THEN
  227: *
  228: *        Initialize partial column norms. The first n elements of
  229: *        work store the exact column norms.
  230: *
  231:          DO 20 I = ITEMP + 1, N
  232:             WORK( I ) = DNRM2( M-ITEMP, A( ITEMP+1, I ), 1 )
  233:             WORK( N+I ) = WORK( I )
  234:    20    CONTINUE
  235: *
  236: *        Compute factorization
  237: *
  238:          DO 40 I = ITEMP + 1, MN
  239: *
  240: *           Determine ith pivot column and swap if necessary
  241: *
  242:             PVT = ( I-1 ) + IDAMAX( N-I+1, WORK( I ), 1 )
  243: *
  244:             IF( PVT.NE.I ) THEN
  245:                CALL DSWAP( M, A( 1, PVT ), 1, A( 1, I ), 1 )
  246:                ITEMP = JPVT( PVT )
  247:                JPVT( PVT ) = JPVT( I )
  248:                JPVT( I ) = ITEMP
  249:                WORK( PVT ) = WORK( I )
  250:                WORK( N+PVT ) = WORK( N+I )
  251:             END IF
  252: *
  253: *           Generate elementary reflector H(i)
  254: *
  255:             IF( I.LT.M ) THEN
  256:                CALL DLARFG( M-I+1, A( I, I ), A( I+1, I ), 1, TAU( I ) )
  257:             ELSE
  258:                CALL DLARFG( 1, A( M, M ), A( M, M ), 1, TAU( M ) )
  259:             END IF
  260: *
  261:             IF( I.LT.N ) THEN
  262: *
  263: *              Apply H(i) to A(i:m,i+1:n) from the left
  264: *
  265:                AII = A( I, I )
  266:                A( I, I ) = ONE
  267:                CALL DLARF( 'LEFT', M-I+1, N-I, A( I, I ), 1, TAU( I ),
  268:      $                     A( I, I+1 ), LDA, WORK( 2*N+1 ) )
  269:                A( I, I ) = AII
  270:             END IF
  271: *
  272: *           Update partial column norms
  273: *
  274:             DO 30 J = I + 1, N
  275:                IF( WORK( J ).NE.ZERO ) THEN
  276: *
  277: *                 NOTE: The following 4 lines follow from the analysis in
  278: *                 Lapack Working Note 176.
  279: *
  280:                   TEMP = ABS( A( I, J ) ) / WORK( J )
  281:                   TEMP = MAX( ZERO, ( ONE+TEMP )*( ONE-TEMP ) )
  282:                   TEMP2 = TEMP*( WORK( J ) / WORK( N+J ) )**2
  283:                   IF( TEMP2 .LE. TOL3Z ) THEN
  284:                      IF( M-I.GT.0 ) THEN
  285:                         WORK( J ) = DNRM2( M-I, A( I+1, J ), 1 )
  286:                         WORK( N+J ) = WORK( J )
  287:                      ELSE
  288:                         WORK( J ) = ZERO
  289:                         WORK( N+J ) = ZERO
  290:                      END IF
  291:                   ELSE
  292:                      WORK( J ) = WORK( J )*SQRT( TEMP )
  293:                   END IF
  294:                END IF
  295:    30       CONTINUE
  296: *
  297:    40    CONTINUE
  298:       END IF
  299:       RETURN
  300: *
  301: *     End of DGEQPF
  302: *
  303:       END

CVSweb interface <joel.bertrand@systella.fr>