diff --git a/fixed_wide_vectors/src/macros/matrix.rs b/fixed_wide_vectors/src/macros/matrix.rs index 6a10406..fedf100 100644 --- a/fixed_wide_vectors/src/macros/matrix.rs +++ b/fixed_wide_vectors/src/macros/matrix.rs @@ -59,12 +59,14 @@ macro_rules! impl_matrix { where T:Copy { + #[inline(always)] pub const fn from_value(value:T)->Self{ Self::new([[value;X];Y]) } } impl Default for Matrix{ + #[inline] fn default()->Self{ Self::new( core::array::from_fn(|_|core::array::from_fn(|_|Default::default())) @@ -123,11 +125,13 @@ macro_rules! impl_matrix_named_fields_shape { ) => { impl core::ops::Deref for Matrix<$size_outer,$size_inner,T>{ type Target=$struct_outer>; + #[inline] fn deref(&self)->&Self::Target{ unsafe{core::mem::transmute(&self.array)} } } impl core::ops::DerefMut for Matrix<$size_outer,$size_inner,T>{ + #[inline] fn deref_mut(&mut self)->&mut Self::Target{ unsafe{core::mem::transmute(&mut self.array)} } diff --git a/fixed_wide_vectors/src/macros/vector.rs b/fixed_wide_vectors/src/macros/vector.rs index 5264958..17f5406 100644 --- a/fixed_wide_vectors/src/macros/vector.rs +++ b/fixed_wide_vectors/src/macros/vector.rs @@ -39,6 +39,7 @@ macro_rules! impl_vector { } impl Default for Vector{ + #[inline] fn default()->Self{ Self::new( core::array::from_fn(|_|Default::default()) @@ -90,6 +91,7 @@ macro_rules! impl_vector { impl,V> core::ops::Neg for Vector{ type Output=Vector; + #[inline] fn neg(self)->Self::Output{ Vector::new( self.array.map(|t|-t) @@ -151,12 +153,14 @@ macro_rules! impl_vector_operator { ($trait: ident, $method: ident ) => { impl,U,V> core::ops::$trait> for Vector{ type Output=Vector; + #[inline] fn $method(self,rhs:Vector)->Self::Output{ self.map_zip(rhs,|(a,b)|a.$method(b)) } } impl> core::ops::$trait for Vector{ type Output=Self; + #[inline] fn $method(self,rhs:i64)->Self::Output{ self.map(|t|t.$method(rhs)) } @@ -168,12 +172,14 @@ macro_rules! impl_vector_operator { macro_rules! impl_vector_assign_operator { ($trait: ident, $method: ident ) => { impl,U> core::ops::$trait> for Vector{ + #[inline] fn $method(&mut self,rhs:Vector){ self.array.iter_mut().zip(rhs.array) .for_each(|(a,b)|a.$method(b)) } } impl> core::ops::$trait for Vector{ + #[inline] fn $method(&mut self,rhs:i64){ self.array.iter_mut() .for_each(|t|t.$method(rhs)) @@ -204,11 +210,13 @@ macro_rules! impl_vector_named_fields { ( $struct:ident, $size: expr ) => { impl core::ops::Deref for Vector<$size,T>{ type Target=$struct; + #[inline] fn deref(&self)->&Self::Target{ unsafe{core::mem::transmute(&self.array)} } } impl core::ops::DerefMut for Vector<$size,T>{ + #[inline] fn deref_mut(&mut self)->&mut Self::Target{ unsafe{core::mem::transmute(&mut self.array)} }