|
|
|
|
@@ -85,7 +85,37 @@ macro_rules! impl_wide_vector_operations {
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul_transpose_helper {
|
|
|
|
|
macro_rules! impl_vector_3_wide_cross {
|
|
|
|
|
(
|
|
|
|
|
(),
|
|
|
|
|
($lhs:expr, $rhs:expr)
|
|
|
|
|
)=>{
|
|
|
|
|
impl Vector3<fixed_wide::fixed::Fixed<{$lhs},{$lhs*32}>>{
|
|
|
|
|
paste::item!{
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn [<wide_cross_ $lhs _ $rhs>](self,rhs:Vector3<fixed_wide::fixed::Fixed<{$rhs},{$rhs*32}>>)->Vector3<fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>>{
|
|
|
|
|
Vector3{
|
|
|
|
|
x:self.y.[<wide_mul_ $lhs _ $rhs>](rhs.z)-self.z.[<wide_mul_ $lhs _ $rhs>](rhs.y),
|
|
|
|
|
y:self.z.[<wide_mul_ $lhs _ $rhs>](rhs.x)-self.x.[<wide_mul_ $lhs _ $rhs>](rhs.z),
|
|
|
|
|
z:self.x.[<wide_mul_ $lhs _ $rhs>](rhs.y)-self.y.[<wide_mul_ $lhs _ $rhs>](rhs.x)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_vector_wide_3 {
|
|
|
|
|
()=>{
|
|
|
|
|
$crate::do_macro_8x8!(impl_vector_3_wide_cross,());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_dot_transpose_helper {
|
|
|
|
|
(
|
|
|
|
|
$lhs_axis:expr, $wide_mul:ident, $rhs:ident,
|
|
|
|
|
($struct: ident { $($field: ident), + }),
|
|
|
|
|
@@ -99,7 +129,7 @@ macro_rules! impl_matrix_wide_mul_transpose_helper {
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul_inner {
|
|
|
|
|
macro_rules! impl_matrix_wide_dot_inner {
|
|
|
|
|
(
|
|
|
|
|
// MatY<VecX>.MatX<VecZ> = MatY<VecZ>
|
|
|
|
|
$lhs:ident, $lhs_field_outer:ident, $wide_mul:ident, $rhs:ident,
|
|
|
|
|
@@ -111,8 +141,8 @@ macro_rules! impl_matrix_wide_mul_inner {
|
|
|
|
|
$rhs_struct_inner {
|
|
|
|
|
$(
|
|
|
|
|
//directly dot product to avoid a copy
|
|
|
|
|
$rhs_field_inner: $crate::impl_matrix_wide_mul_transpose_helper!{
|
|
|
|
|
//lhs_axis
|
|
|
|
|
$rhs_field_inner: $crate::impl_matrix_wide_dot_transpose_helper!{
|
|
|
|
|
//lhs.axis.wide_mul(rhs_t.axis)
|
|
|
|
|
$lhs.$lhs_field_outer,$wide_mul,$rhs,
|
|
|
|
|
$struct_inner_thru, //VecZ
|
|
|
|
|
$rhs_outer, //MatX
|
|
|
|
|
@@ -124,7 +154,7 @@ macro_rules! impl_matrix_wide_mul_inner {
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul_outer {
|
|
|
|
|
macro_rules! impl_matrix_wide_dot_outer {
|
|
|
|
|
(
|
|
|
|
|
// MatY<VecX>.MatX<VecZ> = MatY<VecZ>
|
|
|
|
|
$lhs:ident, $wide_mul:ident, $rhs:ident,
|
|
|
|
|
@@ -138,7 +168,7 @@ macro_rules! impl_matrix_wide_mul_outer {
|
|
|
|
|
) => {
|
|
|
|
|
$struct_outer {
|
|
|
|
|
$(
|
|
|
|
|
$field_outer: $crate::impl_matrix_wide_mul_inner!{
|
|
|
|
|
$field_outer: $crate::impl_matrix_wide_dot_inner!{
|
|
|
|
|
$lhs, $field_outer, $wide_mul, $rhs,
|
|
|
|
|
$struct_inner, //VecX
|
|
|
|
|
$struct_inner, //VecX
|
|
|
|
|
@@ -166,7 +196,7 @@ macro_rules! impl_matrix_wide_mul_outer {
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul {
|
|
|
|
|
macro_rules! impl_matrix_wide_dot {
|
|
|
|
|
(
|
|
|
|
|
($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),
|
|
|
|
|
@@ -177,7 +207,7 @@ 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}>>>{
|
|
|
|
|
$crate::impl_matrix_wide_mul_outer!(
|
|
|
|
|
$crate::impl_matrix_wide_dot_outer!(
|
|
|
|
|
//constituent idents
|
|
|
|
|
self,[<wide_mul_ $lhs _ $rhs>],rhs,
|
|
|
|
|
//result matrix shape
|
|
|
|
|
@@ -195,32 +225,32 @@ macro_rules! impl_matrix_wide_mul {
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul_shim {
|
|
|
|
|
macro_rules! impl_matrix_wide_dot_shim {
|
|
|
|
|
(
|
|
|
|
|
($outer_info:tt,$inner_info:tt,$rhs_info:tt),
|
|
|
|
|
($lhs: expr, $rhs: expr)
|
|
|
|
|
) => {
|
|
|
|
|
$crate::impl_matrix_wide_mul!($outer_info,$inner_info,$rhs_info,($lhs,$rhs));
|
|
|
|
|
$crate::impl_matrix_wide_dot!($outer_info,$inner_info,$rhs_info,($lhs,$rhs));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul_8x8 {
|
|
|
|
|
macro_rules! impl_matrix_wide_dot_8x8 {
|
|
|
|
|
(
|
|
|
|
|
($outer_info:tt,$inner_info:tt),
|
|
|
|
|
$rhs_info:tt
|
|
|
|
|
) => {
|
|
|
|
|
$crate::do_macro_8x8!(impl_matrix_wide_mul_shim,($outer_info,$inner_info,$rhs_info));
|
|
|
|
|
$crate::do_macro_8x8!(impl_matrix_wide_dot_shim,($outer_info,$inner_info,$rhs_info));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_mul_repeat_rhs {
|
|
|
|
|
macro_rules! impl_matrix_wide_dot_repeat_rhs {
|
|
|
|
|
(
|
|
|
|
|
($outer_info:tt,($($rhs_info:tt),+)),
|
|
|
|
|
$inner_info:tt
|
|
|
|
|
) => {
|
|
|
|
|
$crate::macro_repeated!(impl_matrix_wide_mul_8x8,($outer_info,$inner_info),$($rhs_info),+);
|
|
|
|
|
$crate::macro_repeated!(impl_matrix_wide_dot_8x8,($outer_info,$inner_info),$($rhs_info),+);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
@@ -263,6 +293,72 @@ macro_rules! impl_wide_matrix_operations_1arg_not_const_generic {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! do_macro_4_dumb{
|
|
|
|
|
(
|
|
|
|
|
$macro:ident,
|
|
|
|
|
$any:tt
|
|
|
|
|
)=>{
|
|
|
|
|
$crate::macro_repeated!($macro, $any, (1,2),(2,4),(3,6),(4,8));
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_3x3_det_not_const_generic {
|
|
|
|
|
(
|
|
|
|
|
$n: expr,
|
|
|
|
|
$_2n: expr
|
|
|
|
|
)=>{
|
|
|
|
|
impl Matrix3<Vector3<fixed_wide::fixed::Fixed<$n,{$n*32}>>>{
|
|
|
|
|
paste::item!{
|
|
|
|
|
pub fn [<wide_det_3x3_ $n>](self)->fixed_wide::fixed::Fixed<{$n*3},{$n*3*32}>{
|
|
|
|
|
//[<wide_dot_ $n _ $n*2>] will not compile, so the doubles are hardcoded above
|
|
|
|
|
self.x_axis.[<wide_dot_ $n _ $_2n>](self.y_axis.[<wide_cross_ $n _ $n>](self.z_axis))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_3x3_det_not_const_generic_shim {
|
|
|
|
|
(
|
|
|
|
|
(),($n: expr,$_2n: expr)
|
|
|
|
|
)=>{
|
|
|
|
|
$crate::impl_matrix_wide_3x3_det_not_const_generic!($n,$_2n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_3x3_adjugate_not_const_generic {
|
|
|
|
|
(
|
|
|
|
|
(),
|
|
|
|
|
$n: expr
|
|
|
|
|
)=>{
|
|
|
|
|
impl Matrix3<Vector3<fixed_wide::fixed::Fixed<$n,{$n*32}>>>{
|
|
|
|
|
paste::item!{
|
|
|
|
|
pub fn [<wide_adjugate_3x3_ $n>](self)->Matrix3<Vector3<fixed_wide::fixed::Fixed<{$n*2},{$n*2*32}>>>{
|
|
|
|
|
Matrix3{
|
|
|
|
|
x_axis:Vector3{x:self.y_axis.y.[<wide_mul_ $n _ $n>](self.z_axis.z)-self.y_axis.z.[<wide_mul_ $n _ $n>](self.z_axis.y),y:self.x_axis.z.[<wide_mul_ $n _ $n>](self.z_axis.y)-self.x_axis.y.[<wide_mul_ $n _ $n>](self.z_axis.z),z:self.x_axis.y.[<wide_mul_ $n _ $n>](self.y_axis.z)-self.x_axis.z.[<wide_mul_ $n _ $n>](self.y_axis.y)},
|
|
|
|
|
y_axis:Vector3{x:self.y_axis.z.[<wide_mul_ $n _ $n>](self.z_axis.x)-self.y_axis.x.[<wide_mul_ $n _ $n>](self.z_axis.z),y:self.x_axis.x.[<wide_mul_ $n _ $n>](self.z_axis.z)-self.x_axis.z.[<wide_mul_ $n _ $n>](self.z_axis.x),z:self.x_axis.z.[<wide_mul_ $n _ $n>](self.y_axis.x)-self.x_axis.x.[<wide_mul_ $n _ $n>](self.y_axis.z)},
|
|
|
|
|
z_axis:Vector3{x:self.y_axis.x.[<wide_mul_ $n _ $n>](self.z_axis.y)-self.y_axis.y.[<wide_mul_ $n _ $n>](self.z_axis.x),y:self.x_axis.y.[<wide_mul_ $n _ $n>](self.z_axis.x)-self.x_axis.x.[<wide_mul_ $n _ $n>](self.z_axis.y),z:self.x_axis.x.[<wide_mul_ $n _ $n>](self.y_axis.y)-self.x_axis.y.[<wide_mul_ $n _ $n>](self.y_axis.x)},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
#[macro_export(local_inner_macros)]
|
|
|
|
|
macro_rules! impl_matrix_wide_3x3 {
|
|
|
|
|
()=>{
|
|
|
|
|
$crate::do_macro_4_dumb!(impl_matrix_wide_3x3_det_not_const_generic_shim,());
|
|
|
|
|
$crate::do_macro_8!(impl_matrix_wide_3x3_adjugate_not_const_generic,());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// HACK: Allows us to sum repeating tokens in macros.
|
|
|
|
|
// See: https://stackoverflow.com/a/60187870/17452730
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
|
|