# HG changeset patch # User Tuomo Valkonen # Date 1756911150 18000 # Node ID b4a47e8e80d13329c46d45c8649c5f80377d5a42 # Parent bea0c3841cedd0aa34e7a2fb5c8e2d624fbbfa71 convexity etc. fubar diff -r bea0c3841ced -r b4a47e8e80d1 src/convex.rs --- a/src/convex.rs Wed Sep 03 09:16:03 2025 -0500 +++ b/src/convex.rs Wed Sep 03 09:52:30 2025 -0500 @@ -17,7 +17,7 @@ /// /// TODO: should constrain `Mapping::Codomain` to implement a partial order, /// but this makes everything complicated with little benefit. -pub trait ConvexMapping, F: Num = f64>: Mapping { +pub trait ConvexMapping: Mapping { /// Returns (a lower estimate of) the factor of strong convexity in the norm of `Domain`. fn factor_of_strong_convexity(&self) -> F { F::ZERO @@ -42,7 +42,7 @@ /// but a `Preconjugable` mapping has to be convex. pub trait Preconjugable: ConvexMapping where - Domain: Normed, + Domain: Space, Predual: HasDual, { type Preconjugate<'a>: Mapping @@ -88,7 +88,7 @@ impl ConvexMapping for NormMapping where - Domain: Normed, + Domain: Space, E: NormExponent, F: Float, Self: Mapping, @@ -97,7 +97,8 @@ impl Mapping for NormConstraint where - Domain: Space + Norm, + Domain: Space, + Domain::OwnedSpace: Norm, F: Float, E: NormExponent, { @@ -114,7 +115,7 @@ impl ConvexMapping for NormConstraint where - Domain: Normed, + Domain: Space, E: NormExponent, F: Float, Self: Mapping, @@ -125,7 +126,8 @@ where E: HasDualExponent, F: Float, - Domain: HasDual + Norm + Normed, + Domain: HasDual, + Domain::OwnedSpace: Norm, >::DualSpace: Norm, { type Conjugate<'a> @@ -143,7 +145,8 @@ C: Constant, E: HasDualExponent, F: Float, - Domain: HasDual + Norm + Space, + Domain: HasDual, + Domain::OwnedSpace: Norm, >::DualSpace: Norm, { type Conjugate<'a> @@ -161,7 +164,8 @@ impl Prox for NormConstraint where - Domain: Space + Norm, + Domain: Space, + Domain::OwnedSpace: Norm, E: NormExponent, F: Float, NormProjection: Mapping, @@ -201,8 +205,8 @@ impl Mapping for NormProjection where - Domain: Normed + Projection, - Domain::OwnedSpace: ClosedSpace, + Domain: Space, + Domain::OwnedSpace: ClosedSpace + Projection, F: Float, E: NormExponent, { @@ -232,7 +236,7 @@ } } -impl, F: Float> ConvexMapping for Zero {} +impl ConvexMapping for Zero {} impl, F: Float> Conjugable for Zero { type Conjugate<'a> @@ -249,7 +253,7 @@ impl Preconjugable for Zero where Domain: Normed, - Predual: HasDual, + Predual: HasDual, { type Preconjugate<'a> = ZeroIndicator @@ -284,7 +288,12 @@ } } -impl, F: Float> Mapping for ZeroIndicator { +impl Mapping for ZeroIndicator +where + F: Float, + Domain: Space, + Domain::OwnedSpace: Normed, +{ type Codomain = F; /// Compute the value of `self` at `x`. @@ -293,13 +302,21 @@ } } -impl, F: Float> ConvexMapping for ZeroIndicator { +impl ConvexMapping for ZeroIndicator +where + Domain: Space, + Domain::OwnedSpace: Normed, +{ fn factor_of_strong_convexity(&self) -> F { F::INFINITY } } -impl, F: Float> Conjugable for ZeroIndicator { +impl Conjugable for ZeroIndicator +where + Domain: HasDual, + Domain::Owned: Normed, +{ type Conjugate<'a> = Zero where @@ -313,7 +330,8 @@ impl Preconjugable for ZeroIndicator where - Domain: Normed, + Domain: Space, + Domain::OwnedSpace: Normed, Predual: HasDual, { type Preconjugate<'a> diff -r bea0c3841ced -r b4a47e8e80d1 src/instance.rs --- a/src/instance.rs Wed Sep 03 09:16:03 2025 -0500 +++ b/src/instance.rs Wed Sep 03 09:52:30 2025 -0500 @@ -193,7 +193,7 @@ #[derive(Copy, Clone, Debug)] pub struct BasicDecomposition; -impl Decomposition for BasicDecomposition { +impl Decomposition for BasicDecomposition { type Decomposition<'b> = MyCow<'b, X> where @@ -282,7 +282,7 @@ } } -impl Instance for X { +impl Instance for X { #[inline] fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R where @@ -302,7 +302,7 @@ } } -impl<'a, X: Space + Clone> Instance for &'a X { +impl<'a, X: Space> Instance for &'a X { #[inline] fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R where @@ -322,7 +322,7 @@ } } -impl<'a, X: Space + Clone> Instance for &'a mut X { +impl<'a, X: Space> Instance for &'a mut X { #[inline] fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R where @@ -342,7 +342,7 @@ } } -impl<'a, X: Space + Clone> Instance for MyCow<'a, X> { +impl<'a, X: Space> Instance for MyCow<'a, X> { #[inline] fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R where diff -r bea0c3841ced -r b4a47e8e80d1 src/linops.rs --- a/src/linops.rs Wed Sep 03 09:16:03 2025 -0500 +++ b/src/linops.rs Wed Sep 03 09:52:30 2025 -0500 @@ -919,10 +919,11 @@ impl Mapping for Scaled where F: Float, - Domain: Space + Mul, - >::Output: ClosedSpace, + Domain: Space, + Domain::OwnedSpace: Mul, + >::Output: ClosedSpace, { - type Codomain = >::Output; + type Codomain = >::Output; /// Compute the value of `self` at `x`. fn apply>(&self, x: I) -> Self::Codomain { @@ -933,7 +934,8 @@ impl Linear for Scaled where F: Float, - Domain: Space + Mul, - >::Output: ClosedSpace, + Domain: Space, + Domain::OwnedSpace: Mul, + >::Output: ClosedSpace, { } diff -r bea0c3841ced -r b4a47e8e80d1 src/norms.rs --- a/src/norms.rs Wed Sep 03 09:16:03 2025 -0500 +++ b/src/norms.rs Wed Sep 03 09:52:30 2025 -0500 @@ -201,7 +201,8 @@ where F: Float, E: NormExponent, - Domain: Space + Norm, + Domain: Space, + Domain::OwnedSpace: Norm, { type Codomain = F; diff -r bea0c3841ced -r b4a47e8e80d1 src/sets.rs --- a/src/sets.rs Wed Sep 03 09:16:03 2025 -0500 +++ b/src/sets.rs Wed Sep 03 09:52:30 2025 -0500 @@ -50,9 +50,9 @@ ($($range:ident),*) => { $( impl Set for $range where - Idx : PartialOrd, - U : PartialOrd + Space + Clone, - Idx : PartialOrd + U : Space, + U::OwnedSpace : PartialOrd, + Idx : PartialOrd + PartialOrd, { #[inline] fn contains>(&self, item : I) -> bool {