9 use colored::ColoredString; |
9 use colored::ColoredString; |
10 use crate::manifold::{EmbeddedManifoldPoint, ManifoldPoint}; |
10 use crate::manifold::{EmbeddedManifoldPoint, ManifoldPoint}; |
11 |
11 |
12 /// Trait for function objects that implement gradients |
12 /// Trait for function objects that implement gradients |
13 pub trait Grad<M : ManifoldPoint> { |
13 pub trait Grad<M : ManifoldPoint> { |
|
14 /// Calculates the gradient of `self` at `x`. |
14 fn grad(&self, x : &M) -> M::Tangent; |
15 fn grad(&self, x : &M) -> M::Tangent; |
15 } |
16 } |
16 |
17 |
17 /// Trait for function objects that implement gradient steps |
18 /// Trait for function objects that implement gradient steps |
18 pub trait Desc<M : ManifoldPoint> { |
19 pub trait Desc<M : ManifoldPoint> { |
|
20 /// Calculates the gradient steps of `self` at `x` for the step length `τ`. |
19 fn desc(&self, τ : f64, x : M) -> M; |
21 fn desc(&self, τ : f64, x : M) -> M; |
20 } |
22 } |
21 |
23 |
22 /*impl<M : ManifoldPoint, T : Grad<M>> Desc<M> for T { |
24 /*impl<M : ManifoldPoint, T : Grad<M>> Desc<M> for T { |
23 fn desc(&self, τ : f64, x : M) -> M { |
25 fn desc(&self, τ : f64, x : M) -> M { |
37 } |
39 } |
38 } |
40 } |
39 |
41 |
40 /// Trait for function objects that implement proximal steps |
42 /// Trait for function objects that implement proximal steps |
41 pub trait Prox<M : ManifoldPoint> { |
43 pub trait Prox<M : ManifoldPoint> { |
|
44 /// Calculates the proximap map of `self` at `x` for the step length `τ`. |
42 fn prox(&self, τ : f64, x : M) -> M; |
45 fn prox(&self, τ : f64, x : M) -> M; |
43 } |
46 } |
44 |
47 |
45 /// This structure is used to store information from algorithm iterations |
48 /// This structure is used to store information from algorithm iterations |
46 #[derive(Clone,Debug,Serialize)] |
49 #[derive(Clone,Debug,Serialize)] |