src/operator_arithmetic.rs

branch
dev
changeset 171
fa8df5a14486
parent 151
402d717bb5c0
equal deleted inserted replaced
170:221728aeeb7e 171:fa8df5a14486
97 M::Codomain: std::iter::Sum + Clone, 97 M::Codomain: std::iter::Sum + Clone,
98 { 98 {
99 type Codomain = M::Codomain; 99 type Codomain = M::Codomain;
100 100
101 fn apply<I: Instance<Domain>>(&self, x: I) -> Self::Codomain { 101 fn apply<I: Instance<Domain>>(&self, x: I) -> Self::Codomain {
102 x.eval_ref_decompose(|xr| self.0.iter().map(|c| c.apply(xr)).sum()) 102 x.eval_ref(|xr| self.0.iter().map(|c| c.apply(xr)).sum())
103 } 103 }
104 } 104 }
105 105
106 impl<Domain, M> DifferentiableImpl<Domain> for MappingSum<M> 106 impl<Domain, M> DifferentiableImpl<Domain> for MappingSum<M>
107 where 107 where
110 M::DerivativeDomain: std::iter::Sum, 110 M::DerivativeDomain: std::iter::Sum,
111 { 111 {
112 type Derivative = M::DerivativeDomain; 112 type Derivative = M::DerivativeDomain;
113 113
114 fn differential_impl<I: Instance<Domain>>(&self, x: I) -> Self::Derivative { 114 fn differential_impl<I: Instance<Domain>>(&self, x: I) -> Self::Derivative {
115 x.eval_ref_decompose(|xr| self.0.iter().map(|c| c.differential(xr)).sum()) 115 x.eval_ref(|xr| self.0.iter().map(|c| c.differential(xr)).sum())
116 } 116 }
117 } 117 }

mercurial