# HG changeset patch # User Tuomo Valkonen # Date 1730905206 18000 # Node ID ad68dacabe4f49e7bd17ce07c4cd64af829090d9 # Parent a6efe0fafd902344e1991c1c9c528e629a6e7388 Implement prox for DistTo diff -r a6efe0fafd90 -r ad68dacabe4f src/dist.rs --- 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(pub M); @@ -58,3 +59,16 @@ x.log(&self.0) } } + +impl Prox for DistTo { + /// 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)) ) + } + } +}