pub trait ComplexOps<T>where
T: RealNumber,{
// Required methods
fn multiply_complex_exponential(&mut self, a: T, b: T);
fn conj(&mut self);
}Expand description
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§
Sourcefn multiply_complex_exponential(&mut self, a: T, b: T)
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!(Complex::new(1.0, 2.0), Complex::new(3.0, 4.0)).to_complex_time_vec();
vector.multiply_complex_exponential(2.0, 3.0);
let actual = &vector[..];
let expected = &[Complex::new(-1.2722325, -1.838865), Complex::new(4.6866837, -1.7421241)];
assert_eq!(actual.len(), expected.len());
for i in 0..actual.len() {
assert!((actual[i] - expected[i]).norm() < 1e-4);
}