pub fn vector_norm(v: &Vector, kind: NormVec) -> f64
Expand description

Returns the vector norm

Computes one of:

One:  1-norm (taxicab or sum of abs values)

      ‖u‖_1 := sum_i |uᵢ|
Euc:  Euclidean-norm

      ‖u‖_2 = sqrt(Σ_i uᵢ⋅uᵢ)
Max:  max-norm (inf-norm)

      ‖u‖_max = max_i ( |uᵢ| ) == ‖u‖_∞

Example

use russell_lab::{vector_norm, NormVec, Vector};

fn main() {
    let u = Vector::from(&[2.0, -2.0, 2.0, -2.0, -3.0]);
    assert_eq!(vector_norm(&u, NormVec::One), 11.0);
    assert_eq!(vector_norm(&u, NormVec::Euc), 5.0);
    assert_eq!(vector_norm(&u, NormVec::Max), 3.0);
}