[][src]Function lsh_rs::dist::l2_norm

pub fn l2_norm(x: &[f32]) -> f32

L2 norm of a single vector.

Examples

use lsh_rs::dist::l2_norm;
let a = vec![1., -1.];
let norm_a = l2_norm(&a);

// norm between two vectors
let b = vec![0.2, 1.2];
let c: Vec<f32> = a.iter().zip(b).map(|(ai, bi)| ai - bi).collect();
let norm_ab = l2_norm(&c);