During testing I have noticed something strange.
I’m FFT’ing a lot of vectors, and from time to time the numpy FFT function seemed to crash.
I briefly debu
I think that power 2 padding of array some times has several disadvantages:
I have found in this topic that fft performance depends on the array size prime factorization. If the array length is prime number it lead to long calculation time. So I propose following code that decreases array length looking for best it factorization.
from sympy.ntheory import factorint
FACTOR_LIMIT = 100
def bestFFTlength(n):
while max(factorint(n)) >= FACTOR_LIMIT:
n -= 1
return n
a = np.zeros(166400)
audio_fft = np.fft.fft(a,bestFFTlength(len(a)))