lance_linalg::distance::cosine

Function cosine_distance_batch

Source
pub fn cosine_distance_batch<'a, T: Cosine>(
    from: &'a [T],
    batch: &'a [T],
    dimension: usize,
) -> Box<dyn Iterator<Item = f32> + 'a>
Expand description

Cosine Distance

https://en.wikipedia.org/wiki/Cosine_similarity

§Parameters

  • from: the vector to compute distance from.
  • to: the batch of vectors to compute distance to.
  • dimension: the dimension of the vector.

§Returns

An iterator of pair-wise cosine distance between from vector to each vector in the batch.