File tree Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change 3636
3737import mkl_fft
3838
39- from distutils . version import LooseVersion
40- if LooseVersion ( np . __version__ ) < LooseVersion ( '1.17.0' ):
41- import numpy . fft . fftpack as np_fft
42- else :
43- import numpy . fft . pocketfft as np_fft
39+ def naive_fft1d ( vec ):
40+ L = len ( vec )
41+ phase = - 2j * np . pi * ( np . arange ( L ) / float ( L ))
42+ phase = np . arange ( L ). reshape ( - 1 , 1 ) * phase
43+ return np . sum ( vec * np . exp ( phase ), axis = 1 )
4444
4545
4646def _datacopied (arr , original ):
@@ -66,11 +66,11 @@ def setUp(self):
6666 def test_vector1 (self ):
6767 """check that mkl_fft gives the same result of numpy.fft"""
6868 f1 = mkl_fft .fft (self .xz1 )
69- f2 = np_fft . fft (self .xz1 )
69+ f2 = naive_fft1d (self .xz1 )
7070 assert_allclose (f1 ,f2 , rtol = 1e-7 , atol = 2e-12 )
7171
7272 f1 = mkl_fft .fft (self .xc1 )
73- f2 = np_fft . fft (self .xc1 )
73+ f2 = naive_fft1d (self .xc1 )
7474 assert_allclose (f1 ,f2 , rtol = 2e-6 , atol = 2e-6 )
7575
7676 def test_vector2 (self ):
Original file line number Diff line number Diff line change 3636
3737import mkl_fft
3838
39- from distutils .version import LooseVersion
40- if LooseVersion (np .__version__ ) < LooseVersion ('1.17.0' ):
41- import numpy .fft .fftpack as np_fft
42- else :
43- import numpy .fft .pocketfft as np_fft
44-
4539reps_64 = (2 ** 11 )* np .finfo (np .float64 ).eps
4640reps_32 = (2 ** 11 )* np .finfo (np .float32 ).eps
4741atol_64 = (2 ** 8 )* np .finfo (np .float64 ).eps
You can’t perform that action at this time.
0 commit comments