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