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 36
36
37
37
import mkl_fft
38
38
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 )
44
44
45
45
46
46
def _datacopied (arr , original ):
@@ -66,11 +66,11 @@ def setUp(self):
66
66
def test_vector1 (self ):
67
67
"""check that mkl_fft gives the same result of numpy.fft"""
68
68
f1 = mkl_fft .fft (self .xz1 )
69
- f2 = np_fft . fft (self .xz1 )
69
+ f2 = naive_fft1d (self .xz1 )
70
70
assert_allclose (f1 ,f2 , rtol = 1e-7 , atol = 2e-12 )
71
71
72
72
f1 = mkl_fft .fft (self .xc1 )
73
- f2 = np_fft . fft (self .xc1 )
73
+ f2 = naive_fft1d (self .xc1 )
74
74
assert_allclose (f1 ,f2 , rtol = 2e-6 , atol = 2e-6 )
75
75
76
76
def test_vector2 (self ):
Original file line number Diff line number Diff line change 36
36
37
37
import mkl_fft
38
38
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
-
45
39
reps_64 = (2 ** 11 )* np .finfo (np .float64 ).eps
46
40
reps_32 = (2 ** 11 )* np .finfo (np .float32 ).eps
47
41
atol_64 = (2 ** 8 )* np .finfo (np .float64 ).eps
You can’t perform that action at this time.
0 commit comments