diff --git a/fixed_wide_vectors/src/tests/tests.rs b/fixed_wide_vectors/src/tests/tests.rs index ed0d8d8..a3530ea 100644 --- a/fixed_wide_vectors/src/tests/tests.rs +++ b/fixed_wide_vectors/src/tests/tests.rs @@ -1,4 +1,4 @@ -use crate::types::Vector3; +use crate::types::{Vector3,Matrix3x4,Matrix4x2,Matrix3x2}; #[test] fn test_bool(){ @@ -7,3 +7,36 @@ fn test_bool(){ assert_eq!(Vector3::new([false,false,true]).all(),false); assert_eq!(Vector3::new([true,true,true]).all(),true); } + +#[test] +fn test_arithmetic(){ + let a=Vector3::new([1,2,3]); + assert_eq!((a+a*2).array,Vector3::new([1*3,2*3,3*3]).array); +} + +#[test] +fn matrix_dot(){ + let lhs=Matrix3x4::new([ + [1.0,2.0,3.0,4.0], + [5.0,6.0,7.0,8.0], + [9.0,1.0,1.0,1.0], + ]); + let rhs=Matrix4x2::new([ + [1.0,2.0], + [3.0,4.0], + [5.0,6.0], + [7.0,8.0], + ]); + // Mat3.dot(Mat4) -> Mat3 + let m_dot=lhs.dot(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.array, + Matrix3x2::new([ + [50.0,60.0], + [114.0,140.0], + [178.0,220.0], + ]).array + ); +}