Trait basic_dsp_vector::ReorganizeDataOps
source · [−]pub trait ReorganizeDataOps<T>where
T: RealNumber,{
fn reverse(&mut self);
fn swap_halves(&mut self);
}
Expand description
This trait allows to reorganize the data by changing positions of the individual elements.
Required Methods
sourcefn reverse(&mut self)
fn reverse(&mut self)
Reverses the data inside the vector.
Example
use basic_dsp_vector::*;
let mut vector = vec!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0).to_real_time_vec();
vector.reverse();
assert_eq!([8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0], vector[..]);
sourcefn swap_halves(&mut self)
fn swap_halves(&mut self)
This function swaps both halves of the vector. This operation is also called FFT shift
Use it after a plain_fft
to get a spectrum which is centered at 0 Hz
.
swap_halvesb
requires a buffer but performs faster.
Example
use basic_dsp_vector::*;
let mut vector = vec!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0).to_real_time_vec();
vector.swap_halves();
assert_eq!([5.0, 6.0, 7.0, 8.0, 1.0, 2.0, 3.0, 4.0], vector[..]);