001:       SUBROUTINE ZPBSV( UPLO, N, KD, NRHS, AB, LDAB, 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, KD, LDAB, LDB, N, NRHS
011: *     ..
012: *     .. Array Arguments ..
013:       COMPLEX*16         AB( LDAB, * ), B( LDB, * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  ZPBSV 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 band matrix and X
022: *  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 band matrix, and L is a lower
028: *  triangular band matrix, with the same number of superdiagonals or
029: *  subdiagonals as A.  The factored form of A is then used to solve the
030: *  system of equations A * X = B.
031: *
032: *  Arguments
033: *  =========
034: *
035: *  UPLO    (input) CHARACTER*1
036: *          = 'U':  Upper triangle of A is stored;
037: *          = 'L':  Lower triangle of A is stored.
038: *
039: *  N       (input) INTEGER
040: *          The number of linear equations, i.e., the order of the
041: *          matrix A.  N >= 0.
042: *
043: *  KD      (input) INTEGER
044: *          The number of superdiagonals of the matrix A if UPLO = 'U',
045: *          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
046: *
047: *  NRHS    (input) INTEGER
048: *          The number of right hand sides, i.e., the number of columns
049: *          of the matrix B.  NRHS >= 0.
050: *
051: *  AB      (input/output) COMPLEX*16 array, dimension (LDAB,N)
052: *          On entry, the upper or lower triangle of the Hermitian band
053: *          matrix A, stored in the first KD+1 rows of the array.  The
054: *          j-th column of A is stored in the j-th column of the array AB
055: *          as follows:
056: *          if UPLO = 'U', AB(KD+1+i-j,j) = A(i,j) for max(1,j-KD)<=i<=j;
057: *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(N,j+KD).
058: *          See below for further details.
059: *
060: *          On exit, if INFO = 0, the triangular factor U or L from the
061: *          Cholesky factorization A = U**H*U or A = L*L**H of the band
062: *          matrix A, in the same storage format as A.
063: *
064: *  LDAB    (input) INTEGER
065: *          The leading dimension of the array AB.  LDAB >= KD+1.
066: *
067: *  B       (input/output) COMPLEX*16 array, dimension (LDB,NRHS)
068: *          On entry, the N-by-NRHS right hand side matrix B.
069: *          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
070: *
071: *  LDB     (input) INTEGER
072: *          The leading dimension of the array B.  LDB >= max(1,N).
073: *
074: *  INFO    (output) INTEGER
075: *          = 0:  successful exit
076: *          < 0:  if INFO = -i, the i-th argument had an illegal value
077: *          > 0:  if INFO = i, the leading minor of order i of A is not
078: *                positive definite, so the factorization could not be
079: *                completed, and the solution has not been computed.
080: *
081: *  Further Details
082: *  ===============
083: *
084: *  The band storage scheme is illustrated by the following example, when
085: *  N = 6, KD = 2, and UPLO = 'U':
086: *
087: *  On entry:                       On exit:
088: *
089: *      *    *   a13  a24  a35  a46      *    *   u13  u24  u35  u46
090: *      *   a12  a23  a34  a45  a56      *   u12  u23  u34  u45  u56
091: *     a11  a22  a33  a44  a55  a66     u11  u22  u33  u44  u55  u66
092: *
093: *  Similarly, if UPLO = 'L' the format of A is as follows:
094: *
095: *  On entry:                       On exit:
096: *
097: *     a11  a22  a33  a44  a55  a66     l11  l22  l33  l44  l55  l66
098: *     a21  a32  a43  a54  a65   *      l21  l32  l43  l54  l65   *
099: *     a31  a42  a53  a64   *    *      l31  l42  l53  l64   *    *
100: *
101: *  Array elements marked * are not used by the routine.
102: *
103: *  =====================================================================
104: *
105: *     .. External Functions ..
106:       LOGICAL            LSAME
107:       EXTERNAL           LSAME
108: *     ..
109: *     .. External Subroutines ..
110:       EXTERNAL           XERBLA, ZPBTRF, ZPBTRS
111: *     ..
112: *     .. Intrinsic Functions ..
113:       INTRINSIC          MAX
114: *     ..
115: *     .. Executable Statements ..
116: *
117: *     Test the input parameters.
118: *
119:       INFO = 0
120:       IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
121:          INFO = -1
122:       ELSE IF( N.LT.0 ) THEN
123:          INFO = -2
124:       ELSE IF( KD.LT.0 ) THEN
125:          INFO = -3
126:       ELSE IF( NRHS.LT.0 ) THEN
127:          INFO = -4
128:       ELSE IF( LDAB.LT.KD+1 ) THEN
129:          INFO = -6
130:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
131:          INFO = -8
132:       END IF
133:       IF( INFO.NE.0 ) THEN
134:          CALL XERBLA( 'ZPBSV ', -INFO )
135:          RETURN
136:       END IF
137: *
138: *     Compute the Cholesky factorization A = U'*U or A = L*L'.
139: *
140:       CALL ZPBTRF( UPLO, N, KD, AB, LDAB, INFO )
141:       IF( INFO.EQ.0 ) THEN
142: *
143: *        Solve the system A*X = B, overwriting B with X.
144: *
145:          CALL ZPBTRS( UPLO, N, KD, NRHS, AB, LDAB, B, LDB, INFO )
146: *
147:       END IF
148:       RETURN
149: *
150: *     End of ZPBSV
151: *
152:       END
153: