pub struct VectorOps;Expand description
Vector similarity calculations optimized for different distance metrics
Implementations§
Source§impl VectorOps
impl VectorOps
Sourcepub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32
Calculate cosine similarity between two vectors
Sourcepub fn euclidean_distance(a: &[f32], b: &[f32]) -> f32
pub fn euclidean_distance(a: &[f32], b: &[f32]) -> f32
Calculate Euclidean distance between two vectors
Sourcepub fn dot_product(a: &[f32], b: &[f32]) -> f32
pub fn dot_product(a: &[f32], b: &[f32]) -> f32
Calculate dot product between two vectors
Sourcepub fn calculate_similarity(
a: &[f32],
b: &[f32],
metric: &DistanceMetric,
) -> f32
pub fn calculate_similarity( a: &[f32], b: &[f32], metric: &DistanceMetric, ) -> f32
Calculate similarity based on the specified distance metric
Sourcepub fn normalized(vector: &[f32]) -> Vec<f32>
pub fn normalized(vector: &[f32]) -> Vec<f32>
Create a normalized copy of a vector
Sourcepub fn compatible_dimensions(a: &[f32], b: &[f32]) -> bool
pub fn compatible_dimensions(a: &[f32], b: &[f32]) -> bool
Check if two vectors have the same dimensions
Sourcepub fn is_valid_vector(vector: &[f32]) -> bool
pub fn is_valid_vector(vector: &[f32]) -> bool
Validate vector for NaN or infinite values
Auto Trait Implementations§
impl Freeze for VectorOps
impl RefUnwindSafe for VectorOps
impl Send for VectorOps
impl Sync for VectorOps
impl Unpin for VectorOps
impl UnwindSafe for VectorOps
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