Enum rust_ad_core::derivatives::forward::Arg [−][src]
Expand description
Gets cumulative derivative for given expression for a given input variable (only supports literals and paths).
This is difficult to explain here.
In practical application we unwrap all statements such that let e=2.*b+d;
becomes 2
statements let _e=2.*b;
and let e=_e+d;
, when we do this can optimize this
function, instead of needing to do d/db(2.*b+d)
and d/dd(2.*b+d)
we can
simply know in an addition if the component is a variable the deriative is 1.
since d/d_e(_e+d)
and d/d_d(_e+d)
are both 1, thus we know the result
for an input x
would be 1.*_e_x + 1.*d_x
simply _e_x + d_x
.
In this optimization we apply this function t0o each component (e.g. _e
, d
etc.) seperately
with 4 possible results for each:
- Where the component is a literal (not a variable) it is simply
0.
, - Where the component is not a function input, we get the cumulative deriative for this
variable with respect to our function input (e.g.
_e_x
). - Where the component is an input and we looking at the cumulative derivative for this input it
is our seed input cumulative derivative e.g.
_x
since1. * _x
. - Where the component is an input, but we are not looking at the cumulative derivative for this
input, it is
0.
since we don’t have cumulative deriatives for inputs with respect to each other with1. * x_wrt_y
,x_wrt_y
doens’t exist and we presume inputs independant.
Variants
Variable(String)
Tuple Fields
0: String
e.g. a
Literal(String)
Tuple Fields
0: String
e.g. 7.3f32