Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
np.exp(-2j*np.pi/g1) omega_y = np.exp(2j*np.pi/g2) omega_y_inv = np.exp(-2j*np.pi/g2) # Perform 2d FFT on p and q p_dft = fft_2d(p, omega_x, omega_y) q_dft = fft_2d(q_new, omega_x, omega_y) # Do elementwise multiplication to get the R matrix r = [[0]*g1 for i in range(g2)] for i in range(g2): for j