impl Mat*Vec

This commit is contained in:
Quaternions 2024-09-09 17:22:37 -07:00
parent dd2140d1d2
commit b772647137

View File

@ -54,6 +54,20 @@ macro_rules! impl_matrix {
)
)
}
#[inline]
// MatY<VecX>.VecX = VecY
pub fn transform_vector<U,V>(self,rhs:Vector<X,U>)->Vector<Y,V>
where
T:core::ops::Mul<U,Output=V>,
V:core::iter::Sum,
U:Copy,
{
Vector::new(
self.array.map(|axis|
Vector::new(axis).dot(rhs)
)
)
}
}
impl<const X:usize,const Y:usize,T> Matrix<X,Y,T>
where
@ -85,6 +99,18 @@ macro_rules! impl_matrix {
self.dot(rhs)
}
}
impl<const X:usize,const Y:usize,T,U,V> core::ops::Mul<Vector<X,U>> for Matrix<X,Y,T>
where
T:core::ops::Mul<U,Output=V>,
V:core::iter::Sum,
U:Copy,
{
type Output=Vector<Y,V>;
#[inline]
fn mul(self,rhs:Vector<X,U>)->Self::Output{
self.transform_vector(rhs)
}
}
#[cfg(feature="fixed_wide")]
$crate::impl_matrix_wide_dot_8x8!();
}