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
trait Transpose{
type Inner;
type Output;
fn transpose(self)->Self::Output;
}

View File

@ -2,6 +2,7 @@
#[macro_export(local_inner_macros)]
macro_rules! impl_wide_vector_operations {
( $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> {
type Output=$struct<U>;
#[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> {
type Output=V;
#[inline]
@ -39,19 +41,14 @@ macro_rules! impl_wide_vector_operations {
#[macro_export(local_inner_macros)]
macro_rules! impl_wide_matrix_operations {
(
($struct_outer: ident { $($field_outer: ident), + }, $size_outer: expr),
($struct_inner: ident, $size_inner: expr), $fields_inner:tt
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident, $size_outer: expr),
($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> {
type Output=$struct<U>;
#[inline]
fn wide_mul(self, rhs: Self) -> Self::Output {
$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> {
/* Hide this
impl<T,U> fixed_wide_traits::wide::WideDot<$struct<U>> for $struct<T>
where
U:$crate::Transpose
{
type Output=V;
#[inline]
fn wide_dot(self, rhs: $struct<U>) -> Self::Output {
@ -60,6 +57,7 @@ macro_rules! impl_wide_matrix_operations {
)
}
}
*/
/* TODO: nasty determinant macro
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> {
#[inline]