FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Analytic::AutoDerive< Function_, DataType_ > Class Template Reference

Auto-Derive function wrapper class template. More...

#include <auto_derive.hpp>

Inheritance diagram for FEAT::Analytic::AutoDerive< Function_, DataType_ >:

Classes

class  Evaluator
 

Public Types

typedef Function_::ImageType ImageType
 specify our image type More...
 

Public Member Functions

template<typename... Args_>
 AutoDerive (Args_ &&... args)
 Standard constructor. More...
 
void config_grad_extrapol (DataType_ initial_h, int max_steps)
 Configures the Gradient extrapolation scheme. More...
 
void config_hess_extrapol (DataType_ initial_h, int max_steps)
 Configures the Hessian extrapolation scheme. More...
 

Static Public Attributes

static constexpr bool can_grad = true
 we provide function gradients More...
 
static constexpr bool can_hess = true
 we provide function hessiants More...
 
static constexpr bool can_value = true
 our base class provides function values More...
 
static constexpr int domain_dim = Function_::domain_dim
 the input function must support value computation More...
 

Protected Attributes

DataType_ _init_grad_h
 initial h for gradient extrapolation More...
 
DataType_ _init_hess_h
 initial h for hessian extrapolation More...
 
int _max_grad_steps
 maximum number of gradient extrapolation steps More...
 
int _max_hess_steps
 maximum number of hessian extrapolation steps More...
 

Detailed Description

template<typename Function_, typename DataType_ = Real>
class FEAT::Analytic::AutoDerive< Function_, DataType_ >

Auto-Derive function wrapper class template.

This class extends another given function by adding the capability of computing gradients and hessians via Richardson extrapolation applied onto second-order central difference quotients. The initial 'h' for the difference quotient as well as the maximum number of extrapolation steps can be adjusted by using the config_grad_extrapol() and config_hess_extrapol() functions, respectively.

Note
If the original function already supports the computation of gradients and/or hessians, then the original function's computation is used instead of the extrapolation scheme. Example: If the input function supports computation of function values and gradients but not hessians, then this class template additionally provides the numerical computation of hessians, but uses the original function's evaluator for the computation of gradients.
Template Parameters
Function_The function to which the numerical computation of gradients and/or hessians is to be added. This function will be used as a base-class for this template instance.
DataType_The floating point data type to be used to store the values of the initial h.
Author
Peter Zajac

Definition at line 90 of file auto_derive.hpp.

Member Typedef Documentation

◆ ImageType

template<typename Function_ , typename DataType_ = Real>
typedef Function_::ImageType FEAT::Analytic::AutoDerive< Function_, DataType_ >::ImageType

specify our image type

Definition at line 101 of file auto_derive.hpp.

Constructor & Destructor Documentation

◆ AutoDerive()

template<typename Function_ , typename DataType_ = Real>
template<typename... Args_>
FEAT::Analytic::AutoDerive< Function_, DataType_ >::AutoDerive ( Args_ &&...  args)
inlineexplicit

Standard constructor.

This constructor configures the Richardson extrapolation steps for both the gradient and hessian evaluation to:

  • initial h = 1E-2
  • maximum steps = 10 which should be sufficient in most (non-exotic) cases.
Parameters
[in]argsThe set of arguments to be forwarded to the original function's constructor.

Definition at line 483 of file auto_derive.hpp.

Member Function Documentation

◆ config_grad_extrapol()

template<typename Function_ , typename DataType_ = Real>
void FEAT::Analytic::AutoDerive< Function_, DataType_ >::config_grad_extrapol ( DataType_  initial_h,
int  max_steps 
)
inline

Configures the Gradient extrapolation scheme.

This function configures the Richardson extrapolation scheme for the evaluation of function gradients (first-order derivatives).

Parameters
[in]initial_hThe initial h for the difference quotient. Must be > 0; default = 1E-2.
[in]max_stepsThe maximum number of Richardson extrapolation steps to be performed. Must be > 0; default = 10.

Definition at line 505 of file auto_derive.hpp.

References FEAT::Analytic::AutoDerive< Function_, DataType_ >::_init_grad_h, FEAT::Analytic::AutoDerive< Function_, DataType_ >::_max_grad_steps, and XASSERTM.

◆ config_hess_extrapol()

template<typename Function_ , typename DataType_ = Real>
void FEAT::Analytic::AutoDerive< Function_, DataType_ >::config_hess_extrapol ( DataType_  initial_h,
int  max_steps 
)
inline

Configures the Hessian extrapolation scheme.

This function configures the Richardson extrapolation scheme for the evaluation of function hessians (second-order derivatives).

Parameters
[in]initial_hThe initial h for the difference quotient. Must be > 0; default = 1E-2.
[in]max_stepsThe maximum number of Richardson extrapolation steps to be performed. Must be > 0; default = 10.

Definition at line 526 of file auto_derive.hpp.

References FEAT::Analytic::AutoDerive< Function_, DataType_ >::_init_hess_h, FEAT::Analytic::AutoDerive< Function_, DataType_ >::_max_hess_steps, and XASSERTM.

Member Data Documentation

◆ _init_grad_h

template<typename Function_ , typename DataType_ = Real>
DataType_ FEAT::Analytic::AutoDerive< Function_, DataType_ >::_init_grad_h
protected

initial h for gradient extrapolation

Definition at line 465 of file auto_derive.hpp.

Referenced by FEAT::Analytic::AutoDerive< Function_, DataType_ >::config_grad_extrapol().

◆ _init_hess_h

template<typename Function_ , typename DataType_ = Real>
DataType_ FEAT::Analytic::AutoDerive< Function_, DataType_ >::_init_hess_h
protected

initial h for hessian extrapolation

Definition at line 467 of file auto_derive.hpp.

Referenced by FEAT::Analytic::AutoDerive< Function_, DataType_ >::config_hess_extrapol().

◆ _max_grad_steps

template<typename Function_ , typename DataType_ = Real>
int FEAT::Analytic::AutoDerive< Function_, DataType_ >::_max_grad_steps
protected

maximum number of gradient extrapolation steps

Definition at line 461 of file auto_derive.hpp.

Referenced by FEAT::Analytic::AutoDerive< Function_, DataType_ >::config_grad_extrapol().

◆ _max_hess_steps

template<typename Function_ , typename DataType_ = Real>
int FEAT::Analytic::AutoDerive< Function_, DataType_ >::_max_hess_steps
protected

maximum number of hessian extrapolation steps

Definition at line 463 of file auto_derive.hpp.

Referenced by FEAT::Analytic::AutoDerive< Function_, DataType_ >::config_hess_extrapol().

◆ can_grad

template<typename Function_ , typename DataType_ = Real>
constexpr bool FEAT::Analytic::AutoDerive< Function_, DataType_ >::can_grad = true
staticconstexpr

we provide function gradients

Definition at line 106 of file auto_derive.hpp.

◆ can_hess

template<typename Function_ , typename DataType_ = Real>
constexpr bool FEAT::Analytic::AutoDerive< Function_, DataType_ >::can_hess = true
staticconstexpr

we provide function hessiants

Definition at line 108 of file auto_derive.hpp.

◆ can_value

template<typename Function_ , typename DataType_ = Real>
constexpr bool FEAT::Analytic::AutoDerive< Function_, DataType_ >::can_value = true
staticconstexpr

our base class provides function values

Definition at line 104 of file auto_derive.hpp.

◆ domain_dim

template<typename Function_ , typename DataType_ = Real>
constexpr int FEAT::Analytic::AutoDerive< Function_, DataType_ >::domain_dim = Function_::domain_dim
staticconstexpr

the input function must support value computation

specify our domain dimension

Definition at line 98 of file auto_derive.hpp.


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