|
1 |
|
2 use alg_tools::mapping::Apply; |
|
3 use crate::manifold::ManifoldPoint; |
|
4 use crate::fb::{Grad, Desc, Prox}; |
|
5 use std::marker::PhantomData; |
|
6 |
|
7 /// Zero function on manifolds. |
|
8 pub struct ZeroFn<M : ManifoldPoint> { |
|
9 _phantoms : PhantomData<M> |
|
10 } |
|
11 |
|
12 impl<M: ManifoldPoint> ZeroFn<M> { |
|
13 pub fn new() -> Self { |
|
14 ZeroFn{_phantoms : PhantomData } |
|
15 } |
|
16 } |
|
17 |
|
18 impl<M : ManifoldPoint> Apply<M> for ZeroFn<M> { |
|
19 type Output = f64; |
|
20 |
|
21 fn apply(&self, _x : M) -> Self::Output { |
|
22 0.0 |
|
23 } |
|
24 } |
|
25 |
|
26 impl<'a, M : ManifoldPoint> Apply<&'a M> for ZeroFn<M> { |
|
27 type Output = f64; |
|
28 |
|
29 fn apply(&self, _x : &'a M) -> Self::Output { |
|
30 0.0 |
|
31 } |
|
32 } |
|
33 |
|
34 impl<M : ManifoldPoint> Desc<M> for ZeroFn<M> { |
|
35 fn desc(&self, _τ : f64, x : M) -> M { |
|
36 x |
|
37 } |
|
38 } |
|
39 |
|
40 impl<M : ManifoldPoint> Grad<M> for ZeroFn<M> { |
|
41 fn grad(&self, x : &M) -> M::Tangent { |
|
42 x.tangent_origin() |
|
43 } |
|
44 } |
|
45 |
|
46 impl<M : ManifoldPoint> Prox<M> for ZeroFn<M> { |
|
47 fn prox(&self, _τ : f64, x : M) -> M { |
|
48 x |
|
49 } |
|
50 } |