Stan  1.0
probability, sampling & optimization
Public Member Functions | Static Public Member Functions | List of all members
stan::agrad::chainable Class Reference

Abstract base class for variable implementations that handles memory management and applying the chain rule. More...

#include <agrad.hpp>

Inheritance diagram for stan::agrad::chainable:
stan::agrad::vari stan::agrad::gevv_vvv_vari stan::agrad::partials_vari

Public Member Functions

 chainable ()
 Construct a chainable object. More...
 
 ~chainable ()
 Throws a logic exception. More...
 
virtual void chain ()
 Apply the chain rule to this variable based on the variables on which it depends. More...
 
virtual void init_dependent ()
 Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation. More...
 
virtual void set_zero_adjoint ()
 Set the value of the adjoint for this chainable to its initial value. More...
 

Static Public Member Functions

static void * operator new (size_t nbytes)
 Allocate memory from the underlying memory pool. More...
 

Detailed Description

Abstract base class for variable implementations that handles memory management and applying the chain rule.

Definition at line 34 of file agrad.hpp.

Constructor & Destructor Documentation

◆ chainable()

stan::agrad::chainable::chainable ( )
inline

Construct a chainable object.

The implementation in this abstract base class is a no-op.

Definition at line 42 of file agrad.hpp.

◆ ~chainable()

stan::agrad::chainable::~chainable ( )
inline

Throws a logic exception.

Chainables are not destructible by clients because the vari stack manages all memory for auto-dif.

Definition at line 49 of file agrad.hpp.

Member Function Documentation

◆ chain()

virtual void stan::agrad::chainable::chain ( )
inlinevirtual

Apply the chain rule to this variable based on the variables on which it depends.

The base implementation in this class is a no-op.

Reimplemented in stan::agrad::partials_vari, stan::agrad::gevv_vvv_vari, and stan::agrad::vari.

Definition at line 58 of file agrad.hpp.

◆ init_dependent()

virtual void stan::agrad::chainable::init_dependent ( )
inlinevirtual

Initialize this chainable's adjoint value to make it the dependent variable in a gradient calculation.

Reimplemented in stan::agrad::vari.

Definition at line 65 of file agrad.hpp.

◆ operator new()

static void* stan::agrad::chainable::operator new ( size_t  nbytes)
inlinestatic

Allocate memory from the underlying memory pool.

This memory is is managed by the gradient program and will be recovered as a whole. Classes should not be allocated with this operator if they have non-trivial destructors.

Parameters
nbytesNumber of bytes to allocate.
Returns
Pointer to allocated bytes.

Definition at line 85 of file agrad.hpp.

◆ set_zero_adjoint()

virtual void stan::agrad::chainable::set_zero_adjoint ( )
inlinevirtual

Set the value of the adjoint for this chainable to its initial value.

Reimplemented in stan::agrad::vari.

Definition at line 72 of file agrad.hpp.


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

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