pub fn project_to_su2(m: CMatrix2) -> CMatrix2
Expand description

Project the matrix to SU(2). Return the identity if the norm after unormalize is subnormal (seef64::is_normal).

Examples

let m = CMatrix2::zeros();
assert_eq_matrix!(project_to_su2(m), CMatrix2::identity(), f64::EPSILON);
for _ in 0..10 {
    let m = random_su2(&mut rng);
    assert_eq_matrix!(project_to_su2(m * Complex::new(0.5_f64, 0_f64)), m, 4_f64 * f64::EPSILON);
    assert_eq_matrix!(project_to_su2(m), m, 4_f64 * f64::EPSILON);
    assert_matrix_is_su_2!(project_to_su2(m), 4_f64 * f64::EPSILON);
}
for _ in 0..10 {
    let m = random_matrix_2(&mut rng);
    assert_matrix_is_su_2!(project_to_su2(m), 4_f64 * f64::EPSILON)
}