use crate::types::{Vector3,Matrix3x4,Matrix4x2,Matrix3x2}; #[test] fn test_bool(){ assert_eq!(Vector3::new([false,false,false]).any(),false); assert_eq!(Vector3::new([false,false,true]).any(),true); 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 rhs=Matrix4x2::new([ [ 1.0, 2.0], [ 3.0, 4.0], [ 5.0, 6.0], [ 7.0, 8.0], ]); // | | | let lhs=Matrix3x4::new([ // | | | [1.0, 2.0, 3.0, 4.0],// [ 50.0, 60.0], [5.0, 6.0, 7.0, 8.0],// [114.0,140.0], [9.0,10.0,11.0,12.0],// [178.0,220.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 ); }