Function norm_l2

Source
pub fn norm_l2(a: &[f32]) -> f32
Expand description

Computes the L2 norm (Euclidean norm) of a vector a.

§Arguments

  • a - The vector.

§Returns

The L2 norm of a.

§Examples

let a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0];
let norm = intspan::norm_l2(&a);
assert_eq!(format!("{:.4}", norm), "19.6214".to_string());