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