![]() |
Stan Math Library
2.6.3
probability, sampling & optimization
|
Abstract base class for variable implementations that handles memory management and applying the chain rule. More...
#include <chainable.hpp>
Public Member Functions | |
chainable () | |
Construct a chainable object. More... | |
virtual | ~chainable () |
Chainables are not destructible and should go on the function call stack or be allocated with operator new. More... | |
virtual void | chain () |
Apply the chain rule to this variable based on the variables on which it depends. More... | |
virtual void | init_dependent () |
Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation. More... | |
virtual void | set_zero_adjoint () |
Set the value of the adjoint for this chainable to its initial value. More... | |
Static Public Member Functions | |
static void * | operator new (size_t nbytes) |
Allocate memory from the underlying memory pool. More... | |
static void | operator delete (void *) |
Delete a pointer from the underlying memory pool. More... | |
Abstract base class for variable implementations that handles memory management and applying the chain rule.
Definition at line 14 of file chainable.hpp.
|
inline |
Construct a chainable object.
The implementation in this abstract base class is a no-op.
Definition at line 20 of file chainable.hpp.
|
inlinevirtual |
Chainables are not destructible and should go on the function call stack or be allocated with operator new.
Definition at line 26 of file chainable.hpp.
|
inlinevirtual |
Apply the chain rule to this variable based on the variables on which it depends.
The base implementation in this class is a no-op.
Reimplemented in stan::math::precomputed_gradients_vari, stan::math::stored_gradient_vari, stan::math::gevv_vvv_vari, stan::math::partials_vari, stan::math::sum_v_vari, stan::math::precomp_vvv_vari, stan::math::precomp_vv_vari, and stan::math::precomp_v_vari.
Definition at line 35 of file chainable.hpp.
|
inlinevirtual |
Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation.
Reimplemented in stan::math::vari.
Definition at line 42 of file chainable.hpp.
|
inlinestatic |
Delete a pointer from the underlying memory pool.
This no-op implementation enables a subclass to throw exceptions in its constructor. An exception thrown in the constructor of a subclass will result in an error being raised, which is in turn caught and calls delete().
See the discussion of "plugging the memory leak" in: http://www.parashift.com/c++-faq/memory-pools.html
Definition at line 75 of file chainable.hpp.
|
inlinestatic |
Allocate memory from the underlying memory pool.
This memory is is managed by the gradient program and will be recovered as a whole. Classes should not be allocated with this operator if they have non-trivial destructors.
nbytes | Number of bytes to allocate. |
Definition at line 61 of file chainable.hpp.
|
inlinevirtual |
Set the value of the adjoint for this chainable to its initial value.
Reimplemented in stan::math::vari.
Definition at line 49 of file chainable.hpp.