Anonymous user
Fast Fourier transform: Difference between revisions
m
→{{header|Python}}: Tidy
m (→{{header|Python}}: Tidy) |
|||
Line 75:
print fft([1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0])</lang>
'''Output:'''
<pre>[(4+0j), (1-2.4142135623730949j), 0j, (1-0.41421356237309492j), 0j, (0.99999999999999989+0.41421356237309492j), 0j, (0.99999999999999967+2.4142135623730949j)]</pre>
===Using module [http://numpy.scipy.org/ numpy]
<lang python>>>> from numpy.fft import fft
>>> from numpy import array
>>> a = array((0.0, 0.924, 0.707, -0.383, -1.0, -0.383, 0.707, 0.924, 0.0, -0.924, -0.707, 0.383, 1.0, 0.383, -0.707, -0.924))
>>> print( ' '.join("%5.3f" % abs(f) for f in fft(a)) )
0.000 0.001 0.000 8.001 0.000 0.001 0.000 0.001 0.000 0.001 0.000 0.001 0.000 8.001 0.000 0.001</lang>
=={{header|Tcl}}==
|