Fast Fourier transform: Difference between revisions
Content added Content deleted
(→Tcl: Added implementation) |
m (→{{header|Tcl}}: Make it clearer what is produced) |
||
Line 102: | Line 102: | ||
printwave wave |
printwave wave |
||
# Uses FFT if input length is power of 2, and a less efficient algorithm otherwise |
# Uses FFT if input length is power of 2, and a less efficient algorithm otherwise |
||
set fft |
set fft [math::fourier::dft $wave] |
||
# Convert to magnitudes for printing |
|||
⚫ | |||
set fft2 [waveMagnitude $fft] |
|||
⚫ | |||
Output: |
Output: |
||
<pre> |
<pre> |
||
wave: 0.000 0.924 0.707 -0.383 -1.000 -0.383 0.707 0.924 0.000 -0.924 -0.707 0.383 1.000 0.383 -0.707 -0.924 |
wave: 0.000 0.924 0.707 -0.383 -1.000 -0.383 0.707 0.924 0.000 -0.924 -0.707 0.383 1.000 0.383 -0.707 -0.924 |
||
fft2: 0.000 0.000 0.000 8.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 8.000 0.000 0.000 |
|||
</pre> |
</pre> |