```001:       SUBROUTINE CPPTRS( UPLO, N, NRHS, AP, B, LDB, INFO )
002: *
003: *  -- LAPACK 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            AP( * ), B( LDB, * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  CPPTRS solves a system of linear equations A*X = B with a Hermitian
020: *  positive definite matrix A in packed storage using the Cholesky
021: *  factorization A = U**H*U or A = L*L**H computed by CPPTRF.
022: *
023: *  Arguments
024: *  =========
025: *
026: *  UPLO    (input) CHARACTER*1
027: *          = 'U':  Upper triangle of A is stored;
028: *          = 'L':  Lower triangle of A is stored.
029: *
030: *  N       (input) INTEGER
031: *          The order of the matrix A.  N >= 0.
032: *
033: *  NRHS    (input) INTEGER
034: *          The number of right hand sides, i.e., the number of columns
035: *          of the matrix B.  NRHS >= 0.
036: *
037: *  AP      (input) COMPLEX array, dimension (N*(N+1)/2)
038: *          The triangular factor U or L from the Cholesky factorization
039: *          A = U**H*U or A = L*L**H, packed columnwise in a linear
040: *          array.  The j-th column of U or L is stored in the array AP
041: *          as follows:
042: *          if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j;
043: *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n.
044: *
045: *  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
046: *          On entry, the right hand side matrix B.
047: *          On exit, the solution matrix X.
048: *
049: *  LDB     (input) INTEGER
050: *          The leading dimension of the array B.  LDB >= max(1,N).
051: *
052: *  INFO    (output) INTEGER
053: *          = 0:  successful exit
054: *          < 0:  if INFO = -i, the i-th argument had an illegal value
055: *
056: *  =====================================================================
057: *
058: *     .. Local Scalars ..
059:       LOGICAL            UPPER
060:       INTEGER            I
061: *     ..
062: *     .. External Functions ..
063:       LOGICAL            LSAME
064:       EXTERNAL           LSAME
065: *     ..
066: *     .. External Subroutines ..
067:       EXTERNAL           CTPSV, XERBLA
068: *     ..
069: *     .. Intrinsic Functions ..
070:       INTRINSIC          MAX
071: *     ..
072: *     .. Executable Statements ..
073: *
074: *     Test the input parameters.
075: *
076:       INFO = 0
077:       UPPER = LSAME( UPLO, 'U' )
078:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
079:          INFO = -1
080:       ELSE IF( N.LT.0 ) THEN
081:          INFO = -2
082:       ELSE IF( NRHS.LT.0 ) THEN
083:          INFO = -3
084:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
085:          INFO = -6
086:       END IF
087:       IF( INFO.NE.0 ) THEN
088:          CALL XERBLA( 'CPPTRS', -INFO )
089:          RETURN
090:       END IF
091: *
092: *     Quick return if possible
093: *
094:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
095:      \$   RETURN
096: *
097:       IF( UPPER ) THEN
098: *
099: *        Solve A*X = B where A = U'*U.
100: *
101:          DO 10 I = 1, NRHS
102: *
103: *           Solve U'*X = B, overwriting B with X.
104: *
105:             CALL CTPSV( 'Upper', 'Conjugate transpose', 'Non-unit', N,
106:      \$                  AP, B( 1, I ), 1 )
107: *
108: *           Solve U*X = B, overwriting B with X.
109: *
110:             CALL CTPSV( 'Upper', 'No transpose', 'Non-unit', N, AP,
111:      \$                  B( 1, I ), 1 )
112:    10    CONTINUE
113:       ELSE
114: *
115: *        Solve A*X = B where A = L*L'.
116: *
117:          DO 20 I = 1, NRHS
118: *
119: *           Solve L*Y = B, overwriting B with X.
120: *
121:             CALL CTPSV( 'Lower', 'No transpose', 'Non-unit', N, AP,
122:      \$                  B( 1, I ), 1 )
123: *
124: *           Solve L'*X = Y, overwriting B with X.
125: *
126:             CALL CTPSV( 'Lower', 'Conjugate transpose', 'Non-unit', N,
127:      \$                  AP, B( 1, I ), 1 )
128:    20    CONTINUE
129:       END IF
130: *
131:       RETURN
132: *
133: *     End of CPPTRS
134: *
135:       END
136: ```