1 #ifndef STAN_MATH_REV_CORE_VARI_HPP 2 #define STAN_MATH_REV_CORE_VARI_HPP 58 explicit vari(
double x) : val_(x), adj_(0.0) {
62 vari(
double x,
bool stacked) : val_(x), adj_(0.0) {
112 return os << v->
val_ <<
":" << v->
adj_;
125 static inline void*
operator new(
size_t nbytes) {
140 static inline void operator delete(
void* ) {
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.
The variable implementation base class.
std::vector< ChainableT * > var_stack_
static STAN_THREADS_DEF AutodiffStackStorage * instance_
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.
std::vector< ChainableT * > var_nochain_stack_
vari(double x)
Construct a variable implementation from a value.
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...
void * alloc(size_t len)
Return a newly allocated block of memory of the appropriate size managed by the stack allocator...
vari(double x, bool stacked)