How can I optimize the FFT of very large arrays
13 views (last 30 days)
Show older comments
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
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.
Answers (1)
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)
tic
FTsignal1 = fft(signal)/L;
toc
NFFT = 2^nextpow2(L)
tic
FTsignal2 = fft(signal,NFFT)/L;
toc
For the same signal, the calculation time is about 25% that of the un-padded signal.
.
0 Comments
See Also
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!