optimization_solvers/
number.rs1use super::*;
2
3pub type Floating = f64;
4
5pub trait BoxProjection {
6 fn box_projection(
7 &self,
8 lower_bound: &DVector<Floating>,
9 upper_bound: &DVector<Floating>,
10 ) -> Self;
11}
12
13impl BoxProjection for DVector<Floating> {
14 fn box_projection(
15 &self,
16 lower_bound: &DVector<Floating>,
17 upper_bound: &DVector<Floating>,
18 ) -> DVector<Floating> {
19 self.sup(lower_bound).inf(upper_bound)
20 }
21}
22
23pub trait InfinityNorm {
24 fn infinity_norm(&self) -> Floating;
25}
26
27impl InfinityNorm for DVector<Floating> {
28 fn infinity_norm(&self) -> Floating {
29 self.iter().fold(0.0f64, |acc, x| acc.max(x.abs()))
30 }
31}