%  MULT   performs an O(n) matrix vector multiplication
%    
%    B=MULT(sd,d,X) is the vector B=T*X where T is the symmetric
%    tridiagonal matrix with sub/superdiagonal elements in sd, and the
%    diagonal elements stored in d.
%
%
%    Software of the MaSe - Group
%    mase-at-cs.kuleuven.ac.be
%    Revision Date: 04/10/2004
%


function b=MULT(sd,d,x)
    
  n=length(d);
  if n~=0
    % performs the multiplication with the
    % upper triangular part of the matrix
    if n~=1
      b(n)=x(n); 
      for i=2:n-1
        b(i)=sd(i-1)*x(i-1)+d(i)*x(i)+sd(i)*x(i+1);
      end
      b(1)=x(1)*d(1)+x(2)*sd(1);
      b(n)=x(n)*d(n)+x(n-1)*sd(n-1);
      b=b';
    else
      b=x*d;
    end
  else
    b=[];
  end
  
  