mirror of
https://github.com/mborgerding/kissfft.git
synced 2025-05-27 21:20:27 -04:00
*** empty log message ***
This commit is contained in:
parent
18e5e8e360
commit
66b0646c9c
17
fft.py
17
fft.py
@ -4,21 +4,18 @@ pi=math.pi
|
||||
e=math.e
|
||||
j=complex(0,1)
|
||||
|
||||
def T(n,k):
|
||||
return e ** -2*j*pi*k/n
|
||||
|
||||
def fft(f):
|
||||
n=len(f)
|
||||
if n==1:
|
||||
return f
|
||||
|
||||
for p in 4,3,2,5:
|
||||
for p in 2,3,5:
|
||||
if n%p==0:
|
||||
break
|
||||
else:
|
||||
raise Exception('%s not factorable ' % n)
|
||||
m = n/p
|
||||
|
||||
m = n/p
|
||||
Fm=[]
|
||||
for q in range(p): # 0,1
|
||||
fp = f[q::p]
|
||||
@ -29,9 +26,17 @@ def fft(f):
|
||||
for k in range(n):
|
||||
val = 0
|
||||
for q in range(p):
|
||||
t = e ** ( -j*2*pi*k*q/n )
|
||||
t = e ** ( j*2*pi*k*q/n )
|
||||
val += Fm[ q*m + (k%m) ] * t
|
||||
Fout[k] = val
|
||||
|
||||
return Fout
|
||||
|
||||
def test(f=range(256),ntimes=10):
|
||||
import time
|
||||
t0 = time.time()
|
||||
for i in range(ntimes):
|
||||
fft(f)
|
||||
t1 = time.time()
|
||||
print '%ss'% (t1-t0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user