# HG changeset patch # User Tuomo Valkonen # Date 1734186687 18000 # Node ID 1a38447a89fa5c573aef980d6cc92ffa34ab6dfd # Parent 1b3b1687b9ede104853037eaebd2a8acb49e1844 Convex analysis basics diff -r 1b3b1687b9ed -r 1a38447a89fa src/convex.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/convex.rs Sat Dec 14 09:31:27 2024 -0500 @@ -0,0 +1,50 @@ +/*! +Some convex analysis basics +*/ + +use crate::mapping::{Apply, Mapping}; + +/// Trait for convex mappings. Has no features, just serves as a constraint +/// +/// TODO: should constrain `Mapping::Codomain` to implement a partial order, +/// but this makes everything complicated with little benefit. +pub trait ConvexMapping : Mapping {} + +/// Trait for mappings with a Fenchel conjugate +/// +/// The conjugate type has to implement [`ConvexMapping`], but a `Conjugable` mapping need +/// not be convex. +pub trait Conjugable : Mapping { + type DualDomain; + type Conjugate<'a> : ConvexMapping where Self : 'a; + + fn conjugate(&self) -> Self::Conjugate<'_>; +} + +/// Trait for mappings with a Fenchel preconjugate +/// +/// In contrast to [`Conjugable`], the preconjugate need not implement [`ConvexMapping`], +/// but a `Preconjugable` mapping has be convex. +pub trait Preconjugable : ConvexMapping { + type PredualDomain; + type Preconjugate<'a> : Mapping where Self : 'a; + + fn preconjugate(&self) -> Self::Preconjugate<'_>; +} + +/// Trait for mappings with a proximap map +/// +/// The conjugate type has to implement [`ConvexMapping`], but a `Conjugable` mapping need +/// not be convex. +pub trait HasProx : Mapping { + type Prox<'a> : Mapping where Self : 'a; + + /// Returns a proximal mapping with weight τ + fn prox_mapping(&self, τ : Self::Codomain) -> Self::Prox<'_>; + + /// Calculate the proximal mapping with weight τ + fn prox(&self, z : Domain, τ : Self::Codomain) -> Domain { + self.prox_mapping(τ).apply(z) + } +} + diff -r 1b3b1687b9ed -r 1a38447a89fa src/lib.rs --- a/src/lib.rs Fri Dec 13 22:37:12 2024 -0500 +++ b/src/lib.rs Sat Dec 14 09:31:27 2024 -0500 @@ -42,5 +42,6 @@ pub mod nalgebra_support; pub(crate) mod metaprogramming; pub mod direct_product; +pub mod convex; pub use types::*;