From 7a9aaf9fe07cf1a5aebb2646fbe39418227a99f8 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 6 Sep 2024 11:38:22 -0700 Subject: [PATCH] matrix mul --- fixed_wide_vectors/src/macros/fixed_wide.rs | 38 +++++++++++++++++++++ fixed_wide_vectors/src/macros/matrix.rs | 2 ++ 2 files changed, 40 insertions(+) diff --git a/fixed_wide_vectors/src/macros/fixed_wide.rs b/fixed_wide_vectors/src/macros/fixed_wide.rs index 76458d6..cc213c5 100644 --- a/fixed_wide_vectors/src/macros/fixed_wide.rs +++ b/fixed_wide_vectors/src/macros/fixed_wide.rs @@ -118,6 +118,44 @@ macro_rules! do_macro_4_dumb{ }; } +#[doc(hidden)] +#[macro_export(local_inner_macros)] +macro_rules! impl_matrix_wide_dot { + ( + (), + ($lhs: expr, $rhs: expr) + ) => { + impl Matrix>{ + paste::item!{ + #[inline] + pub fn [](self,rhs:Matrix>)->Matrix>{ + let mut array_of_iterators=rhs.array.map(|axis|axis.into_iter().cycle()); + Matrix{ + array:self.array.map(|axis| + core::array::from_fn(|_| + // axis dot product with transposed rhs array + axis.iter().zip( + array_of_iterators.iter_mut() + ).map(|(&lhs_value,rhs_iter)| + lhs_value.[](rhs_iter.next().unwrap()) + ).sum() + ) + ) + } + } + } + } + } +} + +#[doc(hidden)] +#[macro_export(local_inner_macros)] +macro_rules! impl_matrix_wide_dot_8x8 { + () => { + $crate::do_macro_8x8!(impl_matrix_wide_dot,()); + } +} + #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_matrix_wide_3x3_det_not_const_generic { diff --git a/fixed_wide_vectors/src/macros/matrix.rs b/fixed_wide_vectors/src/macros/matrix.rs index 14013ac..269cdcb 100644 --- a/fixed_wide_vectors/src/macros/matrix.rs +++ b/fixed_wide_vectors/src/macros/matrix.rs @@ -73,6 +73,8 @@ macro_rules! impl_matrix { } } } + #[cfg(feature="fixed_wide")] + $crate::impl_matrix_wide_dot_8x8!(); } }