Skip to main content

complex_vec_unzip

Function complex_vec_unzip 

Source
pub fn complex_vec_unzip(
    real: &mut Vector,
    imag: &mut Vector,
    v: &ComplexVector,
) -> Result<(), StrError>
Expand description

Zips two arrays (real and imag) to make a new ComplexVector

§Examples

use russell_lab::*;

fn main() -> Result<(), StrError> {
    let v = ComplexVector::from(&[cpx!(1.0, 0.1), cpx!(2.0, 0.2), cpx!(3.0, 0.3)]);
    let mut real = Vector::new(3);
    let mut imag = Vector::new(3);
    complex_vec_unzip(&mut real, &mut imag, &v)?;
    assert_eq!(
        format!("{}", real),
        "┌   ┐\n\
         │ 1 │\n\
         │ 2 │\n\
         │ 3 │\n\
         └   ┘"
    );
    assert_eq!(
        format!("{}", imag),
        "┌     ┐\n\
         │ 0.1 │\n\
         │ 0.2 │\n\
         │ 0.3 │\n\
         └     ┘"
    );
    Ok(())
}