#[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_wide_vector_operations_2arg_not_const_generic { ( (), ($lhs:expr, $rhs:expr) ) => { impl Vector>{ paste::item!{ #[inline] pub fn [](self,rhs:Vector>)->Vector>{ self.map_zip(rhs,|(a,b)|a.[](b)) } #[inline] pub fn [](self,rhs:Vector>)->fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>{ self.array.into_iter().zip(rhs.array).map(|(a,b)|a.[](b)).sum() } } } } } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_wide_vector_operations_1arg_not_const_generic { ( (), $n:expr ) => { impl Vector>{ paste::item!{ #[inline] pub fn wide_length_squared(&self)->fixed_wide::fixed::Fixed<{$n*2},{$n*2*32}>{ self.array.into_iter().map(|t|t.[](t)).sum() } } } }; } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! do_macro_8x8{ ( $macro:ident, $any:tt )=>{ $crate::macro_repeated!($macro, $any, (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1), (1,2),(2,2),(3,2),(4,2),(5,2),(6,2),(7,2),(8,2), (1,3),(2,3),(3,3),(4,3),(5,3),(6,3),(7,3),(8,3), (1,4),(2,4),(3,4),(4,4),(5,4),(6,4),(7,4),(8,4), (1,5),(2,5),(3,5),(4,5),(5,5),(6,5),(7,5),(8,5), (1,6),(2,6),(3,6),(4,6),(5,6),(6,6),(7,6),(8,6), (1,7),(2,7),(3,7),(4,7),(5,7),(6,7),(7,7),(8,7), (1,8),(2,8),(3,8),(4,8),(5,8),(6,8),(7,8),(8,8) ); }; } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! do_macro_8{ ( $macro:ident, $any:tt )=>{ $crate::macro_repeated!($macro, $any, 1,2,3,4,5,6,7,8); }; } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_wide_vector_operations { () => { $crate::do_macro_8!(impl_wide_vector_operations_1arg_not_const_generic,()); $crate::do_macro_8x8!(impl_wide_vector_operations_2arg_not_const_generic,()); }; } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_vector_3_wide_cross { ( (), ($lhs:expr, $rhs:expr) )=>{ impl Vector<3,fixed_wide::fixed::Fixed<{$lhs},{$lhs*32}>>{ paste::item!{ #[inline] pub fn [](self,rhs:Vector<3,fixed_wide::fixed::Fixed<{$rhs},{$rhs*32}>>)->Vector<3,fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>>{ Vector::new([ self.y.[](rhs.z)-self.z.[](rhs.y), self.z.[](rhs.x)-self.x.[](rhs.z), self.x.[](rhs.y)-self.y.[](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! 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_dot { ( (), ($lhs: expr, $rhs: expr) ) => { impl Matrix>{ paste::item!{ #[inline] pub fn [](self,rhs:Matrix>)->Matrix>{ let mut array_of_iterators=rhs.array.map(|axis|axis.into_iter().cycle()); Matrix::new( self.array.map(|axis| core::array::from_fn(|_| // axis dot product with transposed rhs array axis.iter().zip( array_of_iterators.iter_mut() ).map(|(&lhs_value,rhs_iter)| lhs_value.[](rhs_iter.next().unwrap()) ).sum() ) ) ) } } } } } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_matrix_wide_dot_8x8 { () => { $crate::do_macro_8x8!(impl_matrix_wide_dot,()); } } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_matrix_wide_3x3_det_not_const_generic { ( $n: expr, $_2n: expr )=>{ impl Matrix<3,3,fixed_wide::fixed::Fixed<$n,{$n*32}>>{ paste::item!{ pub fn [](self)->fixed_wide::fixed::Fixed<{$n*3},{$n*3*32}>{ //[] will not compile, so the doubles are hardcoded above self.x_axis.[](self.y_axis.[](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 Matrix<3,3,fixed_wide::fixed::Fixed<$n,{$n*32}>>{ paste::item!{ pub fn [](self)->Matrix<3,3,fixed_wide::fixed::Fixed<{$n*2},{$n*2*32}>>{ Matrix::new([ [self.y_axis.y.[](self.z_axis.z)-self.y_axis.z.[](self.z_axis.y),self.x_axis.z.[](self.z_axis.y)-self.x_axis.y.[](self.z_axis.z),self.x_axis.y.[](self.y_axis.z)-self.x_axis.z.[](self.y_axis.y)], [self.y_axis.z.[](self.z_axis.x)-self.y_axis.x.[](self.z_axis.z),self.x_axis.x.[](self.z_axis.z)-self.x_axis.z.[](self.z_axis.x),self.x_axis.z.[](self.y_axis.x)-self.x_axis.x.[](self.y_axis.z)], [self.y_axis.x.[](self.z_axis.y)-self.y_axis.y.[](self.z_axis.x),self.x_axis.y.[](self.z_axis.x)-self.x_axis.x.[](self.z_axis.y),self.x_axis.x.[](self.y_axis.y)-self.x_axis.y.[](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,()); } }