impemented FFT with numpy and recursion
This commit is contained in:
7
FFT.py
7
FFT.py
@ -20,12 +20,15 @@ def FFT_real(inp):
|
||||
|
||||
|
||||
def FFT(inp):
|
||||
return FFT_np(inp)
|
||||
|
||||
def FFT_np(inp):
|
||||
inp = np.array(inp)
|
||||
N = inp.shape[0]
|
||||
if N == 1:
|
||||
return inp
|
||||
X_even = FFT(inp[::2])
|
||||
X_odd = FFT(inp[1::2])
|
||||
X_even = FFT_np(inp[::2])
|
||||
X_odd = FFT_np(inp[1::2])
|
||||
k = np.arange(N // 2)
|
||||
tw = np.exp(-2j * np.pi * k / N) * X_odd
|
||||
return np.concatenate((X_even + tw, X_even - tw))
|
||||
|
||||
Reference in New Issue
Block a user