MFEM  v4.4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
mfem::ad::FDualNumber< tbase > Class Template Reference

#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...
 

Detailed Description

template<typename tbase>
class mfem::ad::FDualNumber< tbase >

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:

template<typename tbase>
inline FDualNumber<tbase> cos(const FDualNumber<tbase> &f)
{
return FDualNumber<tbase>(cos(f.real()), -f.dual() * sin(f.real()));
}

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().

Definition at line 55 of file fdual.hpp.

Constructor & Destructor Documentation

template<typename tbase>
mfem::ad::FDualNumber< tbase >::FDualNumber ( )
inline

Standard constructor - both values are set to zero.

Definition at line 65 of file fdual.hpp.

template<typename tbase>
template<class fltyp , class = typename std::enable_if<std::is_arithmetic<fltyp>::value>::type>
mfem::ad::FDualNumber< tbase >::FDualNumber ( fltyp &  f)
inline

The constructor utilized in nested definition of dual numbers. It is used for second and higher order derivatives.

Definition at line 71 of file fdual.hpp.

template<typename tbase>
template<class fltyp , class = typename std::enable_if<std::is_arithmetic<fltyp>::value>::type>
mfem::ad::FDualNumber< tbase >::FDualNumber ( const fltyp &  f)
inline

The constructor utilized in nested definition of dual numbers. It is used for second and higher order derivatives.

Definition at line 78 of file fdual.hpp.

template<typename tbase>
mfem::ad::FDualNumber< tbase >::FDualNumber ( tbase &  pr_,
tbase &  du_ 
)
inline

Standard constructor with user supplied input for both parts of the dual number.

Definition at line 83 of file fdual.hpp.

template<typename tbase>
mfem::ad::FDualNumber< tbase >::FDualNumber ( const tbase &  pr_,
const tbase &  du_ 
)
inline

Standard constructor with user supplied input for both parts of the dual number.

Definition at line 87 of file fdual.hpp.

template<typename tbase>
mfem::ad::FDualNumber< tbase >::FDualNumber ( FDualNumber< tbase > &  nm)
inline

Standard constructor with user supplied dual number.

Definition at line 90 of file fdual.hpp.

template<typename tbase>
mfem::ad::FDualNumber< tbase >::FDualNumber ( const FDualNumber< tbase > &  nm)
inline

Standard constructor with user supplied dual number.

Definition at line 93 of file fdual.hpp.

Member Function Documentation

template<typename tbase>
tbase mfem::ad::FDualNumber< tbase >::dual ( ) const
inline

Return the dual value of the dual number.

Definition at line 102 of file fdual.hpp.

template<typename tbase>
void mfem::ad::FDualNumber< tbase >::dual ( const tbase &  du_)
inline

Set the dual value.

Definition at line 118 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator*= ( tbase  sc_)
inline

operator *=

Definition at line 149 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator*= ( const FDualNumber< tbase > &  f)
inline

operator *=

Definition at line 189 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator+= ( tbase  sc_)
inline

operator +=

Definition at line 135 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator+= ( const FDualNumber< tbase > &  f)
inline

operator +=

Definition at line 173 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator-= ( tbase  sc_)
inline

operator -=

Definition at line 142 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator-= ( const FDualNumber< tbase > &  f)
inline

operator -=

Definition at line 181 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator/= ( tbase  sc_)
inline

operator /=

Definition at line 157 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator/= ( const FDualNumber< tbase > &  f_)
inline

operator /=

Definition at line 198 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator= ( tbase  sc_)
inline

operator =

Definition at line 127 of file fdual.hpp.

template<typename tbase>
FDualNumber<tbase>& mfem::ad::FDualNumber< tbase >::operator= ( const FDualNumber< tbase > &  f)
inline

operator =

Definition at line 165 of file fdual.hpp.

template<typename tbase>
tbase mfem::ad::FDualNumber< tbase >::prim ( ) const
inline

Return the real value of the dual number.

Definition at line 96 of file fdual.hpp.

template<typename tbase>
void mfem::ad::FDualNumber< tbase >::prim ( const tbase &  pr_)
inline

Set the primal value.

Definition at line 112 of file fdual.hpp.

template<typename tbase>
tbase mfem::ad::FDualNumber< tbase >::real ( ) const
inline

Same as prim(). Return the real value of the dual number.

Definition at line 99 of file fdual.hpp.

template<typename tbase>
void mfem::ad::FDualNumber< tbase >::real ( const tbase &  pr_)
inline

Set the primal value.

Definition at line 115 of file fdual.hpp.

template<typename tbase>
void mfem::ad::FDualNumber< tbase >::set ( const tbase &  pr_,
const tbase &  du_ 
)
inline

Set the primal and the dual values.

Definition at line 105 of file fdual.hpp.

template<typename tbase>
void mfem::ad::FDualNumber< tbase >::setDual ( const tbase &  du_)
inline

Set the dual value.

Definition at line 124 of file fdual.hpp.

template<typename tbase>
void mfem::ad::FDualNumber< tbase >::setReal ( const tbase &  pr_)
inline

Set the primal value.

Definition at line 121 of file fdual.hpp.


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