Wed, 06 Nov 2024 10:00:06 -0500
Implement prox for DistTo
src/dist.rs | file | annotate | diff | comparison | revisions |
--- a/src/dist.rs Fri Oct 25 13:16:25 2024 -0500 +++ b/src/dist.rs Wed Nov 06 10:00:06 2024 -0500 @@ -3,8 +3,9 @@ */ use alg_tools::mapping::Apply; +use alg_tools::euclidean::Euclidean; use crate::manifold::ManifoldPoint; -use crate::fb::{Grad, Desc}; +use crate::fb::{Grad, Desc, Prox}; /// Structure for distance-to functions pub struct DistTo<M : ManifoldPoint>(pub M); @@ -58,3 +59,16 @@ x.log(&self.0) } } + +impl<M : ManifoldPoint> Prox<M> for DistTo<M> { + /// This is proximal map is a type of soft-thresholding on manifolds. + fn prox(&self, τ : f64, x : M) -> M { + let v = x.log(&self.0); + let d = v.norm2(); + if d <= τ { + self.0.clone() + } else { + x.exp( &(v * (τ / d)) ) + } + } +}