def test_3d_complex(self): u = self.__generate(self.shp, 3, 1) fft = Fft(u) uf = fft.fft(u) uf0 = np.fft.fftn(u) errmax = np.abs(uf - uf0).max() maxtol = 1e-7 # error increase with dimensions self.assertTrue(errmax < maxtol, msg="FFT 3D failed on shape %s (err_max = %e when it should be < %e)" % (str(u.shape), errmax, self.maxtol))
def test_2d_real(self): u = self.__generate(self.shp, 2, 0) fft = Fft(u) uf = fft.fft(u) uf0 = np.fft.rfft2(u) errmax = np.abs(uf - uf0).max() self.assertTrue(errmax < self.maxtol, msg="RFFT 2D failed on shape %s (err_max = %e when it should be < %e)" % (str(u.shape), errmax, self.maxtol)) u1 = fft.ifft(uf) #~ u0 = np.fft.irfft(uf0) errmax = np.abs(u1 - u).max() # for odd sizes, numpy.fft.irfft outputs modified shapes self.assertTrue(errmax < self.maxtol, msg="IRFFT 2D failed on shape %s (err_max = %e when it should be < %e)" % (str(u.shape), errmax, self.maxtol))