First, this is not a duplicate! I found similar questions on this site but they do not answer this question.
I tried to use the convolution theorem in Python. I have two N*N arrays where I can change the value of N.
For example,
import numpy as np
import scipy.signal as sp
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
b = np.array([[1,2,3],[4,5,6],[7,8,9]])
np.fft.fft2(a*b)
sp.convolve2d(np.fft.fft2(a), np.fft.fft2(b), mode='same', boundary='wrap') / 9
The /9 arises becasue Numpy fft uses backward normalization and I need to divide the number of elements here. However, the above two do not agree. I don't know where I went wrong.
I need to note that the above code somehow works when N = 2, i.e. when the size of the array is 2x2.
Also, FT( convolve(a,b) ) = FT(a) times FT(b) holds, but the alternate form I have here does not hold FT(a times b) = convolve( FT(a) , FT(b) )
I want to know where I went wrong and a correct example for FT(a times b) = convolved (FT(a), FT(b))
FFT( convolution(a,b)) = FFT(a) * FFT(b)