#include <numerical_differentiation.h>
Public Member Functions | |
NumericalDifferentiation () | |
virtual | ~NumericalDifferentiation () |
Destructor. More... | |
const Index & | get_precision_digits () const |
Enumeration of available methods for numerical differentiation. More... | |
const bool & | get_display () const |
Returns the flag used by this class for displaying or not displaying warnings. More... | |
void | set (const NumericalDifferentiation &) |
void | set_precision_digits (const Index &) |
void | set_display (const bool &) |
void | set_default () |
type | calculate_eta () const |
type | calculate_h (const type &) const |
Tensor< type, 1 > | calculate_h (const Tensor< type, 1 > &) const |
Tensor< type, 2 > | calculate_h (const Tensor< type, 2 > &) const |
Tensor< type, 4 > | calculate_h (const Tensor< type, 4 > &) const |
template<class T > | |
type | calculate_derivatives (const T &t, type(T::*f)(const type &) const, const type &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_derivatives (const T &t, Tensor< type, 1 >(T::*f)(const Tensor< type, 1 > &) const, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_derivatives (const T &t, Tensor< type, 2 >(T::*f)(const Tensor< type, 2 > &) const, const Tensor< type, 2 > &x) const |
template<class T > | |
Tensor< type, 4 > | calculate_derivatives (const T &t, Tensor< type, 4 >(T::*f)(const Tensor< type, 4 > &) const, const Tensor< type, 4 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_derivatives (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &) const, const Index &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_derivatives (const T &t, void(T::*f)(const Tensor< type, 2 > &, Tensor< type, 2 > &) const, const Index &dummy, const Tensor< type, 2 > &x) const |
template<class T > | |
Tensor< type, 4 > | calculate_derivatives (const T &t, void(T::*f)(const Tensor< type, 4 > &, Tensor< type, 4 > &) const, const Index &dummy, const Tensor< type, 4 > &x) const |
template<class T > | |
type | calculate_second_derivatives (const T &t, type(T::*f)(const type &) const, const type &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_second_derivatives (const T &t, Tensor< type, 1 >(T::*f)(const Tensor< type, 1 > &) const, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_second_derivatives (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &) const, const Index &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_gradient (const T &t, type(T::*f)(const Tensor< type, 1 > &) const, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_gradient (const T &t, type(T::*f)(const Tensor< type, 1 > &), const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_gradient (const T &t, type(T::*f)(const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Tensor< type, 1 > &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_gradient (const T &t, type(T::*f)(const Index &, const Tensor< type, 1 > &) const, const Index &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_gradient (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 2 > &) const, const Index &dummy, const Tensor< type, 2 > &x) const |
template<class T > | |
Tensor< type, 1 > | calculate_gradient (const T &t, type(T::*f)(const Tensor< Index, 1 > &, const Tensor< type, 1 > &) const, const Tensor< Index, 1 > &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_gradient_matrix (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 2 > &) const, const Index &integer, const Tensor< type, 2 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_hessian (const T &t, type(T::*f)(const Tensor< type, 1 > &) const, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_hessian (const T &t, type(T::*f)(const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Tensor< type, 1 > &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_hessian (const T &t, type(T::*f)(const Index &, const Tensor< type, 1 > &) const, const Index &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_Jacobian (const T &t, Tensor< type, 1 >(T::*f)(const Tensor< type, 1 > &) const, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_Jacobian (const T &t, Tensor< type, 1 >(T::*f)(const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Tensor< type, 1 > &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_Jacobian (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &) const, const Index &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_Jacobian (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Index &dummy_int, const Tensor< type, 1 > &dummy_vector, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< type, 2 > | calculate_Jacobian (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Index &, const Tensor< type, 1 > &) const, const Index &dummy_int_1, const Index &dummy_int_2, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< Tensor< type, 2 >, 1 > | calculate_hessian (const T &t, Tensor< type, 1 >(T::*f)(const Tensor< type, 1 > &) const, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< Tensor< type, 2 >, 1 > | calculate_hessian (const T &t, Tensor< type, 1 >(T::*f)(const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Tensor< type, 1 > &dummy_vector, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< Tensor< type, 2 >, 1 > | calculate_hessian (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &) const, const Index &dummy, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< Tensor< type, 2 >, 1 > | calculate_hessian (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Index &dummy_int, const Tensor< type, 1 > &dummy_vector, const Tensor< type, 1 > &x) const |
template<class T > | |
Tensor< Tensor< type, 2 >, 2 > | calculate_hessian_matrices (const T &t, Tensor< type, 1 >(T::*f)(const Index &, const Tensor< type, 1 > &, const Tensor< type, 1 > &) const, const Index &dummy_int, const Tensor< type, 1 > &dummy_vector, const Tensor< type, 1 > &x) const |
Private Attributes | |
Index | precision_digits |
Number of precision digits. More... | |
bool | display = true |
Flag for displaying warning messages from this class. More... | |
This class contains methods for numerical differentiation of functions. In particular it implements the forward and central differences methods for derivatives, Jacobians, hessians or hessian forms.
Definition at line 33 of file numerical_differentiation.h.
|
explicit |
Default constructor. It creates a numerical differentiation object with the default members.
Definition at line 17 of file numerical_differentiation.cpp.
|
virtual |
Destructor.
Definition at line 25 of file numerical_differentiation.cpp.
|
inline |
Returns the derivatives of a vector function using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Index&, const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 153 of file numerical_differentiation.h.
|
inline |
Returns the derivatives of a vector function using the central differences method.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 88 of file numerical_differentiation.h.
|
inline |
Definition at line 108 of file numerical_differentiation.h.
|
inline |
Definition at line 127 of file numerical_differentiation.h.
|
inline |
Definition at line 68 of file numerical_differentiation.h.
|
inline |
Definition at line 170 of file numerical_differentiation.h.
|
inline |
Definition at line 192 of file numerical_differentiation.h.
type calculate_eta | ( | ) | const |
Definition at line 78 of file numerical_differentiation.cpp.
|
inline |
Returns the gradient of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&) const. The first integer argument is used for the function definition, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 483 of file numerical_differentiation.h.
|
inline |
Returns the gradient of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&) const. The first integer argument is used for the function definition, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 441 of file numerical_differentiation.h.
|
inline |
Returns the gradient of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&) const. The first integer argument is used for the function definition, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 525 of file numerical_differentiation.h.
|
inline |
Returns the gradient of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 316 of file numerical_differentiation.h.
|
inline |
Returns the gradient of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 359 of file numerical_differentiation.h.
|
inline |
Returns the gradient of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first vector argument is dummy, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 400 of file numerical_differentiation.h.
|
inline |
Definition at line 558 of file numerical_differentiation.h.
Tensor< type, 1 > calculate_h | ( | const Tensor< type, 1 > & | x | ) | const |
Calculates a vector of step sizes for computing the derivatives, as a function of a vector of inputs.
x | Input vector. |
Definition at line 98 of file numerical_differentiation.cpp.
Tensor< type, 2 > calculate_h | ( | const Tensor< type, 2 > & | x | ) | const |
Calculates a tensor of step sizes for computing the derivatives, as a function of a vector of inputs.
x | Input tensor. |
Definition at line 118 of file numerical_differentiation.cpp.
Tensor< type, 4 > calculate_h | ( | const Tensor< type, 4 > & | x | ) | const |
Definition at line 139 of file numerical_differentiation.cpp.
type calculate_h | ( | const type & | x | ) | const |
Calculates a proper step size for computing the derivatives, as a function of the inputs point value.
x | Input value. |
Definition at line 87 of file numerical_differentiation.cpp.
|
inline |
Returns the hessian form, as a vector of matrices, of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Index&, const Tensor<type, 1>&) const. The first argument is dummy, differentiation is performed with respect to the second argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 1397 of file numerical_differentiation.h.
|
inline |
Returns the hessian form, as a vector of matrices, of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Index&, const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first and second arguments are dummy, differentiation is performed with respect to the third argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy_int | Dummy integer for the method prototype. |
dummy_vector | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 1513 of file numerical_differentiation.h.
|
inline |
Returns the hessian form, as a vector of matrices, of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 1164 of file numerical_differentiation.h.
|
inline |
Returns the hessian form, as a vector of matrices, of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Index&, const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first and second arguments are dummy, differentiation is performed with respect to the third argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy_vector | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 1280 of file numerical_differentiation.h.
|
inline |
Returns the hessian matrix of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&) const. The first integer argument is dummy, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 820 of file numerical_differentiation.h.
|
inline |
Returns the hessian matrix of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 601 of file numerical_differentiation.h.
|
inline |
Returns the hessian matrix of a function of several dimensions using the central differences method. The function to be differentiated is of the following form: type f(const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first vector argument is dummy, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 711 of file numerical_differentiation.h.
|
inline |
Returns the hessian matrices, as a matrix of matrices, of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Index&, const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first and second arguments are dummy, differentiation is performed with respect to the third argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy_int | Dummy integer for the method prototype. |
dummy_vector | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 1630 of file numerical_differentiation.h.
|
inline |
Returns the Jacobian matrix of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first and second arguments are dummy, differentiation is performed with respect to the third argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy_int_1 | Dummy integer for the method prototype. |
dummy_int_2 | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 1118 of file numerical_differentiation.h.
|
inline |
Returns the Jacobian matrix of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&) const. The first integer argument is dummy, differentiation is performed with respect to the second vector argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 1021 of file numerical_differentiation.h.
|
inline |
Returns the Jacobian matrix of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: type f(const Index&, const Tensor<type, 1>&, const Tensor<type, 1>&) const. The first and second arguments are dummy, differentiation is performed with respect to the third argument.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy_int | Dummy integer for the method prototype. |
dummy_vector | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 1069 of file numerical_differentiation.h.
|
inline |
Returns the Jacobian matrix of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Tensor<type, 1>&, const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 927 of file numerical_differentiation.h.
|
inline |
Returns the Jacobian matrix of a function of many inputs and many outputs using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Tensor<type, 1>&, const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy vector for the method prototype. |
x | Input vector. |
Definition at line 974 of file numerical_differentiation.h.
|
inline |
Returns the second derivatives of a vector function using the central differences method. The function to be differentiated is of the following form: Tensor<type, 1> f(const Index&, const Tensor<type, 1>&) const.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
dummy | Dummy integer for the method prototype. |
x | Input vector. |
Definition at line 285 of file numerical_differentiation.h.
|
inline |
Returns the second derivative of a vector function using the central differences method.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Input vector. |
Definition at line 255 of file numerical_differentiation.h.
|
inline |
Returns the second derivative of a function using the central differences method.
t | : Object constructor containing the member method to differentiate. |
f | Pointer to the member method. |
x | Differentiation point. |
Definition at line 221 of file numerical_differentiation.h.
const bool & get_display | ( | ) | const |
Returns the flag used by this class for displaying or not displaying warnings.
Definition at line 40 of file numerical_differentiation.cpp.
const Index & get_precision_digits | ( | ) | const |
Enumeration of available methods for numerical differentiation.
Returns the number of precision digits required for the derivatives.
Definition at line 32 of file numerical_differentiation.cpp.
void set_default | ( | ) |
Sets default values for the members of this object:
Definition at line 70 of file numerical_differentiation.cpp.
void set_display | ( | const bool & | new_display | ) |
Sets a new flag for displaying warnings from this class or not.
new_display | Display flag. |
Definition at line 48 of file numerical_differentiation.cpp.
void set_precision_digits | ( | const Index & | new_precision_digits | ) |
Sets a new number of precision digits required for the derivatives.
new_precision_digits | Number of precision digits. |
Definition at line 57 of file numerical_differentiation.cpp.
|
private |
Flag for displaying warning messages from this class.
Definition at line 1750 of file numerical_differentiation.h.
|
private |
Number of precision digits.
Definition at line 1746 of file numerical_differentiation.h.