File:  [local] / rpl / lapack / lapack / dspsvx.f
Revision 1.13: download - view: text, annotated - select for diffs - revision graph
Fri Dec 14 14:22:40 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> DSPSVX computes the solution to system of linear equations A * X = B for OTHER matrices</b>
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at 
    6: *            http://www.netlib.org/lapack/explore-html/ 
    7: *
    8: *> \htmlonly
    9: *> Download DSPSVX + dependencies 
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dspsvx.f"> 
   11: *> [TGZ]</a> 
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dspsvx.f"> 
   13: *> [ZIP]</a> 
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dspsvx.f"> 
   15: *> [TXT]</a>
   16: *> \endhtmlonly 
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE DSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X,
   22: *                          LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
   23:    24: *       .. Scalar Arguments ..
   25: *       CHARACTER          FACT, UPLO
   26: *       INTEGER            INFO, LDB, LDX, N, NRHS
   27: *       DOUBLE PRECISION   RCOND
   28: *       ..
   29: *       .. Array Arguments ..
   30: *       INTEGER            IPIV( * ), IWORK( * )
   31: *       DOUBLE PRECISION   AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
   32: *      $                   FERR( * ), WORK( * ), X( LDX, * )
   33: *       ..
   34: *  
   35: *
   36: *> \par Purpose:
   37: *  =============
   38: *>
   39: *> \verbatim
   40: *>
   41: *> DSPSVX uses the diagonal pivoting factorization A = U*D*U**T or
   42: *> A = L*D*L**T to compute the solution to a real system of linear
   43: *> equations A * X = B, where A is an N-by-N symmetric matrix stored
   44: *> in packed format and X and B are N-by-NRHS matrices.
   45: *>
   46: *> Error bounds on the solution and a condition estimate are also
   47: *> provided.
   48: *> \endverbatim
   49: *
   50: *> \par Description:
   51: *  =================
   52: *>
   53: *> \verbatim
   54: *>
   55: *> The following steps are performed:
   56: *>
   57: *> 1. If FACT = 'N', the diagonal pivoting method is used to factor A as
   58: *>       A = U * D * U**T,  if UPLO = 'U', or
   59: *>       A = L * D * L**T,  if UPLO = 'L',
   60: *>    where U (or L) is a product of permutation and unit upper (lower)
   61: *>    triangular matrices and D is symmetric and block diagonal with
   62: *>    1-by-1 and 2-by-2 diagonal blocks.
   63: *>
   64: *> 2. If some D(i,i)=0, so that D is exactly singular, then the routine
   65: *>    returns with INFO = i. Otherwise, the factored form of A is used
   66: *>    to estimate the condition number of the matrix A.  If the
   67: *>    reciprocal of the condition number is less than machine precision,
   68: *>    INFO = N+1 is returned as a warning, but the routine still goes on
   69: *>    to solve for X and compute error bounds as described below.
   70: *>
   71: *> 3. The system of equations is solved for X using the factored form
   72: *>    of A.
   73: *>
   74: *> 4. Iterative refinement is applied to improve the computed solution
   75: *>    matrix and calculate error bounds and backward error estimates
   76: *>    for it.
   77: *> \endverbatim
   78: *
   79: *  Arguments:
   80: *  ==========
   81: *
   82: *> \param[in] FACT
   83: *> \verbatim
   84: *>          FACT is CHARACTER*1
   85: *>          Specifies whether or not the factored form of A has been
   86: *>          supplied on entry.
   87: *>          = 'F':  On entry, AFP and IPIV contain the factored form of
   88: *>                  A.  AP, AFP and IPIV will not be modified.
   89: *>          = 'N':  The matrix A will be copied to AFP and factored.
   90: *> \endverbatim
   91: *>
   92: *> \param[in] UPLO
   93: *> \verbatim
   94: *>          UPLO is CHARACTER*1
   95: *>          = 'U':  Upper triangle of A is stored;
   96: *>          = 'L':  Lower triangle of A is stored.
   97: *> \endverbatim
   98: *>
   99: *> \param[in] N
  100: *> \verbatim
  101: *>          N is INTEGER
  102: *>          The number of linear equations, i.e., the order of the
  103: *>          matrix A.  N >= 0.
  104: *> \endverbatim
  105: *>
  106: *> \param[in] NRHS
  107: *> \verbatim
  108: *>          NRHS is INTEGER
  109: *>          The number of right hand sides, i.e., the number of columns
  110: *>          of the matrices B and X.  NRHS >= 0.
  111: *> \endverbatim
  112: *>
  113: *> \param[in] AP
  114: *> \verbatim
  115: *>          AP is DOUBLE PRECISION array, dimension (N*(N+1)/2)
  116: *>          The upper or lower triangle of the symmetric matrix A, packed
  117: *>          columnwise in a linear array.  The j-th column of A is stored
  118: *>          in the array AP as follows:
  119: *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  120: *>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  121: *>          See below for further details.
  122: *> \endverbatim
  123: *>
  124: *> \param[in,out] AFP
  125: *> \verbatim
  126: *>          AFP is DOUBLE PRECISION array, dimension
  127: *>                            (N*(N+1)/2)
  128: *>          If FACT = 'F', then AFP is an input argument and on entry
  129: *>          contains the block diagonal matrix D and the multipliers used
  130: *>          to obtain the factor U or L from the factorization
  131: *>          A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as
  132: *>          a packed triangular matrix in the same storage format as A.
  133: *>
  134: *>          If FACT = 'N', then AFP is an output argument and on exit
  135: *>          contains the block diagonal matrix D and the multipliers used
  136: *>          to obtain the factor U or L from the factorization
  137: *>          A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as
  138: *>          a packed triangular matrix in the same storage format as A.
  139: *> \endverbatim
  140: *>
  141: *> \param[in,out] IPIV
  142: *> \verbatim
  143: *>          IPIV is INTEGER array, dimension (N)
  144: *>          If FACT = 'F', then IPIV is an input argument and on entry
  145: *>          contains details of the interchanges and the block structure
  146: *>          of D, as determined by DSPTRF.
  147: *>          If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  148: *>          interchanged and D(k,k) is a 1-by-1 diagonal block.
  149: *>          If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
  150: *>          columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
  151: *>          is a 2-by-2 diagonal block.  If UPLO = 'L' and IPIV(k) =
  152: *>          IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
  153: *>          interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
  154: *>
  155: *>          If FACT = 'N', then IPIV is an output argument and on exit
  156: *>          contains details of the interchanges and the block structure
  157: *>          of D, as determined by DSPTRF.
  158: *> \endverbatim
  159: *>
  160: *> \param[in] B
  161: *> \verbatim
  162: *>          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
  163: *>          The N-by-NRHS right hand side matrix B.
  164: *> \endverbatim
  165: *>
  166: *> \param[in] LDB
  167: *> \verbatim
  168: *>          LDB is INTEGER
  169: *>          The leading dimension of the array B.  LDB >= max(1,N).
  170: *> \endverbatim
  171: *>
  172: *> \param[out] X
  173: *> \verbatim
  174: *>          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
  175: *>          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
  176: *> \endverbatim
  177: *>
  178: *> \param[in] LDX
  179: *> \verbatim
  180: *>          LDX is INTEGER
  181: *>          The leading dimension of the array X.  LDX >= max(1,N).
  182: *> \endverbatim
  183: *>
  184: *> \param[out] RCOND
  185: *> \verbatim
  186: *>          RCOND is DOUBLE PRECISION
  187: *>          The estimate of the reciprocal condition number of the matrix
  188: *>          A.  If RCOND is less than the machine precision (in
  189: *>          particular, if RCOND = 0), the matrix is singular to working
  190: *>          precision.  This condition is indicated by a return code of
  191: *>          INFO > 0.
  192: *> \endverbatim
  193: *>
  194: *> \param[out] FERR
  195: *> \verbatim
  196: *>          FERR is DOUBLE PRECISION array, dimension (NRHS)
  197: *>          The estimated forward error bound for each solution vector
  198: *>          X(j) (the j-th column of the solution matrix X).
  199: *>          If XTRUE is the true solution corresponding to X(j), FERR(j)
  200: *>          is an estimated upper bound for the magnitude of the largest
  201: *>          element in (X(j) - XTRUE) divided by the magnitude of the
  202: *>          largest element in X(j).  The estimate is as reliable as
  203: *>          the estimate for RCOND, and is almost always a slight
  204: *>          overestimate of the true error.
  205: *> \endverbatim
  206: *>
  207: *> \param[out] BERR
  208: *> \verbatim
  209: *>          BERR is DOUBLE PRECISION array, dimension (NRHS)
  210: *>          The componentwise relative backward error of each solution
  211: *>          vector X(j) (i.e., the smallest relative change in
  212: *>          any element of A or B that makes X(j) an exact solution).
  213: *> \endverbatim
  214: *>
  215: *> \param[out] WORK
  216: *> \verbatim
  217: *>          WORK is DOUBLE PRECISION array, dimension (3*N)
  218: *> \endverbatim
  219: *>
  220: *> \param[out] IWORK
  221: *> \verbatim
  222: *>          IWORK is INTEGER array, dimension (N)
  223: *> \endverbatim
  224: *>
  225: *> \param[out] INFO
  226: *> \verbatim
  227: *>          INFO is INTEGER
  228: *>          = 0: successful exit
  229: *>          < 0: if INFO = -i, the i-th argument had an illegal value
  230: *>          > 0:  if INFO = i, and i is
  231: *>                <= N:  D(i,i) is exactly zero.  The factorization
  232: *>                       has been completed but the factor D is exactly
  233: *>                       singular, so the solution and error bounds could
  234: *>                       not be computed. RCOND = 0 is returned.
  235: *>                = N+1: D is nonsingular, but RCOND is less than machine
  236: *>                       precision, meaning that the matrix is singular
  237: *>                       to working precision.  Nevertheless, the
  238: *>                       solution and error bounds are computed because
  239: *>                       there are a number of situations where the
  240: *>                       computed solution can be more accurate than the
  241: *>                       value of RCOND would suggest.
  242: *> \endverbatim
  243: *
  244: *  Authors:
  245: *  ========
  246: *
  247: *> \author Univ. of Tennessee 
  248: *> \author Univ. of California Berkeley 
  249: *> \author Univ. of Colorado Denver 
  250: *> \author NAG Ltd. 
  251: *
  252: *> \date April 2012
  253: *
  254: *> \ingroup doubleOTHERsolve
  255: *
  256: *> \par Further Details:
  257: *  =====================
  258: *>
  259: *> \verbatim
  260: *>
  261: *>  The packed storage scheme is illustrated by the following example
  262: *>  when N = 4, UPLO = 'U':
  263: *>
  264: *>  Two-dimensional storage of the symmetric matrix A:
  265: *>
  266: *>     a11 a12 a13 a14
  267: *>         a22 a23 a24
  268: *>             a33 a34     (aij = aji)
  269: *>                 a44
  270: *>
  271: *>  Packed storage of the upper triangle of A:
  272: *>
  273: *>  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  274: *> \endverbatim
  275: *>
  276: *  =====================================================================
  277:       SUBROUTINE DSPSVX( FACT, UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X,
  278:      $                   LDX, RCOND, FERR, BERR, WORK, IWORK, INFO )
  279: *
  280: *  -- LAPACK driver routine (version 3.4.1) --
  281: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  282: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  283: *     April 2012
  284: *
  285: *     .. Scalar Arguments ..
  286:       CHARACTER          FACT, UPLO
  287:       INTEGER            INFO, LDB, LDX, N, NRHS
  288:       DOUBLE PRECISION   RCOND
  289: *     ..
  290: *     .. Array Arguments ..
  291:       INTEGER            IPIV( * ), IWORK( * )
  292:       DOUBLE PRECISION   AFP( * ), AP( * ), B( LDB, * ), BERR( * ),
  293:      $                   FERR( * ), WORK( * ), X( LDX, * )
  294: *     ..
  295: *
  296: *  =====================================================================
  297: *
  298: *     .. Parameters ..
  299:       DOUBLE PRECISION   ZERO
  300:       PARAMETER          ( ZERO = 0.0D+0 )
  301: *     ..
  302: *     .. Local Scalars ..
  303:       LOGICAL            NOFACT
  304:       DOUBLE PRECISION   ANORM
  305: *     ..
  306: *     .. External Functions ..
  307:       LOGICAL            LSAME
  308:       DOUBLE PRECISION   DLAMCH, DLANSP
  309:       EXTERNAL           LSAME, DLAMCH, DLANSP
  310: *     ..
  311: *     .. External Subroutines ..
  312:       EXTERNAL           DCOPY, DLACPY, DSPCON, DSPRFS, DSPTRF, DSPTRS,
  313:      $                   XERBLA
  314: *     ..
  315: *     .. Intrinsic Functions ..
  316:       INTRINSIC          MAX
  317: *     ..
  318: *     .. Executable Statements ..
  319: *
  320: *     Test the input parameters.
  321: *
  322:       INFO = 0
  323:       NOFACT = LSAME( FACT, 'N' )
  324:       IF( .NOT.NOFACT .AND. .NOT.LSAME( FACT, 'F' ) ) THEN
  325:          INFO = -1
  326:       ELSE IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) )
  327:      $          THEN
  328:          INFO = -2
  329:       ELSE IF( N.LT.0 ) THEN
  330:          INFO = -3
  331:       ELSE IF( NRHS.LT.0 ) THEN
  332:          INFO = -4
  333:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
  334:          INFO = -9
  335:       ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
  336:          INFO = -11
  337:       END IF
  338:       IF( INFO.NE.0 ) THEN
  339:          CALL XERBLA( 'DSPSVX', -INFO )
  340:          RETURN
  341:       END IF
  342: *
  343:       IF( NOFACT ) THEN
  344: *
  345: *        Compute the factorization A = U*D*U**T or A = L*D*L**T.
  346: *
  347:          CALL DCOPY( N*( N+1 ) / 2, AP, 1, AFP, 1 )
  348:          CALL DSPTRF( UPLO, N, AFP, IPIV, INFO )
  349: *
  350: *        Return if INFO is non-zero.
  351: *
  352:          IF( INFO.GT.0 )THEN
  353:             RCOND = ZERO
  354:             RETURN
  355:          END IF
  356:       END IF
  357: *
  358: *     Compute the norm of the matrix A.
  359: *
  360:       ANORM = DLANSP( 'I', UPLO, N, AP, WORK )
  361: *
  362: *     Compute the reciprocal of the condition number of A.
  363: *
  364:       CALL DSPCON( UPLO, N, AFP, IPIV, ANORM, RCOND, WORK, IWORK, INFO )
  365: *
  366: *     Compute the solution vectors X.
  367: *
  368:       CALL DLACPY( 'Full', N, NRHS, B, LDB, X, LDX )
  369:       CALL DSPTRS( UPLO, N, NRHS, AFP, IPIV, X, LDX, INFO )
  370: *
  371: *     Use iterative refinement to improve the computed solutions and
  372: *     compute error bounds and backward error estimates for them.
  373: *
  374:       CALL DSPRFS( UPLO, N, NRHS, AP, AFP, IPIV, B, LDB, X, LDX, FERR,
  375:      $             BERR, WORK, IWORK, INFO )
  376: *
  377: *     Set INFO = N+1 if the matrix is singular to working precision.
  378: *
  379:       IF( RCOND.LT.DLAMCH( 'Epsilon' ) )
  380:      $   INFO = N + 1
  381: *
  382:       RETURN
  383: *
  384: *     End of DSPSVX
  385: *
  386:       END

CVSweb interface <joel.bertrand@systella.fr>