use super::*;
fn test_multiply_matrices_generic< D : the_module::mat::Descriptor >()
where
the_module::Mat< 1, 2, f32, D > : the_module::ScalarMut< Scalar = f32 >,
the_module::Mat< 1, 3, f32, D > : the_module::IndexingRef< Scalar = f32 >,
the_module::Mat< 3, 2, f32, D > : the_module::IndexingRef< Scalar = f32 >,
the_module::Mat< 1, 2, f32, D > : the_module::Indexable< Index = the_module::Ix2 >,
the_module::Mat< 1, 3, f32, D > : the_module::Indexable< Index = the_module::Ix2 >,
the_module::Mat< 3, 2, f32, D > : the_module::Indexable< Index = the_module::Ix2 >,
the_module::Mat< 1, 2, f32, D > : the_module::RawSliceMut< Scalar = f32 >,
the_module::Mat< 1, 3, f32, D > : the_module::RawSliceMut< Scalar = f32 >,
the_module::Mat< 3, 2, f32, D > : the_module::RawSliceMut< Scalar = f32 >,
for< 'a > &'a the_module::Mat< 1, 3, f32, D > : core::ops::Mul< &'a the_module::Mat< 3, 2, f32, D >, Output = the_module::Mat< 1, 2, f32, D > >,
the_module::Mat< 1, 3, f32, D > : core::ops::Mul< the_module::Mat< 3, 2, f32, D >, Output = the_module::Mat< 1, 2, f32, D > >,
{
use the_module::
{
Mat,
RawSlice,
d2,
};
let mat_a = Mat::< 1, 3, f32, D >::default().set_row_major
(&[
1.0, 2.0, 3.0,
]);
let mat_b = Mat::< 3, 2, f32, D >::default().set_row_major
(&[
7.0, 8.0,
9.0, 10.0,
11.0, 12.0,
]);
let mut mat_r = Mat::< 1, 2, f32, D >::default();
println!( "Before mul" );
d2::mul( &mut mat_r, &mat_a, &mat_b );
println!( "After mul" );
let exp = Mat::< 1, 2, f32, D >::default().set_row_major
(&[
58.0, 64.0,
]);
assert_eq!( mat_r.raw_slice(), exp.raw_slice(), "Expected {:?}, got {:?}", exp.raw_slice(), mat_r.raw_slice() );
let mat_r = &mat_a * &mat_b;
assert_eq!( mat_r.raw_slice(), exp.raw_slice(), "Expected {:?}, got {:?}", exp.raw_slice(), mat_r.raw_slice() );
let mat_r = mat_a * mat_b;
assert_eq!( mat_r.raw_slice(), exp.raw_slice(), "Expected {:?}, got {:?}", exp.raw_slice(), mat_r.raw_slice() );
}
#[ test ]
fn test_multiply_matrices_row_major()
{
use the_module::mat::DescriptorOrderRowMajor;
test_multiply_matrices_generic::< DescriptorOrderRowMajor >();
}
#[ test ]
fn test_multiply_matrices_column_major()
{
use the_module::mat::DescriptorOrderColumnMajor;
test_multiply_matrices_generic::< DescriptorOrderColumnMajor >();
}