numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::auto_diff::backward Namespace Reference

Namespace of backward-mode automatic differentiation. More...

Namespaces

namespace  graph
 Namespace of graphs in backward-mode automatic differentiation.
 
namespace  impl
 Namespace of internal implementations.
 

Classes

struct  constant_tag
 Tag class to specify constants. More...
 
class  variable
 Class of variables in backward-mode automatic differentiation [17]. More...
 
struct  variable_tag
 Tag class to specify variables. More...
 

Typedefs

template<base::concepts::real_scalar_dense_vector ValueVector>
using variable_vector_type
 Get type of vectors of variables.
 

Functions

template<base::concepts::real_scalar Scalar>
auto create_diff_variable (const Scalar &value) -> variable< Scalar >
 Create a variable by which functions will be differentiated.
 
template<base::concepts::real_scalar_dense_vector ValueVector>
auto create_diff_variable_vector (const Eigen::MatrixBase< ValueVector > &value_vec) -> Eigen::CwiseNullaryOp< impl::create_diff_variable_vector_functor< ValueVector >, typename impl::create_diff_variable_vector_functor< ValueVector >::result_type >
 Create a vector of variables.
 
template<typename FuncValType , typename ArgType >
auto differentiate (const Eigen::MatrixBase< FuncValType > &func_value, const Eigen::MatrixBase< ArgType > &arg) -> Eigen::CwiseNullaryOp< impl::differentiate_vector_with_vector_functor< FuncValType, ArgType >, typename impl::differentiate_vector_with_vector_functor< FuncValType, ArgType >::result_type >
 Compute differential coefficients.
 
template<typename Scalar , typename ArgDerived >
auto differentiate (const variable< Scalar > &func_value, const Eigen::MatrixBase< ArgDerived > &arg) -> Eigen::CwiseNullaryOp< impl::differentiate_scalar_with_matrix_functor< ArgDerived >, typename impl::differentiate_scalar_with_matrix_functor< ArgDerived >::result_type >
 Compute differential coefficients.
 
template<typename Scalar >
auto differentiate (const variable< Scalar > &func_value, const variable< Scalar > &arg) -> Scalar
 Compute a differential coefficient.
 
template<typename Scalar >
auto exp (const variable< Scalar > &x) -> variable< Scalar >
 Calculate exponential.
 
template<typename Scalar >
auto log (const variable< Scalar > &x) -> variable< Scalar >
 Calculate logarithm.
 
template<typename Scalar >
auto operator* (const Scalar &left, const variable< Scalar > &right) -> variable< Scalar >
 Multiply two variables.
 
template<typename Scalar >
auto operator* (const variable< Scalar > &left, const Scalar &right) -> variable< Scalar >
 Multiply two variables.
 
template<typename Scalar >
auto operator* (const variable< Scalar > &left, const variable< Scalar > &right) -> variable< Scalar >
 Multiply two variables.
 
template<typename Scalar >
auto operator+ (const Scalar &left, const variable< Scalar > &right) -> variable< Scalar >
 Add two variables.
 
template<typename Scalar >
auto operator+ (const variable< Scalar > &left, const Scalar &right) -> variable< Scalar >
 Add two variables.
 
template<typename Scalar >
auto operator+ (const variable< Scalar > &left, const variable< Scalar > &right) -> variable< Scalar >
 Add two variables.
 
template<typename Scalar >
auto operator- (const Scalar &left, const variable< Scalar > &right) -> variable< Scalar >
 Subtract a variable from another variable.
 
template<typename Scalar >
auto operator- (const variable< Scalar > &left, const Scalar &right) -> variable< Scalar >
 Subtract a variable from another variable.
 
template<typename Scalar >
auto operator- (const variable< Scalar > &left, const variable< Scalar > &right) -> variable< Scalar >
 Subtract a variable from another variable.
 
template<typename Scalar >
auto operator/ (const Scalar &left, const variable< Scalar > &right) -> variable< Scalar >
 Divide a variable from another variable.
 
template<typename Scalar >
auto operator/ (const variable< Scalar > &left, const Scalar &right) -> variable< Scalar >
 Divide a variable from another variable.
 
template<typename Scalar >
auto operator/ (const variable< Scalar > &left, const variable< Scalar > &right) -> variable< Scalar >
 Divide a variable from another variable.
 
template<typename Scalar >
auto sqrt (const variable< Scalar > &x) -> variable< Scalar >
 Calculate square root.
 

Detailed Description

Namespace of backward-mode automatic differentiation.

Typedef Documentation

◆ variable_vector_type

template<base::concepts::real_scalar_dense_vector ValueVector>
using num_collect::auto_diff::backward::variable_vector_type
Initial value:
Eigen::Matrix<variable<typename ValueVector::Scalar>,
ValueVector::RowsAtCompileTime, 1, Eigen::ColMajor,
ValueVector::MaxRowsAtCompileTime, 1>

Get type of vectors of variables.

Template Parameters
ValueVectorType of vectors of values.

Definition at line 54 of file create_diff_variable.h.

Function Documentation

◆ create_diff_variable()

template<base::concepts::real_scalar Scalar>
auto num_collect::auto_diff::backward::create_diff_variable ( const Scalar & value) -> variable<Scalar>
inlinenodiscard

Create a variable by which functions will be differentiated.

Template Parameters
ScalarType of scalars.
Parameters
[in]valueValue.
Returns
Variable.

Definition at line 43 of file create_diff_variable.h.

◆ create_diff_variable_vector()

template<base::concepts::real_scalar_dense_vector ValueVector>
auto num_collect::auto_diff::backward::create_diff_variable_vector ( const Eigen::MatrixBase< ValueVector > & value_vec) -> Eigen::CwiseNullaryOp< impl::create_diff_variable_vector_functor<ValueVector>, typename impl::create_diff_variable_vector_functor< ValueVector>::result_type>
inlinenodiscard

Create a vector of variables.

Template Parameters
ValueVectorType of vectors of values.
Parameters
[in]value_vecVector of values.
Returns
Vector of variables.

Definition at line 118 of file create_diff_variable.h.

◆ differentiate() [1/3]

template<typename FuncValType , typename ArgType >
auto num_collect::auto_diff::backward::differentiate ( const Eigen::MatrixBase< FuncValType > & func_value,
const Eigen::MatrixBase< ArgType > & arg ) -> Eigen::CwiseNullaryOp< impl::differentiate_vector_with_vector_functor<FuncValType, ArgType>, typename impl::differentiate_vector_with_vector_functor<FuncValType, ArgType>::result_type>
inlinenodiscard

Compute differential coefficients.

Template Parameters
FuncValTypeType of function values.
ArgTypeType of function arguments.
Parameters
[in]func_valueVariable of the function value.
[in]argVariable of the argument.
Returns
Expression of differential coefficients.

Definition at line 208 of file differentiate.h.

◆ differentiate() [2/3]

template<typename Scalar , typename ArgDerived >
auto num_collect::auto_diff::backward::differentiate ( const variable< Scalar > & func_value,
const Eigen::MatrixBase< ArgDerived > & arg ) -> Eigen::CwiseNullaryOp< impl::differentiate_scalar_with_matrix_functor<ArgDerived>, typename impl::differentiate_scalar_with_matrix_functor< ArgDerived>::result_type>
inlinenodiscard

Compute differential coefficients.

Template Parameters
ScalarType of scalars.
ArgDerivedDerived class of argument.
Parameters
[in]func_valueVariable of the function value.
[in]argVariable of the argument.
Returns
Expression of differential coefficients.

Definition at line 119 of file differentiate.h.

◆ differentiate() [3/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::differentiate ( const variable< Scalar > & func_value,
const variable< Scalar > & arg ) -> Scalar
inlinenodiscard

Compute a differential coefficient.

Template Parameters
ScalarType of scalars.
Parameters
[in]func_valueVariable of the function value.
[in]argVariable of the argument.
Returns
Differential coefficient.

Definition at line 48 of file differentiate.h.

◆ exp()

template<typename Scalar >
auto num_collect::auto_diff::backward::exp ( const variable< Scalar > & x) -> variable<Scalar>
inlinenodiscard

Calculate exponential.

Template Parameters
ScalarType of scalars.
Parameters
[in]xArgument.
Returns
Value.

Definition at line 60 of file variable_math.h.

◆ log()

template<typename Scalar >
auto num_collect::auto_diff::backward::log ( const variable< Scalar > & x) -> variable<Scalar>
inlinenodiscard

Calculate logarithm.

Template Parameters
ScalarType of scalars.
Parameters
[in]xArgument.
Returns
Value.

Definition at line 74 of file variable_math.h.

◆ operator*() [1/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator* ( const Scalar & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Multiply two variables.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Product.

Definition at line 353 of file variable.h.

◆ operator*() [2/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator* ( const variable< Scalar > & left,
const Scalar & right ) -> variable<Scalar>
inlinenodiscard

Multiply two variables.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Product.

Definition at line 367 of file variable.h.

◆ operator*() [3/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator* ( const variable< Scalar > & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Multiply two variables.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Product.

Definition at line 339 of file variable.h.

◆ operator+() [1/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator+ ( const Scalar & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Add two variables.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Sum.

Definition at line 269 of file variable.h.

◆ operator+() [2/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator+ ( const variable< Scalar > & left,
const Scalar & right ) -> variable<Scalar>
inlinenodiscard

Add two variables.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Sum.

Definition at line 283 of file variable.h.

◆ operator+() [3/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator+ ( const variable< Scalar > & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Add two variables.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Sum.

Definition at line 255 of file variable.h.

◆ operator-() [1/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator- ( const Scalar & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Subtract a variable from another variable.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Difference.

Definition at line 311 of file variable.h.

◆ operator-() [2/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator- ( const variable< Scalar > & left,
const Scalar & right ) -> variable<Scalar>
inlinenodiscard

Subtract a variable from another variable.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Difference.

Definition at line 325 of file variable.h.

◆ operator-() [3/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator- ( const variable< Scalar > & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Subtract a variable from another variable.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Difference.

Definition at line 297 of file variable.h.

◆ operator/() [1/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator/ ( const Scalar & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Divide a variable from another variable.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Quotient.

Definition at line 395 of file variable.h.

◆ operator/() [2/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator/ ( const variable< Scalar > & left,
const Scalar & right ) -> variable<Scalar>
inlinenodiscard

Divide a variable from another variable.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Quotient.

Definition at line 409 of file variable.h.

◆ operator/() [3/3]

template<typename Scalar >
auto num_collect::auto_diff::backward::operator/ ( const variable< Scalar > & left,
const variable< Scalar > & right ) -> variable<Scalar>
inlinenodiscard

Divide a variable from another variable.

Template Parameters
ScalarType of scalars.
Parameters
[in]leftLeft-hand-side variable.
[in]rightRight-hand-side variable.
Returns
Quotient.

Definition at line 381 of file variable.h.

◆ sqrt()

template<typename Scalar >
auto num_collect::auto_diff::backward::sqrt ( const variable< Scalar > & x) -> variable<Scalar>
inlinenodiscard

Calculate square root.

Template Parameters
ScalarType of scalars.
Parameters
[in]xArgument.
Returns
Value.

Definition at line 88 of file variable_math.h.