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