forgotten inlines
This commit is contained in:
parent
6cbd3446e5
commit
dd2140d1d2
@ -59,12 +59,14 @@ macro_rules! impl_matrix {
|
|||||||
where
|
where
|
||||||
T:Copy
|
T:Copy
|
||||||
{
|
{
|
||||||
|
#[inline(always)]
|
||||||
pub const fn from_value(value:T)->Self{
|
pub const fn from_value(value:T)->Self{
|
||||||
Self::new([[value;X];Y])
|
Self::new([[value;X];Y])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const X:usize,const Y:usize,T:Default> Default for Matrix<X,Y,T>{
|
impl<const X:usize,const Y:usize,T:Default> Default for Matrix<X,Y,T>{
|
||||||
|
#[inline]
|
||||||
fn default()->Self{
|
fn default()->Self{
|
||||||
Self::new(
|
Self::new(
|
||||||
core::array::from_fn(|_|core::array::from_fn(|_|Default::default()))
|
core::array::from_fn(|_|core::array::from_fn(|_|Default::default()))
|
||||||
@ -123,11 +125,13 @@ macro_rules! impl_matrix_named_fields_shape {
|
|||||||
) => {
|
) => {
|
||||||
impl<T> core::ops::Deref for Matrix<$size_outer,$size_inner,T>{
|
impl<T> core::ops::Deref for Matrix<$size_outer,$size_inner,T>{
|
||||||
type Target=$struct_outer<Vector<$size_inner,T>>;
|
type Target=$struct_outer<Vector<$size_inner,T>>;
|
||||||
|
#[inline]
|
||||||
fn deref(&self)->&Self::Target{
|
fn deref(&self)->&Self::Target{
|
||||||
unsafe{core::mem::transmute(&self.array)}
|
unsafe{core::mem::transmute(&self.array)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T> core::ops::DerefMut for Matrix<$size_outer,$size_inner,T>{
|
impl<T> core::ops::DerefMut for Matrix<$size_outer,$size_inner,T>{
|
||||||
|
#[inline]
|
||||||
fn deref_mut(&mut self)->&mut Self::Target{
|
fn deref_mut(&mut self)->&mut Self::Target{
|
||||||
unsafe{core::mem::transmute(&mut self.array)}
|
unsafe{core::mem::transmute(&mut self.array)}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ macro_rules! impl_vector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<const N:usize,T:Default> Default for Vector<N,T>{
|
impl<const N:usize,T:Default> Default for Vector<N,T>{
|
||||||
|
#[inline]
|
||||||
fn default()->Self{
|
fn default()->Self{
|
||||||
Self::new(
|
Self::new(
|
||||||
core::array::from_fn(|_|Default::default())
|
core::array::from_fn(|_|Default::default())
|
||||||
@ -90,6 +91,7 @@ macro_rules! impl_vector {
|
|||||||
|
|
||||||
impl<const N:usize,T:core::ops::Neg<Output=V>,V> core::ops::Neg for Vector<N,T>{
|
impl<const N:usize,T:core::ops::Neg<Output=V>,V> core::ops::Neg for Vector<N,T>{
|
||||||
type Output=Vector<N,V>;
|
type Output=Vector<N,V>;
|
||||||
|
#[inline]
|
||||||
fn neg(self)->Self::Output{
|
fn neg(self)->Self::Output{
|
||||||
Vector::new(
|
Vector::new(
|
||||||
self.array.map(|t|-t)
|
self.array.map(|t|-t)
|
||||||
@ -151,12 +153,14 @@ macro_rules! impl_vector_operator {
|
|||||||
($trait: ident, $method: ident ) => {
|
($trait: ident, $method: ident ) => {
|
||||||
impl<const N:usize,T:core::ops::$trait<U,Output=V>,U,V> core::ops::$trait<Vector<N,U>> for Vector<N,T>{
|
impl<const N:usize,T:core::ops::$trait<U,Output=V>,U,V> core::ops::$trait<Vector<N,U>> for Vector<N,T>{
|
||||||
type Output=Vector<N,V>;
|
type Output=Vector<N,V>;
|
||||||
|
#[inline]
|
||||||
fn $method(self,rhs:Vector<N,U>)->Self::Output{
|
fn $method(self,rhs:Vector<N,U>)->Self::Output{
|
||||||
self.map_zip(rhs,|(a,b)|a.$method(b))
|
self.map_zip(rhs,|(a,b)|a.$method(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<const N:usize,T:core::ops::$trait<i64,Output=T>> core::ops::$trait<i64> for Vector<N,T>{
|
impl<const N:usize,T:core::ops::$trait<i64,Output=T>> core::ops::$trait<i64> for Vector<N,T>{
|
||||||
type Output=Self;
|
type Output=Self;
|
||||||
|
#[inline]
|
||||||
fn $method(self,rhs:i64)->Self::Output{
|
fn $method(self,rhs:i64)->Self::Output{
|
||||||
self.map(|t|t.$method(rhs))
|
self.map(|t|t.$method(rhs))
|
||||||
}
|
}
|
||||||
@ -168,12 +172,14 @@ macro_rules! impl_vector_operator {
|
|||||||
macro_rules! impl_vector_assign_operator {
|
macro_rules! impl_vector_assign_operator {
|
||||||
($trait: ident, $method: ident ) => {
|
($trait: ident, $method: ident ) => {
|
||||||
impl<const N:usize,T:core::ops::$trait<U>,U> core::ops::$trait<Vector<N,U>> for Vector<N,T>{
|
impl<const N:usize,T:core::ops::$trait<U>,U> core::ops::$trait<Vector<N,U>> for Vector<N,T>{
|
||||||
|
#[inline]
|
||||||
fn $method(&mut self,rhs:Vector<N,U>){
|
fn $method(&mut self,rhs:Vector<N,U>){
|
||||||
self.array.iter_mut().zip(rhs.array)
|
self.array.iter_mut().zip(rhs.array)
|
||||||
.for_each(|(a,b)|a.$method(b))
|
.for_each(|(a,b)|a.$method(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<const N:usize,T:core::ops::$trait<i64>> core::ops::$trait<i64> for Vector<N,T>{
|
impl<const N:usize,T:core::ops::$trait<i64>> core::ops::$trait<i64> for Vector<N,T>{
|
||||||
|
#[inline]
|
||||||
fn $method(&mut self,rhs:i64){
|
fn $method(&mut self,rhs:i64){
|
||||||
self.array.iter_mut()
|
self.array.iter_mut()
|
||||||
.for_each(|t|t.$method(rhs))
|
.for_each(|t|t.$method(rhs))
|
||||||
@ -204,11 +210,13 @@ macro_rules! impl_vector_named_fields {
|
|||||||
( $struct:ident, $size: expr ) => {
|
( $struct:ident, $size: expr ) => {
|
||||||
impl<T> core::ops::Deref for Vector<$size,T>{
|
impl<T> core::ops::Deref for Vector<$size,T>{
|
||||||
type Target=$struct<T>;
|
type Target=$struct<T>;
|
||||||
|
#[inline]
|
||||||
fn deref(&self)->&Self::Target{
|
fn deref(&self)->&Self::Target{
|
||||||
unsafe{core::mem::transmute(&self.array)}
|
unsafe{core::mem::transmute(&self.array)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T> core::ops::DerefMut for Vector<$size,T>{
|
impl<T> core::ops::DerefMut for Vector<$size,T>{
|
||||||
|
#[inline]
|
||||||
fn deref_mut(&mut self)->&mut Self::Target{
|
fn deref_mut(&mut self)->&mut Self::Target{
|
||||||
unsafe{core::mem::transmute(&mut self.array)}
|
unsafe{core::mem::transmute(&mut self.array)}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user