pub fn complex_matrix_from_vec(x0: Real, x: Vector3<Real>) -> CMatrix2
Expand description

Return x0 1 + i x_i * \sigma_i.

Examples

use lattice_qcd_rs::{
    assert_eq_matrix,
    su2::{complex_matrix_from_vec, PAULI_1},
    CMatrix2,
};

let m = complex_matrix_from_vec(1.0, nalgebra::Vector3::new(0_f64, 0_f64, 0_f64));
assert_eq_matrix!(
    m,
    CMatrix2::new(
        nalgebra::Complex::new(1_f64, 0_f64),
        nalgebra::Complex::new(0_f64, 0_f64),
        nalgebra::Complex::new(0_f64, 0_f64),
        nalgebra::Complex::new(1_f64, 0_f64)
    ),
    f64::EPSILON
);

let m = complex_matrix_from_vec(0.5_f64, nalgebra::Vector3::new(1_f64, 0_f64, 0_f64));
let m2 = CMatrix2::new(
    nalgebra::Complex::new(1_f64, 0_f64),
    nalgebra::Complex::new(0_f64, 0_f64),
    nalgebra::Complex::new(0_f64, 0_f64),
    nalgebra::Complex::new(1_f64, 0_f64),
) * nalgebra::Complex::new(0.5_f64, 0_f64)
    + PAULI_1 * nalgebra::Complex::new(0_f64, 1_f64);
assert_eq_matrix!(m, m2, f64::EPSILON);