deferred division for vector + matrix
This commit is contained in:
parent
9f77531995
commit
1a24de3cd9
1
linear_ops/Cargo.lock
generated
1
linear_ops/Cargo.lock
generated
@ -29,6 +29,7 @@ name = "linear_ops"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fixed_wide",
|
"fixed_wide",
|
||||||
|
"ratio_ops",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -6,6 +6,10 @@ edition = "2021"
|
|||||||
[features]
|
[features]
|
||||||
default=["named-fields"]
|
default=["named-fields"]
|
||||||
named-fields=[]
|
named-fields=[]
|
||||||
|
deferred-division=["dep:ratio_ops"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ratio_ops = { path = "../ratio_ops", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
fixed_wide = { version = "0.1.0", path = "../fixed_wide" }
|
fixed_wide = { version = "0.1.0", path = "../fixed_wide" }
|
||||||
|
@ -127,6 +127,22 @@ macro_rules! impl_matrix {
|
|||||||
self.transform_vector(rhs)
|
self.transform_vector(rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature="deferred-division")]
|
||||||
|
$crate::impl_matrix_deferred_division!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_matrix_deferred_division {
|
||||||
|
() => {
|
||||||
|
impl<const X:usize,const Y:usize,T,U> core::ops::Div<U> for Matrix<X,Y,T>{
|
||||||
|
type Output=ratio_ops::ratio::Ratio<Matrix<X,Y,T>,U>;
|
||||||
|
#[inline]
|
||||||
|
fn div(self,rhs:U)->Self::Output{
|
||||||
|
ratio_ops::ratio::Ratio::new(self,rhs)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,10 @@ macro_rules! impl_vector {
|
|||||||
$crate::impl_vector_assign_operator_scalar!(MulAssign, mul_assign );
|
$crate::impl_vector_assign_operator_scalar!(MulAssign, mul_assign );
|
||||||
$crate::impl_vector_operator_scalar!(Mul, mul );
|
$crate::impl_vector_operator_scalar!(Mul, mul );
|
||||||
$crate::impl_vector_assign_operator_scalar!(DivAssign, div_assign );
|
$crate::impl_vector_assign_operator_scalar!(DivAssign, div_assign );
|
||||||
|
#[cfg(not(feature="deferred-division"))]
|
||||||
$crate::impl_vector_operator_scalar!(Div, div );
|
$crate::impl_vector_operator_scalar!(Div, div );
|
||||||
|
#[cfg(feature="deferred-division")]
|
||||||
|
$crate::impl_vector_deferred_division!();
|
||||||
|
|
||||||
// Impl bitwise operators
|
// Impl bitwise operators
|
||||||
$crate::impl_vector_assign_operator!(BitAndAssign, bitand_assign );
|
$crate::impl_vector_assign_operator!(BitAndAssign, bitand_assign );
|
||||||
@ -165,6 +168,19 @@ macro_rules! impl_vector {
|
|||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[macro_export(local_inner_macros)]
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_vector_deferred_division {
|
||||||
|
() => {
|
||||||
|
impl<const N:usize,T,U> core::ops::Div<U> for Vector<N,T>{
|
||||||
|
type Output=ratio_ops::ratio::Ratio<Vector<N,T>,U>;
|
||||||
|
#[inline]
|
||||||
|
fn div(self,rhs:U)->Self::Output{
|
||||||
|
ratio_ops::ratio::Ratio::new(self,rhs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
macro_rules! impl_vector_operator_scalar {
|
macro_rules! impl_vector_operator_scalar {
|
||||||
($trait: ident, $method: ident ) => {
|
($trait: ident, $method: ident ) => {
|
||||||
impl<const N:usize,T:core::ops::$trait<U,Output=V>,U:Copy,V> core::ops::$trait<U> for Vector<N,T>{
|
impl<const N:usize,T:core::ops::$trait<U,Output=V>,U:Copy,V> core::ops::$trait<U> for Vector<N,T>{
|
||||||
|
Loading…
Reference in New Issue
Block a user