1

I need two functions fft and ifft in python to a 2d numpy matrix of dtype complex128.

Howevr, I checked possible solutions online:

  1. Numba obviously is not supporting any fft. except numba.cuda

  2. pyfft, was not downloadable in visual studio, and had only fft, on ifft. see examples here https://pypi.org/project/pyfft/0.3.3/#cuda

  3. similiar reikna.fft does not have IFFT

(Basically from this post Improving FFT performance in Python)

  1. from the introduction of pyfftw https://pypi.org/project/pyFFTW/ , it did not provide any advantage over numpy.

  2. compare to numpy, scipy was around 5%-10% faster, and better.

  3. there seemed a mention of nufft, see https://jakevdp.github.io/blog/2015/02/24/optimizing-python-with-numpy-and-numba/ , but again it's not download in visual studio.

  4. The other option left to pycuda, yet, it seemed much complicated(even compare to pyfft, and I don't have the time right now to figure out basically another language.)

But notice that, since scipy's fft and ifft does not seem to implement parallel computation, it's much slower than matlab's fft and ifft, by around 2 to 2.5 times.

So the only option left seem to write fft and use numba to translate it into paralla c code: (algorithm)2D Fourier Transformation in C and (amplitude)amplitude of numpy's fft results is to be multiplied by sampling period? . Also, see Matlab's formulas: https://www.mathworks.com/help/matlab/ref/fft2.html and https://www.mathworks.com/help/matlab/ref/ifft2.html .

Question 1: What's the best way to utilize cpu or gpu to calculate fft AND ifft(in 2D and 3D)? Like that of pyfft's Plan(gpu), or paralla cpu computation?

Question 2: Could you provide some links to papers or algorithms, or is there existing packages that's is easy to use(for visual studio)? like pseudocode: https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm#Pseudocode

b-fg
  • 3,959
  • 2
  • 28
  • 44
  • 1
    Unfortunately, questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. – Andreas Dec 17 '18 at 04:38
  • 2
    Checkout this nice blog post: https://blog.mide.com/matlab-vs-python-speed-for-vibration-analysis-free-download. There is also cupy (http://docs-cupy.chainer.org/en/stable/reference/fft.html), a GPU-accelerated version of numpy. – anki Dec 17 '18 at 09:40
  • 1
    "from the introduction of pyfftw, it did not provide any advantage over numpy." -- From the landing page of pyFFTW, which you linked: "Operating FFTW in multithreaded mode is supported." FFTW is what MATLAB uses. If you want to match MATLAB's speed, use pyFFTW. – Cris Luengo Dec 17 '18 at 16:00
  • 1
    Apart from FFTW you can also try the MKL implementation. https://github.com/IntelPython/mkl_fft – max9111 Dec 18 '18 at 08:43

0 Answers0