'===========================================================================
' Subject: SOLVE TRIDIAGONAL LINEAR SYSTEM    Date: 09-23-99 (08:21)       
'  Author: Robert L. Roach                    Code: QB, QBasic, PDS        
'  Origin: rroach@cvd-pro.com               Packet: ALGOR.ABC
'===========================================================================
1000 REM------------------- SUBROUTINE TSOLV ------------------------
REM
REM        This subroutine solves a tridiagonal linear system of the form:
REM
REM               C(i) * x(i-1)  +   B(i) * x(i)  +  A(i) * x(i+1)  =  D(i)
REM
REM         It is assumed that the user has defined the vectors and the
REM         number of unknowns, N.  This routine is designed to be called
REM         in a GOSUB statement.  The solution is returned in the D(i) array.
REM
REM--------------------------------------------------------------------------------
REM------- Eliminate the C diagonal
        FOR I = 2 TO N
          CBI = C(I) / B(I - 1)
          B(I) = B(I) - CBI * A(I - 1)
          D(I) = D(I) - CBI * D(I - 1)
        NEXT

REM-------- Solution on last Row 
       D(N) = D(N) / B(N)

REM-------- Solution Elsewhere
        FOR I = N - 1 TO 1 STEP -1
          D(I) = (D(I) - A(I) * D(I + 1)) / B(I)
        NEXT

REM------- Done ----------------
        RETURN
