Automatic Differentiation
 
Loading...
Searching...
No Matches
stan::math::internal::partials_propagator< ReturnType, require_var_t< ReturnType >, Ops... > Class Template Reference

Detailed Description

template<typename ReturnType, typename... Ops>
class stan::math::internal::partials_propagator< ReturnType, require_var_t< ReturnType >, Ops... >

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.

Template Parameters
OpsType of the operands placed into the edges
ReturnTypeThe type returned from the build() method.

Definition at line 50 of file partials_propagator.hpp.

#include <partials_propagator.hpp>

Public Member Functions

template<typename... Types>
 partials_propagator (Types &&... ops)
 
var build (double value)
 Build the node to be stored on the autodiff graph.
 

Public Attributes

std::tuple< internal::ops_partials_edge< double, plain_type_t< std::decay_t< Ops > > >... > edges_
 

The documentation for this class was generated from the following file: