From 103697fbdd1fb360e667f92ed2c9d50b63aec350 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 4 Sep 2024 13:55:11 -0700 Subject: [PATCH] matrix: test det + adjugate --- fixed_wide_vectors/src/tests/fixed_wide.rs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/fixed_wide_vectors/src/tests/fixed_wide.rs b/fixed_wide_vectors/src/tests/fixed_wide.rs index e382ffa..1f87fb0 100644 --- a/fixed_wide_vectors/src/tests/fixed_wide.rs +++ b/fixed_wide_vectors/src/tests/fixed_wide.rs @@ -61,3 +61,34 @@ fn wide_matrix_dot(){ ]) ); } + +#[test] +fn wide_matrix_det(){ + let m=Matrix3::from([ + Vector3::from([Planar64::from(1),Planar64::from(2),Planar64::from(3)]), + Vector3::from([Planar64::from(4),Planar64::from(5),Planar64::from(7)]), + Vector3::from([Planar64::from(6),Planar64::from(8),Planar64::from(9)]), + ]); + // In[2]:= Det[{{1, 2, 3}, {4, 5, 7}, {6, 8, 9}}] + // Out[2]= 7 + assert_eq!(m.wide_det_3x3_1(),fixed_wide::fixed::Fixed::<3,96>::from(7)); +} + +#[test] +fn wide_matrix_adjugate(){ + let m=Matrix3::from([ + Vector3::from([Planar64::from(1),Planar64::from(2),Planar64::from(3)]), + Vector3::from([Planar64::from(4),Planar64::from(5),Planar64::from(7)]), + Vector3::from([Planar64::from(6),Planar64::from(8),Planar64::from(9)]), + ]); + // In[6]:= Adjugate[{{1, 2, 3}, {4, 5, 7}, {6, 8, 9}}] + // Out[6]= {{-11, 6, -1}, {6, -9, 5}, {2, 4, -3}} + assert_eq!( + m.wide_adjugate_3x3_1(), + Matrix3::from([ + Vector3::from([Planar64Wide1::from(-11),Planar64Wide1::from(6),Planar64Wide1::from(-1)]), + Vector3::from([Planar64Wide1::from(6),Planar64Wide1::from(-9),Planar64Wide1::from(5)]), + Vector3::from([Planar64Wide1::from(2),Planar64Wide1::from(4),Planar64Wide1::from(-3)]), + ]) + ); +}