diff --git a/fixed_wide_vectors/src/macros/fixed_wide.rs b/fixed_wide_vectors/src/macros/fixed_wide.rs index 824dc54..98398c3 100644 --- a/fixed_wide_vectors/src/macros/fixed_wide.rs +++ b/fixed_wide_vectors/src/macros/fixed_wide.rs @@ -87,16 +87,14 @@ macro_rules! impl_wide_vector_operations { #[macro_export(local_inner_macros)] macro_rules! impl_matrix_wide_dot_transpose_helper { ( - $value:ident, + $lhs_axis:expr, $wide_mul:ident, $rhs:ident, ($struct: ident { $($field: ident), + }), ($from_struct: ident { $($from_field: ident), + }), $static_field: ident ) => { - $struct { - $( - $field: $value.$from_field.$static_field - ), + - } + $crate::sum_repeating!( + $( + $lhs_axis.$field.$wide_mul($rhs.$from_field.$static_field) ) + + ) } } #[doc(hidden)] @@ -104,7 +102,7 @@ macro_rules! impl_matrix_wide_dot_transpose_helper { macro_rules! impl_matrix_wide_dot_inner { ( // MatY.MatX = MatY - $lhs:ident, $lhs_field_outer:ident, $wide_dot:ident, $rhs:ident, + $lhs:ident, $lhs_field_outer:ident, $wide_mul:ident, $rhs:ident, $struct_inner_thru: tt, //VecX ($struct_inner: ident { $($field_inner: ident), + }), //VecX ($rhs_struct_inner: ident { $($rhs_field_inner: ident), + }), //VecZ @@ -112,15 +110,14 @@ macro_rules! impl_matrix_wide_dot_inner { ) => { $rhs_struct_inner { $( - $rhs_field_inner: $lhs.$lhs_field_outer.$wide_dot( - //construct a transposed vector with the same width as $struct_outer - $crate::impl_matrix_wide_dot_transpose_helper!{ - $rhs, - $struct_inner_thru, //VecZ - $rhs_outer, //MatX - $rhs_field_inner - } - ) + //directly dot product to avoid a copy + $rhs_field_inner: $crate::impl_matrix_wide_dot_transpose_helper!{ + //lhs.axis.wide_mul(rhs_t.axis) + $lhs.$lhs_field_outer,$wide_mul,$rhs, + $struct_inner_thru, //VecZ + $rhs_outer, //MatX + $rhs_field_inner + } ), + } } @@ -130,7 +127,7 @@ macro_rules! impl_matrix_wide_dot_inner { macro_rules! impl_matrix_wide_dot_outer { ( // MatY.MatX = MatY - $lhs:ident, $wide_dot:ident, $rhs:ident, + $lhs:ident, $wide_mul:ident, $rhs:ident, //result matrix shape ($struct_outer: ident { $($field_outer: ident), + }),//MatY $rhs_struct_inner: tt,//VecZ @@ -142,7 +139,7 @@ macro_rules! impl_matrix_wide_dot_outer { $struct_outer { $( $field_outer: $crate::impl_matrix_wide_dot_inner!{ - $lhs, $field_outer, $wide_dot, $rhs, + $lhs, $field_outer, $wide_mul, $rhs, $struct_inner, //VecX $struct_inner, //VecX $rhs_struct_inner, //VecZ @@ -182,7 +179,7 @@ macro_rules! impl_matrix_wide_dot { pub fn [](self,rhs:$matrix_inner<$rhs_struct_inner>>)->$struct_outer<$rhs_struct_inner>>{ $crate::impl_matrix_wide_dot_outer!( //constituent idents - self,[],rhs, + self,[],rhs, //result matrix shape ($struct_outer { $($field_outer), + }), ($rhs_struct_inner { $($rhs_field_inner), + }),