Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
stan::agrad::precomputed_gradients_vari Class Reference

This is a var implementation class that takes precomputed gradient values. More...

#include <precomputed_gradients.hpp>

Inheritance diagram for stan::agrad::precomputed_gradients_vari:
stan::agrad::vari stan::agrad::chainable

Public Member Functions

 precomputed_gradients_vari (const double val, std::vector< vari * > &varis, const std::vector< double > &gradients)
 Constructs a precomputed_gradients_vari. More...
 
void chain ()
 Implements the chain rule for this variable. More...
 
- Public Member Functions inherited from stan::agrad::vari
 vari (const double x)
 Construct a variable implementation from a value. More...
 
 vari (const double x, bool stacked)
 
virtual ~vari ()
 Throw an illegal argument exception. More...
 
virtual void init_dependent ()
 Initialize the adjoint for this (dependent) variable to 1. More...
 
virtual void set_zero_adjoint ()
 Set the adjoint value of this variable to 0. More...
 
- Public Member Functions inherited from stan::agrad::chainable
 chainable ()
 Construct a chainable object. More...
 
virtual ~chainable ()
 Chainables are not destructible and should go on the function call stack or be allocated with operator new. More...
 

Protected Attributes

std::vector< vari * > varis_
 
std::vector< double > gradients_
 

Additional Inherited Members

- Static Public Member Functions inherited from stan::agrad::chainable
static void * operator new (size_t nbytes)
 Allocate memory from the underlying memory pool. More...
 
static void operator delete (void *)
 Delete a pointer from the underlying memory pool. More...
 
- Public Attributes inherited from stan::agrad::vari
const double val_
 The value of this variable. More...
 
double adj_
 The adjoint of this variable, which is the partial derivative of this variable with respect to the root variable. More...
 

Detailed Description

This is a var implementation class that takes precomputed gradient values.

Stan users should use function precomputed_gradients directly.

Definition at line 20 of file precomputed_gradients.hpp.

Constructor & Destructor Documentation

stan::agrad::precomputed_gradients_vari::precomputed_gradients_vari ( const double  val,
std::vector< vari * > &  varis,
const std::vector< double > &  gradients 
)
inline

Constructs a precomputed_gradients_vari.

The the value, pointers to the varis, and gradient values need to be provided.

Note: this class is slow since it

Parameters
valThe value of the variable.
varisVector of pointers to the varis of independent variables of this class.
gradientsVector of gradients with respect to the independent variables. These must be indexed in the same order as varis.
Exceptions
std::invalid_argumentif the sizes don't match

Definition at line 41 of file precomputed_gradients.hpp.

Member Function Documentation

void stan::agrad::precomputed_gradients_vari::chain ( )
inlinevirtual

Implements the chain rule for this variable.

Each of the independent variables' adjoints are updated with the appropriate gradient value.

Reimplemented from stan::agrad::chainable.

Definition at line 58 of file precomputed_gradients.hpp.

Member Data Documentation

std::vector<double> stan::agrad::precomputed_gradients_vari::gradients_
protected

Definition at line 23 of file precomputed_gradients.hpp.

std::vector<vari *> stan::agrad::precomputed_gradients_vari::varis_
protected

Definition at line 22 of file precomputed_gradients.hpp.


The documentation for this class was generated from the following file:

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