From b7726471371cacb9a276fdd9781f87bb600ee818 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 9 Sep 2024 17:22:37 -0700 Subject: [PATCH] impl Mat*Vec --- fixed_wide_vectors/src/macros/matrix.rs | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fixed_wide_vectors/src/macros/matrix.rs b/fixed_wide_vectors/src/macros/matrix.rs index fedf100..ecd0d85 100644 --- a/fixed_wide_vectors/src/macros/matrix.rs +++ b/fixed_wide_vectors/src/macros/matrix.rs @@ -54,6 +54,20 @@ macro_rules! impl_matrix { ) ) } + #[inline] + // MatY.VecX = VecY + pub fn transform_vector(self,rhs:Vector)->Vector + where + T:core::ops::Mul, + V:core::iter::Sum, + U:Copy, + { + Vector::new( + self.array.map(|axis| + Vector::new(axis).dot(rhs) + ) + ) + } } impl Matrix where @@ -85,6 +99,18 @@ macro_rules! impl_matrix { self.dot(rhs) } } + impl core::ops::Mul> for Matrix + where + T:core::ops::Mul, + V:core::iter::Sum, + U:Copy, + { + type Output=Vector; + #[inline] + fn mul(self,rhs:Vector)->Self::Output{ + self.transform_vector(rhs) + } + } #[cfg(feature="fixed_wide")] $crate::impl_matrix_wide_dot_8x8!(); }