      SUBROUTINE BCHSLV ( W, NBANDS, NROW, B )
C  FROM  * A PRACTICAL GUIDE TO SPLINES *  BY C. DE BOOR
C  SOLVES THE LINEAR SYSTEM     C*X = B   OF ORDER  N R O W  FOR  X
C  PROVIDED  W  CONTAINS THE CHOLESKY FACTORIZATION FOR THE BANDED (SYM-
C  METRIC) POSITIVE DEFINITE MATRIX  C  AS CONSTRUCTED IN THE SUBROUTINE
C    B C H F A C  (QUO VIDE).
C
C******  I N P U T  ******
C  NROW.....IS THE ORDER OF THE MATRIX  C .
C  NBANDS.....INDICATES THE BANDWIDTH OF  C .
C  W.....CONTAINS THE CHOLESKY FACTORIZATION FOR  C , AS OUTPUT FROM
C        SUBROUTINE BCHFAC  (QUO VIDE).
C  B.....THE VECTOR OF LENGTH  N R O W  CONTAINING THE RIGHT SIDE.
C
C******  O U T P U T  ******
C  B.....THE VECTOR OF LENGTH  N R O W  CONTAINING THE SOLUTION.
C
C******  M E T H O D  ******
C  WITH THE FACTORIZATION  C = L*D*L-TRANSPOSE  AVAILABLE, WHERE  L  IS
C  UNIT LOWER TRIANGULAR AND  D  IS DIAGONAL, THE TRIANGULAR SYSTEM
C  L*Y = B  IS SOLVED FOR  Y (FORWARD SUBSTITUTION), Y IS STORED IN  B,
C  THE VECTOR  D**(-1)*Y IS COMPUTED AND STORED IN  B, THEN THE TRIANG-
C  ULAR SYSTEM  L-TRANSPOSE*X = D**(-1)*Y IS SOLVED FOR  X (BACKSUBSTIT-
C  UTION).
      REAL W(NBANDS,NROW),B(NROW)
      IF (NROW .GT. 1)                  GO TO 21
      B(1) = B(1)*W(1,1)
                                        RETURN
C
C                 FORWARD SUBSTITUTION. SOLVE L*Y = B FOR Y, STORE IN B.
   21 NBNDM1 = NBANDS - 1
      DO 30 N=1,NROW
         JMAX = MIN0(NBNDM1,NROW-N)
         IF (JMAX .LT. 1)               GO TO 30
         DO 25 J=1,JMAX
            JPN = J + N
   25       B(JPN) = B(JPN) - W(J+1,N)*B(N)
   30    CONTINUE
C
C     BACKSUBSTITUTION. SOLVE L-TRANSP.X = D**(-1)*Y  FOR X, STORE IN B.
      N = NROW
   31    B(N) = B(N)*W(1,N)
         JMAX = MIN0(NBNDM1,NROW-N)
         IF (JMAX .LT. 1)               GO TO 40
         DO 35 J=1,JMAX
            JPN = J + N
   35       B(N) = B(N) - W(J+1,N)*B(JPN)
   40    N = N-1
      IF (N.GT.0)                       GO TO 31
                                        RETURN
      END
