Trait basic_dsp::FrequencyDomainOperations
[−]
[src]
pub trait FrequencyDomainOperations<T>: DataVector<T> where T: RealNumber { type ComplexTimePartner; fn plain_ifft(self) -> VecResult<Self::ComplexTimePartner>; fn mirror(self) -> VecResult<Self>; fn ifft(self) -> VecResult<Self::ComplexTimePartner>; fn windowed_ifft(self, window: &WindowFunction<T>) -> VecResult<Self::ComplexTimePartner>; fn fft_shift(self) -> VecResult<Self>; fn ifft_shift(self) -> VecResult<Self>; }
Defines all operations which are valid on DataVectors
containing frequency domain data.
Failures
All operations in this trait fail with VectorMustBeInFrquencyDomain
or VectorMustBeComplex
if the vector isn't in frequency domain and complex number space.
Associated Types
type ComplexTimePartner
Required Methods
fn plain_ifft(self) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector.
This version of the IFFT neither applies a window nor does it scale the vector.
Example
use basic_dsp::{ComplexFreqVector32, FrequencyDomainOperations, DataVector}; let vector = ComplexFreqVector32::from_interleaved(&[0.0, 0.0, 1.0, 0.0, 0.0, 0.0]); let result = vector.plain_ifft().expect("Ignoring error handling in examples"); let actual = result.data(); let expected = &[1.0, 0.0, -0.5, 0.8660254, -0.5, -0.8660254]; assert_eq!(actual.len(), expected.len()); for i in 0..actual.len() { assert!((actual[i] - expected[i]).abs() < 1e-4); }
fn mirror(self) -> VecResult<Self>
This function mirrors the spectrum vector to transform a symmetric spectrum into a full spectrum with the DC element at index 0 (no fft shift/swap halves).
The argument indicates whether the resulting real vector should have 2*N
or 2*N-1
points.
Example
use basic_dsp::{ComplexFreqVector32, FrequencyDomainOperations, DataVector}; let vector = ComplexFreqVector32::from_interleaved(&[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); let result = vector.mirror().expect("Ignoring error handling in examples"); assert_eq!([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 5.0, -6.0, 3.0, -4.0], result.data());
fn ifft(self) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector.
Example
use basic_dsp::{ComplexFreqVector32, FrequencyDomainOperations, DataVector}; let vector = ComplexFreqVector32::from_interleaved(&[0.0, 0.0, 0.0, 0.0, 3.0, 0.0]); let result = vector.ifft().expect("Ignoring error handling in examples"); let actual = result.data(); let expected = &[1.0, 0.0, -0.5, 0.8660254, -0.5, -0.8660254]; assert_eq!(actual.len(), expected.len()); for i in 0..actual.len() { assert!((actual[i] - expected[i]).abs() < 1e-4); }
fn windowed_ifft(self, window: &WindowFunction<T>) -> VecResult<Self::ComplexTimePartner>
Performs an Inverse Fast Fourier Transformation transforming a frequency domain vector into a time domain vector and removes the FFT window.
fn fft_shift(self) -> VecResult<Self>
Swaps vector halves after a Fourier Transformation.
fn ifft_shift(self) -> VecResult<Self>
Swaps vector halves before an Inverse Fourier Transformation.
Implementors
impl FrequencyDomainOperations<f32> for GenericDataVector<f32>
impl FrequencyDomainOperations<f32> for ComplexFreqVector<f32>
impl FrequencyDomainOperations<f64> for GenericDataVector<f64>
impl FrequencyDomainOperations<f64> for ComplexFreqVector<f64>