This commit is contained in:
Quaternions 2024-08-30 14:48:36 -07:00
parent 2da8130402
commit 85d0b3d1ac
2 changed files with 11 additions and 12 deletions

View File

@ -12,6 +12,7 @@ pub use matrix::Matrix4;
//internal trait for matrix wide_dot //internal trait for matrix wide_dot
trait Transpose{ trait Transpose{
type Inner;
type Output; type Output;
fn transpose(self)->Self::Output; fn transpose(self)->Self::Output;
} }

View File

@ -2,6 +2,7 @@
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! impl_wide_vector_operations { macro_rules! impl_wide_vector_operations {
( $struct: ident { $($field: ident), + }, $size: expr ) => { ( $struct: ident { $($field: ident), + }, $size: expr ) => {
//this one is shared between vec and mat
impl<U,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> fixed_wide_traits::wide::WideMul for $struct<T> { impl<U,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> fixed_wide_traits::wide::WideMul for $struct<T> {
type Output=$struct<U>; type Output=$struct<U>;
#[inline] #[inline]
@ -11,6 +12,7 @@ macro_rules! impl_wide_vector_operations {
} }
} }
} }
//these ones are vec only
impl<V:core::ops::Add<Output=V>,U,T:fixed_wide_traits::wide::WideMul<U,Output=V>> fixed_wide_traits::wide::WideDot<$struct<U>> for $struct<T> { impl<V:core::ops::Add<Output=V>,U,T:fixed_wide_traits::wide::WideMul<U,Output=V>> fixed_wide_traits::wide::WideDot<$struct<U>> for $struct<T> {
type Output=V; type Output=V;
#[inline] #[inline]
@ -39,19 +41,14 @@ macro_rules! impl_wide_vector_operations {
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! impl_wide_matrix_operations { macro_rules! impl_wide_matrix_operations {
( (
($struct_outer: ident { $($field_outer: ident), + }, $size_outer: expr), ($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident, $size_outer: expr),
($struct_inner: ident, $size_inner: expr), $fields_inner:tt ($struct_inner: ident { $($field_inner: ident), + }, $matrix_inner: ident, $size_inner: expr)
) => { ) => {
impl<U,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> fixed_wide_traits::wide::WideMul for $struct<T> { /* Hide this
type Output=$struct<U>; impl<T,U> fixed_wide_traits::wide::WideDot<$struct<U>> for $struct<T>
#[inline] where
fn wide_mul(self, rhs: Self) -> Self::Output { U:$crate::Transpose
$struct{ {
$( $field_outer: self.$field_outer.wide_mul(rhs.$field_outer) ), +
}
}
}
impl<U,T:fixed_wide_traits::wide::WideMul<U,Output=V>> fixed_wide_traits::wide::WideDot<$struct<U>> for $struct<T> {
type Output=V; type Output=V;
#[inline] #[inline]
fn wide_dot(self, rhs: $struct<U>) -> Self::Output { fn wide_dot(self, rhs: $struct<U>) -> Self::Output {
@ -60,6 +57,7 @@ macro_rules! impl_wide_matrix_operations {
) )
} }
} }
*/
/* 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]