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