wip mat mul
This commit is contained in:
parent
176eb762e3
commit
1f1568ebe9
@ -83,6 +83,74 @@ macro_rules! impl_wide_vector_operations {
|
||||
};
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! impl_matrix_wide_mul_transpose_helper {
|
||||
(
|
||||
$value:ident,
|
||||
($struct: ident { $($field: ident), + }),
|
||||
($from_struct: ident { $($from_field: ident), + }),
|
||||
$static_field: ident
|
||||
) => {
|
||||
$struct {
|
||||
$(
|
||||
$field: $value.$from_field.$static_field
|
||||
), +
|
||||
}
|
||||
}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! impl_matrix_wide_mul_inner {
|
||||
(
|
||||
$lhs:ident, $lhs_field_outer:ident, $wide_dot:ident, $rhs:ident,
|
||||
//pass this in twice, once for pass through and once to parse
|
||||
$struct_inner_thru: tt,
|
||||
($struct_inner: ident { $($field_inner: ident), + }),
|
||||
$rhs_outer_thru: tt,
|
||||
($rhs_outer: ident { $($rhs_outer_field: ident), + })
|
||||
) => {
|
||||
$struct_inner {
|
||||
$(
|
||||
$field_inner: $lhs.$lhs_field_outer.$wide_dot(
|
||||
//construct a transposed vector with the same width as $struct_outer
|
||||
$crate::impl_matrix_wide_mul_transpose_helper!{
|
||||
$rhs,
|
||||
$struct_inner_thru,
|
||||
$rhs_outer_thru,
|
||||
$rhs_outer_field
|
||||
}
|
||||
)
|
||||
), +
|
||||
}
|
||||
}
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[macro_export(local_inner_macros)]
|
||||
macro_rules! impl_matrix_wide_mul_outer {
|
||||
(
|
||||
$lhs:ident, $wide_dot:ident, $rhs:ident,
|
||||
|
||||
($struct_outer: ident { $($field_outer: ident), + }),
|
||||
$rhs_struct_inner: tt,
|
||||
|
||||
$struct_inner: tt,
|
||||
$rhs_matrix: tt
|
||||
|
||||
) => {
|
||||
$struct_outer {
|
||||
$(
|
||||
$field_outer: $crate::impl_matrix_wide_mul_inner!{
|
||||
$lhs, $field_outer, $wide_dot, $rhs,
|
||||
$struct_inner,//thru
|
||||
$struct_inner,
|
||||
$rhs_matrix,//thru
|
||||
$rhs_matrix
|
||||
}
|
||||
), +
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Notes:
|
||||
// Mat3<Vec2>.dot(Vec2) -> Vec3
|
||||
@ -103,13 +171,15 @@ macro_rules! impl_matrix_wide_mul {
|
||||
paste::item!{
|
||||
#[inline]
|
||||
pub fn [<wide_dot_ $size_outer x $size_inner _ $size_inner x $rhs_size_inner _ $lhs _ $rhs>](self,rhs:$matrix_inner<$rhs_struct_inner<fixed_wide::fixed::Fixed<{$rhs},{$rhs*32}>>>)->$struct_outer<$rhs_struct_inner<fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>>>{
|
||||
//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_ $lhs _ $rhs>](trax)
|
||||
).to_vector()
|
||||
$crate::impl_matrix_wide_mul_outer!(
|
||||
//constituent idents
|
||||
self,[<wide_dot_ $lhs _ $rhs>],rhs,
|
||||
//result matrix shape
|
||||
($struct_outer { $($field_outer), + }),
|
||||
($rhs_struct_inner { $($rhs_field_inner), + }),
|
||||
//inner loop shape
|
||||
($struct_inner { $($field_inner), + }),
|
||||
($matrix_inner { $($matrix_field_inner), + })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user