144 self.base_fn.apply(x - &self.shift) |
144 self.base_fn.apply(x - &self.shift) |
145 } |
145 } |
146 } |
146 } |
147 |
147 |
148 impl<'a, T, V, F : Float, const N : usize> Differentiable<&'a Loc<F, N>> for Shift<T,F,N> |
148 impl<'a, T, V, F : Float, const N : usize> Differentiable<&'a Loc<F, N>> for Shift<T,F,N> |
149 where T : Differentiable<Loc<F, N>, Output=V> { |
149 where T : Differentiable<Loc<F, N>, Derivative=V> { |
150 type Output = V; |
150 type Derivative = V; |
151 #[inline] |
151 #[inline] |
152 fn differential(&self, x : &'a Loc<F, N>) -> Self::Output { |
152 fn differential(&self, x : &'a Loc<F, N>) -> Self::Derivative { |
153 self.base_fn.differential(x - &self.shift) |
153 self.base_fn.differential(x - &self.shift) |
154 } |
154 } |
155 } |
155 } |
156 |
156 |
157 impl<'a, T, V, F : Float, const N : usize> Differentiable<Loc<F, N>> for Shift<T,F,N> |
157 impl<'a, T, V, F : Float, const N : usize> Differentiable<Loc<F, N>> for Shift<T,F,N> |
158 where T : Differentiable<Loc<F, N>, Output=V> { |
158 where T : Differentiable<Loc<F, N>, Derivative=V> { |
159 type Output = V; |
159 type Derivative = V; |
160 #[inline] |
160 #[inline] |
161 fn differential(&self, x : Loc<F, N>) -> Self::Output { |
161 fn differential(&self, x : Loc<F, N>) -> Self::Derivative { |
162 self.base_fn.differential(x - &self.shift) |
162 self.base_fn.differential(x - &self.shift) |
163 } |
163 } |
164 } |
164 } |
165 |
165 |
166 impl<'a, T, F : Float, const N : usize> Support<F,N> for Shift<T,F,N> |
166 impl<'a, T, F : Float, const N : usize> Support<F,N> for Shift<T,F,N> |
249 self.base_fn.apply(x) * self.weight.value() |
249 self.base_fn.apply(x) * self.weight.value() |
250 } |
250 } |
251 } |
251 } |
252 |
252 |
253 impl<'a, T, V, F : Float, C, const N : usize> Differentiable<&'a Loc<F, N>> for Weighted<T, C> |
253 impl<'a, T, V, F : Float, C, const N : usize> Differentiable<&'a Loc<F, N>> for Weighted<T, C> |
254 where T : for<'b> Differentiable<&'b Loc<F, N>, Output=V>, |
254 where T : for<'b> Differentiable<&'b Loc<F, N>, Derivative=V>, |
255 V : std::ops::Mul<F, Output=V>, |
255 V : std::ops::Mul<F, Output=V>, |
256 C : Constant<Type=F> { |
256 C : Constant<Type=F> { |
257 type Output = V; |
257 type Derivative = V; |
258 #[inline] |
258 #[inline] |
259 fn differential(&self, x : &'a Loc<F, N>) -> Self::Output { |
259 fn differential(&self, x : &'a Loc<F, N>) -> Self::Derivative { |
260 self.base_fn.differential(x) * self.weight.value() |
260 self.base_fn.differential(x) * self.weight.value() |
261 } |
261 } |
262 } |
262 } |
263 |
263 |
264 impl<'a, T, V, F : Float, C, const N : usize> Differentiable<Loc<F, N>> for Weighted<T, C> |
264 impl<'a, T, V, F : Float, C, const N : usize> Differentiable<Loc<F, N>> for Weighted<T, C> |
265 where T : Differentiable<Loc<F, N>, Output=V>, |
265 where T : Differentiable<Loc<F, N>, Derivative=V>, |
266 V : std::ops::Mul<F, Output=V>, |
266 V : std::ops::Mul<F, Output=V>, |
267 C : Constant<Type=F> { |
267 C : Constant<Type=F> { |
268 type Output = V; |
268 type Derivative = V; |
269 #[inline] |
269 #[inline] |
270 fn differential(&self, x : Loc<F, N>) -> Self::Output { |
270 fn differential(&self, x : Loc<F, N>) -> Self::Derivative { |
271 self.base_fn.differential(x) * self.weight.value() |
271 self.base_fn.differential(x) * self.weight.value() |
272 } |
272 } |
273 } |
273 } |
274 |
274 |
275 impl<'a, T, F : Float, C, const N : usize> Support<F,N> for Weighted<T, C> |
275 impl<'a, T, F : Float, C, const N : usize> Support<F,N> for Weighted<T, C> |