def FFT(P):
n = len(P) # n is power of 2
if n == 1;
return P
w = e^(2*pi*i/n)
Pe,Po = [p0,p2,...,pn-2],[p1,p3,...,pn-1]
ye,yo = FFP(Pe),FFT(Po)
y = [0]*n
for j in range(n/2):
y[j] = ye[j] + wj*yo[j]
y[j+n/2] = ye[j]-wj*yo[j]
return y
把值转化为系数表示
写成程序
def FFT(P):
n = len(P) # n is power of 2
if n == 1;
return P
w = (1/n)*e^(-2*pi*i/n)
Pe,Po = P[::2],P[1::2]
ye,yo = FFP(Pe),FFT(Po)
y = [0]*n
for j in range(n/2):
y[j] = ye[j] + wj*yo[j]
y[j+n/2] = ye[j]-wj*yo[j]
return y