%% circconvs.m
% usage: Y = circconvs(X,hp,hn) 
% Sparse circular convolution
% by a causal anti-causal filter pair
% Performs circular convolution by hp+hn on X, 
% the result has the same size as X.
% It is assumed that length(hp)+length(hn) <= length(X). 
% The result is the same as computing the circular 
% convolution by h = [hp 0 ... 0,hn]
% where h has been zero-padded out to the length of X, 
% hp is the causal part of h and hn is the anticausal part

% S. Allen Broughton 28 Oct 10

function Y=circconvs(X,hp,hn)
s = length(hn);
t = length(X);
Z = X(:);
Yp = circconv(Z,hp);
Yn = circconv(Z,hn);
Yn = [Yn(s+1:t);Yn(1,s)];
Y= Yp+Yn;
if (size(X,1)==1) Y = Y.'; end;

                   
