pub trait ScalarField:
Mul<Self, Output = Self>
+ Div<Self, Output = Self>
+ Add<Self, Output = Self>
+ Sub<Self, Output = Self>
+ Neg<Output = Self>
+ Default
+ Debug
+ Clone
+ Copy {
const ZERO: Self;
const ONE: Self;
// Provided method
fn recip(self) -> Self { ... }
}Expand description
A type that supports the operations of a scalar field. An implementation should support:
- Addition and subtraction
- Multiplication and division
- Negation
- Zero (additive identity)
- One (multiplicative identity)
Within the limitations of floating point arithmetic, all the following are required to hold:
- (Associativity of addition) For all
u, v, w: Self,(u + v) + w == u + (v + w). - (Commutativity of addition) For all
u, v: Self,u + v == v + u. - (Additive identity) For all
v: Self,v + Self::ZERO == v. - (Additive inverse) For all
v: Self,v - v == v + (-v) == Self::ZERO. - (Associativity of multiplication) For all
u, v, w: Self,(u * v) * w == u * (v * w). - (Commutativity of multiplication) For all
u, v: Self,u * v == v * u. - (Multiplicative identity) For all
v: Self,v * Self::ONE == v. - (Multiplicative inverse) For all
v: Self,v / v == v * v.inverse() == Self::ONE. - (Distributivity over addition) For all
a, b: Self,u, v: Self,(u + v) * a == u * a + v * a.
Required Associated Constants§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".