From 43c1f8fb9d931cbb7d3df2aac8dedbe644e483ba Mon Sep 17 00:00:00 2001 From: metric-space Date: Mon, 27 Dec 2021 02:12:54 -0500 Subject: [PATCH] Increased strength of tests for polar decomposition --- tests/linalg/svd.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/linalg/svd.rs b/tests/linalg/svd.rs index 251156b5..13c54a8b 100644 --- a/tests/linalg/svd.rs +++ b/tests/linalg/svd.rs @@ -449,7 +449,11 @@ fn dynamic_square_matrix_polar_decomposition() { let svd = m.clone().svd(true, true); let (p,u) = svd.to_polar().unwrap(); - assert_relative_eq!(m, p*u, epsilon = 1.0e-5); + assert_relative_eq!(m, &p*&u, epsilon = 1.0e-5); + // unitary check + assert_eq!(true, u.is_orthogonal(1.0e-5)); + // hermitian check + assert_relative_eq!(p, p.adjoint(), epsilon = 1.0e-5); } @@ -460,5 +464,9 @@ fn dynamic_rectangular_matrix_polar_decomposition() { let svd = m.clone().svd(true, true); let (p,u) = svd.to_polar().unwrap(); - assert_relative_eq!(m, p*u, epsilon = 1.0e-5); + assert_relative_eq!(m, &p*&u, epsilon = 1.0e-5); + // semi-unitary check + assert_eq!(true, (u.is_orthogonal(1.0e-5))); + // hermitian check + assert_relative_eq!(p, p.adjoint(), epsilon = 1.0e-5); }