1 #ifndef STAN_MATH_REV_CORE_VARI_HPP
2 #define STAN_MATH_REV_CORE_VARI_HPP
58 explicit vari(
const double x):
64 vari(
const double x,
bool stacked):
121 return os << v->
val_ <<
":" << v->
adj_;
134 static inline void*
operator new(
size_t nbytes) {
149 static inline void operator delete(
void* ) {
vari(const double x)
Construct a variable implementation from a value.
virtual void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
friend std::ostream & operator<<(std::ostream &os, const vari *v)
Insertion operator for vari.
static stack_alloc memalloc_
The variable implementation base class.
Independent (input) and dependent (output) variables for gradients.
virtual ~vari()
Throw an illegal argument exception.
const double val_
The value of this variable.
void set_zero_adjoint()
Set the adjoint value of this variable to 0.
vari(const double x, bool stacked)
static std::vector< ChainableT * > var_nochain_stack_
void init_dependent()
Initialize the adjoint for this (dependent) variable to 1.
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
static std::vector< ChainableT * > var_stack_
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...