Trait basic_dsp_vector::ComplexOps
[−]
[src]
pub trait ComplexOps<T> where
T: RealNumber, { fn multiply_complex_exponential(&mut self, a: T, b: T); fn conj(&mut self); }
Operations on complex types.
Failures
If one of the methods is called on real data then self.len() will be set to 0.
To avoid this it's recommended to use the to_real_time_vec, to_real_freq_vec
to_complex_time_vec and to_complex_freq_vec constructor methods since
the resulting types will already check at compile time (using the type system) that the
data is complex.
Required Methods
fn multiply_complex_exponential(&mut self, a: T, b: T)
Multiplies each vector element with exp(j*(a*idx*self.delta() + b))
where a and b are arguments and idx is the index of the data points
in the vector ranging from 0 to self.points() - 1. j is the imaginary number and
exp the exponential function.
This method can be used to perform a frequency shift in time domain.
Example
use basic_dsp_vector::*; let mut vector = vec!(1.0, 2.0, 3.0, 4.0).to_complex_time_vec(); vector.multiply_complex_exponential(2.0, 3.0); let actual = &vector[..]; let expected = &[-1.2722325, -1.838865, 4.6866837, -1.7421241]; assert_eq!(actual.len(), expected.len()); for i in 0..actual.len() { assert!(f64::abs(actual[i] - expected[i]) < 1e-4); }
fn conj(&mut self)
Calculates the complex conjugate of the vector.
Example
use basic_dsp_vector::*; let mut vector = vec!(1.0, 2.0, 3.0, 4.0).to_complex_time_vec(); vector.conj(); assert_eq!([1.0, -2.0, 3.0, -4.0], vector[..]);
Implementors
impl<S, T, N, D> ComplexOps<T> for DspVec<S, T, N, D> where
S: ToSliceMut<T>,
T: RealNumber,
N: ComplexNumberSpace,
D: Domain,impl<T, N, D> ComplexOps<T> for Identifier<T, N, D> where
T: RealNumber,
N: ComplexNumberSpace,
D: Domain,