python - Replacing numpy.fft routines with pyfftw, not working as expected -


i have working python code making use of numpy.fft package, here snippet:

for in range(steps):     print     psixvec = ux * psixvec     psikvec = uk * np.fft.fftn(psixvec)     psixvec = np.fft.ifftn(psikvec)  return psixvec 

i tried rewrite code make use of pyfftw package. came following code, should work:

fft = fftw.builders.fftn(psix_align, auto_align_input = true, auto_contiguous = true,                       overwrite_input = false, threads = 1, avoid_copy = false)  ifft = fftw.builders.ifftn(psik_align, auto_align_input = true, auto_contiguous = true,                       overwrite_input = false, threads = 1, avoid_copy = false)    in range(steps):     psix_align[:] = ux * psix_align     psik_align[:] = uk * fft()     psix_align[:] = ifft()  return psix_align 

the problem is, code not produce same result using numpy.fft package. see attached images.

numpy fft package pyfftw package

solved. initialization using

psix_align = fftw.n_byte_align(psi0, fftw.simd_alignment, dtype='complex64') psik_align = fftw.n_byte_align(np.zeros_like(psi0), fftw.simd_alignment, dtype='complex64') 

i needed replace complex64 complex128. same result. that's due fact numbers involved small (see 1e-11 on z-axis).

edit: maybe can add pyfftw tags of question?


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -