% MULUV   multiply a vector with a generator representable semiseparable matrix
%       
%       x=MULUV(U,V,b) This function multiplies the generator
%       representable matrix S, with generators U and V with the vector b
%  
%       U and V are two column vectors.
%
%       b should be an arbitrary column vector of corresponding dimension.
%       the output vector x contains the solution
%       
%
%
%       Software of the MaSe - Group
%       mase-at-cs.kuleuven.ac.be
%       Revision Date: 08/04/2005

function b=MULUV(u,v,d,x)
  
  % initialization 
    n=length(x);
  
  % the part corresponding to multiplication with the diagonal
    b1=d.*x;
    
  % Now the part corresponding to the multiplication of the upper
  % triangular part.
    
  factor=x(n)*u(n);
  b2(n)=0;
  
  for i=n-1:-1:1
    b2(i)=factor*v(i);
    factor=factor+x(i)*u(i);
  end
  
  % Now the part corresponding to the multiplication of the lower
  % triangular part of the matrix
  
  factor=0;
  
  for i=1:n
    factor=factor+x(i)*v(i);
    b3(i)=factor*u(i);
  end
  
  % So the final solution is the sum of all these three components
  b=b1+b2'+b3';
  
  %b1,b2,b3
  
  
  