MFEM
v4.4.0
Finite element discretization library
|
#include <fdual.hpp>
Public Member Functions | |
FDualNumber () | |
Standard constructor - both values are set to zero. More... | |
template<class fltyp , class = typename std::enable_if<std::is_arithmetic<fltyp>::value>::type> | |
FDualNumber (fltyp &f) | |
template<class fltyp , class = typename std::enable_if<std::is_arithmetic<fltyp>::value>::type> | |
FDualNumber (const fltyp &f) | |
FDualNumber (tbase &pr_, tbase &du_) | |
FDualNumber (const tbase &pr_, const tbase &du_) | |
FDualNumber (FDualNumber< tbase > &nm) | |
Standard constructor with user supplied dual number. More... | |
FDualNumber (const FDualNumber< tbase > &nm) | |
Standard constructor with user supplied dual number. More... | |
tbase | prim () const |
Return the real value of the dual number. More... | |
tbase | real () const |
Same as prim(). Return the real value of the dual number. More... | |
tbase | dual () const |
Return the dual value of the dual number. More... | |
void | set (const tbase &pr_, const tbase &du_) |
Set the primal and the dual values. More... | |
void | prim (const tbase &pr_) |
Set the primal value. More... | |
void | real (const tbase &pr_) |
Set the primal value. More... | |
void | dual (const tbase &du_) |
Set the dual value. More... | |
void | setReal (const tbase &pr_) |
Set the primal value. More... | |
void | setDual (const tbase &du_) |
Set the dual value. More... | |
FDualNumber< tbase > & | operator= (tbase sc_) |
operator = More... | |
FDualNumber< tbase > & | operator+= (tbase sc_) |
operator += More... | |
FDualNumber< tbase > & | operator-= (tbase sc_) |
operator -= More... | |
FDualNumber< tbase > & | operator*= (tbase sc_) |
operator *= More... | |
FDualNumber< tbase > & | operator/= (tbase sc_) |
operator /= More... | |
FDualNumber< tbase > & | operator= (const FDualNumber< tbase > &f) |
operator = More... | |
FDualNumber< tbase > & | operator+= (const FDualNumber< tbase > &f) |
operator += More... | |
FDualNumber< tbase > & | operator-= (const FDualNumber< tbase > &f) |
operator -= More... | |
FDualNumber< tbase > & | operator*= (const FDualNumber< tbase > &f) |
operator *= More... | |
FDualNumber< tbase > & | operator/= (const FDualNumber< tbase > &f_) |
operator /= More... | |
The FDualNumber template class provides forward automatic differentiation (see https://en.wikipedia.org/wiki/Automatic_differentiation) implementation based on dual numbers.
The derivative of an arbitrary function double f(double a) can be obtained by replacing the double type for the return value and the argument a with FDualNumber<double>, i.e., FDualNumber<double> f(FDualNumber<double> a). The derivative is evaluated automatically by calling the function r=f(a). The value of the function is stored in r.pr and the derivative in r.du. These can be extracted by the corresponding methods real()/prim() and dual().
Internally, the function f can be composed of standard functions predefined for FDualNumber type. These consist of a large set of functions replicating the functionality of the standard math library, i.e., sin, cos, exp, log, etc. New functions (non-member) can be equally added to the class. Example:
The real part of the return value consists of the standard real value of the function, i.e., cos(f.real()).
The dual part of the return value consists of the first derivative of the function with respect to the real part of the argument -sin(f.reaf) multiplied with the dual part of the argument f.dual().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |