pub trait Distance<F: Float>:
Clone
+ Send
+ Sync
+ Unpin {
// Required method
fn distance<D: Dimension>(
&self,
a: ArrayView<'_, F, D>,
b: ArrayView<'_, F, D>,
) -> F;
// Provided methods
fn rdistance<D: Dimension>(
&self,
a: ArrayView<'_, F, D>,
b: ArrayView<'_, F, D>,
) -> F { ... }
fn rdist_to_dist(&self, rdist: F) -> F { ... }
fn dist_to_rdist(&self, dist: F) -> F { ... }
}
Expand description
A distance function that can be used in spatial algorithms such as nearest neighbour.
Required Methods§
Provided Methods§
Sourcefn rdistance<D: Dimension>(
&self,
a: ArrayView<'_, F, D>,
b: ArrayView<'_, F, D>,
) -> F
fn rdistance<D: Dimension>( &self, a: ArrayView<'_, F, D>, b: ArrayView<'_, F, D>, ) -> F
A faster version of the distance metric that keeps the order of the distance function. That
is, dist(a, b) > dist(c, d)
implies rdist(a, b) > rdist(c, d)
. For most algorithms this
is the same as distance
. Unlike distance
, this function does not need to satisfy
the Triangle Inequality.
Sourcefn rdist_to_dist(&self, rdist: F) -> F
fn rdist_to_dist(&self, rdist: F) -> F
Converts the result of rdistance
to distance
Sourcefn dist_to_rdist(&self, dist: F) -> F
fn dist_to_rdist(&self, dist: F) -> F
Converts the result of distance
to rdistance
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.