Exemple #1
0
 def test_hfft(self):
     x = random(14) + 1j*random(14)
     x_herm = np.concatenate((random(1), x, random(1)))
     x = np.concatenate((x_herm, x[::-1].conj()))
     assert_array_almost_equal(fft.fft(x), fft.hfft(x_herm))
     assert_array_almost_equal(fft.hfft(x_herm) / np.sqrt(30),
                               fft.hfft(x_herm, norm="ortho"))
Exemple #2
0
 def test_ihfft(self):
     x = random(14) + 1j * random(14)
     x_herm = np.concatenate((random(1), x, random(1)))
     x = np.concatenate((x_herm, x[::-1].conj()))
     assert_array_almost_equal(x_herm, fft.ihfft(fft.hfft(x_herm)))
     for norm in ["backward", "ortho", "forward"]:
         assert_array_almost_equal(
             x_herm, fft.ihfft(fft.hfft(x_herm, norm=norm), norm=norm))
Exemple #3
0
 def test_hfft(self):
     x = random(14) + 1j * random(14)
     x_herm = np.concatenate((random(1), x, random(1)))
     x = np.concatenate((x_herm, x[::-1].conj()))
     expect = fft.fft(x)
     assert_array_almost_equal(expect, fft.hfft(x_herm))
     assert_array_almost_equal(expect, fft.hfft(x_herm, norm="backward"))
     assert_array_almost_equal(expect / np.sqrt(30),
                               fft.hfft(x_herm, norm="ortho"))
     assert_array_almost_equal(expect / 30, fft.hfft(x_herm,
                                                     norm="forward"))
Exemple #4
0
 def test_dtypes(self, dtype):
     # make sure that all input precisions are accepted
     x = random(30).astype(dtype)
     assert_array_almost_equal(fft.ifft(fft.fft(x)), x)
     assert_array_almost_equal(fft.irfft(fft.rfft(x)), x)
     assert_array_almost_equal(fft.hfft(fft.ihfft(x), len(x)), x)