Stan Math Library  2.6.3
probability, sampling & optimization
 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 
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
chainable()
Construct a chainable object.
Definition: chainable.hpp:20
Abstract base class for variable implementations that handles memory management and applying the chai...
Definition: chainable.hpp:14
virtual void set_zero_adjoint()
Set the value of the adjoint for this chainable to its initial value.
Definition: chainable.hpp:49
virtual void init_dependent()
Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation...
Definition: chainable.hpp:42
virtual ~chainable()
Chainables are not destructible and should go on the function call stack or be allocated with operato...
Definition: chainable.hpp:26
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...
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.