pub struct VecVector {
pub dimensions: usize,
pub precision: VectorPrecision,
pub values: VectorData,
pub metadata: Option<HashMap<String, String>>,
}Expand description
Multi-precision vector with enhanced functionality
Fields§
§dimensions: usize§precision: VectorPrecision§values: VectorData§metadata: Option<HashMap<String, String>>Implementations§
Source§impl Vector
impl Vector
Sourcepub fn pearson_correlation(&self, other: &Vector) -> Result<f32, Error>
pub fn pearson_correlation(&self, other: &Vector) -> Result<f32, Error>
Calculate Pearson correlation coefficient
Sourcepub fn spearman_correlation(&self, other: &Vector) -> Result<f32, Error>
pub fn spearman_correlation(&self, other: &Vector) -> Result<f32, Error>
Calculate Spearman rank correlation
Sourcepub fn jaccard_similarity(&self, other: &Vector) -> Result<f32, Error>
pub fn jaccard_similarity(&self, other: &Vector) -> Result<f32, Error>
Calculate Jaccard similarity for binary vectors
Sourcepub fn hamming_distance(&self, other: &Vector) -> Result<u32, Error>
pub fn hamming_distance(&self, other: &Vector) -> Result<u32, Error>
Calculate Hamming distance for binary vectors
Sourcepub fn jensen_shannon_divergence(&self, other: &Vector) -> Result<f32, Error>
pub fn jensen_shannon_divergence(&self, other: &Vector) -> Result<f32, Error>
Calculate Jensen-Shannon divergence
Sourcepub fn kl_divergence(&self, other: &Vector) -> Result<f32, Error>
pub fn kl_divergence(&self, other: &Vector) -> Result<f32, Error>
Calculate Kullback-Leibler divergence
Sourcepub fn hellinger_distance(&self, other: &Vector) -> Result<f32, Error>
pub fn hellinger_distance(&self, other: &Vector) -> Result<f32, Error>
Calculate Hellinger distance
Sourcepub fn earth_movers_distance(&self, other: &Vector) -> Result<f32, Error>
pub fn earth_movers_distance(&self, other: &Vector) -> Result<f32, Error>
Calculate Earth Mover’s Distance (1D approximation)
Source§impl Vector
impl Vector
Sourcepub fn with_precision(values: VectorData) -> Vector
pub fn with_precision(values: VectorData) -> Vector
Create a new vector with specific precision
Sourcepub fn with_metadata(
values: Vec<f32>,
metadata: HashMap<String, String>,
) -> Vector
pub fn with_metadata( values: Vec<f32>, metadata: HashMap<String, String>, ) -> Vector
Create a new vector with metadata
Sourcepub fn quantize_to_i8(values: &[f32]) -> Vec<i8>
pub fn quantize_to_i8(values: &[f32]) -> Vec<i8>
Quantize f32 vector to i8
Sourcepub fn to_binary(values: &[f32], threshold: f32) -> Vec<u8> ⓘ
pub fn to_binary(values: &[f32], threshold: f32) -> Vec<u8> ⓘ
Convert to binary representation using threshold
Sourcepub fn cosine_similarity(&self, other: &Vector) -> Result<f32, Error>
pub fn cosine_similarity(&self, other: &Vector) -> Result<f32, Error>
Calculate cosine similarity with another vector
Sourcepub fn euclidean_distance(&self, other: &Vector) -> Result<f32, Error>
pub fn euclidean_distance(&self, other: &Vector) -> Result<f32, Error>
Calculate Euclidean distance to another vector
Sourcepub fn manhattan_distance(&self, other: &Vector) -> Result<f32, Error>
pub fn manhattan_distance(&self, other: &Vector) -> Result<f32, Error>
Calculate Manhattan distance (L1 norm) to another vector
Sourcepub fn minkowski_distance(&self, other: &Vector, p: f32) -> Result<f32, Error>
pub fn minkowski_distance(&self, other: &Vector, p: f32) -> Result<f32, Error>
Calculate Minkowski distance (general Lp norm) to another vector
Sourcepub fn chebyshev_distance(&self, other: &Vector) -> Result<f32, Error>
pub fn chebyshev_distance(&self, other: &Vector) -> Result<f32, Error>
Calculate Chebyshev distance (L∞ norm) to another vector
Sourcepub fn normalized(&self) -> Vector
pub fn normalized(&self) -> Vector
Get a normalized copy of this vector
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Vector
impl<'de> Deserialize<'de> for Vector
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vector, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Vector, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Vector
impl Serialize for Vector
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.