scipy.fftpack.next_fast_len¶

scipy.fftpack.
next_fast_len
(target)[source]¶ Find the next fast size of input data to
fft
, for zeropadding, etc.SciPy’s FFTPACK has efficient functions for radix {2, 3, 4, 5}, so this returns the next composite of the prime factors 2, 3, and 5 which is greater than or equal to target. (These are also known as 5smooth numbers, regular numbers, or Hamming numbers.)
 Parameters
 targetint
Length to start searching from. Must be a positive integer.
 Returns
 outint
The first 5smooth number greater than or equal to target.
Notes
New in version 0.18.0.
Examples
On a particular machine, an FFT of prime length takes 133 ms:
>>> from scipy import fftpack >>> min_len = 10007 # prime length is worst case for speed >>> a = np.random.randn(min_len) >>> b = fftpack.fft(a)
Zeropadding to the next 5smooth length reduces computation time to 211 us, a speedup of 630 times:
>>> fftpack.helper.next_fast_len(min_len) 10125 >>> b = fftpack.fft(a, 10125)
Rounding up to the next power of 2 is not optimal, taking 367 us to compute, 1.7 times as long as the 5smooth size:
>>> b = fftpack.fft(a, 16384)