Fast Fourier transform: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: give terser functional version, along with its drawback and fix) |
m (Bug fix for the optimized version.) |
||
Line 392: | Line 392: | ||
// Better optimized but less intuitive |
// Better optimized but less intuitive |
||
// !!! Warning : in some cases this code make result different from not optimased version above (need to fix bug) |
// !!! Warning : in some cases this code make result different from not optimased version above (need to fix bug) |
||
// The bug is now fixed @2017/05/30 |
|||
void fft(CArray &x) |
void fft(CArray &x) |
||
{ |
{ |
||
Line 397: | Line 398: | ||
unsigned int N = x.size(), k = N, n; |
unsigned int N = x.size(), k = N, n; |
||
double thetaT = 3.14159265358979323846264338328L / N; |
double thetaT = 3.14159265358979323846264338328L / N; |
||
Complex phiT = Complex(cos(thetaT), sin(thetaT)), T; |
Complex phiT = Complex(cos(thetaT), -sin(thetaT)), T; |
||
while (k > 1) |
while (k > 1) |
||
{ |
{ |