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

%  TRI_MUL multiplies a tridiagonal matrix times a vector.
%
%  function b = tri_mul ( sub, diag, sup, x )
%
%  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 X(N), the vector to be multiplied.
%
%  real B(N), the product A*X.
%
%  Author:
%
%    John Burkardt
%
 n = length ( x );
 b = zeros ( size ( x ) );
 
 b(1:n) = diag(1:n) .* x(1:n);
 b(1:n-1) = b(1:n-1) + sup(1:n-1) .* x(2:n);
 b(2:n) = b(2:n) + sub(1:n-1) .* x(1:n-1);
 