Stan Math Library
4.8.1
Automatic Differentiation
|
The variable implementation for floating point types.
This class is complete (not abstract) and may be used for constants.
A variable implementation is constructed with a constant value. It also stores the adjoint for storing the partial derivative with respect to the root of the derivative tree.
#include <vari.hpp>
Public Types | |
using | value_type = std::decay_t< T > |
Public Member Functions | |
template<typename S , require_convertible_t< S &, T > * = nullptr> | |
vari_value (S x) noexcept | |
Construct a variable implementation from a value. | |
template<typename S , require_convertible_t< S &, T > * = nullptr> | |
vari_value (S x, bool stacked) noexcept | |
Construct a variable implementation from a value. | |
const auto & | val () const |
Return a constant reference to the value of this vari. | |
auto & | adj () const |
Return a reference of the derivative of the root expression with respect to this expression. | |
auto & | adj () |
Return a reference to the derivative of the root expression with respect to this expression. | |
void | chain () |
Apply the chain rule to this variable based on the variables on which it depends. | |
void | init_dependent () noexcept |
Initialize the adjoint for this (dependent) variable to 1. | |
void | set_zero_adjoint () noexcept final |
Set the adjoint value of this variable to 0. | |
Static Public Member Functions | |
static void * | operator new (size_t nbytes) noexcept |
Allocate memory from the underlying memory pool. | |
static void | operator delete (void *) noexcept |
Delete a pointer from the underlying memory pool. | |
Public Attributes | |
const value_type | val_ |
The value of this variable. | |
value_type | adj_ {0.0} |
The adjoint of this variable, which is the partial derivative of this variable with respect to the root variable. | |
Friends | |
template<typename , typename > | |
class | var_value |
std::ostream & | operator<< (std::ostream &os, const vari_value< T > *v) |
Insertion operator for vari. | |