Trait array_math::SliceMath

source ·
pub trait SliceMath<T>: SliceOps<T> {
    // Required methods
    fn recip_assign_all(&mut self)
       where T: Inv<Output = T>;
    fn conj_assign_all(&mut self)
       where T: ComplexFloat;
    fn convolve_direct<Rhs, C>(&self, rhs: &[Rhs]) -> C
       where T: Mul<Rhs> + Copy,
             <T as Mul<Rhs>>::Output: AddAssign + Zero,
             Rhs: Copy,
             C: FromIterator<<T as Mul<Rhs>>::Output>;
    fn convolve_fft_cooley_tukey<Rhs, C>(&self, rhs: &[Rhs]) -> C
       where T: Float + Copy,
             Rhs: Float + Copy,
             Complex<T>: MulAssign + ComplexFloat + From<Complex<<Complex<T> as ComplexFloat>::Real>> + Mul<Complex<Rhs>>,
             <Complex<T> as ComplexFloat>::Real: Float,
             <Complex<T> as Mul<Complex<Rhs>>>::Output: ComplexFloat + MulAssign + From<Complex<<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real>>,
             <<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real: Float,
             Complex<Rhs>: MulAssign + ComplexFloat + From<Complex<<Complex<Rhs> as ComplexFloat>::Real>>,
             <Complex<Rhs> as ComplexFloat>::Real: Float,
             C: FromIterator<<<Complex<T> as Mul<Complex<Rhs>>>::Output as ComplexFloat>::Real>;
    fn fft_cooley_tukey(&mut self)
       where T: ComplexFloat + MulAssign + From<Complex<<T as ComplexFloat>::Real>>,
             <T as ComplexFloat>::Real: Float;
    fn ifft_cooley_tukey(&mut self)
       where T: ComplexFloat + MulAssign + From<Complex<<T as ComplexFloat>::Real>>,
             <T as ComplexFloat>::Real: Float;
    fn fft_rec_cooley_tukey(&mut self)
       where T: ComplexFloat + MulAssign + From<Complex<<T as ComplexFloat>::Real>>,
             <T as ComplexFloat>::Real: Float;
    fn ifft_rec_cooley_tukey(&mut self)
       where T: ComplexFloat + MulAssign + From<Complex<<T as ComplexFloat>::Real>>,
             <T as ComplexFloat>::Real: Float;
}

Required Methods§

source

fn recip_assign_all(&mut self)
where T: Inv<Output = T>,

source

fn conj_assign_all(&mut self)
where T: ComplexFloat,

source

fn convolve_direct<Rhs, C>(&self, rhs: &[Rhs]) -> C
where T: Mul<Rhs> + Copy, <T as Mul<Rhs>>::Output: AddAssign + Zero, Rhs: Copy, C: FromIterator<<T as Mul<Rhs>>::Output>,

source

fn convolve_fft_cooley_tukey<Rhs, C>(&self, rhs: &[Rhs]) -> C

source

fn fft_cooley_tukey(&mut self)

source

fn ifft_cooley_tukey(&mut self)

source

fn fft_rec_cooley_tukey(&mut self)

source

fn ifft_rec_cooley_tukey(&mut self)

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> SliceMath<T> for [T]

source§

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. Length must be a power of two.

§Examples
use num::Complex;
use slice_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.as_mut_slice().fft_cooley_tukey();
y.as_mut_slice().ifft_cooley_tukey();
 
let avg_error = x.into_iter()
    .zip(y.into_iter())
    .map(|(x, y)| (x - y).norm())
    .sum::<f64>()/x.len() as f64;
assert!(avg_error < 1.0e-16);
source§

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. Length must be a power of two.

§Examples
use num::Complex;
use slice_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.as_mut_slice().fft_cooley_tukey();
y.as_mut_slice().ifft_cooley_tukey();
 
let avg_error = x.into_iter()
    .zip(y.into_iter())
    .map(|(x, y)| (x - y).norm())
    .sum::<f64>()/x.len() as f64;
assert!(avg_error < 1.0e-16);
source§

fn fft_rec_cooley_tukey(&mut self)

Performs a recursive radix-2 FFT algorithm. Length must be a power of two.

§Examples
use num::Complex;
use slice_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.as_mut_slice().fft_rec_cooley_tukey();
y.as_mut_slice().ifft_rec_cooley_tukey();
 
assert_eq!(x, y);
source§

fn ifft_rec_cooley_tukey(&mut self)

Performs a recursive radix-2 IFFT algorithm. Length must be a power of two.

§Examples
use num::Complex;
use slice_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.as_mut_slice().fft_rec_cooley_tukey();
y.as_mut_slice().ifft_rec_cooley_tukey();
 
assert_eq!(x, y);
source§

fn recip_assign_all(&mut self)
where T: Inv<Output = T>,

source§

fn conj_assign_all(&mut self)
where T: ComplexFloat,

source§

fn convolve_direct<Rhs, C>(&self, rhs: &[Rhs]) -> C
where T: Mul<Rhs> + Copy, <T as Mul<Rhs>>::Output: AddAssign + Zero, Rhs: Copy, C: FromIterator<<T as Mul<Rhs>>::Output>,

source§

fn convolve_fft_cooley_tukey<Rhs, C>(&self, rhs: &[Rhs]) -> C

Implementors§