matrix wide dot

This commit is contained in:
Quaternions 2024-09-03 09:20:15 -07:00
parent 014b8333ff
commit c24ce58dbf

View File

@ -104,26 +104,48 @@ macro_rules! impl_wide_matrix_mul {
$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>;
paste::item!{
#[inline]
fn wide_dot(self,rhs:$matrix_inner<$rhs_struct_inner<U>>)->Self::Output{
fn [<wide_dot_ $size_outer x $size_inner _ $size_inner x $rhs_size_inner _ $lhs _ $rhs>](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)
axis.[<wide_dot_ $lhs _ $rhs>](trax)
).to_vector()
)
}
}
}
}
}
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_wide_matrix_operations {
macro_rules! impl_wide_matrix_operations_2arg_not_const_generic {
(
$lhs: expr, $rhs: 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)
) => {
/* TODO: nasty determinant macro
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> {
#[inline]
pub fn wide_dot(&self) -> U {
$crate::sum_repeating!(
$( + self.$field.wide_mul(self.$field) ) +
)
}
}
*/
};
}
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_wide_matrix_operations_1arg_not_const_generic {
(
$n: expr,
($struct_outer: ident { $($field_outer: ident), + }, $vector_outer: ident { $($vector_field_outer: ident), + }, $size_outer: expr),
) => {
/* TODO: nasty determinant macro
impl<U:std::ops::Add<Output=U>,T:Copy+fixed_wide_traits::wide::WideMul<Output=U>> $struct<T> {