use na::{Real, DefaultAllocator}; use traits::{Alloc, Dimension}; use aliases::Vec; /// The squared distance between two points. pub fn distance2(p0: &Vec, p1: &Vec) -> N where DefaultAllocator: Alloc { (p1 - p0).norm_squared() } /// The l1-norm of `x - y`. pub fn l1_distance(x: &Vec, y: &Vec) -> N where DefaultAllocator: Alloc { l1_norm(&(x - y)) } /// The l1-norm of `v`. pub fn l1_norm(v: &Vec) -> N where DefaultAllocator: Alloc { ::comp_add(&v.abs()) } /// The l2-norm of `x - y`. pub fn l2_distance(x: &Vec, y: &Vec) -> N where DefaultAllocator: Alloc { l2_norm(&(y - x)) } /// The l2-norm of `v`. pub fn l2_norm(x: &Vec) -> N where DefaultAllocator: Alloc { x.norm() } /// The squared magnitude of `x`. pub fn length2(x: &Vec) -> N where DefaultAllocator: Alloc { x.norm_squared() } /// The squared magnitude of `x`. pub fn magnitude2(x: &Vec) -> N where DefaultAllocator: Alloc { x.norm_squared() } //pub fn lxNorm(x: &Vec, y: &Vec, unsigned int Depth) -> N // where DefaultAllocator: Alloc { // unimplemented!() //} // //pub fn lxNorm(x: &Vec, unsigned int Depth) -> N // where DefaultAllocator: Alloc { // unimplemented!() //}