Increased strength of tests for polar decomposition

This commit is contained in:
metric-space 2021-12-27 02:12:54 -05:00
parent dbaefed8d1
commit 43c1f8fb9d
1 changed files with 10 additions and 2 deletions

View File

@ -449,7 +449,11 @@ fn dynamic_square_matrix_polar_decomposition() {
let svd = m.clone().svd(true, true); let svd = m.clone().svd(true, true);
let (p,u) = svd.to_polar().unwrap(); 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 svd = m.clone().svd(true, true);
let (p,u) = svd.to_polar().unwrap(); 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);
} }