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 - Op5 must be arithmetic primitives like int or double. This is controlled with the T_return_type type parameter.
Ops | type of the operands |
ReturnType | The type returned from calling the build() method. |
Definition at line 51 of file partials_propagator.hpp.
#include <partials_propagator.hpp>
Public Member Functions | |
template<typename... Types> | |
partials_propagator (Types &&...) noexcept | |
Static Public Member Functions | |
static double | build (double value) noexcept |
Build the node to be stored on the autodiff graph. | |
Public Attributes | |
std::tuple< internal::ops_partials_edge< double, std::decay_t< Ops > >... > | edges_ |