diff --git a/fixed_wide_vectors/src/macros/matrix.rs b/fixed_wide_vectors/src/macros/matrix.rs index bba1e65..73023db 100644 --- a/fixed_wide_vectors/src/macros/matrix.rs +++ b/fixed_wide_vectors/src/macros/matrix.rs @@ -32,6 +32,29 @@ macro_rules! impl_matrix { ) } } + #[inline] + // MatX.MatY = MatX + pub fn dot(self,rhs:Matrix)->Matrix + where + T:core::ops::Mul+Copy, + V:core::iter::Sum, + { + let mut array_of_iterators=rhs.array.map(|axis|axis.into_iter()); + Matrix{ + array:self.array.map(|axis| + core::array::from_fn(|_| + // axis dot product with transposed rhs array + axis.into_iter().zip( + array_of_iterators.each_mut().map(|iter| + iter.next().unwrap() + ) + ).map(|(a,b)| + a*b + ).sum() + ) + ) + } + } } impl Matrix where