% The anti_alias function multiplies the a signal by a filter function in the
% frequency domain. This must correspond to a convolution in the time domain.
% Question: what is the convolution kernel that corresponds to this filter?
N = 8;
fft_delta = ones(1,N); % This is the FFT of a delta function at the origin.
fft_filter = anti_alias(fft_delta);
kernel = ifftn(fft_filter);

figure(1)
hold off
bar(real(kernel),'b') 
hold on
bar(imag(kernel),'r')
title("Convolution kernel of the anti-aliasing filter")
xlabel("time, t (array index)")
ylabel("Kernel, K(t)")
legend("Re(K)","Im(K)")
hold off
print("test4_N8.pdf","-dpdf")


N = 100;
fft_delta = ones(1,N); % This is the FFT of a delta function at the origin.
fft_filter = anti_alias(fft_delta);
kernel = ifftn(fft_filter);

figure(2)
hold off
bar(real(kernel),'b') 
hold on
bar(imag(kernel),'r') 
title("Convolution kernel of the anti-aliasing filter")
xlabel("time, t (array index)")
ylabel("Kernel, K(t)")
legend("Re(K)","Im(K)")
hold off
print("test4_N100.pdf","-dpdf")
