numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::auto_diff::forward::variable< Value, Diff > Class Template Reference

Class of variables in forward-mode automatic differentiation [17]. More...

#include <num_collect/auto_diff/forward/variable.h>

+ Collaboration diagram for num_collect::auto_diff::forward::variable< Value, Diff >:

Public Types

using diff_type = Diff
 Type of differential coefficients.
 
using value_type = Value
 Type of values.
 

Public Member Functions

 variable ()
 Constructor.
 
 variable (const value_type &value)
 Constructor.
 
template<typename DiffArg >
 variable (const value_type &value, DiffArg &&diff)
 Constructor.
 
auto diff () const -> const diff_type &
 Get the differential coefficients.
 
auto has_diff () const noexcept -> bool
 Get whether this variable has differential coefficients.
 
auto operator*= (const variable &right) -> variable &
 Multiply a variable.
 
auto operator+= (const variable &right) -> variable &
 Add a variable.
 
auto operator- () const -> variable
 Negate this variable.
 
auto operator-= (const variable &right) -> variable &
 Subtract a variable.
 
auto operator/= (const variable &right) -> variable &
 Divide by a variable.
 
auto value () const noexcept -> const value_type &
 Get the value.
 

Private Attributes

std::optional< diff_typediff_ {}
 Differential coefficients.
 
value_type value_
 Value.
 

Detailed Description

template<base::concepts::real_scalar Value, typename Diff = Value>
class num_collect::auto_diff::forward::variable< Value, Diff >

Class of variables in forward-mode automatic differentiation [17].

Template Parameters
ValueType of values.
DiffType of differential coefficients (scalars, vectors, or matrices).

Definition at line 43 of file variable.h.

Member Typedef Documentation

◆ diff_type

template<base::concepts::real_scalar Value, typename Diff = Value>
using num_collect::auto_diff::forward::variable< Value, Diff >::diff_type = Diff

Type of differential coefficients.

Definition at line 49 of file variable.h.

◆ value_type

template<base::concepts::real_scalar Value, typename Diff = Value>
using num_collect::auto_diff::forward::variable< Value, Diff >::value_type = Value

Type of values.

Definition at line 46 of file variable.h.

Constructor & Destructor Documentation

◆ variable() [1/3]

template<base::concepts::real_scalar Value, typename Diff = Value>
template<typename DiffArg >
num_collect::auto_diff::forward::variable< Value, Diff >::variable ( const value_type & value,
DiffArg && diff )
inline

Constructor.

Parameters
[in]valueValue.
[in]diffDifferential coefficients.

Definition at line 58 of file variable.h.

◆ variable() [2/3]

template<base::concepts::real_scalar Value, typename Diff = Value>
num_collect::auto_diff::forward::variable< Value, Diff >::variable ( const value_type & value)
inline

Constructor.

Parameters
[in]valueValue.

Definition at line 66 of file variable.h.

◆ variable() [3/3]

template<base::concepts::real_scalar Value, typename Diff = Value>
num_collect::auto_diff::forward::variable< Value, Diff >::variable ( )
inline

Constructor.

Definition at line 72 of file variable.h.

Member Function Documentation

◆ diff()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::diff ( ) const -> const diff_type&
inlinenodiscard

Get the differential coefficients.

Returns
Differential coefficients.

Definition at line 97 of file variable.h.

◆ has_diff()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::has_diff ( ) const -> bool
inlinenodiscardnoexcept

Get whether this variable has differential coefficients.

Returns
Whether this variable has differential coefficients.

Definition at line 88 of file variable.h.

◆ operator*=()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::operator*= ( const variable< Value, Diff > & right) -> variable&
inline

Multiply a variable.

Parameters
[in]rightRight-hand-side variable.
Returns
This.

Definition at line 158 of file variable.h.

◆ operator+=()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::operator+= ( const variable< Value, Diff > & right) -> variable&
inline

Add a variable.

Parameters
[in]rightRight-hand-side variable.
Returns
This.

Definition at line 122 of file variable.h.

◆ operator-()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::operator- ( ) const -> variable
inline

Negate this variable.

Returns
Negated variable.

Definition at line 109 of file variable.h.

◆ operator-=()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::operator-= ( const variable< Value, Diff > & right) -> variable&
inline

Subtract a variable.

Parameters
[in]rightRight-hand-side variable.
Returns
This.

Definition at line 140 of file variable.h.

◆ operator/=()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::operator/= ( const variable< Value, Diff > & right) -> variable&
inline

Divide by a variable.

Parameters
[in]rightRight-hand-side variable.
Returns
This.

Definition at line 181 of file variable.h.

◆ value()

template<base::concepts::real_scalar Value, typename Diff = Value>
auto num_collect::auto_diff::forward::variable< Value, Diff >::value ( ) const -> const value_type&
inlinenodiscardnoexcept

Get the value.

Returns
Value.

Definition at line 79 of file variable.h.

Member Data Documentation

◆ diff_

template<base::concepts::real_scalar Value, typename Diff = Value>
std::optional<diff_type> num_collect::auto_diff::forward::variable< Value, Diff >::diff_ {}
private

Differential coefficients.

Definition at line 202 of file variable.h.

◆ value_

template<base::concepts::real_scalar Value, typename Diff = Value>
value_type num_collect::auto_diff::forward::variable< Value, Diff >::value_
private

Value.

Definition at line 199 of file variable.h.


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