pub trait ElementaryWrapAroundOps<A, T: RealNumber, N: NumberSpace, D: Domain>where
A: GetMetaData<T, N, D>,{
// Required methods
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;
}Expand description
Elementary algebra on types where the argument might contain less data points than self.
Required Methods§
Sourcefn add_smaller(&mut self, summand: &A) -> VoidResult
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..]);Sourcefn sub_smaller(&mut self, summand: &A) -> VoidResult
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..]);Sourcefn mul_smaller(&mut self, factor: &A) -> VoidResult
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..]);Sourcefn div_smaller(&mut self, divisor: &A) -> VoidResult
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..]);