tweak dot

This commit is contained in:
Quaternions 2024-09-06 10:36:24 -07:00
parent 607706ee2a
commit 5cad8637cd

View File

@ -38,7 +38,7 @@ macro_rules! impl_matrix {
where where
T:core::ops::Mul<U,Output=V>+Copy, T:core::ops::Mul<U,Output=V>+Copy,
V:core::iter::Sum, V:core::iter::Sum,
U:Clone, U:Copy,
{ {
let mut array_of_iterators=rhs.array.map(|axis|axis.into_iter().cycle()); let mut array_of_iterators=rhs.array.map(|axis|axis.into_iter().cycle());
Matrix{ Matrix{
@ -46,11 +46,9 @@ macro_rules! impl_matrix {
core::array::from_fn(|_| core::array::from_fn(|_|
// axis dot product with transposed rhs array // axis dot product with transposed rhs array
axis.iter().zip( axis.iter().zip(
array_of_iterators.each_mut().map(|iter| array_of_iterators.iter_mut()
iter.next().unwrap() ).map(|(&lhs_value,rhs_iter)|
) lhs_value*rhs_iter.next().unwrap()
).map(|(&a,b)|
a*b
).sum() ).sum()
) )
) )