Skip to main content

Minkowski

Struct Minkowski 

Source
pub struct Minkowski<const P: u32, R>(/* private fields */);
Expand description

Generalized integer-power Minkowski distance metric.

This implementation returns the sum of powered absolute differences, sum(|dx|^P), rather than taking the final 1/P root. That preserves nearest-neighbour ordering while avoiding an unnecessary root in query hot paths, just like [crate::SquaredEuclidean] does for P = 2.

Trait Implementations§

Source§

impl<A, R, const P: u32> DistanceMetricScalar<A> for Minkowski<P, R>
where A: Copy, R: Axis<Coord = R> + WideningCastFrom<A> + Float,

Source§

type Output = R

Accumulator / distance scalar type.
Source§

fn widen_coord(a: A) -> R

Widen a coordinate to the output type.
Source§

fn dist1(a: R, b: R) -> R

Single-axis contribution in widened coordinates.
Source§

fn widen_axis(axis: &[A], out: &mut [Self::Output])

Bulk widen hook. Read more
Source§

fn combine_component(acc: &mut Self::Output, component: Self::Output)

Combine a per-axis contribution into an accumulated point or box distance. Read more
Source§

fn dist1_raw(a: A, b: A) -> Self::Output

Single-axis contribution on raw coordinates.
Source§

fn dist<const K: usize>( a: &[Self::Output; K], b: &[Self::Output; K], ) -> Self::Output

Full point distance in widened coordinates.
Source§

fn dist_raw<const K: usize>(a: &[A; K], b: &[A; K]) -> Self::Output

Full point distance on raw coordinates.
Source§

fn rect_dist_from_off<const K: usize>(off: &[Self::Output; K]) -> Self::Output

Bounding-box distance derived from per-axis offsets to the query.
Source§

fn rect_dist_after_update<const K: usize>( rd: Self::Output, off: &[Self::Output; K], dim: usize, new_off: Self::Output, ) -> Self::Output

Bounding-box distance after replacing a single axis offset. Read more
Source§

fn rect_dist_after_axis_update( rd: Self::Output, old_off: Self::Output, new_off: Self::Output, ) -> Self::Output

Bounding-box distance after replacing a single axis offset, for callers that only have that axis’s previous offset rather than the whole off array. Read more
Source§

fn cmp(a: Self::Output, b: Self::Output) -> Ordering

Distance comparison helper.

Auto Trait Implementations§

§

impl<const P: u32, R> Freeze for Minkowski<P, R>
where PhantomData<R>: Freeze,

§

impl<const P: u32, R> RefUnwindSafe for Minkowski<P, R>

§

impl<const P: u32, R> Send for Minkowski<P, R>
where PhantomData<R>: Send,

§

impl<const P: u32, R> Sync for Minkowski<P, R>
where PhantomData<R>: Sync,

§

impl<const P: u32, R> Unpin for Minkowski<P, R>
where PhantomData<R>: Unpin,

§

impl<const P: u32, R> UnsafeUnpin for Minkowski<P, R>

§

impl<const P: u32, R> UnwindSafe for Minkowski<P, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T, A> DistanceMetric<A> for T

Source§

fn backtrack_block3<const K: usize>( query_wide: Self::Output, stems_ptr: NonNull<u8>, block_base_idx: usize, old_off: Self::Output, rd: Self::Output, best_dist: Self::Output, ) -> u8
where A: Axis<Coord = A>, Self: Sized, Self::Output: Axis<Coord = Self::Output> + Add<Output = Self::Output> + Sub<Output = Self::Output>,

Autovec/scalar Block3 backtrack mask generation.
Source§

fn backtrack_block3_with_bounds<const K: usize>( query_wide: Self::Output, stems_ptr: NonNull<u8>, block_base_idx: usize, parent_lower_bound: Self::Output, parent_upper_bound: Self::Output, old_off: Self::Output, rd: Self::Output, best_dist: Self::Output, ) -> u8
where A: Axis<Coord = A>, Self: Sized, Self::Output: Axis<Coord = Self::Output>,

Block3 bounds-aware backtrack mask generation.
Source§

fn fill_block3_values_and_bounds<const K: usize>( query_wide: Self::Output, stems_ptr: NonNull<u8>, block_base_idx: usize, parent_lower_bound: Self::Output, parent_upper_bound: Self::Output, old_off: Self::Output, rd: Self::Output, best_dist: Self::Output, new_off_values: &mut [Self::Output; 8], rd_values: &mut [Self::Output; 8], lower_bounds: &mut [Self::Output; 8], upper_bounds: &mut [Self::Output; 8], ) -> u8
where A: Axis<Coord = A>, Self: Sized, Self::Output: Axis<Coord = Self::Output>,

Block3 bounds-aware backtrack state fill.
Source§

fn backtrack_block4<const K: usize>( query_wide: Self::Output, stems_ptr: NonNull<u8>, block_base_idx: usize, old_off: Self::Output, rd: Self::Output, best_dist: Self::Output, ) -> u16
where A: Axis<Coord = A>, Self: Sized, Self::Output: Axis<Coord = Self::Output> + Add<Output = Self::Output> + Sub<Output = Self::Output>,

Autovec/scalar Block4 backtrack mask generation.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, A> QueryMetric<A> for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.