Wed, 03 Sep 2025 09:52:30 -0500
convexity etc. fubar
| src/convex.rs | file | annotate | diff | comparison | revisions | |
| src/instance.rs | file | annotate | diff | comparison | revisions | |
| src/linops.rs | file | annotate | diff | comparison | revisions | |
| src/norms.rs | file | annotate | diff | comparison | revisions | |
| src/sets.rs | file | annotate | diff | comparison | revisions |
--- 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<Domain: Normed<F>, F: Num = f64>: Mapping<Domain, Codomain = F> { +pub trait ConvexMapping<Domain: Space, F: Num = f64>: Mapping<Domain, Codomain = F> { /// 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<Domain, Predual, F: Num = f64>: ConvexMapping<Domain, F> where - Domain: Normed<F>, + Domain: Space, Predual: HasDual<F>, { type Preconjugate<'a>: Mapping<Predual, Codomain = F> @@ -88,7 +88,7 @@ impl<Domain, E, F> ConvexMapping<Domain, F> for NormMapping<F, E> where - Domain: Normed<F>, + Domain: Space, E: NormExponent, F: Float, Self: Mapping<Domain, Codomain = F>, @@ -97,7 +97,8 @@ impl<F, E, Domain> Mapping<Domain> for NormConstraint<F, E> where - Domain: Space + Norm<E, F>, + Domain: Space, + Domain::OwnedSpace: Norm<E, F>, F: Float, E: NormExponent, { @@ -114,7 +115,7 @@ impl<Domain, E, F> ConvexMapping<Domain, F> for NormConstraint<F, E> where - Domain: Normed<F>, + Domain: Space, E: NormExponent, F: Float, Self: Mapping<Domain, Codomain = F>, @@ -125,7 +126,8 @@ where E: HasDualExponent, F: Float, - Domain: HasDual<F> + Norm<E, F> + Normed<F>, + Domain: HasDual<F>, + Domain::OwnedSpace: Norm<E, F>, <Domain as HasDual<F>>::DualSpace: Norm<E::DualExp, F>, { type Conjugate<'a> @@ -143,7 +145,8 @@ C: Constant<Type = F>, E: HasDualExponent, F: Float, - Domain: HasDual<F> + Norm<E, F> + Space, + Domain: HasDual<F>, + Domain::OwnedSpace: Norm<E, F>, <Domain as HasDual<F>>::DualSpace: Norm<E::DualExp, F>, { type Conjugate<'a> @@ -161,7 +164,8 @@ impl<Domain, E, F> Prox<Domain> for NormConstraint<F, E> where - Domain: Space + Norm<E, F>, + Domain: Space, + Domain::OwnedSpace: Norm<E, F>, E: NormExponent, F: Float, NormProjection<F, E>: Mapping<Domain, Codomain = Domain::OwnedSpace>, @@ -201,8 +205,8 @@ impl<F, E, Domain> Mapping<Domain> for NormProjection<F, E> where - Domain: Normed<F> + Projection<F, E>, - Domain::OwnedSpace: ClosedSpace, + Domain: Space, + Domain::OwnedSpace: ClosedSpace + Projection<F, E>, F: Float, E: NormExponent, { @@ -232,7 +236,7 @@ } } -impl<Domain: Normed<F>, F: Float> ConvexMapping<Domain, F> for Zero<Domain, F> {} +impl<Domain: Space, F: Float> ConvexMapping<Domain, F> for Zero<Domain, F> {} impl<Domain: HasDual<F>, F: Float> Conjugable<Domain, F> for Zero<Domain, F> { type Conjugate<'a> @@ -249,7 +253,7 @@ impl<Domain, Predual, F: Float> Preconjugable<Domain, Predual, F> for Zero<Domain, F> where Domain: Normed<F>, - Predual: HasDual<F>, + Predual: HasDual<F, Owned = Predual>, { type Preconjugate<'a> = ZeroIndicator<Predual, F> @@ -284,7 +288,12 @@ } } -impl<Domain: Normed<F>, F: Float> Mapping<Domain> for ZeroIndicator<Domain, F> { +impl<Domain, F> Mapping<Domain> for ZeroIndicator<Domain, F> +where + F: Float, + Domain: Space, + Domain::OwnedSpace: Normed<F>, +{ type Codomain = F; /// Compute the value of `self` at `x`. @@ -293,13 +302,21 @@ } } -impl<Domain: Normed<F>, F: Float> ConvexMapping<Domain, F> for ZeroIndicator<Domain, F> { +impl<Domain, F: Float> ConvexMapping<Domain, F> for ZeroIndicator<Domain, F> +where + Domain: Space, + Domain::OwnedSpace: Normed<F>, +{ fn factor_of_strong_convexity(&self) -> F { F::INFINITY } } -impl<Domain: HasDual<F>, F: Float> Conjugable<Domain, F> for ZeroIndicator<Domain, F> { +impl<Domain, F: Float> Conjugable<Domain, F> for ZeroIndicator<Domain, F> +where + Domain: HasDual<F>, + Domain::Owned: Normed<F>, +{ type Conjugate<'a> = Zero<Domain::DualSpace, F> where @@ -313,7 +330,8 @@ impl<Domain, Predual, F: Float> Preconjugable<Domain, Predual, F> for ZeroIndicator<Domain, F> where - Domain: Normed<F>, + Domain: Space, + Domain::OwnedSpace: Normed<F>, Predual: HasDual<F>, { type Preconjugate<'a>
--- 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<X: Space + Clone> Decomposition<X> for BasicDecomposition { +impl<X: Space> Decomposition<X> for BasicDecomposition { type Decomposition<'b> = MyCow<'b, X> where @@ -282,7 +282,7 @@ } } -impl<X: Space + Clone> Instance<X, BasicDecomposition> for X { +impl<X: Space> Instance<X, BasicDecomposition> 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<X, BasicDecomposition> for &'a X { +impl<'a, X: Space> Instance<X, BasicDecomposition> 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<X, BasicDecomposition> for &'a mut X { +impl<'a, X: Space> Instance<X, BasicDecomposition> 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<X, BasicDecomposition> for MyCow<'a, X> { +impl<'a, X: Space> Instance<X, BasicDecomposition> for MyCow<'a, X> { #[inline] fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R where
--- 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<Domain, F> Mapping<Domain> for Scaled<F> where F: Float, - Domain: Space + Mul<F>, - <Domain as Mul<F>>::Output: ClosedSpace, + Domain: Space, + Domain::OwnedSpace: Mul<F>, + <Domain::OwnedSpace as Mul<F>>::Output: ClosedSpace, { - type Codomain = <Domain as Mul<F>>::Output; + type Codomain = <Domain::OwnedSpace as Mul<F>>::Output; /// Compute the value of `self` at `x`. fn apply<I: Instance<Domain>>(&self, x: I) -> Self::Codomain { @@ -933,7 +934,8 @@ impl<Domain, F> Linear<Domain> for Scaled<F> where F: Float, - Domain: Space + Mul<F>, - <Domain as Mul<F>>::Output: ClosedSpace, + Domain: Space, + Domain::OwnedSpace: Mul<F>, + <Domain::OwnedSpace as Mul<F>>::Output: ClosedSpace, { }
--- 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<E, F>, + Domain: Space, + Domain::OwnedSpace: Norm<E, F>, { type Codomain = F;
--- 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<U,Idx> Set<U> for $range<Idx> where - Idx : PartialOrd<U>, - U : PartialOrd<Idx> + Space<Decomp=BasicDecomposition> + Clone, - Idx : PartialOrd + U : Space<Decomp=BasicDecomposition>, + U::OwnedSpace : PartialOrd<Idx>, + Idx : PartialOrd + PartialOrd<U::OwnedSpace>, { #[inline] fn contains<I : Instance<U>>(&self, item : I) -> bool {