[][src]Trait basic_dsp_vector::ElementaryWrapAroundOps

pub trait ElementaryWrapAroundOps<A, T: RealNumber, N: NumberSpace, D: Domain> where
    A: GetMetaData<T, N, D>, 
{ pub fn add_smaller(&mut self, summand: &A) -> VoidResult;
pub fn sub_smaller(&mut self, summand: &A) -> VoidResult;
pub fn mul_smaller(&mut self, factor: &A) -> VoidResult;
pub fn div_smaller(&mut self, divisor: &A) -> VoidResult; }

Elementary algebra on types where the argument might contain less data points than self.

Required methods

pub fn add_smaller(&mut self, summand: &A) -> VoidResult[src]

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:

  1. InvalidArgumentLength: self.points() isn't dividable by summand.points()
  2. VectorMetaDataMustAgree: self and summand must 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..]);

pub fn sub_smaller(&mut self, summand: &A) -> VoidResult[src]

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:

  1. InvalidArgumentLength: self.points() isn't dividable by subtrahend.points()
  2. VectorMetaDataMustAgree: self and subtrahend must 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..]);

pub fn mul_smaller(&mut self, factor: &A) -> VoidResult[src]

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:

  1. InvalidArgumentLength: self.points() isn't dividable by factor.points()
  2. VectorMetaDataMustAgree: self and factor must 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..]);

pub fn div_smaller(&mut self, divisor: &A) -> VoidResult[src]

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:

  1. InvalidArgumentLength: self.points() isn't dividable by divisor.points()
  2. VectorMetaDataMustAgree: self and divisor must 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..]);
Loading content...

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> + GetMetaData<T, NO, DO>,
    NO: PosEq<N> + NumberSpace,
    DO: PosEq<D> + Domain
[src]

Loading content...