#![allow(non_snake_case)]

use num_complex::Complex64;

```
fn main() {
let one= Complex64::new(1.0, 0.0);
let zz = Complex64::new(0.0, 0.0);
let mut data = vec![one,one,one,one, zz,zz,zz,zz,];
let test = vec![one,one,one,one, zz,zz,zz,zz,];
fft (&mut data); // ifft (&mut data, DC);
let mut E = 0_u32; for (k,s) in data.iter().enumerate() { if (s -test[k]).norm() > 1.0e-8 { E += 1; } }
println!(" abs(ifft vs test data) Errors {}", E);
}
const PI: f64 = 3.14159265358979323846264338327950288_f64;
fn fft (x: &mut Vec<Complex64> )
{ let N = x.len() as usize; if N <= 1 { return ; }
let mut even = vec![Complex64::default(); N/2];
let mut odd = vec![Complex64::default(); N/2];
let mut k = 0_usize;
while k< N/2 { even.push(x[2*k]); odd.push(x[2*k+1]); k += 1; }
///////////
assert!( even[0]==x[0] && (odd[0]==x[1])) ;
///////////
fft( &mut even); fft( &mut odd);
// for k in 0..N/2
k= 0; let mut Ninv = 0.0_f64;
while k< N/2
{ let t= odd[k]* (Complex64::from_polar(1.0, -2.0*PI*Ninv) ).exp(); // (k as f64)/(N as f64)) ).exp();
x[k] = even[k] +t;
x[k +N/2]= even[k] -t;
Ninv += 1.0/(N as f64);
k += 1;
}
}
```