Trait efd::Distance

source ·
pub trait Distance: Sized {
    // Required method
    fn err_buf(&self, rhs: &Self) -> Vec<f64>;

    // Provided methods
    fn square_err(&self, rhs: &Self) -> f64 { ... }
    fn l0_norm(&self, rhs: &Self) -> f64 { ... }
    fn l1_norm(&self, rhs: &Self) -> f64 { ... }
    fn l2_norm(&self, rhs: &Self) -> f64 { ... }
    fn lp_norm(&self, rhs: &Self, p: i32) -> f64 { ... }
}
Expand description

Be able to calculate the distance between two instances.

Each data number has the same weight by default, but you can change it by implementing Self::err_buf().

Required Methods§

source

fn err_buf(&self, rhs: &Self) -> Vec<f64>

Calculate the error between each pair of datas.

Provided Methods§

source

fn square_err(&self, rhs: &Self) -> f64

Calculate the square error.

source

fn l0_norm(&self, rhs: &Self) -> f64

Calculate the L0 norm of the error.

source

fn l1_norm(&self, rhs: &Self) -> f64

Calculate the L1 norm of the error.

source

fn l2_norm(&self, rhs: &Self) -> f64

Calculate the L2 norm of the error.

source

fn lp_norm(&self, rhs: &Self, p: i32) -> f64

Calculate the Lp norm of the error.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<const N: usize> Distance for [f64; N]

source§

fn err_buf(&self, rhs: &Self) -> Vec<f64>

Implementors§

source§

impl<D: EfdDim> Distance for Efd<D>