Trait L2

Source
pub trait L2: Num {
    // Required method
    fn l2(x: &[Self], y: &[Self]) -> f32;

    // Provided method
    fn l2_batch<'a>(
        x: &'a [Self],
        y: &'a [Self],
        dimension: usize,
    ) -> Box<dyn Iterator<Item = f32> + 'a> { ... }
}
Expand description

Calculate the L2 distance between two vectors.

Required Methods§

Source

fn l2(x: &[Self], y: &[Self]) -> f32

Calculate the L2 distance between two vectors.

Provided Methods§

Source

fn l2_batch<'a>( x: &'a [Self], y: &'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.

Implementations on Foreign Types§

Source§

impl L2 for f32

Source§

fn l2(x: &[Self], y: &[Self]) -> f32

Source§

fn l2_batch<'a>( x: &'a [Self], y: &'a [Self], dimension: usize, ) -> Box<dyn Iterator<Item = f32> + 'a>

Source§

impl L2 for f64

Source§

fn l2(x: &[Self], y: &[Self]) -> f32

Source§

impl L2 for u8

Source§

fn l2(x: &[Self], y: &[Self]) -> f32

Source§

impl L2 for bf16

Source§

fn l2(x: &[Self], y: &[Self]) -> f32

Source§

impl L2 for f16

Source§

fn l2(x: &[Self], y: &[Self]) -> f32

Implementors§