opensrdk-optimization 0.1.4

Standard mathematical optimization library for OpenSRDK toolchain.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use rayon::prelude::*;

pub trait Vector {
    fn l2_norm(&self) -> f64;
}

impl Vector for [f64] {
    fn l2_norm(&self) -> f64 {
        self.into_par_iter()
            .map(|xi| xi.powi(2))
            .sum::<f64>()
            .sqrt()
    }
}