Compare

Trait Compare 

Source
pub trait Compare<N>
where N: Num + Copy,
{ // Required methods fn dot(vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>) -> f64; fn cosine_similarity( vec: impl Iterator<Item = (usize, N)>, other: impl Iterator<Item = (usize, N)>, ) -> f64; fn euclidean_distance( vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>, ) -> f64; fn manhattan_distance( vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>, ) -> f64; fn chebyshev_distance( vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>, ) -> f64; }

Required Methods§

Source

fn dot(vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>) -> f64

dot積 d(a, b) = Σ(a_i * b_i)

Source

fn cosine_similarity( vec: impl Iterator<Item = (usize, N)>, other: impl Iterator<Item = (usize, N)>, ) -> f64

コサイン類似度 cos(θ) = Σ(a_i * b_i) / (||a|| * ||b||) ||a|| = sqrt(Σ(a_i^2))

Source

fn euclidean_distance( vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>, ) -> f64

ユークリッド距離 d(a, b) = sqrt(Σ((a_i - b_i)^2))

Source

fn manhattan_distance( vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>, ) -> f64

マンハッタン距離 d(a, b) = Σ(|a_i - b_i|)

Source

fn chebyshev_distance( vec: impl Iterator<Item = N>, other: impl Iterator<Item = N>, ) -> f64

チェビシェフ距離 d(a, b) = max(|a_i - b_i|)

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.

Implementors§