diff -r 495448cca603 -r 6aa955ad8122 src/norms.rs --- a/src/norms.rs Thu May 01 08:40:33 2025 -0500 +++ b/src/norms.rs Thu May 01 13:06:58 2025 -0500 @@ -92,7 +92,7 @@ /// /// println!("{}, {} {}", x.norm(L1), x.norm(L2), x.norm(Linfinity)) /// ``` -pub trait Norm { +pub trait Norm { /// Calculate the norm. fn norm(&self, _p: Exponent) -> F; } @@ -110,7 +110,7 @@ } /// Trait for distances with respect to a norm. -pub trait Dist: Norm + Space { +pub trait Dist: Norm + Space { /// Calculate the distance fn dist>(&self, other: I, _p: Exponent) -> F; } @@ -125,7 +125,7 @@ /// /// println!("{:?}, {:?}", x.proj_ball(1.0, L2), x.proj_ball(0.5, Linfinity)); /// ``` -pub trait Projection: Norm + Sized +pub trait Projection: Norm + Sized where F: Float, { @@ -139,14 +139,14 @@ fn proj_ball_mut(&mut self, ρ: F, q: Exponent); } -/*impl> Norm for E { +/*impl> Norm for E { #[inline] fn norm(&self, _p : L2) -> F { self.norm2() } fn dist(&self, other : &Self, _p : L2) -> F { self.dist2(other) } }*/ -impl + Norm> Projection for E { +impl + Norm> Projection for E { #[inline] fn proj_ball(self, ρ: F, _p: L2) -> Self { self.proj_ball2(ρ) @@ -176,7 +176,7 @@ } } -impl + Normed> Norm> for E { +impl + Normed> Norm, F> for E { fn norm(&self, huber: HuberL1) -> F { huber.apply(self.norm2_squared()) } @@ -188,7 +188,7 @@ } } -// impl> Norm for Vec { +// impl> Norm for Vec { // fn norm(&self, _l21 : L21) -> F { // self.iter().map(|e| e.norm(L2)).sum() // } @@ -204,7 +204,7 @@ where F: Float, E: NormExponent, - Domain: Space + Norm, + Domain: Space + Norm, { type Codomain = F; @@ -214,7 +214,7 @@ } } -pub trait Normed: Space + Norm { +pub trait Normed: Space + Norm { type NormExp: NormExponent; fn norm_exponent(&self) -> Self::NormExp; @@ -283,7 +283,7 @@ impl Norm> for D where F: Float, - D: Norm, + D: Norm<$exponent, F>, C: Constant, { fn norm(&self, e: Weighted<$exponent, C>) -> F {