001:       SUBROUTINE DPOSV( UPLO, N, NRHS, A, LDA, B, LDB, INFO )
002: *
003: *  -- LAPACK driver routine (version 3.2) --
004: *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
005: *     November 2006
006: *
007: *     .. Scalar Arguments ..
008:       CHARACTER          UPLO
009:       INTEGER            INFO, LDA, LDB, N, NRHS
010: *     ..
011: *     .. Array Arguments ..
012:       DOUBLE PRECISION   A( LDA, * ), B( LDB, * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  DPOSV computes the solution to a real system of linear equations
019: *     A * X = B,
020: *  where A is an N-by-N symmetric positive definite matrix and X and B
021: *  are N-by-NRHS matrices.
022: *
023: *  The Cholesky decomposition is used to factor A as
024: *     A = U**T* U,  if UPLO = 'U', or
025: *     A = L * L**T,  if UPLO = 'L',
026: *  where U is an upper triangular matrix and L is a lower triangular
027: *  matrix.  The factored form of A is then used to solve the system of
028: *  equations A * X = B.
029: *
030: *  Arguments
031: *  =========
032: *
033: *  UPLO    (input) CHARACTER*1
034: *          = 'U':  Upper triangle of A is stored;
035: *          = 'L':  Lower triangle of A is stored.
036: *
037: *  N       (input) INTEGER
038: *          The number of linear equations, i.e., the order of the
039: *          matrix A.  N >= 0.
040: *
041: *  NRHS    (input) INTEGER
042: *          The number of right hand sides, i.e., the number of columns
043: *          of the matrix B.  NRHS >= 0.
044: *
045: *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
046: *          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
047: *          N-by-N upper triangular part of A contains the upper
048: *          triangular part of the matrix A, and the strictly lower
049: *          triangular part of A is not referenced.  If UPLO = 'L', the
050: *          leading N-by-N lower triangular part of A contains the lower
051: *          triangular part of the matrix A, and the strictly upper
052: *          triangular part of A is not referenced.
053: *
054: *          On exit, if INFO = 0, the factor U or L from the Cholesky
055: *          factorization A = U**T*U or A = L*L**T.
056: *
057: *  LDA     (input) INTEGER
058: *          The leading dimension of the array A.  LDA >= max(1,N).
059: *
060: *  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
061: *          On entry, the N-by-NRHS right hand side matrix B.
062: *          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
063: *
064: *  LDB     (input) INTEGER
065: *          The leading dimension of the array B.  LDB >= max(1,N).
066: *
067: *  INFO    (output) INTEGER
068: *          = 0:  successful exit
069: *          < 0:  if INFO = -i, the i-th argument had an illegal value
070: *          > 0:  if INFO = i, the leading minor of order i of A is not
071: *                positive definite, so the factorization could not be
072: *                completed, and the solution has not been computed.
073: *
074: *  =====================================================================
075: *
076: *     .. External Functions ..
077:       LOGICAL            LSAME
078:       EXTERNAL           LSAME
079: *     ..
080: *     .. External Subroutines ..
081:       EXTERNAL           DPOTRF, DPOTRS, XERBLA
082: *     ..
083: *     .. Intrinsic Functions ..
084:       INTRINSIC          MAX
085: *     ..
086: *     .. Executable Statements ..
087: *
088: *     Test the input parameters.
089: *
090:       INFO = 0
091:       IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
092:          INFO = -1
093:       ELSE IF( N.LT.0 ) THEN
094:          INFO = -2
095:       ELSE IF( NRHS.LT.0 ) THEN
096:          INFO = -3
097:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
098:          INFO = -5
099:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
100:          INFO = -7
101:       END IF
102:       IF( INFO.NE.0 ) THEN
103:          CALL XERBLA( 'DPOSV ', -INFO )
104:          RETURN
105:       END IF
106: *
107: *     Compute the Cholesky factorization A = U'*U or A = L*L'.
108: *
109:       CALL DPOTRF( UPLO, N, A, LDA, INFO )
110:       IF( INFO.EQ.0 ) THEN
111: *
112: *        Solve the system A*X = B, overwriting B with X.
113: *
114:          CALL DPOTRS( UPLO, N, NRHS, A, LDA, B, LDB, INFO )
115: *
116:       END IF
117:       RETURN
118: *
119: *     End of DPOSV
120: *
121:       END
122: