diff -r 2f1798c65fd6 -r c4e394a9c84c src/convex.rs --- a/src/convex.rs Mon Sep 01 00:04:22 2025 -0500 +++ b/src/convex.rs Mon Sep 01 13:51:03 2025 -0500 @@ -4,7 +4,7 @@ use crate::error::DynResult; use crate::euclidean::Euclidean; -use crate::instance::{DecompositionMut, Instance, InstanceMut}; +use crate::instance::{ClosedSpace, DecompositionMut, Instance}; use crate::linops::{IdOp, Scaled, SimpleZeroOp, AXPY}; use crate::mapping::{DifferentiableImpl, LipschitzDifferentiableImpl, Mapping, Space}; use crate::norms::*; @@ -57,7 +57,7 @@ /// The conjugate type has to implement [`ConvexMapping`], but a `Conjugable` mapping need /// not be convex. pub trait Prox: Mapping { - type Prox<'a>: Mapping + type Prox<'a>: Mapping where Self: 'a; @@ -65,16 +65,15 @@ fn prox_mapping(&self, τ: Self::Codomain) -> Self::Prox<'_>; /// Calculate the proximal mapping with weight τ - fn prox>(&self, τ: Self::Codomain, z: I) -> Domain { + fn prox>(&self, τ: Self::Codomain, z: I) -> Domain::OwnedSpace { self.prox_mapping(τ).apply(z) } /// Calculate the proximal mapping with weight τ in-place - fn prox_mut<'b>(&self, τ: Self::Codomain, y: &'b mut Domain) + fn prox_mut<'b>(&self, τ: Self::Codomain, y: &'b mut Domain::OwnedSpace) where - &'b mut Domain: InstanceMut, Domain::Decomp: DecompositionMut, - for<'a> &'a Domain: Instance, + for<'a> &'a Domain::OwnedSpace: Instance, { *y = self.prox(τ, &*y); } @@ -165,7 +164,7 @@ Domain: Space + Norm, E: NormExponent, F: Float, - NormProjection: Mapping, + NormProjection: Mapping, { type Prox<'a> = NormProjection @@ -203,12 +202,13 @@ impl Mapping for NormProjection where Domain: Normed + Projection, + Domain::OwnedSpace: ClosedSpace, F: Float, E: NormExponent, { - type Codomain = Domain; + type Codomain = Domain::OwnedSpace; - fn apply>(&self, d: I) -> Domain { + fn apply>(&self, d: I) -> Self::Codomain { d.own().proj_ball(self.radius, self.exponent) } } @@ -262,7 +262,7 @@ } } -impl Prox for Zero { +impl Prox for Zero { type Prox<'a> = IdOp where @@ -395,7 +395,7 @@ impl Prox for Norm222 where F: Float, - X: Euclidean, + X: Euclidean + ClosedMul, { type Prox<'a> = Scaled @@ -410,11 +410,11 @@ impl DifferentiableImpl for Norm222 where F: Float, - X: Euclidean, + X: Euclidean, { - type Derivative = X; + type Derivative = X::Owned; - fn differential_impl>(&self, x: I) -> X { + fn differential_impl>(&self, x: I) -> Self::Derivative { x.own() } } @@ -422,7 +422,7 @@ impl LipschitzDifferentiableImpl for Norm222 where F: Float, - X: Euclidean, + X: Euclidean, { type FloatType = F;