Stan Math Library
5.0.0
Automatic Differentiation
|
This class builds partial derivatives with respect to a set of operands.
There are two reason for the generality of this class. The first is to handle vector and scalar arguments without needing to write additional code. The second is to use this class for writing probability distributions that handle primitives, reverse mode, and forward mode variables seamlessly.
Conceptually, this class is used when we want to manually calculate the derivative of a function and store this manual result on the autodiff stack in a sort of "compressed" form. Think of it like an easy-to-use interface to rev/core/precomputed_gradients.
This class now supports multivariate use-cases as well by exposing edge::_.partials_vec
This is the specialization for when the return type is var, which should be for all of the reverse mode cases.
NB: since ops_partials_edge.partials_ and ops_partials_edge.partials_vec are sometimes represented internally as a broadcast_array, we need to take care with assignments to them. Indeed, we can assign any right hand side which allows for indexing to a broadcast_array. The resulting behaviour is that the entry for the first index is what gets assigned. The most common use-case should be where the rhs is some container of length 1.
Op1 | type of the first operand |
Op2 | type of the second operand |
Op3 | type of the third operand |
Op4 | type of the fourth operand |
Op5 | type of the fifth operand |
Op6 | type of the sixth operand |
Op7 | type of the seventh operand |
Op8 | type of the eighth operand |
Definition at line 298 of file operands_and_partials.hpp.
#include <operands_and_partials.hpp>
Public Member Functions | |
operands_and_partials (const Op1 &o1) | |
operands_and_partials (const Op1 &o1, const Op2 &o2) | |
operands_and_partials (const Op1 &o1, const Op2 &o2, const Op3 &o3) | |
operands_and_partials (const Op1 &o1, const Op2 &o2, const Op3 &o3, const Op4 &o4) | |
operands_and_partials (const Op1 &o1, const Op2 &o2, const Op3 &o3, const Op4 &o4, const Op5 &o5) | |
operands_and_partials (const Op1 &o1, const Op2 &o2, const Op3 &o3, const Op4 &o4, const Op5 &o5, const Op6 &o6) | |
operands_and_partials (const Op1 &o1, const Op2 &o2, const Op3 &o3, const Op4 &o4, const Op5 &o5, const Op6 &o6, const Op7 &o7) | |
operands_and_partials (const Op1 &o1, const Op2 &o2, const Op3 &o3, const Op4 &o4, const Op5 &o5, const Op6 &o6, const Op7 &o7, const Op8 &o8) | |
var | build (double value) |
Build the node to be stored on the autodiff graph. | |
Public Attributes | |
internal::ops_partials_edge< double, std::decay_t< Op1 > > | edge1_ |
internal::ops_partials_edge< double, std::decay_t< Op2 > > | edge2_ |
internal::ops_partials_edge< double, std::decay_t< Op3 > > | edge3_ |
internal::ops_partials_edge< double, std::decay_t< Op4 > > | edge4_ |
internal::ops_partials_edge< double, std::decay_t< Op5 > > | edge5_ |
internal::ops_partials_edge< double, std::decay_t< Op6 > > | edge6_ |
internal::ops_partials_edge< double, std::decay_t< Op7 > > | edge7_ |
internal::ops_partials_edge< double, std::decay_t< Op8 > > | edge8_ |