fn real_dft(samples: &[f32], size: usize) -> Vec<f32> {
    let mut ft_data = Vec::with_capacity(samples.len());
    for n in 0..size {
        if n < samples.len() {
            ft_data.push(samples[n]);
        } else {
            ft_data.push(0f32);
        }
    }
    let plan = Plan::new(Operation::Forward, size);
    dft::transform(&mut ft_data, &plan);

    let mut freq_data = Vec::with_capacity(samples.len() / 2 + 1);
    for i in 0..((ft_data.len() / 2) + 1) {
        freq_data.push(ft_data[i] / (samples.len() as f32));
    }
    freq_data
}
/// Calculate the DFT of a real-valued signal
Calculate the DFT of a real-valued signal
Calculate the DFT of a real - valued signal
fn real_dft(samples: &[f32], size: usize) -> Vec<f32> {
    let mut ft_data = Vec::with_capacity(samples.len());
    for n in 0..size {
        if n < samples.len() {
            ft_data.push(samples[n]);
        } else {
            ft_data.push(0f32);
        }
    }
    let plan = Plan::new(Operation::Forward, size);
    dft::transform(&mut ft_data, &plan);
    let mut freq_data = Vec::with_capacity(samples.len() / 2 + 1);
    for i in 0..((ft_data.len() / 2) + 1) {
        freq_data.push(ft_data[i] / (samples.len() as f32));
    }
    freq_data
}
fn real_dft ( samples : & [ f32 ] , size : usize ) -> Vec < f32 > { let mut ft_data = Vec :: with_capacity ( samples . len ( ) ) ; for n in 0 .. size { if n < samples . len ( ) { ft_data . push ( samples [ n ] ) ; } else { ft_data . push ( 0f32 ) ; } } let plan = Plan :: new ( Operation :: Forward , size ) ; dft :: transform ( & mut ft_data , & plan ) ; let mut freq_data = Vec :: with_capacity ( samples . len ( ) / 2 + 1 ) ; for i in 0 .. ( ( ft_data . len ( ) / 2 ) + 1 ) { freq_data . push ( ft_data [ i ] / ( samples . len ( ) as f32 ) ) ; } freq_data }
Calculate the DFT of a real-valued signal
Calculate the DFT of a real - valued signal
samples
&[f32]
size
usize