pub trait NormedVectorSpace: VectorSpace {
// Required method
fn norm(self) -> Self::Scalar;
// Provided methods
fn norm_squared(self) -> Self::Scalar { ... }
fn distance(self, rhs: Self) -> Self::Scalar { ... }
fn distance_squared(self, rhs: Self) -> Self::Scalar { ... }
}Expand description
A type that supports the operations of a normed vector space; i.e. a norm operation in addition
to those of VectorSpace. Specifically, the implementor must guarantee that the following
relationships hold, within the limitations of floating point arithmetic:
- (Nonnegativity) For all
v: Self,v.norm() >= 0.0. - (Positive definiteness) For all
v: Self,v.norm() == 0.0impliesv == Self::ZERO. - (Absolute homogeneity) For all
c: Self::Scalar,v: Self,(v * c).norm() == v.norm() * c.abs(). - (Triangle inequality) For all
v, w: Self,(v + w).norm() <= v.norm() + w.norm().
Note that, because implementing types use floating point arithmetic, they are not required to actually
implement PartialEq or Eq.
Required Methods§
Provided Methods§
Sourcefn norm_squared(self) -> Self::Scalar
fn norm_squared(self) -> Self::Scalar
The squared norm of this element. Computing this is often faster than computing
NormedVectorSpace::norm.
Sourcefn distance(self, rhs: Self) -> Self::Scalar
fn distance(self, rhs: Self) -> Self::Scalar
The distance between this element and another, as determined by the norm.
Sourcefn distance_squared(self, rhs: Self) -> Self::Scalar
fn distance_squared(self, rhs: Self) -> Self::Scalar
The squared distance between this element and another, as determined by the norm. Note that
this is often faster to compute in practice than NormedVectorSpace::distance.
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.