function f = pconv(a,b)
% PCONV(A,B) is the periodic convolution of two row vectors A and B.
% A and B must be the same length. The convolution is normalised.
% The first convolution of [a1 a2 a3 a4] with [b1 b2 b3 b4] is the 
% product [a1b1 + a2b4 + a3b3 + a4b2] and the sense then proceeds as
% if B were rotated right. That is:
% PCONV([1 2 3 4], [0 4 0 0]) = [4 1 2 3].  Compare with
% PCORR([1 2 3 4], [0 4 0 0]) = [2 3 4 1].

% written by DG on 30/4/02. Uses Matlab function CONV.

N = length(a);
if (length(b) ~= N)
    error('Vectors for convolution function must be same length')
end

f = conv(a,[b b]);
f = f(N+1:2*N)/N;

