1 #ifndef STAN__AGRAD__REV__CHAINABLE_HPP
2 #define STAN__AGRAD__REV__CHAINABLE_HPP
63 static inline void*
operator new(
size_t nbytes) {
77 static inline void operator delete(
void* ) {
119 typedef std::vector<chainable*>::reverse_iterator it_t;
123 for (it_t it = begin; it < end; ++it) {
virtual void init_dependent()
Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation...
static void set_zero_all_adjoints()
Reset all adjoint values in the stack to zero.
Abstract base class for variable implementations that handles memory management and applying the chai...
memory::stack_alloc memalloc_
static void grad(chainable *vi)
Compute the gradient for all variables starting from the specified root variable implementation.
static size_t nested_size()
virtual void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
virtual ~chainable()
Chainables are not destructible and should go on the function call stack or be allocated with operato...
chainable()
Construct a chainable object.
std::vector< chainable * > var_stack_
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...
virtual void set_zero_adjoint()
Set the value of the adjoint for this chainable to its initial value.
static bool empty_nested()
Return true if there is no nested autodiff being executed.
std::vector< chainable * > var_nochain_stack_