%
%  FIR filtering and decimation by 2 on p-periodic input

function v=pcqfilter(u, f, p)
p2=p/2;       % Period of output v, decimated by 2
v=zeros(1,p2);  % Allocate output array
lf=length(f);    % FIR filter length.
for n=0:p2-1
  for k=0:lf-1
    v(1+n) = v(1+n) + f(1+k)*u(1+mod(k+2*n,p));
  end
end
return

