Trait basic_dsp_vector::ComplexToRealGetterOps [] [src]

pub trait ComplexToRealGetterOps<T>: ToRealResult where T: RealNumber {
    fn get_real(&self, destination: &mut Self::RealResult);
    fn get_imag(&self, destination: &mut Self::RealResult);
    fn get_magnitude(&self, destination: &mut Self::RealResult);
    fn get_magnitude_squared(&self, destination: &mut Self::RealResult);
    fn get_phase(&self, destination: &mut Self::RealResult);
    fn get_real_imag(&self,
                 real: &mut Self::RealResult,
                 imag: &mut Self::RealResult); fn get_mag_phase(&self,
                 mag: &mut Self::RealResult,
                 phase: &mut Self::RealResult); }

Defines getters to get real data from complex types.

Failures

All operations in this trait set the arguments len() to 0 if the type isn't in the complex number space.

Required Methods

Copies all real elements into the given vector.

Example

use basic_dsp_vector::*;
let vector = vec!(1.0, 2.0, 3.0, 4.0).to_complex_time_vec();
let mut target = Vec::new().to_real_time_vec();
vector.get_real(&mut target);
assert_eq!([1.0, 3.0], target[..]);

Copies all imag elements into the given vector.

Example

use basic_dsp_vector::*;
let vector = vec!(1.0, 2.0, 3.0, 4.0).to_complex_time_vec();
let mut target = Vec::new().to_real_time_vec();
vector.get_imag(&mut target);
assert_eq!([2.0, 4.0], target[..]);

Copies the absolute value or magnitude of all vector elements into the given target vector.

Example

use basic_dsp_vector::*;
let vector = vec!(3.0, -4.0, -3.0, 4.0).to_complex_time_vec();
let mut target = Vec::new().to_real_time_vec();
vector.get_magnitude(&mut target);
assert_eq!([5.0, 5.0], target[..]);

Copies the absolute value squared or magnitude squared of all vector elements into the given target vector.

Example

Copies the absolute value or magnitude of all vector elements into the given target vector.

Example

use basic_dsp_vector::*;
let vector = vec!(3.0, -4.0, -3.0, 4.0).to_complex_time_vec();
let mut target = Vec::new().to_real_time_vec();
vector.get_magnitude_squared(&mut target);
assert_eq!([25.0, 25.0], target[..]);

Copies the phase of all elements in [rad] into the given vector.

Example

use basic_dsp_vector::*;
let vector =
    vec!(1.0, 0.0, 0.0, 4.0, -2.0, 0.0, 0.0, -3.0, 1.0, 1.0).to_complex_time_vec();
let mut target = Vec::new().to_real_time_vec();
vector.get_phase(&mut target);
let actual = &target[..];
let expected = &[0.0, 1.5707964, 3.1415927, -1.5707964, 0.7853982];
assert_eq!(actual.len(), expected.len());
for i in 0..actual.len() {
       assert!(f64::abs(actual[i] - expected[i]) < 1e-4);
}

Gets the real and imaginary parts and stores them in the given vectors. See also get_phase and get_complex_abs for further information.

Gets the magnitude and phase and stores them in the given vectors. See also get_real and get_imag for further information.

Implementors