src/scaled.rs

changeset 56
34f8ec636368
parent 55
15f01efc034b
equal deleted inserted replaced
55:15f01efc034b 56:34f8ec636368
1 /*! 1 /*!
2 Implementation of scaling of functions on a manifold by a scalar. 2 Implementation of scaling of functions on a manifold by a scalar.
3 */ 3 */
4 4
5 use alg_tools::mapping::{Mapping, Instance}; 5 use alg_tools::mapping::{Mapping, Instance, Space};
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 8
9 /// Structure for a function of type `G`, scaled by a scalar. 9 /// Structure for a function of type `G`, scaled by a scalar.
10 pub struct Scaled<G> { 10 pub struct Scaled<G> {
20 pub fn new(α : f64, g : G) -> Self { 20 pub fn new(α : f64, g : G) -> Self {
21 Scaled{ α, g } 21 Scaled{ α, g }
22 } 22 }
23 } 23 }
24 24
25 impl<M, G : Mapping<M, Codomain=f64>> Mapping<M> for Scaled< G> { 25 impl<M : Space, G : Mapping<M, Codomain=f64>> Mapping<M> for Scaled< G> {
26 type Codomain = f64; 26 type Codomain = f64;
27 27
28 fn apply<I : Instance<M>>(&self, x : I) -> Self::Codomain { 28 fn apply<I : Instance<M>>(&self, x : I) -> Self::Codomain {
29 self.g.apply(x) * self.α 29 self.g.apply(x) * self.α
30 } 30 }

mercurial