pub trait Linear: Affine<Diff = Self> {
type Scalar: Sized;
// Required methods
fn zero() -> Self;
fn mul(&self, scalar: Self::Scalar) -> Self;
// Provided method
fn neg(&self) -> Self { ... }
}Expand description
Trait for types representing elements of a linear space (vector space).
A Linear type is a type that is Affine and
additionally satisfies the following conditions:
- The difference type
Diffis equal toSelf - The type has an additive identity, returned by the
zeromethod - Every value has an additive inverse, returned by the
negmethod
TODO More documentation
Required Associated Types§
Required Methods§
Sourcefn mul(&self, scalar: Self::Scalar) -> Self
fn mul(&self, scalar: Self::Scalar) -> Self
Multiplies all components of self by scalar.
mul is commutative and associative, and distributes over
add and sub (up to rounding errors):
v.mul(w) == w.mul(v);
v.mul(w).mul(x) == v.mul(w.mul(x));
v.mul(a).add(&w.mul(a)) == v.add(&w).mul(a);
v.mul(a).sub(&w.mul(a)) == v.add(&w).sub(&a);Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.