Trait basic_dsp_vector::InsertZerosOpsBuffered [] [src]

pub trait InsertZerosOpsBuffered<S, T> where T: RealNumber, S: ToSliceMut<T> {
    fn zero_pad_b<B>(&mut self,
                 buffer: &mut B,
                 points: usize,
                 option: PaddingOption) where B: Buffer<S, T>; fn zero_interleave_b<B>(&mut self, buffer: &mut B, factor: u32) where B: Buffer<S, T>; }

A trait to insert zeros into the data at some specified positions. A buffer is used for types which can't be resized and/or to speed up the calculation.

Required Methods

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();
let mut buffer = SingleBuffer::new();
vector.zero_pad_b(&mut buffer, 4, PaddingOption::End);
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_b(&mut buffer, 2, PaddingOption::End);
assert_eq!([1.0, 2.0, 0.0, 0.0], vector[..]);

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();
let mut buffer = SingleBuffer::new();
vector.zero_interleave_b(&mut buffer, 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_b(&mut buffer, 2);
assert_eq!([1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0], vector[..]);

Implementors