1 /*! |
1 /*! |
2 Implementation of the the constant zero function on a manifold. |
2 Implementation of the the constant zero function on a manifold. |
3 */ |
3 */ |
4 |
4 |
5 use alg_tools::mapping::Apply; |
5 use alg_tools::mapping::{Mapping, Instance}; |
6 use crate::manifold::ManifoldPoint; |
6 use crate::manifold::ManifoldPoint; |
7 use crate::fb::{Grad, Desc, Prox}; |
7 use crate::fb::{Grad, Desc, Prox}; |
8 use std::marker::PhantomData; |
8 use std::marker::PhantomData; |
9 |
9 |
10 /// Zero function on manifolds. |
10 /// Zero function on manifolds. |
17 pub fn new() -> Self { |
17 pub fn new() -> Self { |
18 ZeroFn{_phantoms : PhantomData } |
18 ZeroFn{_phantoms : PhantomData } |
19 } |
19 } |
20 } |
20 } |
21 |
21 |
22 impl<M : ManifoldPoint> Apply<M> for ZeroFn<M> { |
22 impl<M : ManifoldPoint> Mapping<M> for ZeroFn<M> { |
23 type Output = f64; |
23 type Codomain = f64; |
24 |
24 |
25 fn apply(&self, _x : M) -> Self::Output { |
25 fn apply<I : Instance<M>>(&self, _x : I) -> Self::Codomain { |
26 0.0 |
26 0.0 |
27 } |
27 } |
28 } |
28 } |
29 |
29 |
30 impl<'a, M : ManifoldPoint> Apply<&'a M> for ZeroFn<M> { |
|
31 type Output = f64; |
|
32 |
|
33 fn apply(&self, _x : &'a M) -> Self::Output { |
|
34 0.0 |
|
35 } |
|
36 } |
|
37 |
30 |
38 impl<M : ManifoldPoint> Desc<M> for ZeroFn<M> { |
31 impl<M : ManifoldPoint> Desc<M> for ZeroFn<M> { |
39 fn desc(&self, _τ : f64, x : M) -> M { |
32 fn desc(&self, _τ : f64, x : M) -> M { |
40 x |
33 x |
41 } |
34 } |