Trait basic_dsp_vector::ElementaryWrapAroundOps
[−]
[src]
pub trait ElementaryWrapAroundOps<A, T: RealNumber, N: NumberSpace, D: Domain> where
A: GetMetaData<T, N, D>, { fn add_smaller(&mut self, summand: &A) -> VoidResult; fn sub_smaller(&mut self, summand: &A) -> VoidResult; fn mul_smaller(&mut self, factor: &A) -> VoidResult; fn div_smaller(&mut self, divisor: &A) -> VoidResult; }
Elementary algebra on types where the argument might contain less data points than self.
Required Methods
fn add_smaller(&mut self, summand: &A) -> VoidResult
Calculates the sum of self + summand. summand may be smaller than self as long
as self.len() % summand.len() == 0. THe result is the same as it would be if
you would repeat summand until it has the same length as self.
It consumes self and returns the result.
Failures
TransRes may report the following ErrorReason members:
InvalidArgumentLength:self.points()isn't dividable bysummand.points()VectorMetaDataMustAgree:selfandsummandmust be in the same domain and number space
Example
use basic_dsp_vector::*; let mut vector1 = vec!(10.0, 11.0, 12.0, 13.0).to_real_time_vec(); let vector2 = vec!(1.0, 2.0).to_real_time_vec(); vector1.add_smaller(&vector2).expect("Ignoring error handling in examples"); assert_eq!([11.0, 13.0, 13.0, 15.0], vector1[0..]);
fn sub_smaller(&mut self, summand: &A) -> VoidResult
Calculates the sum of self - subtrahend. subtrahend may be smaller than self as long
as self.len() % subtrahend.len() == 0. THe result is the same as it would be if
you would repeat subtrahend until it has the same length as self.
It consumes self and returns the result.
Failures
TransRes may report the following ErrorReason members:
InvalidArgumentLength:self.points()isn't dividable bysubtrahend.points()VectorMetaDataMustAgree:selfandsubtrahendmust be in the same domain and number space
Example
use basic_dsp_vector::*; let mut vector1 = vec!(10.0, 11.0, 12.0, 13.0).to_real_time_vec(); let vector2 = vec!(1.0, 2.0).to_real_time_vec(); vector1.sub_smaller(&vector2).expect("Ignoring error handling in examples"); assert_eq!([9.0, 9.0, 11.0, 11.0], vector1[0..]);
fn mul_smaller(&mut self, factor: &A) -> VoidResult
Calculates the sum of self - factor. factor may be smaller than self as long
as self.len() % factor.len() == 0. THe result is the same as it would be if
you would repeat factor until it has the same length as self.
It consumes self and returns the result.
Failures
TransRes may report the following ErrorReason members:
InvalidArgumentLength:self.points()isn't dividable byfactor.points()VectorMetaDataMustAgree:selfandfactormust be in the same domain and number space
Example
use basic_dsp_vector::*; let mut vector1 = vec!(10.0, 11.0, 12.0, 13.0).to_real_time_vec(); let vector2 = vec!(1.0, 2.0).to_real_time_vec(); vector1.mul_smaller(&vector2).expect("Ignoring error handling in examples"); assert_eq!([10.0, 22.0, 12.0, 26.0], vector1[0..]);
fn div_smaller(&mut self, divisor: &A) -> VoidResult
Calculates the sum of self - divisor. divisor may be smaller than self as long
as self.len() % divisor.len() == 0. THe result is the same as it would be if
you would repeat divisor until it has the same length as self.
It consumes self and returns the result.
Failures
TransRes may report the following ErrorReason members:
InvalidArgumentLength:self.points()isn't dividable bydivisor.points()VectorMetaDataMustAgree:selfanddivisormust be in the same domain and number space
Example
use basic_dsp_vector::*; let mut vector1 = vec!(10.0, 12.0, 12.0, 14.0).to_real_time_vec(); let vector2 = vec!(1.0, 2.0).to_real_time_vec(); vector1.div_smaller(&vector2).expect("Ignoring error handling in examples"); assert_eq!([10.0, 6.0, 12.0, 7.0], vector1[0..]);
Implementors
impl<S, T, N, D, O, NO, DO> ElementaryWrapAroundOps<O, T, NO, DO> for DspVec<S, T, N, D> where
S: ToSliceMut<T>,
T: RealNumber,
N: NumberSpace,
D: Domain,
O: Vector<T> + Index<RangeFull, Output = [T]> + GetMetaData<T, NO, DO>,
NO: PosEq<N> + NumberSpace,
DO: PosEq<D> + Domain,