pub struct MaxSim<'a> { /* private fields */ }Expand description
Computes per-query-vector maximum similarities to document vectors.
For each query vector qᵢ, finds the maximum similarity (minimum negated
inner product) to any document vector:
scores[i] = minⱼ -IP(qᵢ, dⱼ)Implements DistanceFnMut for various matrix types
(e.g., MatRef<Standard<f32>>).
§Usage
- Create with
MaxSim::new, providing a mutable scores buffer. - Call
DistanceFnMut::evaluatewith query and document matrices. - Read results from the scores buffer.
Implementations§
Source§impl<'a> MaxSim<'a>
impl<'a> MaxSim<'a>
Sourcepub fn new(scores: &'a mut [f32]) -> Result<Self, MaxSimError>
pub fn new(scores: &'a mut [f32]) -> Result<Self, MaxSimError>
Sourcepub fn scores_mut(&mut self) -> &mut [f32]
pub fn scores_mut(&mut self) -> &mut [f32]
Returns a mutable reference to the internal buffer of scores.
This is useful for implementations external to crate as well as optimized implementations to access the buffer if needed.
Trait Implementations§
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.
Auto Trait Implementations§
impl<'a> Freeze for MaxSim<'a>
impl<'a> RefUnwindSafe for MaxSim<'a>
impl<'a> Send for MaxSim<'a>
impl<'a> Sync for MaxSim<'a>
impl<'a> Unpin for MaxSim<'a>
impl<'a> !UnwindSafe for MaxSim<'a>
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> 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