diff options
Diffstat (limited to 'src/retain.rs')
| -rw-r--r-- | src/retain.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/retain.rs b/src/retain.rs index 49730e1..8c4c8eb 100644 --- a/src/retain.rs +++ b/src/retain.rs @@ -2,26 +2,26 @@ use num_complex::Complex; use rustc_hash::FxHashSet; #[inline(always)] -pub fn retain_top_n_magnitudes(fft_real_signal: &mut [Complex<f32>], n: usize) { +pub fn retain_top_n_magnitudes(spectrum: &mut [Complex<f32>], n: usize) { // you'd be keeping the entire signal // or keeping nothing at all - if n >= fft_real_signal.len() { + if n >= spectrum.len() { return; } else if n == 0 { - for phasor in fft_real_signal { + for phasor in spectrum { *phasor = Complex::ZERO; } return; } - let mut indexed = fft_real_signal + let mut indexed = spectrum .iter() .copied() .enumerate() .collect::<Vec<(usize, Complex<f32>)>>(); - let target = fft_real_signal.len() - n; + let target = spectrum.len() - n; indexed.select_nth_unstable_by(target, |(_, c0), (_, c1)| c0.norm().total_cmp(&c1.norm())); let top_indices = indexed[target..] @@ -29,7 +29,7 @@ pub fn retain_top_n_magnitudes(fft_real_signal: &mut [Complex<f32>], n: usize) { .map(|&(i, _)| i) .collect::<FxHashSet<usize>>(); - for (i, phasor) in fft_real_signal.iter_mut().enumerate() { + for (i, phasor) in spectrum.iter_mut().enumerate() { if !top_indices.contains(&i) { *phasor = Complex::ZERO; } |
