| 40 pub fn new(weight: C, base_fn: T) -> Self { |
40 pub fn new(weight: C, base_fn: T) -> Self { |
| 41 Weighted { weight, base_fn } |
41 Weighted { weight, base_fn } |
| 42 } |
42 } |
| 43 } |
43 } |
| 44 |
44 |
| 45 impl<'a, T, V, D, F, C> Mapping<D> for Weighted<T, C> |
45 impl<'a, T, D, F, C> Mapping<D> for Weighted<T, C> |
| 46 where |
46 where |
| 47 F: Float, |
47 F: Float, |
| 48 D: Space, |
48 D: Space, |
| 49 T: Mapping<D, Codomain = V>, |
49 T: Mapping<D>, |
| 50 V: Space + ClosedMul<F>, |
50 T::Codomain: ClosedMul<F>, |
| 51 C: Constant<Type = F>, |
51 C: Constant<Type = F>, |
| 52 { |
52 { |
| 53 type Codomain = V; |
53 type Codomain = T::Codomain; |
| 54 |
54 |
| 55 #[inline] |
55 #[inline] |
| 56 fn apply<I: Instance<D>>(&self, x: I) -> Self::Codomain { |
56 fn apply<I: Instance<D>>(&self, x: I) -> Self::Codomain { |
| 57 self.base_fn.apply(x) * self.weight.value() |
57 self.base_fn.apply(x) * self.weight.value() |
| 58 } |
58 } |