pub struct Vector { /* private fields */ }Expand description
A vector of floating point numbers
Implementations§
Source§impl Vector
impl Vector
pub fn new(data: Vec<f32>) -> Self
pub fn from_slice(data: &[f32]) -> Self
pub fn dim(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_slice(&self) -> &[f32]
pub fn as_mut_slice(&mut self) -> &mut [f32]
Sourcepub fn cosine_similarity(&self, other: &Vector) -> f32
pub fn cosine_similarity(&self, other: &Vector) -> f32
Compute cosine similarity with another vector Uses SIMD-optimized operations for both dot product and norms
Sourcepub fn l2_distance(&self, other: &Vector) -> f32
pub fn l2_distance(&self, other: &Vector) -> f32
Compute L2 (Euclidean) distance
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Normalize the vector to unit length Uses SIMD-optimized norm calculation
Sourcepub fn normalized(&self) -> Self
pub fn normalized(&self) -> Self
Get normalized copy
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Vector
impl<'de> Deserialize<'de> for Vector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Vector> for VectorData
impl From<Vector> for VectorData
impl StructuralPartialEq for Vector
Auto Trait Implementations§
impl Freeze for Vector
impl RefUnwindSafe for Vector
impl Send for Vector
impl Sync for Vector
impl Unpin for Vector
impl UnwindSafe for Vector
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