How can I optimize the FFT of very large arrays

6 views (last 30 days)
Hello,
I am running a code involving the FFT and the IFFT of very big (up to millions of elements in total) 3D arrays currently using fftn and ifftn. Since the operation is carried out several times, it constitutes a big chunck of the calculation time of my code. How can I optimize my code?
  • Would the use of fftw library be beneficial?
  • The MATLAB guide for fftn also includes the use of thread-based environments, GPU, and distributed arrays to improve the performance of the code. How would these work? I'm sorry, but I'm not familiar to these methodologies.
Thank you for your help in advance
  6 Comments
Walter Roberson
Walter Roberson on 16 Sep 2022
MATLAB fft function implementation is already compiled code that automatically uses multiple cores if available. It is not written in MATLAB itself.

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 16 Sep 2022
One option may be to be certain that the original signal so that its length is zero-padded to a power of 2:
Fs = 256;
t = linspace(0, 1E+8, 1E+8+1)/Fs;
signal = sin(2*pi*t*2);
L = numel(signal)
L = 100000001
tic
FTsignal1 = fft(signal)/L;
toc
Elapsed time is 16.542528 seconds.
NFFT = 2^nextpow2(L)
NFFT = 134217728
tic
FTsignal2 = fft(signal,NFFT)/L;
toc
Elapsed time is 4.468461 seconds.
For the same signal, the calculation time is about 25% that of the un-padded signal.
.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!