pub struct CachedNorm { /* private fields */ }Expand description
Pre-computed L2 norm for efficient repeated cosine similarity calculations.
When comparing a query vector against many candidates, computing the query’s norm once and reusing it is more efficient than recomputing it for each comparison.
§Example
ⓘ
use manifoldb_vector::distance::CachedNorm;
let query = [1.0, 2.0, 3.0];
let cached_norm = CachedNorm::new(&query);
// Use cached norm for many comparisons
for candidate in candidates {
let candidate_norm = CachedNorm::new(&candidate);
let similarity = cached_norm.cosine_similarity_to(&query, &candidate, &candidate_norm);
}Implementations§
Source§impl CachedNorm
impl CachedNorm
Trait Implementations§
Source§impl Clone for CachedNorm
impl Clone for CachedNorm
Source§fn clone(&self) -> CachedNorm
fn clone(&self) -> CachedNorm
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 Debug for CachedNorm
impl Debug for CachedNorm
impl Copy for CachedNorm
Auto Trait Implementations§
impl Freeze for CachedNorm
impl RefUnwindSafe for CachedNorm
impl Send for CachedNorm
impl Sync for CachedNorm
impl Unpin for CachedNorm
impl UnwindSafe for CachedNorm
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