umm the macro
This commit is contained in:
parent
f7ae745bef
commit
6aba246453
@ -103,22 +103,22 @@ macro_rules! impl_matrix_wide_mul_transpose_helper {
|
|||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! impl_matrix_wide_mul_inner {
|
macro_rules! impl_matrix_wide_mul_inner {
|
||||||
(
|
(
|
||||||
|
// MatY<VecX>.MatX<VecZ> = MatY<VecZ>
|
||||||
$lhs:ident, $lhs_field_outer:ident, $wide_dot:ident, $rhs:ident,
|
$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, //VecX
|
||||||
$rhs_struct_inner: tt,
|
($struct_inner: ident { $($field_inner: ident), + }), //VecX
|
||||||
($struct_inner: ident { $($field_inner: ident), + }),
|
($rhs_struct_inner: ident { $($rhs_field_inner: ident), + }), //VecZ
|
||||||
$rhs_outer_thru: tt,
|
$rhs_outer: tt //MatX
|
||||||
($rhs_outer: ident { $($rhs_field_outer: ident), + })
|
|
||||||
) => {
|
) => {
|
||||||
$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
|
//construct a transposed vector with the same width as $struct_outer
|
||||||
$crate::impl_matrix_wide_mul_transpose_helper!{
|
$crate::impl_matrix_wide_mul_transpose_helper!{
|
||||||
$rhs,
|
$rhs,
|
||||||
$rhs_struct_inner,//into
|
$struct_inner_thru, //VecZ
|
||||||
$rhs_outer_thru,//from
|
$rhs_outer, //MatX
|
||||||
$rhs_field_outer
|
$rhs_field_inner
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
), +
|
), +
|
||||||
@ -129,23 +129,24 @@ macro_rules! impl_matrix_wide_mul_inner {
|
|||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! impl_matrix_wide_mul_outer {
|
macro_rules! impl_matrix_wide_mul_outer {
|
||||||
(
|
(
|
||||||
|
// MatY<VecX>.MatX<VecZ> = MatY<VecZ>
|
||||||
$lhs:ident, $wide_dot:ident, $rhs:ident,
|
$lhs:ident, $wide_dot:ident, $rhs:ident,
|
||||||
|
//result matrix shape
|
||||||
($struct_outer: ident { $($field_outer: ident), + }),
|
($struct_outer: ident { $($field_outer: ident), + }),//MatY
|
||||||
$rhs_struct_inner: tt,
|
$rhs_struct_inner: tt,//VecZ
|
||||||
|
//inner loop shape
|
||||||
$struct_inner: tt,
|
$struct_inner: tt,//VecX
|
||||||
$rhs_matrix: tt
|
$rhs_matrix: tt//MatX
|
||||||
|
|
||||||
) => {
|
) => {
|
||||||
$struct_outer {
|
$struct_outer {
|
||||||
$(
|
$(
|
||||||
$field_outer: $crate::impl_matrix_wide_mul_inner!{
|
$field_outer: $crate::impl_matrix_wide_mul_inner!{
|
||||||
$lhs, $field_outer, $wide_dot, $rhs,
|
$lhs, $field_outer, $wide_dot, $rhs,
|
||||||
$struct_inner,//thru
|
$struct_inner, //VecX
|
||||||
$rhs_struct_inner,
|
$struct_inner, //VecX
|
||||||
$rhs_matrix,//thru
|
$rhs_struct_inner, //VecZ
|
||||||
$rhs_matrix
|
$rhs_matrix //MatX
|
||||||
}
|
}
|
||||||
), +
|
), +
|
||||||
}
|
}
|
||||||
@ -154,14 +155,22 @@ macro_rules! impl_matrix_wide_mul_outer {
|
|||||||
|
|
||||||
// Notes:
|
// Notes:
|
||||||
// Mat3<Vec2>.dot(Vec2) -> Vec3
|
// 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>
|
// 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)]
|
#[doc(hidden)]
|
||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! impl_matrix_wide_mul {
|
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_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),
|
($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),
|
($rhs_struct_inner: ident { $($rhs_field_inner: ident), + }, $rhs_matrix_inner: ident { $($rhs_matrix_field_inner: ident), + }, $rhs_size_inner: expr),
|
||||||
|
Loading…
Reference in New Issue
Block a user