FFT [Python] by 바죠

#!/usr/bin/env python
from numpy.fft import fft
from numpy import zeros
aa=((1., 2., 3., 2., 1. ))
aa_fft=fft(aa)/len(aa)
for i in range(len(aa)):
   print aa_fft[i]
bb=zeros(len(aa)*2,complex)
for i in range(len(aa)):
   bb[i]=aa_fft[i]
#for i in range(len(bb)):
#   print bb[i]


bb_fft=fft(bb)
for i in range(len(bb)):
   print bb_fft[i]



(1.8+0j)
(-0.42360679775-0.307768353718j)
(0.02360679775+0.0726542528005j)
(0.02360679775-0.0726542528005j)
(-0.42360679775+0.307768353718j)
(1+0j)
(1.8-5.51642065361e-16j)
(1+0j)
(1.8+0.906153718637j)
(2+0j)
(1.8+0.760845213036j)
(3+0j)
(1.8-0.760845213036j)
(2+0j)
(1.8-0.906153718637j)

----------------------------------------------
#!/usr/bin/env python
from numpy.fft import fft
from numpy import zeros
aa=((0., 1., 2., 3., 2., 1. ))
print '======'
for i in range(len(aa)):
   print aa[i]
print '======'
aa_fft=fft(aa)/len(aa)
for i in range(len(aa)):
   print aa_fft[i]
print '======'
bb=zeros(len(aa)*2,complex)
for i in range(len(aa)*2):
   bb[i]=0.+0.j
for i in range(len(aa)):
   bb[2*i]=aa_fft[i]

print '======'


bb_fft=fft(bb)
for i in range(len(bb)):
   print bb_fft[i]


======
0.0
1.0
2.0
3.0
2.0
1.0
======
(1.5+0j)
(-0.666666666667+1.48029736617e-16j)
0j
(-0.166666666667-2.90348170526e-16j)
0j
(-0.666666666667+1.4231843391e-16j)
======
======
0j
(1+6.38378239159e-16j)
(2-1.13797860024e-15j)
(3+0j)
(2-6.38378239159e-16j)
(1+1.13797860024e-15j)
0j
(1+6.38378239159e-16j)
(2-1.13797860024e-15j)
(3+0j)
(2-6.38378239159e-16j)
(1+1.13797860024e-15j)


핑백

덧글

댓글 입력 영역

최근 포토로그



MathJax