Trait basic_dsp::TimeDomainOperations [] [src]

pub trait TimeDomainOperations<T>: DataVector<T> where T: RealNumber {
    type FreqPartner;
    fn plain_fft(self) -> VecResult<Self::FreqPartner>;
    fn fft(self) -> VecResult<Self::FreqPartner>;
    fn windowed_fft(self, window: &WindowFunction<T>) -> VecResult<Self::FreqPartner>;
    fn apply_window(self, window: &WindowFunction<T>) -> VecResult<Self>;
    fn unapply_window(self, window: &WindowFunction<T>) -> VecResult<Self>;
}

Defines all operations which are valid on DataVectors containing time domain data.

Failures

All operations in this trait fail with VectorMustBeInTimeDomain if the vector isn't in time domain.

Associated Types

Required Methods

fn plain_fft(self) -> VecResult<Self::FreqPartner>

Performs a Fast Fourier Transformation transforming a time domain vector into a frequency domain vector.

This version of the FFT neither applies a window nor does it scale the vector.

Example

use basic_dsp::{ComplexTimeVector32, TimeDomainOperations, DataVector};
let vector = ComplexTimeVector32::from_interleaved(&[1.0, 0.0, -0.5, 0.8660254, -0.5, -0.8660254]);
let result = vector.plain_fft().expect("Ignoring error handling in examples");
let actual = result.data();
let expected = &[0.0, 0.0, 3.0, 0.0, 0.0, 0.0];
assert_eq!(actual.len(), expected.len());
for i in 0..actual.len() {
    assert!((actual[i] - expected[i]).abs() < 1e-4);
}

fn fft(self) -> VecResult<Self::FreqPartner>

Performs a Fast Fourier Transformation transforming a time domain vector into a frequency domain vector.

Unstable

FFTs of real vectors are unstable.

Example

use basic_dsp::{ComplexTimeVector32, TimeDomainOperations, DataVector};
let vector = ComplexTimeVector32::from_interleaved(&[1.0, 0.0, -0.5, 0.8660254, -0.5, -0.8660254]);
let result = vector.fft().expect("Ignoring error handling in examples");
let actual = result.data();
let expected = &[0.0, 0.0, 0.0, 0.0, 3.0, 0.0];
assert_eq!(actual.len(), expected.len());
for i in 0..actual.len() {
    assert!((actual[i] - expected[i]).abs() < 1e-4);
}

fn windowed_fft(self, window: &WindowFunction<T>) -> VecResult<Self::FreqPartner>

Applies a FFT window and performs a Fast Fourier Transformation transforming a time domain vector into a frequency domain vector.

fn apply_window(self, window: &WindowFunction<T>) -> VecResult<Self>

Applies a window to the data vector.

fn unapply_window(self, window: &WindowFunction<T>) -> VecResult<Self>

Removes a window from the data vector.

Implementors