1 #ifndef STAN__AGRAD__REV__VAR_HPP
2 #define STAN__AGRAD__REV__VAR_HPP
12 static void grad(chainable* vi);
52 return (
vi_ == static_cast<vari*>(0U));
82 vi_(new
vari(static_cast<double>(b))) {
92 vi_(new
vari(static_cast<double>(c))) {
102 vi_(new
vari(static_cast<double>(n))) {
112 vi_(new
vari(static_cast<double>(n))) {
122 vi_(new
vari(static_cast<double>(n))) {
132 vi_(new
vari(static_cast<double>(n))) {
142 vi_(new
vari(static_cast<double>(n))) {
151 var(
unsigned long int n) :
152 vi_(new
vari(static_cast<double>(n))) {
161 var(
unsigned long long n) :
162 vi_(new
vari(static_cast<double>(n))) {
172 vi_(new
vari(static_cast<double>(n))) {
182 vi_(new
vari(static_cast<double>(x))) {
201 vi_(new
vari(static_cast<double>(x))) {
209 inline double val()
const {
221 inline double adj()
const {
238 std::vector<double>& g) {
241 for (
size_t i = 0; i < x.size(); ++i)
390 return os <<
"uninitialized";
391 return os << v.
val() <<
':' << v.
adj();
var & operator/=(const var &b)
The compound divide/assignment operator for variables (C++).
var & operator-=(const var &b)
The compound subtract/assignment operator for variables (C++).
double adj() const
Return the derivative of the root expression with respect to this expression.
vari * operator->()
Return a pointer to the underlying implementation of this variable.
var(int n)
Construct a variable by static casting the specified value to double.
double val() const
Return the value of this variable.
const double val_
The value of this variable.
var(float x)
Construct a variable by static casting the specified value to double.
var(long int n)
Construct a variable by static casting the specified value to double.
static void grad(chainable *vi)
Compute the gradient for all variables starting from the specified root variable implementation.
var(unsigned short n)
Construct a variable by static casting the specified value to double.
vari & operator*()
Return a reference to underlying implementation of this variable.
vari * vi_
Pointer to the implementation of this variable.
var(char c)
Construct a variable by static casting the specified value to double.
var & operator*=(const var &b)
The compound multiply/assignment operator for variables (C++).
var(unsigned long int n)
Construct a variable by static casting the specified value to double.
var(bool b)
Construct a variable by static casting the specified value to double.
void grad(std::vector< var > &x, std::vector< double > &g)
Compute the gradient of this (dependent) variable with respect to the specified vector of (independen...
The variable implementation base class.
var(short n)
Construct a variable by static casting the specified value to double.
var(long long n)
Construct a variable by static casting the specified value to double.
var(long double x)
Construct a variable by static casting the specified value to double.
var(vari *vi)
Construct a variable from a pointer to a variable implementation.
var(unsigned int n)
Construct a variable by static casting the specified value to double.
bool is_uninitialized()
Return true if this variable has been declared, but not been defined.
var(double x)
Construct a variable with the specified value.
Independent (input) and dependent (output) variables for gradients.
friend std::ostream & operator<<(std::ostream &os, const var &v)
Write the value of this auto-dif variable and its adjoint to the specified output stream...
var(unsigned long long n)
Construct a variable by static casting the specified value to double.
var & operator+=(const var &b)
The compound add/assignment operator for variables (C++).
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
var()
Construct a variable for later assignment.