Trait acap::distance::Metric[][src]

pub trait Metric<T: ?Sized = Self>: Proximity<T> { }
Expand description

Marker trait for metric spaces.

A metric must be symmetric and obey the triangle inequality. More precisely, let $x$, $y$, and $z$ be any elements of a metric space, and let $d(x, y) = x.\mathrm{distance}(y).\mathrm{value}()$. Then the following rules must hold:

\begin{aligned}
d(x, x) &= 0 \\
d(x, y) &= d(y, x) & \text{(symmetry)} \\
d(x, z) &\le d(x, y) + d(y, z) & \text{(triangle inequality)}
\end{aligned}

Those conditions also imply the following condition:

\begin{aligned}
d(x, y) &\ge \rlap{0}\phantom{d(x, y) + d(y, z)} & \text{\phantom{(triangle inequality)}\llap{(non-negativity)}}
\end{aligned}

Because we do not prohibit $d(x, y) = 0$ for distinct $x$ and $y$, these spaces are more properly known as pseudometric spaces. This distinction is usually unimportant.

Implementations on Foreign Types

Blanket Metric implementation for references.

Implementors

Angular distance is a metric.

Angular distance is a metric.

Angular distance is a metric.

Angular distance is a metric.

Euclidean distance is a metric.

Angular distance is a metric.

Angular distance is a metric.

Chebyshev distance is a metric.

Taxicab distance is a metric.

Hamming distance is a metric.