function y=firfilt(x, h)
% Direct convolution sum evaluation. x is assumed to be very
% long, and the initial and final values of y where does not
% fully overlap x are ignored.
x = x(:); % make sure h and x are column vectors
h = h(:);
P = length(h);
N = length(x);
h_ = flipud(h); % Time reverse h
y = zeros(N-P+1,1);
flops(0);
for n = 1:N-P+1
y(n) = h_.'* x(n:n+P-1);
end