From 15bd78c0e1ef56483969df6fbad266183f4f2c49 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 3 Sep 2024 10:43:07 -0700 Subject: [PATCH] matrix wide dot test --- fixed_wide_vectors/src/tests/fixed_wide.rs | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/fixed_wide_vectors/src/tests/fixed_wide.rs b/fixed_wide_vectors/src/tests/fixed_wide.rs index 9eb6bec..e382ffa 100644 --- a/fixed_wide_vectors/src/tests/fixed_wide.rs +++ b/fixed_wide_vectors/src/tests/fixed_wide.rs @@ -1,4 +1,4 @@ -use crate::{Vector2,Vector3,Matrix3}; +use crate::{Vector2,Vector3,Vector4,Matrix3,Matrix4}; type Planar64=fixed_wide::types::I32F32; type Planar64Wide1=fixed_wide::types::I64F64; @@ -37,9 +37,27 @@ fn wide_vec3_length_squared(){ #[test] fn wide_matrix_dot(){ - let m=Matrix3::>::from_value_2d(Planar64::from(3)); - //normal matrix product - todo!() - //let m_dot=m.wide_dot_1_1(m); - //assert_eq!(m_dot,Matrix3::>::from_value_2d(Planar64Wide1::from(3i128.pow(2)))); + let lhs=Matrix3::from([ + Vector4::from([Planar64::from(1),Planar64::from(2),Planar64::from(3),Planar64::from(4)]), + Vector4::from([Planar64::from(5),Planar64::from(6),Planar64::from(7),Planar64::from(8)]), + Vector4::from([Planar64::from(9),Planar64::from(10),Planar64::from(11),Planar64::from(12)]), + ]); + let rhs=Matrix4::from([ + Vector2::from([Planar64::from(1),Planar64::from(2)]), + Vector2::from([Planar64::from(3),Planar64::from(4)]), + Vector2::from([Planar64::from(5),Planar64::from(6)]), + Vector2::from([Planar64::from(7),Planar64::from(8)]), + ]); + // Mat3.dot(Mat4) -> Mat3 + let m_dot=lhs.wide_dot_3x4_4x2_1_1(rhs); + //In[1]:= {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}} . {{1, 2}, {3, 4}, {5, 6}, {7, 8}} + //Out[1]= {{50, 60}, {114, 140}, {178, 220}} + assert_eq!( + m_dot, + Matrix3::from([ + Vector2::from([Planar64Wide1::from(50),Planar64Wide1::from(60)]), + Vector2::from([Planar64Wide1::from(114),Planar64Wide1::from(140)]), + Vector2::from([Planar64Wide1::from(178),Planar64Wide1::from(220)]), + ]) + ); }