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