fft_next_len() returns the smallest length at least n that zufft
transforms fastest, and fft_prev_len() the largest at most n. Padding
or cropping an input to such a length with the n argument of the
transforms can speed them up considerably. They are SciPy's
next_fast_len() and prev_fast_len().
Details
Fast lengths have no prime factor above 11 for complex transforms, or
above 5 for real ones (real = TRUE), as in ducc0's good_size.
See also
stats::nextn(), R's own version for stats::fft().
Other helpers:
fft_freq(),
fft_shift()
Examples
fft_next_len(c(1009, 999983))
#> [1] 1024 1000000
fft_next_len(1009, real = TRUE)
#> [1] 1024
fft_prev_len(1009)
#> [1] 1008