[][src]Trait maths_traits::analysis::metric::Metric

pub trait Metric<X, R: Real> {
    fn distance(&self, x1: X, x2: X) -> R;
}

A real-valued function on a set X that quantifies the "distance" between objects

This is rigorously defined as a function d:X⨯X -> R such that

  • d(x,y) > 0 for all x != y
  • d(x,x) = 0 for all x
  • d(x,z) <= d(x,y) + d(y,z) for all x,y, and z

Implementation Note

Due to the fact that there are often many metrics for any given space and that a given kind of metric often applies to a whole family of spaces, this trait has been written with the intent of being implemented on type other than the set X to which it applies. This way, a construction can implemented only once while still having access to all applicable metrics.

A good example of this would a struct implementing all Lp norms for a single implementation of a given ℝ3 or similar

Required methods

fn distance(&self, x1: X, x2: X) -> R

Loading content...

Implementors

impl<R: Real, V: InnerProductSpace<R>> Metric<V, R> for InnerProductMetric[src]

Loading content...