%  MULUS   performs an O(n) matrix vector multiplication
%    
%    B=MULUS(G,d,X) is the vector B=US*X where US is the upper triangular
%    semiseparable matrix represented with the Givens-vector
%    representation G,d
%
%
%    Software of the MaSe - Group
%    mase-at-cs.kuleuven.ac.be
%    Revision Date: 04/05/2004
%


function b=MULUS(G,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=n-1:-1:1
        b(i)=b(i+1)*G(2,i)+G(1,i)*x(i);
        b(i+1)=b(i+1)*d(i+1);
      end
      
      b(1)=b(1)*d(1);
      b=b';
    else
      b=x*d;
    end
  else
    b=[];
  end
  
  