tridiag
Solve tridiagonal system of equations,
y=tridiag(dm1,d,dp1,rhs)
Inputs
dm1 The subdiagonal below the main diagonal.
d The main diagonal.
dp1 The subdiagonal above the main diagonal.
rhs The right hand side of the equation.
Outputs
y The solution of the tridiagonal system of equations.


Description
The function solves the diagoal system of equations:
     d[1]x[1]+dp1[1]*x[2] =rhs[1];
    dm1[1]x[1]+ d[2]*x[2]+dp2[2]*x[3] =rhs[2];
     dm1[2]*x[2]+ d[3]*x[3]+dp1[3]*x[4] =rhs[3];
    ...
    ...
No pivoting is used, and so the matrix defined by the inputs must be non-singular and numerically well-conditioned for the results to be reliable.


Example
>>a=[2 -1 0 0;-1 2 -1 0;0,-1,2 -1 ;0 0 -1 2]
>>a
          2         -1          0          0
         -1          2         -1          0
          0         -1          2         -1
          0          0         -1          2

>>rhs=[2 3 4 5]'
>>a\rhs
    6.0000
   10.0000
   11.0000
    8.0000

>>dm1=-ones(4,1),d=ones(4,1)*2,dp1=dm1
>>tridiag(dm1,d,dp1,rhs)
    6.0000
   10.0000
   11.0000
    8.0000