acme_core/specs/
gradient.rs1use crate::id::Identifiable;
6use crate::specs::StoreExt;
7pub trait Jacobian {
8 type Item;
9
10 fn jacobian(&self) -> Self::Item;
11}
12
13pub trait Partial<T> {
14 type Output;
15
16 fn partial(&self, args: T) -> Self::Output;
17}
18
19pub trait Grad {
20 type Args: Identifiable;
21 type Gradient: StoreExt<Self::Args>;
22
23 fn grad(&self) -> Self::Gradient;
24 fn grad_at(&self, wrt: <Self::Args as Identifiable>::Id) -> Self::Args;
25}
26
27pub trait Gradient<T> {
28 type Gradient;
29
30 fn grad(&self, args: T) -> Self::Gradient;
31}
32
33pub trait IsDifferentiable {
34 fn differentiable(&self) -> bool;
36}
37
38impl<S> IsDifferentiable for S
39where
40 S: Grad,
41{
42 fn differentiable(&self) -> bool {
43 true
44 }
45}