Jump to content

Fast Fourier transform: Difference between revisions

Line 1,993:
{{out}}
<pre>{4. + 0. I, 1. - 2.4142136 I, 0. + 0. I, 1. - 0.41421356 I, 0. + 0. I, 1. + 0.41421356 I, 0. + 0. I, 1. + 2.4142136 I}</pre>
 
Here is a user-space definition for good measure.
 
<lang Mathematica>fft[l__ /; Length@l == 1] := N@l
fft[l__] :=
Join[#, #] &@fft@l[[1 ;; ;; 2]] +
Exp[(-2 \[Pi] I)/Length@l (Range@Length@l - 1)] (Join[#, #] &@
fft[l[[2 ;; ;; 2]]])
 
fft[{1, 1, 1, 1, 0, 0, 0, 0}] // Column</lang>
{{out}}
<pre>4.
1. -2.41421 I
0. +0. I
1. -0.414214 I
0.
1. +0.414214 I
0. +0. I
1. +2.41421 I
</pre>
 
=={{header|MATLAB}} / {{header|Octave}}==
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.