function x = tri_sol ( sub, diag, sup, b )

%  TRI_SOL solves a tridiagonal linear system.
%
%  function x = tri_sol ( sub, diag, sup, b )
%
%  real SUB(1:N-1), the subdiagonal elements of the matrix.
%  real DIAG(N), the diagonal elements of the matrix.
%  real SUP(1:N-1), the superdiagonal elements of the matrix.
%  real B(N), the right hand side of the linear system.
%
%  real X(N), the solution of the linear system.
%
%  Reference:
%
%    Charles Van Loan,
%    Introduction to Scientific Computing,
%    Prentice Hall, 1997.
%

%
%  Compute LU factors of the matrix.  A = L*U.
%
[ lvec, uvec ] = tri_fac ( sub, diag, sup );
%
%  Solve L * y = b.
%
y = lbi_sol ( lvec, b );
%
%  Solve U * x = y.
%
x = ubi_sol ( uvec, sup, y );