pub enum Commutativity {
Commutative,
Noncommutative,
}Expand description
Commutativity of an expression or operation
Variants§
Commutative
Operation is commutative (ab = ba) Examples: scalar multiplication, addition
Noncommutative
Operation is noncommutative (ab may not equal ba) Examples: matrix multiplication, operator multiplication, quaternion multiplication
Implementations§
Source§impl Commutativity
impl Commutativity
Sourcepub fn can_sort(self) -> bool
pub fn can_sort(self) -> bool
Can factors be sorted during canonicalization?
Returns true only if commutativity is guaranteed.
Sourcepub fn combine<I>(factors: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn combine<I>(factors: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Combine commutativity of multiple factors
Rule: If ANY factor is noncommutative, the entire product is noncommutative. Only if ALL factors are commutative is the product commutative.
§Examples
use mathhook_core::core::commutativity::Commutativity;
// All commutative → result commutative
let factors = vec![Commutativity::Commutative, Commutativity::Commutative];
assert_eq!(Commutativity::combine(factors), Commutativity::Commutative);
// Any noncommutative → result noncommutative
let factors = vec![Commutativity::Commutative, Commutativity::Noncommutative];
assert_eq!(Commutativity::combine(factors), Commutativity::Noncommutative);Trait Implementations§
Source§impl Clone for Commutativity
impl Clone for Commutativity
Source§fn clone(&self) -> Commutativity
fn clone(&self) -> Commutativity
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Commutativity
impl Debug for Commutativity
Source§impl Hash for Commutativity
impl Hash for Commutativity
Source§impl PartialEq for Commutativity
impl PartialEq for Commutativity
impl Copy for Commutativity
impl Eq for Commutativity
impl StructuralPartialEq for Commutativity
Auto Trait Implementations§
impl Freeze for Commutativity
impl RefUnwindSafe for Commutativity
impl Send for Commutativity
impl Sync for Commutativity
impl Unpin for Commutativity
impl UnwindSafe for Commutativity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more