diff -r f248e1434c3b -r df9628092285 src/zero.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/zero.rs Mon Oct 21 08:44:23 2024 -0500 @@ -0,0 +1,50 @@ + +use alg_tools::mapping::Apply; +use crate::manifold::ManifoldPoint; +use crate::fb::{Grad, Desc, Prox}; +use std::marker::PhantomData; + +/// Zero function on manifolds. +pub struct ZeroFn { + _phantoms : PhantomData +} + +impl ZeroFn { + pub fn new() -> Self { + ZeroFn{_phantoms : PhantomData } + } +} + +impl Apply for ZeroFn { + type Output = f64; + + fn apply(&self, _x : M) -> Self::Output { + 0.0 + } +} + +impl<'a, M : ManifoldPoint> Apply<&'a M> for ZeroFn { + type Output = f64; + + fn apply(&self, _x : &'a M) -> Self::Output { + 0.0 + } +} + +impl Desc for ZeroFn { + fn desc(&self, _τ : f64, x : M) -> M { + x + } +} + +impl Grad for ZeroFn { + fn grad(&self, x : &M) -> M::Tangent { + x.tangent_origin() + } +} + +impl Prox for ZeroFn { + fn prox(&self, _τ : f64, x : M) -> M { + x + } +} \ No newline at end of file