function fg = convSlow(f,g)
%   fg = convSlow(f,g) performs convolution of f and g
if length(g) > length(f), temp = f; f = g; g = temp; end
N1 = length(f);
N2 = length(g);
n = min(N1,N2);

fg = zeros(1,N1+N2-1);
gBackward = g(end:-1:1);

% Deal with the first end points
for t = 1:n
    fg(t) = f(1:t).'*g(t:-1:1);
end

% Deal with the "bulk"
inc = 1:n;
for t = n+1:N1
    fg(t) = f(inc+(t-n)).'*gBackward;
end

% Deal with the last end points
for t = N1+1:N1+n-1
    s = N1+n-t;
    fg(t) = f(end-s+1:end).'* gBackward(1:s);
end

fg = fg.';      % use same conventions as Matlab