Trait array_math::ArrayMath 
source · pub trait ArrayMath<T, const N: usize>: ArrayOps<T, N> {
Show 26 methods
    // Required methods
    fn sum(self) -> T
       where T: AddAssign + Zero;
    fn product(self) -> T
       where T: MulAssign + One;
    fn variance(self) -> <T as Mul>::Output
       where Self: ArrayOps<T, N> + Copy,
             u8: Into<T>,
             T: Div<Output: Mul<Output: Neg<Output = <T as Mul>::Output>> + Copy> + Mul<Output: AddAssign> + AddAssign + Zero;
    fn variance16(self) -> <T as Mul>::Output
       where Self: ArrayOps<T, N> + Copy,
             u16: Into<T>,
             T: Div<Output: Mul<Output: Neg<Output = <T as Mul>::Output>> + Copy> + Mul<Output: AddAssign> + AddAssign + Zero;
    fn variance32(self) -> <T as Mul>::Output
       where Self: ArrayOps<T, N> + Copy,
             u32: Into<T>,
             T: Div<Output: Mul<Output: Neg<Output = <T as Mul>::Output>> + Copy> + Mul<Output: AddAssign> + AddAssign + Zero;
    fn variance64(self) -> <T as Mul>::Output
       where Self: ArrayOps<T, N> + Copy,
             u64: Into<T>,
             T: Div<Output: Mul<Output: Neg<Output = <T as Mul>::Output>> + Copy> + Mul<Output: AddAssign> + AddAssign + Zero;
    fn avg(self) -> <T as Div>::Output
       where u8: Into<T>,
             T: Div + AddAssign + Zero;
    fn avg16(self) -> <T as Div>::Output
       where u16: Into<T>,
             T: Div + AddAssign + Zero;
    fn avg32(self) -> <T as Div>::Output
       where u32: Into<T>,
             T: Div + AddAssign + Zero;
    fn avg64(self) -> <T as Div>::Output
       where u64: Into<T>,
             T: Div + AddAssign + Zero;
    fn mul_dot<Rhs>(self, rhs: [Rhs; N]) -> <T as Mul<Rhs>>::Output
       where T: Mul<Rhs, Output: AddAssign + Zero>;
    fn magnitude_squared(self) -> <T as Mul<T>>::Output
       where T: Mul<T, Output: AddAssign + Zero> + Copy;
    fn magnitude(self) -> <T as Mul<T>>::Output
       where T: Mul<T, Output: AddAssign + Zero + Float> + Copy;
    fn magnitude_inv(self) -> <T as Mul<T>>::Output
       where T: Mul<T, Output: AddAssign + Zero + Float> + Copy;
    fn normalize(self) -> [<T as Mul<<T as Mul<T>>::Output>>::Output; N]
       where T: Mul<T, Output: AddAssign + Zero + Float + Copy> + Mul<<T as Mul<T>>::Output> + Copy;
    fn normalize_to<Rhs>(
        self,
        magnitude: Rhs
    ) -> [<T as Mul<<<T as Mul<T>>::Output as Mul<Rhs>>::Output>>::Output; N]
       where T: Mul<T, Output: AddAssign + Zero + Float + Mul<Rhs, Output: Copy>> + Mul<<<T as Mul<T>>::Output as Mul<Rhs>>::Output> + Copy;
    fn normalize_assign(&mut self)
       where T: Mul<T, Output: AddAssign + Zero + Float + Copy> + MulAssign<<T as Mul<T>>::Output> + Copy;
    fn normalize_assign_to<Rhs>(&mut self, magnitude: Rhs)
       where T: Mul<T, Output: AddAssign + Zero + Float + Mul<Rhs, Output: Copy>> + MulAssign<<<T as Mul<T>>::Output as Mul<Rhs>>::Output> + Copy;
    fn convolve_direct<Rhs, const M: usize>(
        &self,
        rhs: &[Rhs; M]
    ) -> [<T as Mul<Rhs>>::Output; { _ }]
       where T: Mul<Rhs, Output: AddAssign + Zero> + Copy,
             Rhs: Copy;
    fn convolve_fft_cooley_tukey<Rhs, const M: usize, const L: usize>(
        &self,
        rhs: &[Rhs; M]
    ) -> [<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real; { _ }]
       where T: Float + Copy,
             Rhs: Float + Copy,
             Complex<T>: MulAssign + ComplexFloat<Real: Float> + From<Complex<<Complex<T> as ComplexFloat>::Real>> + Mul<Complex<Rhs>, Output: ComplexFloat<Real: Float>>,
             Complex<Rhs>: MulAssign + ComplexFloat<Real: Float> + From<Complex<<Complex<Rhs> as ComplexFloat>::Real>>,
             <Complex<T> as Mul<Complex<Rhs>>>::Output: MulAssign + ComplexFloat<Real: Float> + From<Complex<<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real>>;
    fn recip_all(self) -> [<T as Inv>::Output; N]
       where T: Inv;
    fn recip_assign_all(&mut self)
       where T: Inv<Output = T>;
    fn conj_all(self) -> Self
       where T: ComplexFloat;
    fn conj_assign_all(&mut self)
       where T: ComplexFloat;
    fn fft_cooley_tukey(&mut self)
       where T: ComplexFloat<Real: Float> + MulAssign + From<Complex<T::Real>>;
    fn ifft_cooley_tukey(&mut self)
       where T: ComplexFloat<Real: Float> + MulAssign + From<Complex<T::Real>>;
}Required Methods§
fn sum(self) -> T
fn product(self) -> T
fn variance(self) -> <T as Mul>::Output
fn variance16(self) -> <T as Mul>::Output
fn variance32(self) -> <T as Mul>::Output
fn variance64(self) -> <T as Mul>::Output
fn avg(self) -> <T as Div>::Output
fn avg16(self) -> <T as Div>::Output
fn avg32(self) -> <T as Div>::Output
fn avg64(self) -> <T as Div>::Output
fn mul_dot<Rhs>(self, rhs: [Rhs; N]) -> <T as Mul<Rhs>>::Output
fn magnitude_squared(self) -> <T as Mul<T>>::Output
fn magnitude(self) -> <T as Mul<T>>::Output
fn magnitude_inv(self) -> <T as Mul<T>>::Output
fn normalize(self) -> [<T as Mul<<T as Mul<T>>::Output>>::Output; N]
fn normalize_to<Rhs>( self, magnitude: Rhs ) -> [<T as Mul<<<T as Mul<T>>::Output as Mul<Rhs>>::Output>>::Output; N]
fn normalize_assign(&mut self)
fn normalize_assign_to<Rhs>(&mut self, magnitude: Rhs)
sourcefn convolve_direct<Rhs, const M: usize>(
    &self,
    rhs: &[Rhs; M]
) -> [<T as Mul<Rhs>>::Output; { _ }]
 
fn convolve_direct<Rhs, const M: usize>( &self, rhs: &[Rhs; M] ) -> [<T as Mul<Rhs>>::Output; { _ }]
Performs direct convolution. This is equivalent to a polynomial multiplication.
§Examples
Convolving a unit impulse yields the impulse response.
#![feature(generic_const_exprs)]
 
use array_math::*;
 
let x = [1.0];
let h = [1.0, 0.6, 0.3];
 
let y = x.convolve_direct(&h);
 
assert_eq!(y, h);Convolution can be done directly O(n^2) or using FFT O(nlog(n)).
#![feature(generic_arg_infer)]
#![feature(generic_const_exprs)]
 
use array_math::*;
 
let x = [1.0, 0.0, 1.5, 0.0, 0.0, -1.0];
let h = [1.0, 0.6, 0.3];
 
let y_fft = x.convolve_fft_cooley_tukey::<_, _, 8>(&h);
let y_direct = x.convolve_direct(&h);
 
let avg_error = y_fft.comap(y_direct, |y_fft: f64, y_direct: f64| (y_fft - y_direct).abs()).avg();
assert!(avg_error < 1.0e-15);sourcefn convolve_fft_cooley_tukey<Rhs, const M: usize, const L: usize>(
    &self,
    rhs: &[Rhs; M]
) -> [<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real; { _ }]where
    T: Float + Copy,
    Rhs: Float + Copy,
    Complex<T>: MulAssign + ComplexFloat<Real: Float> + From<Complex<<Complex<T> as ComplexFloat>::Real>> + Mul<Complex<Rhs>, Output: ComplexFloat<Real: Float>>,
    Complex<Rhs>: MulAssign + ComplexFloat<Real: Float> + From<Complex<<Complex<Rhs> as ComplexFloat>::Real>>,
    <Complex<T> as Mul<Complex<Rhs>>>::Output: MulAssign + ComplexFloat<Real: Float> + From<Complex<<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real>>,
 
fn convolve_fft_cooley_tukey<Rhs, const M: usize, const L: usize>(
    &self,
    rhs: &[Rhs; M]
) -> [<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real; { _ }]where
    T: Float + Copy,
    Rhs: Float + Copy,
    Complex<T>: MulAssign + ComplexFloat<Real: Float> + From<Complex<<Complex<T> as ComplexFloat>::Real>> + Mul<Complex<Rhs>, Output: ComplexFloat<Real: Float>>,
    Complex<Rhs>: MulAssign + ComplexFloat<Real: Float> + From<Complex<<Complex<Rhs> as ComplexFloat>::Real>>,
    <Complex<T> as Mul<Complex<Rhs>>>::Output: MulAssign + ComplexFloat<Real: Float> + From<Complex<<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real>>,
Performs convolution using FFT
§Examples
Convolution can be done directly O(n^2) or using FFT O(nlog(n)).
#![feature(generic_arg_infer)]
#![feature(generic_const_exprs)]
 
use array_math::*;
 
let x = [1.0, 0.0, 1.5, 0.0, 0.0, -1.0];
let h = [1.0, 0.6, 0.3];
 
let y_fft = x.convolve_fft_cooley_tukey::<_, _, 8>(&h);
let y_direct = x.convolve_direct(&h);
 
let avg_error = y_fft.comap(y_direct, |y_fft: f64, y_direct: f64| (y_fft - y_direct).abs()).avg();
assert!(avg_error < 1.0e-15);fn recip_all(self) -> [<T as Inv>::Output; N]where
    T: Inv,
fn recip_assign_all(&mut self)where
    T: Inv<Output = T>,
fn conj_all(self) -> Selfwhere
    T: ComplexFloat,
fn conj_assign_all(&mut self)where
    T: ComplexFloat,
sourcefn fft_cooley_tukey(&mut self)
 
fn fft_cooley_tukey(&mut self)
Performs an iterative, in-place radix-2 FFT algorithm as described in https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm#Data_reordering,_bit_reversal,_and_in-place_algorithms.
§Examples
use num::Complex;
use array_math::*;
 
let x = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
    .map(|x| <Complex<_> as From<_>>::from(x));
 
let mut y = x;
 
y.fft_cooley_tukey();
y.ifft_cooley_tukey();
 
let avg_error = x.comap(y, |x, y| (x - y).norm()).avg();
assert!(avg_error < 1.0e-16);sourcefn ifft_cooley_tukey(&mut self)
 
fn ifft_cooley_tukey(&mut self)
Performs an iterative, in-place radix-2 IFFT algorithm as described in https://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm#Data_reordering,_bit_reversal,_and_in-place_algorithms.
§Examples
use num::Complex;
use array_math::*;
 
let x = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
    .map(|x| <Complex<_> as From<_>>::from(x));
 
let mut y = x;
 
y.fft_cooley_tukey();
y.ifft_cooley_tukey();
 
let avg_error = x.comap(y, |x, y| (x - y).norm()).avg();
assert!(avg_error < 1.0e-16);Object Safety§
This trait is not object safe.