Stan Math Library
5.0.0
Automatic Differentiation
|
This template 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 supports nested container ("multivariate") use-cases as well by exposing a partials_vec_ member on edges of the appropriate type.
This base template is instantiated when all operands are primitives and we don't want to calculate derivatives at all. So all Op1 - Op8 must be arithmetic primitives like int or double. This is controlled with the T_return_type type parameter.
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 |
T_return_type | return type of the expression. This defaults to calling a template metaprogram that calculates the scalar promotion of Op1..Op8 |
Definition at line 153 of file operands_and_partials.hpp.
#include <operands_and_partials.hpp>
Public Member Functions | |
operands_and_partials (const Op1 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &, const Op3 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &, const Op3 &, const Op4 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &, const Op7 &) noexcept | |
operands_and_partials (const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &, const Op7 &, const Op8 &) noexcept | |
double | build (double value) const noexcept |
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_ |