Trait efd::Distance

source ·
pub trait Distance {
    // 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 Distance::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.

Implementors§

source§

impl<S: AsRef<[f64]>> Distance for S

source§

impl<const D: usize> Distance for Efd<D>
where U<D>: EfdDim<D>,

source§

impl<const D: usize> Distance for PosedEfd<D>
where U<D>: EfdDim<D>,