[][src]Trait basic_dsp_vector::InsertZerosOps

pub trait InsertZerosOps<T> where
    T: RealNumber
{ fn zero_pad(&mut self, points: usize, option: PaddingOption) -> VoidResult;
fn zero_interleave(&mut self, factor: u32) -> VoidResult; }

A trait to insert zeros into the data at some specified positions.

Required methods

fn zero_pad(&mut self, points: usize, option: PaddingOption) -> VoidResult

Appends zeros add the end of the vector until the vector has the size given in the points argument. If points smaller than the self.len() then this operation won't do anything, however in future it will raise an error.

Note: Each point is two floating point numbers if the vector is complex. Note2: Adding zeros to the signal changes its power. If this function is used to zero pad to a power of 2 in order to speed up FFT calculation then it might be necessary to multiply it with len_after/len_before
so that the spectrum shows the expected power. Of course this is depending on the application.

Example

use basic_dsp_vector::*;
let mut vector = vec!(1.0, 2.0).to_real_time_vec();
vector.zero_pad(4, PaddingOption::End).expect("Ignoring error handling in examples");
assert_eq!([1.0, 2.0, 0.0, 0.0], vector[..]);
let mut vector = vec!(1.0, 2.0).to_complex_time_vec();
vector.zero_pad(2, PaddingOption::End).expect("Ignoring error handling in examples");
assert_eq!([1.0, 2.0, 0.0, 0.0], vector[..]);

fn zero_interleave(&mut self, factor: u32) -> VoidResult

Interleaves zeros factor - 1times after every vector element, so that the resulting vector will have a length of self.len() * factor.

Note: Remember that each complex number consists of two floating points and interleaving will take that into account.

If factor is 0 (zero) then self will be returned.

Example

use basic_dsp_vector::*;
let mut vector = vec!(1.0, 2.0).to_real_time_vec();
vector.zero_interleave(2);
assert_eq!([1.0, 0.0, 2.0, 0.0], vector[..]);
let mut vector = vec!(1.0, 2.0, 3.0, 4.0).to_complex_time_vec();
vector.zero_interleave(2).expect("Ignoring error handling in examples");
assert_eq!([1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0], vector[..]);
Loading content...

Implementors

impl<S, T, N, D> InsertZerosOps<T> for DspVec<S, T, N, D> where
    S: ToSliceMut<T>,
    T: RealNumber,
    N: NumberSpace,
    D: Domain
[src]

Loading content...