File:  [local] / rpl / lapack / lapack / zpstf2.f
Revision 1.10: download - view: text, annotated - select for diffs - revision graph
Fri Dec 14 14:22:54 2012 UTC (11 years, 5 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_16, rpl-4_1_15, rpl-4_1_14, rpl-4_1_13, rpl-4_1_12, rpl-4_1_11, HEAD
Mise à jour de lapack.

    1: *> \brief \b ZPSTF2 computes the Cholesky factorization with complete pivoting of a real symmetric or complex Hermitian positive semi-definite matrix.
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at 
    6: *            http://www.netlib.org/lapack/explore-html/ 
    7: *
    8: *> \htmlonly
    9: *> Download ZPSTF2 + dependencies 
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpstf2.f"> 
   11: *> [TGZ]</a> 
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpstf2.f"> 
   13: *> [ZIP]</a> 
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpstf2.f"> 
   15: *> [TXT]</a>
   16: *> \endhtmlonly 
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE ZPSTF2( UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO )
   22:    23: *       .. Scalar Arguments ..
   24: *       DOUBLE PRECISION   TOL
   25: *       INTEGER            INFO, LDA, N, RANK
   26: *       CHARACTER          UPLO
   27: *       ..
   28: *       .. Array Arguments ..
   29: *       COMPLEX*16         A( LDA, * )
   30: *       DOUBLE PRECISION   WORK( 2*N )
   31: *       INTEGER            PIV( N )
   32: *       ..
   33: *  
   34: *
   35: *> \par Purpose:
   36: *  =============
   37: *>
   38: *> \verbatim
   39: *>
   40: *> ZPSTF2 computes the Cholesky factorization with complete
   41: *> pivoting of a complex Hermitian positive semidefinite matrix A.
   42: *>
   43: *> The factorization has the form
   44: *>    P**T * A * P = U**H * U ,  if UPLO = 'U',
   45: *>    P**T * A * P = L  * L**H,  if UPLO = 'L',
   46: *> where U is an upper triangular matrix and L is lower triangular, and
   47: *> P is stored as vector PIV.
   48: *>
   49: *> This algorithm does not attempt to check that A is positive
   50: *> semidefinite. This version of the algorithm calls level 2 BLAS.
   51: *> \endverbatim
   52: *
   53: *  Arguments:
   54: *  ==========
   55: *
   56: *> \param[in] UPLO
   57: *> \verbatim
   58: *>          UPLO is CHARACTER*1
   59: *>          Specifies whether the upper or lower triangular part of the
   60: *>          symmetric matrix A is stored.
   61: *>          = 'U':  Upper triangular
   62: *>          = 'L':  Lower triangular
   63: *> \endverbatim
   64: *>
   65: *> \param[in] N
   66: *> \verbatim
   67: *>          N is INTEGER
   68: *>          The order of the matrix A.  N >= 0.
   69: *> \endverbatim
   70: *>
   71: *> \param[in,out] A
   72: *> \verbatim
   73: *>          A is COMPLEX*16 array, dimension (LDA,N)
   74: *>          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
   75: *>          n by n upper triangular part of A contains the upper
   76: *>          triangular part of the matrix A, and the strictly lower
   77: *>          triangular part of A is not referenced.  If UPLO = 'L', the
   78: *>          leading n by n lower triangular part of A contains the lower
   79: *>          triangular part of the matrix A, and the strictly upper
   80: *>          triangular part of A is not referenced.
   81: *>
   82: *>          On exit, if INFO = 0, the factor U or L from the Cholesky
   83: *>          factorization as above.
   84: *> \endverbatim
   85: *>
   86: *> \param[out] PIV
   87: *> \verbatim
   88: *>          PIV is INTEGER array, dimension (N)
   89: *>          PIV is such that the nonzero entries are P( PIV(K), K ) = 1.
   90: *> \endverbatim
   91: *>
   92: *> \param[out] RANK
   93: *> \verbatim
   94: *>          RANK is INTEGER
   95: *>          The rank of A given by the number of steps the algorithm
   96: *>          completed.
   97: *> \endverbatim
   98: *>
   99: *> \param[in] TOL
  100: *> \verbatim
  101: *>          TOL is DOUBLE PRECISION
  102: *>          User defined tolerance. If TOL < 0, then N*U*MAX( A( K,K ) )
  103: *>          will be used. The algorithm terminates at the (K-1)st step
  104: *>          if the pivot <= TOL.
  105: *> \endverbatim
  106: *>
  107: *> \param[in] LDA
  108: *> \verbatim
  109: *>          LDA is INTEGER
  110: *>          The leading dimension of the array A.  LDA >= max(1,N).
  111: *> \endverbatim
  112: *>
  113: *> \param[out] WORK
  114: *> \verbatim
  115: *>          WORK is DOUBLE PRECISION array, dimension (2*N)
  116: *>          Work space.
  117: *> \endverbatim
  118: *>
  119: *> \param[out] INFO
  120: *> \verbatim
  121: *>          INFO is INTEGER
  122: *>          < 0: If INFO = -K, the K-th argument had an illegal value,
  123: *>          = 0: algorithm completed successfully, and
  124: *>          > 0: the matrix A is either rank deficient with computed rank
  125: *>               as returned in RANK, or is indefinite.  See Section 7 of
  126: *>               LAPACK Working Note #161 for further information.
  127: *> \endverbatim
  128: *
  129: *  Authors:
  130: *  ========
  131: *
  132: *> \author Univ. of Tennessee 
  133: *> \author Univ. of California Berkeley 
  134: *> \author Univ. of Colorado Denver 
  135: *> \author NAG Ltd. 
  136: *
  137: *> \date September 2012
  138: *
  139: *> \ingroup complex16OTHERcomputational
  140: *
  141: *  =====================================================================
  142:       SUBROUTINE ZPSTF2( UPLO, N, A, LDA, PIV, RANK, TOL, WORK, INFO )
  143: *
  144: *  -- LAPACK computational routine (version 3.4.2) --
  145: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  146: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  147: *     September 2012
  148: *
  149: *     .. Scalar Arguments ..
  150:       DOUBLE PRECISION   TOL
  151:       INTEGER            INFO, LDA, N, RANK
  152:       CHARACTER          UPLO
  153: *     ..
  154: *     .. Array Arguments ..
  155:       COMPLEX*16         A( LDA, * )
  156:       DOUBLE PRECISION   WORK( 2*N )
  157:       INTEGER            PIV( N )
  158: *     ..
  159: *
  160: *  =====================================================================
  161: *
  162: *     .. Parameters ..
  163:       DOUBLE PRECISION   ONE, ZERO
  164:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  165:       COMPLEX*16         CONE
  166:       PARAMETER          ( CONE = ( 1.0D+0, 0.0D+0 ) )
  167: *     ..
  168: *     .. Local Scalars ..
  169:       COMPLEX*16         ZTEMP
  170:       DOUBLE PRECISION   AJJ, DSTOP, DTEMP
  171:       INTEGER            I, ITEMP, J, PVT
  172:       LOGICAL            UPPER
  173: *     ..
  174: *     .. External Functions ..
  175:       DOUBLE PRECISION   DLAMCH
  176:       LOGICAL            LSAME, DISNAN
  177:       EXTERNAL           DLAMCH, LSAME, DISNAN
  178: *     ..
  179: *     .. External Subroutines ..
  180:       EXTERNAL           ZDSCAL, ZGEMV, ZLACGV, ZSWAP, XERBLA
  181: *     ..
  182: *     .. Intrinsic Functions ..
  183:       INTRINSIC          DBLE, DCONJG, MAX, SQRT
  184: *     ..
  185: *     .. Executable Statements ..
  186: *
  187: *     Test the input parameters
  188: *
  189:       INFO = 0
  190:       UPPER = LSAME( UPLO, 'U' )
  191:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  192:          INFO = -1
  193:       ELSE IF( N.LT.0 ) THEN
  194:          INFO = -2
  195:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  196:          INFO = -4
  197:       END IF
  198:       IF( INFO.NE.0 ) THEN
  199:          CALL XERBLA( 'ZPSTF2', -INFO )
  200:          RETURN
  201:       END IF
  202: *
  203: *     Quick return if possible
  204: *
  205:       IF( N.EQ.0 )
  206:      $   RETURN
  207: *
  208: *     Initialize PIV
  209: *
  210:       DO 100 I = 1, N
  211:          PIV( I ) = I
  212:   100 CONTINUE
  213: *
  214: *     Compute stopping value
  215: *
  216:       DO 110 I = 1, N
  217:          WORK( I ) = DBLE( A( I, I ) )
  218:   110 CONTINUE
  219:       PVT = MAXLOC( WORK( 1:N ), 1 )
  220:       AJJ = DBLE( A( PVT, PVT ) )
  221:       IF( AJJ.EQ.ZERO.OR.DISNAN( AJJ ) ) THEN
  222:          RANK = 0
  223:          INFO = 1
  224:          GO TO 200
  225:       END IF
  226: *
  227: *     Compute stopping value if not supplied
  228: *
  229:       IF( TOL.LT.ZERO ) THEN
  230:          DSTOP = N * DLAMCH( 'Epsilon' ) * AJJ
  231:       ELSE
  232:          DSTOP = TOL
  233:       END IF
  234: *
  235: *     Set first half of WORK to zero, holds dot products
  236: *
  237:       DO 120 I = 1, N
  238:          WORK( I ) = 0
  239:   120 CONTINUE
  240: *
  241:       IF( UPPER ) THEN
  242: *
  243: *        Compute the Cholesky factorization P**T * A * P = U**H* U
  244: *
  245:          DO 150 J = 1, N
  246: *
  247: *        Find pivot, test for exit, else swap rows and columns
  248: *        Update dot products, compute possible pivots which are
  249: *        stored in the second half of WORK
  250: *
  251:             DO 130 I = J, N
  252: *
  253:                IF( J.GT.1 ) THEN
  254:                   WORK( I ) = WORK( I ) + 
  255:      $                        DBLE( DCONJG( A( J-1, I ) )*
  256:      $                              A( J-1, I ) )
  257:                END IF
  258:                WORK( N+I ) = DBLE( A( I, I ) ) - WORK( I )
  259: *
  260:   130       CONTINUE
  261: *
  262:             IF( J.GT.1 ) THEN
  263:                ITEMP = MAXLOC( WORK( (N+J):(2*N) ), 1 )
  264:                PVT = ITEMP + J - 1
  265:                AJJ = WORK( N+PVT )
  266:                IF( AJJ.LE.DSTOP.OR.DISNAN( AJJ ) ) THEN
  267:                   A( J, J ) = AJJ
  268:                   GO TO 190
  269:                END IF
  270:             END IF
  271: *
  272:             IF( J.NE.PVT ) THEN
  273: *
  274: *              Pivot OK, so can now swap pivot rows and columns
  275: *
  276:                A( PVT, PVT ) = A( J, J )
  277:                CALL ZSWAP( J-1, A( 1, J ), 1, A( 1, PVT ), 1 )
  278:                IF( PVT.LT.N )
  279:      $            CALL ZSWAP( N-PVT, A( J, PVT+1 ), LDA,
  280:      $                        A( PVT, PVT+1 ), LDA )
  281:                DO 140 I = J + 1, PVT - 1
  282:                   ZTEMP = DCONJG( A( J, I ) )
  283:                   A( J, I ) = DCONJG( A( I, PVT ) )
  284:                   A( I, PVT ) = ZTEMP
  285:   140          CONTINUE
  286:                A( J, PVT ) = DCONJG( A( J, PVT ) )
  287: *
  288: *              Swap dot products and PIV
  289: *
  290:                DTEMP = WORK( J )
  291:                WORK( J ) = WORK( PVT )
  292:                WORK( PVT ) = DTEMP
  293:                ITEMP = PIV( PVT )
  294:                PIV( PVT ) = PIV( J )
  295:                PIV( J ) = ITEMP
  296:             END IF
  297: *
  298:             AJJ = SQRT( AJJ )
  299:             A( J, J ) = AJJ
  300: *
  301: *           Compute elements J+1:N of row J
  302: *
  303:             IF( J.LT.N ) THEN
  304:                CALL ZLACGV( J-1, A( 1, J ), 1 )
  305:                CALL ZGEMV( 'Trans', J-1, N-J, -CONE, A( 1, J+1 ), LDA,
  306:      $                     A( 1, J ), 1, CONE, A( J, J+1 ), LDA )
  307:                CALL ZLACGV( J-1, A( 1, J ), 1 )
  308:                CALL ZDSCAL( N-J, ONE / AJJ, A( J, J+1 ), LDA )
  309:             END IF
  310: *
  311:   150    CONTINUE
  312: *
  313:       ELSE
  314: *
  315: *        Compute the Cholesky factorization P**T * A * P = L * L**H
  316: *
  317:          DO 180 J = 1, N
  318: *
  319: *        Find pivot, test for exit, else swap rows and columns
  320: *        Update dot products, compute possible pivots which are
  321: *        stored in the second half of WORK
  322: *
  323:             DO 160 I = J, N
  324: *
  325:                IF( J.GT.1 ) THEN
  326:                   WORK( I ) = WORK( I ) + 
  327:      $                        DBLE( DCONJG( A( I, J-1 ) )*
  328:      $                              A( I, J-1 ) )
  329:                END IF
  330:                WORK( N+I ) = DBLE( A( I, I ) ) - WORK( I )
  331: *
  332:   160       CONTINUE
  333: *
  334:             IF( J.GT.1 ) THEN
  335:                ITEMP = MAXLOC( WORK( (N+J):(2*N) ), 1 )
  336:                PVT = ITEMP + J - 1
  337:                AJJ = WORK( N+PVT )
  338:                IF( AJJ.LE.DSTOP.OR.DISNAN( AJJ ) ) THEN
  339:                   A( J, J ) = AJJ
  340:                   GO TO 190
  341:                END IF
  342:             END IF
  343: *
  344:             IF( J.NE.PVT ) THEN
  345: *
  346: *              Pivot OK, so can now swap pivot rows and columns
  347: *
  348:                A( PVT, PVT ) = A( J, J )
  349:                CALL ZSWAP( J-1, A( J, 1 ), LDA, A( PVT, 1 ), LDA )
  350:                IF( PVT.LT.N )
  351:      $            CALL ZSWAP( N-PVT, A( PVT+1, J ), 1, A( PVT+1, PVT ),
  352:      $                        1 )
  353:                DO 170 I = J + 1, PVT - 1
  354:                   ZTEMP = DCONJG( A( I, J ) )
  355:                   A( I, J ) = DCONJG( A( PVT, I ) )
  356:                   A( PVT, I ) = ZTEMP
  357:   170          CONTINUE
  358:                A( PVT, J ) = DCONJG( A( PVT, J ) )
  359: *
  360: *              Swap dot products and PIV
  361: *
  362:                DTEMP = WORK( J )
  363:                WORK( J ) = WORK( PVT )
  364:                WORK( PVT ) = DTEMP
  365:                ITEMP = PIV( PVT )
  366:                PIV( PVT ) = PIV( J )
  367:                PIV( J ) = ITEMP
  368:             END IF
  369: *
  370:             AJJ = SQRT( AJJ )
  371:             A( J, J ) = AJJ
  372: *
  373: *           Compute elements J+1:N of column J
  374: *
  375:             IF( J.LT.N ) THEN
  376:                CALL ZLACGV( J-1, A( J, 1 ), LDA )
  377:                CALL ZGEMV( 'No Trans', N-J, J-1, -CONE, A( J+1, 1 ),
  378:      $                     LDA, A( J, 1 ), LDA, CONE, A( J+1, J ), 1 )
  379:                CALL ZLACGV( J-1, A( J, 1 ), LDA )
  380:                CALL ZDSCAL( N-J, ONE / AJJ, A( J+1, J ), 1 )
  381:             END IF
  382: *
  383:   180    CONTINUE
  384: *
  385:       END IF
  386: *
  387: *     Ran to completion, A has full rank
  388: *
  389:       RANK = N
  390: *
  391:       GO TO 200
  392:   190 CONTINUE
  393: *
  394: *     Rank is number of steps completed.  Set INFO = 1 to signal
  395: *     that the factorization cannot be used to solve a system.
  396: *
  397:       RANK = J - 1
  398:       INFO = 1
  399: *
  400:   200 CONTINUE
  401:       RETURN
  402: *
  403: *     End of ZPSTF2
  404: *
  405:       END

CVSweb interface <joel.bertrand@systella.fr>