pub struct QueryMatRef<'a, T: Repr>(pub MatRef<'a, T>);Expand description
A query matrix view for asymmetric distance functions.
This wrapper distinguishes query matrices from document matrices
at compile time, preventing accidental argument swapping in asymmetric
distance computations like MaxSim and Chamfer.
§Example
use diskann_quantization::multi_vector::{MatRef, Standard};
use diskann_quantization::multi_vector::distance::QueryMatRef;
let data = [1.0f32, 2.0, 3.0, 4.0];
let view = MatRef::new(Standard::new(2, 2).unwrap(), &data).unwrap();
let query: QueryMatRef<_> = view.into();Tuple Fields§
§0: MatRef<'a, T>Methods from Deref<Target = MatRef<'a, T>>§
Sourcepub fn num_vectors(&self) -> usize
pub fn num_vectors(&self) -> usize
Returns the number of rows (vectors) in the matrix.
Sourcepub fn get_row(&self, i: usize) -> Option<T::Row<'_>>
pub fn get_row(&self, i: usize) -> Option<T::Row<'_>>
Returns an immutable reference to the i-th row, or None if out of bounds.
Sourcepub fn to_owned(&self) -> Mat<T>where
T: NewCloned,
pub fn to_owned(&self) -> Mat<T>where
T: NewCloned,
Return a Mat with the same contents as self.
Sourcepub fn as_raw_ptr(&self) -> *const u8
pub fn as_raw_ptr(&self) -> *const u8
Return the base pointer for the MatRef.
Trait Implementations§
Source§impl<'a, T: Clone + Repr> Clone for QueryMatRef<'a, T>
impl<'a, T: Clone + Repr> Clone for QueryMatRef<'a, T>
Source§fn clone(&self) -> QueryMatRef<'a, T>
fn clone(&self) -> QueryMatRef<'a, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T: Repr> Deref for QueryMatRef<'a, T>
Deref so that we can transparently access the MatRef in distance functions.
impl<'a, T: Repr> Deref for QueryMatRef<'a, T>
Deref so that we can transparently access the MatRef in distance functions.
Source§impl<const NBITS: usize> DistanceFunctionMut<QueryMatRef<'_, MinMaxMeta<NBITS>>, MatRef<'_, MinMaxMeta<NBITS>>> for MaxSim<'_>where
Unsigned: Representation<NBITS>,
InnerProduct: for<'x, 'y> PureDistanceFunction<BitSlice<'x, NBITS, Unsigned>, BitSlice<'y, NBITS, Unsigned>, MathematicalResult<u32>>,
impl<const NBITS: usize> DistanceFunctionMut<QueryMatRef<'_, MinMaxMeta<NBITS>>, MatRef<'_, MinMaxMeta<NBITS>>> for MaxSim<'_>where
Unsigned: Representation<NBITS>,
InnerProduct: for<'x, 'y> PureDistanceFunction<BitSlice<'x, NBITS, Unsigned>, BitSlice<'y, NBITS, Unsigned>, MathematicalResult<u32>>,
Source§fn evaluate(
&mut self,
query: QueryMatRef<'_, MinMaxMeta<NBITS>>,
doc: MatRef<'_, MinMaxMeta<NBITS>>,
)
fn evaluate( &mut self, query: QueryMatRef<'_, MinMaxMeta<NBITS>>, doc: MatRef<'_, MinMaxMeta<NBITS>>, )
Compute distances between the left and right arguments.
Source§impl<T: Copy> DistanceFunctionMut<QueryMatRef<'_, Standard<T>>, MatRef<'_, Standard<T>>, Result<(), MaxSimError>> for MaxSim<'_>
impl<T: Copy> DistanceFunctionMut<QueryMatRef<'_, Standard<T>>, MatRef<'_, Standard<T>>, Result<(), MaxSimError>> for MaxSim<'_>
Source§fn evaluate(
&mut self,
query: QueryMatRef<'_, Standard<T>>,
doc: MatRef<'_, Standard<T>>,
) -> Result<(), MaxSimError>
fn evaluate( &mut self, query: QueryMatRef<'_, Standard<T>>, doc: MatRef<'_, Standard<T>>, ) -> Result<(), MaxSimError>
Compute distances between the left and right arguments.
Source§impl<const NBITS: usize> PureDistanceFunction<QueryMatRef<'_, MinMaxMeta<NBITS>>, MatRef<'_, MinMaxMeta<NBITS>>> for Chamferwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
impl<const NBITS: usize> PureDistanceFunction<QueryMatRef<'_, MinMaxMeta<NBITS>>, MatRef<'_, MinMaxMeta<NBITS>>> for Chamferwhere
Unsigned: Representation<NBITS>,
InnerProduct: for<'a, 'b> PureDistanceFunction<BitSlice<'a, NBITS, Unsigned>, BitSlice<'b, NBITS, Unsigned>, MathematicalResult<u32>>,
fn evaluate( query: QueryMatRef<'_, MinMaxMeta<NBITS>>, doc: MatRef<'_, MinMaxMeta<NBITS>>, ) -> f32
Source§impl<T: Copy> PureDistanceFunction<QueryMatRef<'_, Standard<T>>, MatRef<'_, Standard<T>>> for Chamfer
impl<T: Copy> PureDistanceFunction<QueryMatRef<'_, Standard<T>>, MatRef<'_, Standard<T>>> for Chamfer
impl<'a, T: Copy + Repr> Copy for QueryMatRef<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for QueryMatRef<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for QueryMatRef<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for QueryMatRef<'a, T>where
T: Send,
impl<'a, T> Sync for QueryMatRef<'a, T>where
T: Sync,
impl<'a, T> Unpin for QueryMatRef<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for QueryMatRef<'a, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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