def types(x): warnings.warn("math.types is deprecated. Use struct.dtype isntead.", DeprecationWarning) try: return math.dtype(x) except NoBackendFound: return type(x)
def fourier_poisson(tensor, times=1): """ Inverse operation to `fourier_laplace`. """ frequencies = math.fft(math.to_complex(tensor)) k = fftfreq(math.staticshape(tensor)[1:-1], mode='square') fft_laplace = -(2 * np.pi)**2 * k fft_laplace[(0, ) * math.ndims(k)] = np.inf return math.cast( math.real( math.ifft(math.divide_no_nan(frequencies, fft_laplace**times))), math.dtype(tensor))