matrix: test det + adjugate

This commit is contained in:
Quaternions 2024-09-04 13:55:11 -07:00
parent cf17460b77
commit 103697fbdd

View File

@ -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)]),
])
);
}