| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
chainable.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_CORE_CHAINABLE_HPP
2 #define STAN_MATH_REV_CORE_CHAINABLE_HPP
3
4 #include <stan/math/rev/core/chainablestack.hpp>
5 #include <cstddef>
6
7 namespace stan {
8 namespace math {
9
14 class chainable {
15 public:
20 chainable() { }
21
26 virtual ~chainable() {
27 // handled automatically
28 }
29
35 virtual void chain() {
36 }
37
42 virtual void init_dependent() {
43 }
44
49 virtual void set_zero_adjoint() {
50 }
51
61 static inline void* operator new(size_t nbytes) {
62 return ChainableStack::memalloc_.alloc(nbytes);
63 }
64
75 static inline void operator delete(void* /* ignore arg */) {
76 /* no op */
77 }
78 };
79
80
81
82 }
83 }
84 #endif
stan::math::chainable::chainable
chainable()
Construct a chainable object.
Definition: chainable.hpp:20
stan::math::chainable
Abstract base class for variable implementations that handles memory management and applying the chai...
Definition: chainable.hpp:14
stan::math::AutodiffStackStorage::memalloc_
static stack_alloc memalloc_
Definition: autodiffstackstorage.hpp:16
stan::math::chainable::set_zero_adjoint
virtual void set_zero_adjoint()
Set the value of the adjoint for this chainable to its initial value.
Definition: chainable.hpp:49
stan::math::chainable::init_dependent
virtual void init_dependent()
Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation...
Definition: chainable.hpp:42
chainablestack.hpp
stan::math::chainable::~chainable
virtual ~chainable()
Chainables are not destructible and should go on the function call stack or be allocated with operato...
Definition: chainable.hpp:26
stan::math::stack_alloc::alloc
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...
Definition: stack_alloc.hpp:170
stan::math::chainable::chain
virtual void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
Definition: chainable.hpp:35

[ Stan Home Page ] © 2011–2015, Stan Development Team.