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