001:       SUBROUTINE CPPSV( UPLO, N, NRHS, AP, 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, LDB, N, NRHS
010: *     ..
011: *     .. Array Arguments ..
012:       COMPLEX            AP( * ), B( LDB, * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  CPPSV computes the solution to a complex system of linear equations
019: *     A * X = B,
020: *  where A is an N-by-N Hermitian positive definite matrix stored in
021: *  packed format and X and B are N-by-NRHS matrices.
022: *
023: *  The Cholesky decomposition is used to factor A as
024: *     A = U**H* U,  if UPLO = 'U', or
025: *     A = L * L**H,  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: *  AP      (input/output) COMPLEX array, dimension (N*(N+1)/2)
046: *          On entry, the upper or lower triangle of the Hermitian matrix
047: *          A, packed columnwise in a linear array.  The j-th column of A
048: *          is stored in the array AP as follows:
049: *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
050: *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
051: *          See below for further details.  
052: *
053: *          On exit, if INFO = 0, the factor U or L from the Cholesky
054: *          factorization A = U**H*U or A = L*L**H, in the same storage
055: *          format as A.
056: *
057: *  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
058: *          On entry, the N-by-NRHS right hand side matrix B.
059: *          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
060: *
061: *  LDB     (input) INTEGER
062: *          The leading dimension of the array B.  LDB >= max(1,N).
063: *
064: *  INFO    (output) INTEGER
065: *          = 0:  successful exit
066: *          < 0:  if INFO = -i, the i-th argument had an illegal value
067: *          > 0:  if INFO = i, the leading minor of order i of A is not
068: *                positive definite, so the factorization could not be
069: *                completed, and the solution has not been computed.
070: *
071: *  Further Details
072: *  ===============
073: *
074: *  The packed storage scheme is illustrated by the following example
075: *  when N = 4, UPLO = 'U':
076: *
077: *  Two-dimensional storage of the Hermitian matrix A:
078: *
079: *     a11 a12 a13 a14
080: *         a22 a23 a24
081: *             a33 a34     (aij = conjg(aji))
082: *                 a44
083: *
084: *  Packed storage of the upper triangle of A:
085: *
086: *  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
087: *
088: *  =====================================================================
089: *
090: *     .. External Functions ..
091:       LOGICAL            LSAME
092:       EXTERNAL           LSAME
093: *     ..
094: *     .. External Subroutines ..
095:       EXTERNAL           CPPTRF, CPPTRS, XERBLA
096: *     ..
097: *     .. Intrinsic Functions ..
098:       INTRINSIC          MAX
099: *     ..
100: *     .. Executable Statements ..
101: *
102: *     Test the input parameters.
103: *
104:       INFO = 0
105:       IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
106:          INFO = -1
107:       ELSE IF( N.LT.0 ) THEN
108:          INFO = -2
109:       ELSE IF( NRHS.LT.0 ) THEN
110:          INFO = -3
111:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
112:          INFO = -6
113:       END IF
114:       IF( INFO.NE.0 ) THEN
115:          CALL XERBLA( 'CPPSV ', -INFO )
116:          RETURN
117:       END IF
118: *
119: *     Compute the Cholesky factorization A = U'*U or A = L*L'.
120: *
121:       CALL CPPTRF( UPLO, N, AP, INFO )
122:       IF( INFO.EQ.0 ) THEN
123: *
124: *        Solve the system A*X = B, overwriting B with X.
125: *
126:          CALL CPPTRS( UPLO, N, NRHS, AP, B, LDB, INFO )
127: *
128:       END IF
129:       RETURN
130: *
131: *     End of CPPSV
132: *
133:       END
134: