pub trait Cosine: Dot + Normalize {
// Provided methods
fn cosine(x: &[Self], other: &[Self]) -> f32 { ... }
fn cosine_fast(x: &[Self], x_norm: f32, y: &[Self]) -> f32 { ... }
fn cosine_with_norms(
x: &[Self],
x_norm: f32,
y_norm: f32,
y: &[Self],
) -> f32 { ... }
fn cosine_batch<'a>(
x: &'a [Self],
batch: &'a [Self],
dimension: usize,
) -> Box<dyn Iterator<Item = f32> + 'a> { ... }
}
Expand description
Cosine Distance
Provided Methods§
Sourcefn cosine_fast(x: &[Self], x_norm: f32, y: &[Self]) -> f32
fn cosine_fast(x: &[Self], x_norm: f32, y: &[Self]) -> f32
Fast cosine function, that assumes that the norm of the first vector is already known.
Sourcefn cosine_with_norms(x: &[Self], x_norm: f32, y_norm: f32, y: &[Self]) -> f32
fn cosine_with_norms(x: &[Self], x_norm: f32, y_norm: f32, y: &[Self]) -> f32
Cosine between two vectors, with the L2 norms of both vectors already known.
fn cosine_batch<'a>( x: &'a [Self], batch: &'a [Self], dimension: usize, ) -> Box<dyn Iterator<Item = f32> + 'a>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.