Fast Fourier transform: Difference between revisions

Updated D code
(Updated D code)
Line 347:
int N = x.length;
if (N <= 1) return x;
auto ev = fft(array(stride(x, 2).array().fft();
auto od = fft(array(stride(x[1 .. $], 2).array().fft();
auto l = map!(k => ev[k] + expi(-2*PI*k/N) * od[k])(iota(N / 2));
auto r = map!(k => ev[k] - expi(-2*PI*k/N) * od[k])(iota(N / 2));
return array(l.chain(l, r).array();
}
 
Line 358:
}</lang>
Output:<pre>[4+0i, 1+-2.41421i, 0+0i, 1+-0.414214i, 0+0i, 1+0.414214i, 0+0i, 1+2.41421i]</pre>
But in D2 built-in complex numbers will be deprecated.
 
=={{header|GAP}}==