no transpose trait
This commit is contained in:
parent
9da1c1ad1e
commit
fd588d1b60
@ -10,12 +10,5 @@ pub use matrix::Matrix2;
|
|||||||
pub use matrix::Matrix3;
|
pub use matrix::Matrix3;
|
||||||
pub use matrix::Matrix4;
|
pub use matrix::Matrix4;
|
||||||
|
|
||||||
//internal trait for matrix wide_dot
|
|
||||||
trait Transpose{
|
|
||||||
type Inner;
|
|
||||||
type Output;
|
|
||||||
fn transpose(self)->Self::Output;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -54,13 +54,6 @@ macro_rules! impl_matrix_inner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T> $crate::Transpose for $struct_outer<$struct_inner<T>>{
|
|
||||||
type Inner=$vector_outer<T>;
|
|
||||||
type Output=$matrix_inner<$vector_outer<T>>;
|
|
||||||
fn transpose(self)->Self::Output{
|
|
||||||
self.transpose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Copy> $struct_outer<$struct_inner<T>> {
|
impl<T: Copy> $struct_outer<$struct_inner<T>> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@ -75,8 +68,8 @@ macro_rules! impl_matrix_inner {
|
|||||||
// Impl floating-point based methods
|
// Impl floating-point based methods
|
||||||
#[cfg(feature="fixed_wide_traits")]
|
#[cfg(feature="fixed_wide_traits")]
|
||||||
$crate::impl_wide_matrix_operations!(
|
$crate::impl_wide_matrix_operations!(
|
||||||
($struct_outer { $($field_outer), + }, $vector_outer, $size_outer),
|
($struct_outer { $($field_outer), + }, $vector_outer { $($vector_field_outer), + }, $size_outer),
|
||||||
($struct_inner { $($field_inner), + }, $matrix_inner, $size_inner)
|
($struct_inner { $($field_inner), + }, $matrix_inner { $($matrix_field_inner), + }, $size_inner)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,33 @@ macro_rules! impl_wide_vector_operations {
|
|||||||
// Mat3<Vec4>.dot(Mat4<Vec2>) -> Mat3<Vec2>
|
// Mat3<Vec4>.dot(Mat4<Vec2>) -> Mat3<Vec2>
|
||||||
// mat.mat can be implemented off the back of mat.vec
|
// mat.mat can be implemented off the back of mat.vec
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_wide_matrix_mul {
|
||||||
|
(
|
||||||
|
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident { $($vector_field_outer: ident), + }, $size_outer: expr),
|
||||||
|
($struct_inner: ident { $($field_inner: ident), + }, $matrix_inner: ident { $($matrix_field_inner: ident), + }, $size_inner: expr),
|
||||||
|
($rhs_struct_inner: ident { $($rhs_field_inner: ident), + }, $rhs_matrix_inner: ident { $($rhs_matrix_field_inner: ident), + }, $rhs_size_inner: expr)
|
||||||
|
) => {
|
||||||
|
impl<T,U> fixed_wide_traits::wide::WideDot<$matrix_inner<$rhs_struct_inner<U>>> for $struct_outer<$struct_inner<T>>
|
||||||
|
where
|
||||||
|
$struct_inner<T>:fixed_wide_traits::wide::WideDot<$rhs_struct_inner<U>>,
|
||||||
|
{
|
||||||
|
type Output=$struct_outer<<$struct_inner<T> as fixed_wide_traits::wide::WideDot<$rhs_struct_inner<U>>::Output>;
|
||||||
|
#[inline]
|
||||||
|
fn wide_dot(self,rhs:$matrix_inner<$rhs_struct_inner<U>>)->Self::Output{
|
||||||
|
//just made this up, don't trust it
|
||||||
|
let tr=rhs.transpose();
|
||||||
|
//TODO: use a macro expansion instead of transpose and map
|
||||||
|
self.map(|axis|
|
||||||
|
tr.map(|trax|
|
||||||
|
axis.wide_dot(trax)
|
||||||
|
).to_vector()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! impl_wide_matrix_operations {
|
macro_rules! impl_wide_matrix_operations {
|
||||||
@ -45,21 +72,6 @@ macro_rules! impl_wide_matrix_operations {
|
|||||||
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident { $($vector_field_outer: ident), + }, $size_outer: expr),
|
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident { $($vector_field_outer: ident), + }, $size_outer: expr),
|
||||||
($struct_inner: ident { $($field_inner: ident), + }, $matrix_inner: ident { $($matrix_field_inner: ident), + }, $size_inner: expr)
|
($struct_inner: ident { $($field_inner: ident), + }, $matrix_inner: ident { $($matrix_field_inner: ident), + }, $size_inner: expr)
|
||||||
) => {
|
) => {
|
||||||
// U is a vec type
|
|
||||||
impl<T,U> fixed_wide_traits::wide::WideDot<$matrix_inner<U>> for $struct_outer<$struct_inner<T>>
|
|
||||||
where
|
|
||||||
$matrix_inner<U>:$crate::Transpose,
|
|
||||||
$struct_inner<T>:fixed_wide_traits::wide::WideDot<U>,
|
|
||||||
$struct_outer<$struct_inner<T>>:fixed_wide_traits::wide::WideDot<<$matrix_inner<U> as $crate::Transpose>::Inner>,
|
|
||||||
{
|
|
||||||
type Output=$struct_outer<<$struct_inner<T> as fixed_wide_traits::wide::WideDot<U>>::Output>;
|
|
||||||
#[inline]
|
|
||||||
fn wide_dot(self, rhs: $matrix_inner<U>) -> Self::Output {
|
|
||||||
//just made this up, don't trust it
|
|
||||||
let tr=rhs.transpose();
|
|
||||||
self.map(|axis|tr.wide_dot(axis))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* TODO: nasty determinant macro
|
/* TODO: nasty determinant macro
|
||||||
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> {
|
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user