matrix mul

This commit is contained in:
Quaternions 2024-09-06 11:38:22 -07:00
parent 9ad90cea2e
commit 7a9aaf9fe0
2 changed files with 40 additions and 0 deletions

View File

@ -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<const X:usize,const Y:usize> Matrix<X,Y,fixed_wide::fixed::Fixed<{$lhs},{$lhs*32}>>{
paste::item!{
#[inline]
pub fn [<wide_dot_ $lhs _ $rhs>]<const Z:usize>(self,rhs:Matrix<Z,X,fixed_wide::fixed::Fixed<{$rhs},{$rhs*32}>>)->Matrix<Z,Y,fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>>{
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.[<wide_mul_ $lhs _ $rhs>](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)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! impl_matrix_wide_3x3_det_not_const_generic { macro_rules! impl_matrix_wide_3x3_det_not_const_generic {

View File

@ -73,6 +73,8 @@ macro_rules! impl_matrix {
} }
} }
} }
#[cfg(feature="fixed_wide")]
$crate::impl_matrix_wide_dot_8x8!();
} }
} }