Fast Fourier transform: Difference between revisions

Content added Content deleted
Line 619: Line 619:


<lang MATLAB> fft([1,1,1,1,0,0,0,0]')
<lang MATLAB> fft([1,1,1,1,0,0,0,0]')

function d = myfft(x)

if x>1
l2 = L/2;
a = myfft(x(1:2:L-1));
b = myfft(x(2:2:L));
c = (cos(2*pi*L^-1)-j*sin(2*pi*L^-1)).^[0:l2-1];
c1 = c.*b;
d = [(a+c1),(a-c1)];
else
d = x;
end

</lang>
</lang>
Output:
Output:
Line 631: Line 645:
0.00000 - 0.00000i
0.00000 - 0.00000i
1.00000 + 2.41421i</pre>
1.00000 + 2.41421i</pre>



=={{header|OCaml}}==
=={{header|OCaml}}==