% crevconv.m
% usage: Y = crevconv(X,h) 
% Performs circular convolution by the time reversal of the causal filter h on X.
% The result has the same size as X.
% It is assumed that length(h) <= length(X).

function Y=crevconv(X,h)
  Y = conv(X,flipud(h(:)));
  m = length(X);
  n = length(Y);
  Y(m+1:n) = Y(m+1:n)+Y(1:n-m);
  Y = Y(n-m+1:n);
  
                   
