umm the macro

This commit is contained in:
Quaternions 2024-09-04 11:55:23 -07:00
parent f7ae745bef
commit 6aba246453

View File

@ -103,22 +103,22 @@ macro_rules! impl_matrix_wide_mul_transpose_helper {
#[macro_export(local_inner_macros)]
macro_rules! impl_matrix_wide_mul_inner {
(
// MatY<VecX>.MatX<VecZ> = MatY<VecZ>
$lhs:ident, $lhs_field_outer:ident, $wide_dot:ident, $rhs:ident,
//pass this in twice, once for pass through and once to parse
$rhs_struct_inner: tt,
($struct_inner: ident { $($field_inner: ident), + }),
$rhs_outer_thru: tt,
($rhs_outer: ident { $($rhs_field_outer: ident), + })
$struct_inner_thru: tt, //VecX
($struct_inner: ident { $($field_inner: ident), + }), //VecX
($rhs_struct_inner: ident { $($rhs_field_inner: ident), + }), //VecZ
$rhs_outer: tt //MatX
) => {
$struct_inner {
$rhs_struct_inner {
$(
$field_inner: $lhs.$lhs_field_outer.$wide_dot(
$rhs_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,
$rhs_struct_inner,//into
$rhs_outer_thru,//from
$rhs_field_outer
$struct_inner_thru, //VecZ
$rhs_outer, //MatX
$rhs_field_inner
}
)
), +
@ -129,23 +129,24 @@ macro_rules! impl_matrix_wide_mul_inner {
#[macro_export(local_inner_macros)]
macro_rules! impl_matrix_wide_mul_outer {
(
// MatY<VecX>.MatX<VecZ> = MatY<VecZ>
$lhs:ident, $wide_dot:ident, $rhs:ident,
($struct_outer: ident { $($field_outer: ident), + }),
$rhs_struct_inner: tt,
$struct_inner: tt,
$rhs_matrix: tt
//result matrix shape
($struct_outer: ident { $($field_outer: ident), + }),//MatY
$rhs_struct_inner: tt,//VecZ
//inner loop shape
$struct_inner: tt,//VecX
$rhs_matrix: tt//MatX
) => {
$struct_outer {
$(
$field_outer: $crate::impl_matrix_wide_mul_inner!{
$lhs, $field_outer, $wide_dot, $rhs,
$struct_inner,//thru
$rhs_struct_inner,
$rhs_matrix,//thru
$rhs_matrix
$struct_inner, //VecX
$struct_inner, //VecX
$rhs_struct_inner, //VecZ
$rhs_matrix //MatX
}
), +
}
@ -154,14 +155,22 @@ macro_rules! impl_matrix_wide_mul_outer {
// Notes:
// Mat3<Vec2>.dot(Vec2) -> Vec3
// lhs.dot(rhs) -> out
// lhs = Mat3<Vec4>
// rhs = Mat4<Vec2>
// out = Mat3<Vec2>
// Mat3<Vec4>.dot(Mat4<Vec2>) -> Mat3<Vec2>
// mat.mat can be implemented off the back of mat.vec
// how to matrix multiply:
// RHS TRANSPOSE
// Mat4<Vec2> -> Mat2<Vec4>
// rhs_t = Mat2<Vec4>
// inner loop:
// out[y][x] = lhs[y].dot(rhs_t[x])
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_matrix_wide_mul {
(
//TODO: Fixed point impls
($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),