Fast Fourier Transform, Algorithms, Pattern Matching, Convolution, Combination Sum.
in range(g1): r[i][j] = p_dft[i][j]*q_dft[i][j] # Do 2d inverse fourier transform on r r_idft = fft_2d(r, omega_x_inv, omega_y_inv) # Coefficient matrix c = [[0]*g1 for i in range(g2)] for i in range(g2): for j in range(g1): x = r_idft[i][j].real c[i][j] = round(x/(g1*g2), 5) return c As you can