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
63e7df14cf
commit
164ab47a25
15
fft.py
15
fft.py
@ -17,19 +17,15 @@ def fft(f,inv):
|
|||||||
else:
|
else:
|
||||||
raise Exception('%s not factorable ' % n)
|
raise Exception('%s not factorable ' % n)
|
||||||
|
|
||||||
#print 'n=%d,p=%d' % (n,p)
|
|
||||||
#print f,' << fin'
|
|
||||||
m = n/p
|
m = n/p
|
||||||
Fout=[]
|
Fout=[]
|
||||||
for q in range(p): # 0,1
|
for q in range(p): # 0,1
|
||||||
fp = f[q::p]
|
fp = f[q::p]
|
||||||
#print fp,'<< fp'
|
|
||||||
Fp = fft( fp ,inv)
|
Fp = fft( fp ,inv)
|
||||||
Fout.extend( Fp )
|
Fout.extend( Fp )
|
||||||
|
|
||||||
for u in range(m):
|
for u in range(m):
|
||||||
scratch = Fout[u::m] # u to end in strides of m
|
scratch = Fout[u::m] # u to end in strides of m
|
||||||
#print scratch
|
|
||||||
for q1 in range(p):
|
for q1 in range(p):
|
||||||
k = q1*m + u # indices to Fout above that became scratch
|
k = q1*m + u # indices to Fout above that became scratch
|
||||||
Fout[ k ] = scratch[0] # cuz e**0==1 in loop below
|
Fout[ k ] = scratch[0] # cuz e**0==1 in loop below
|
||||||
@ -50,8 +46,6 @@ def rifft(F):
|
|||||||
Fok = ( F[k] - F[-k-1].conjugate() ) * e ** (j*pi*k/N)
|
Fok = ( F[k] - F[-k-1].conjugate() ) * e ** (j*pi*k/N)
|
||||||
Z[k] = Fek + j*Fok
|
Z[k] = Fek + j*Fok
|
||||||
|
|
||||||
#print 'Z', Z
|
|
||||||
|
|
||||||
fp = fft(Z , 1)
|
fp = fft(Z , 1)
|
||||||
|
|
||||||
f = []
|
f = []
|
||||||
@ -71,7 +65,6 @@ def real_fft( f,inv ):
|
|||||||
|
|
||||||
fp = [ complex(r,i) for r,i in zip(res,ims) ]
|
fp = [ complex(r,i) for r,i in zip(res,ims) ]
|
||||||
Fp = fft( fp ,0 )
|
Fp = fft( fp ,0 )
|
||||||
#print 'F=',Fp
|
|
||||||
|
|
||||||
F = []
|
F = []
|
||||||
for k in range(N):
|
for k in range(N):
|
||||||
@ -83,14 +76,6 @@ def real_fft( f,inv ):
|
|||||||
F.append( complex( Fp[0].real - Fp[0].imag , 0 ) )
|
F.append( complex( Fp[0].real - Fp[0].imag , 0 ) )
|
||||||
return F
|
return F
|
||||||
|
|
||||||
def test(f=range(1024),ntimes=10):
|
|
||||||
import time
|
|
||||||
t0 = time.time()
|
|
||||||
for i in range(ntimes):
|
|
||||||
fft(f,0)
|
|
||||||
t1 = time.time()
|
|
||||||
print '%ss'% (t1-t0)
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
#fft_func = fft
|
#fft_func = fft
|
||||||
fft_func = real_fft
|
fft_func = real_fft
|
||||||
|
Loading…
Reference in New Issue
Block a user