MCPcopy Create free account
hub / github.com/algorithm-archivists/algorithm-archive / fft

Function fft

contents/cooley_tukey/code/rust/fft.rs:11–22  ·  view source on GitHub ↗
(x: &[Complex<f64>])

Source from the content-addressed store, hash-verified

9// This is based on the Python and C implementations.
10
11fn fft(x: &[Complex<f64>]) -> Vec<Complex<f64>> {
12 let n = x.len();
13 let mut new_x = x.to_vec();
14 let mut y = vec![Complex::new(0.0_f64, 0.0_f64); n];
15
16 let mut planner = FFTplanner::new(false);
17 let this_fft = planner.plan_fft(n);
18 this_fft.process(new_x.as_mut_slice(), y.as_mut_slice());
19
20 // y.into_iter().map(|i| i / (n as f64).sqrt()).collect()
21 y
22}
23
24fn dft(x: &[Complex<f64>]) -> Vec<Complex<f64>> {
25 let n = x.len();

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected