- 3.0.1 core module.
ct::core::DerivativesCppad< IN_DIM, OUT_DIM > Class Template Reference

Jacobian using Auto-Diff Codegeneration. More...

#include <DerivativesCppad.h>

Inheritance diagram for ct::core::DerivativesCppad< IN_DIM, OUT_DIM >:
ct::core::Derivatives< IN_DIM, OUT_DIM, double >

Public Types

typedef Eigen::Matrix< AD_SCALAR, IN_DIM, 1 > IN_TYPE_AD
 function input vector type More...
 
typedef Eigen::Matrix< AD_SCALAR, OUT_DIM, 1 > OUT_TYPE_AD
 function output vector type More...
 
typedef Eigen::Matrix< double, IN_DIM, 1 > IN_TYPE_D
 function input vector type double More...
 
typedef Eigen::Matrix< double, OUT_DIM, 1 > OUT_TYPE_D
 function output vector type More...
 
typedef Eigen::Matrix< double, OUT_DIM, IN_DIM > JAC_TYPE_D
 Jacobian type. More...
 
typedef Eigen::Matrix< double, OUT_DIM, IN_DIM, Eigen::RowMajor > JAC_TYPE_ROW_MAJOR
 Jocobian type in row-major format. More...
 
typedef Eigen::Matrix< double, IN_DIM, IN_DIM > HES_TYPE_D
 
typedef Eigen::Matrix< double, IN_DIM, IN_DIM, Eigen::RowMajor > HES_TYPE_ROW_MAJOR
 
typedef std::function< OUT_TYPE_AD(const IN_TYPE_AD &)> FUN_TYPE_AD
 
typedef Derivatives< IN_DIM, OUT_DIM > DerivativesBase
 
- Public Types inherited from ct::core::Derivatives< IN_DIM, OUT_DIM, double >
typedef Eigen::Matrix< double, IN_DIM, 1 > IN_TYPE
 function input vector type More...
 
typedef Eigen::Matrix< double, OUT_DIM, 1 > OUT_TYPE
 function output vector type More...
 
typedef Eigen::Matrix< double, OUT_DIM, IN_DIM > JAC_TYPE
 
typedef Eigen::Matrix< double, IN_DIM, IN_DIM > HES_TYPE
 

Public Member Functions

 DerivativesCppad (FUN_TYPE_AD &f, int inputDim=IN_DIM, int outputDim=OUT_DIM)
 Constructs the derivatives for autodiff without codegeneration using a FUN_TYPE_AD function. More...
 
 DerivativesCppad (const DerivativesCppad &arg)
 copy constructor More...
 
void update (FUN_TYPE_AD &f, const size_t inputDim=IN_DIM, const size_t outputDim=OUT_DIM)
 update the Jacobian with a new function More...
 
virtual ~DerivativesCppad ()
 destructor More...
 
DerivativesCppadclone () const
 deep cloning of Jacobian More...
 
virtual OUT_TYPE_D forwardZero (const Eigen::VectorXd &x)
 Evaluates the method itself. More...
 
virtual JAC_TYPE_D jacobian (const Eigen::VectorXd &x)
 Evaluates the jacobian with respect to the input. More...
 
virtual void sparseJacobian (const Eigen::VectorXd &x, Eigen::VectorXd &jac, Eigen::VectorXi &iRow, Eigen::VectorXi &jCol)
 Returns the evaluated jacobian in sparse format. More...
 
virtual Eigen::VectorXd sparseJacobianValues (const Eigen::VectorXd &x)
 Returns the non zero values of the jacobian. More...
 
virtual HES_TYPE_D hessian (const Eigen::VectorXd &x, const Eigen::VectorXd &lambda)
 Evaluates the hessian (2nd order derivatives with respect to input) of the method. In case of a vector valued function, the method returns the weighted sum of the hessians with weights w. More...
 
virtual void sparseHessian (const Eigen::VectorXd &x, const Eigen::VectorXd &lambda, Eigen::VectorXd &hes, Eigen::VectorXi &iRow, Eigen::VectorXi &jCol)
 Returns the weighted sum of hessian of the problem in sparse format. More...
 
virtual Eigen::VectorXd sparseHessianValues (const Eigen::VectorXd &x, const Eigen::VectorXd &lambda)
 Returns the non zero elements of the hessian of the problem. More...
 
- Public Member Functions inherited from ct::core::Derivatives< IN_DIM, OUT_DIM, double >
 Derivatives ()
 
virtual ~Derivatives ()
 default destructor More...
 

Public Attributes

EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ADScalar AD_SCALAR
 

Detailed Description

template<int IN_DIM, int OUT_DIM>
class ct::core::DerivativesCppad< IN_DIM, OUT_DIM >

Jacobian using Auto-Diff Codegeneration.

Uses Auto-Diff code generation to compute the Jacobian $ J(x_s) = \frac{df}{dx} |_{x=x_s} $ of a regular vector-valued mathematical function $ y = f(x) $ .

x has IN_DIM dimension and y has OUT_DIM dimension. Thus, they can be scalar functions (IN_DIM = 1, OUT_DIM = 1), fixed or variable size (IN_DIM = -1, OUT_DIM = -1) functions.

Note
In fact, this class is called Jacobian but computes also zero order derivatives
Template Parameters
IN_DIMInput dimensionality of the function (use Eigen::Dynamic (-1) for dynamic size)
OUT_DIMOutput dimensionailty of the function (use Eigen::Dynamic (-1) for dynamic size)

Member Typedef Documentation

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<AD_SCALAR, IN_DIM, 1> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::IN_TYPE_AD

function input vector type

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<AD_SCALAR, OUT_DIM, 1> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::OUT_TYPE_AD

function output vector type

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<double, IN_DIM, 1> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::IN_TYPE_D

function input vector type double

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<double, OUT_DIM, 1> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::OUT_TYPE_D

function output vector type

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<double, OUT_DIM, IN_DIM> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::JAC_TYPE_D

Jacobian type.

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<double, OUT_DIM, IN_DIM, Eigen::RowMajor> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::JAC_TYPE_ROW_MAJOR

Jocobian type in row-major format.

template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<double, IN_DIM, IN_DIM> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::HES_TYPE_D
template<int IN_DIM, int OUT_DIM>
typedef Eigen::Matrix<double, IN_DIM, IN_DIM, Eigen::RowMajor> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::HES_TYPE_ROW_MAJOR
template<int IN_DIM, int OUT_DIM>
typedef std::function<OUT_TYPE_AD(const IN_TYPE_AD&)> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::FUN_TYPE_AD
template<int IN_DIM, int OUT_DIM>
typedef Derivatives<IN_DIM, OUT_DIM> ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::DerivativesBase

Constructor & Destructor Documentation

template<int IN_DIM, int OUT_DIM>
ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::DerivativesCppad ( FUN_TYPE_AD f,
int  inputDim = IN_DIM,
int  outputDim = OUT_DIM 
)
inline

Constructs the derivatives for autodiff without codegeneration using a FUN_TYPE_AD function.

Warning
If IN_DIM and/our OUT_DIM are set to dynamic (-1), then the actual dimensions of x and y have to be passed here.
Parameters
fThe function to be autodiffed
[in]inputDiminputDim input dimension, must be specified if template parameter IN_DIM is -1 (dynamic)
[in]outputDimoutputDim output dimension, must be specified if template parameter IN_DIM is -1 (dynamic)

References ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::update().

template<int IN_DIM, int OUT_DIM>
ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::DerivativesCppad ( const DerivativesCppad< IN_DIM, OUT_DIM > &  arg)
inline

copy constructor

template<int IN_DIM, int OUT_DIM>
virtual ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::~DerivativesCppad ( )
inlinevirtual

destructor

Member Function Documentation

template<int IN_DIM, int OUT_DIM>
void ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::update ( FUN_TYPE_AD f,
const size_t  inputDim = IN_DIM,
const size_t  outputDim = OUT_DIM 
)
inline

update the Jacobian with a new function

Warning
If IN_DIM and/our OUT_DIM are set to dynamic (-1), then the actual dimensions of x and y have to be passed here.
Parameters
fnew function to compute Jacobian of
inputDiminput dimension, must be specified if template parameter IN_DIM is -1 (dynamic)
outputDimoutput dimension, must be specified if template parameter IN_DIM is -1 (dynamic)

Referenced by ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::DerivativesCppad().

template<int IN_DIM, int OUT_DIM>
DerivativesCppad* ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::clone ( ) const
inlinevirtual

deep cloning of Jacobian

Implements ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual OUT_TYPE_D ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::forwardZero ( const Eigen::VectorXd &  x)
inlinevirtual

Evaluates the method itself.

Parameters
[in]xThe point of evaluation
Returns
The evalution of the method

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual JAC_TYPE_D ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::jacobian ( const Eigen::VectorXd &  x)
inlinevirtual

Evaluates the jacobian with respect to the input.

Parameters
[in]xThe point of evaluation
Returns
The evaluated jacobian

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual void ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::sparseJacobian ( const Eigen::VectorXd &  x,
Eigen::VectorXd &  jac,
Eigen::VectorXi &  iRow,
Eigen::VectorXi &  jCol 
)
inlinevirtual

Returns the evaluated jacobian in sparse format.

Parameters
[in]xThe point of evaluation
[out]jacThe non zero values of the jacobian
[out]iRowThe row indices of the non zero values
[out]jColThe column indices of the non zero values

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual Eigen::VectorXd ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::sparseJacobianValues ( const Eigen::VectorXd &  x)
inlinevirtual

Returns the non zero values of the jacobian.

Parameters
[in]xThe point of evaluation
Returns
The non zeros values of the jacobian

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual HES_TYPE_D ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::hessian ( const Eigen::VectorXd &  x,
const Eigen::VectorXd &  lambda 
)
inlinevirtual

Evaluates the hessian (2nd order derivatives with respect to input) of the method. In case of a vector valued function, the method returns the weighted sum of the hessians with weights w.

Parameters
[in]xThe point of evaluation
[in]lambdaThe weights of the sum
Returns
The evaluated hessian

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual void ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::sparseHessian ( const Eigen::VectorXd &  x,
const Eigen::VectorXd &  lambda,
Eigen::VectorXd &  hes,
Eigen::VectorXi &  iRow,
Eigen::VectorXi &  jCol 
)
inlinevirtual

Returns the weighted sum of hessian of the problem in sparse format.

Parameters
[in]xThe point of evaluation
[in]lambdaThe weights of the sum of the hessian
hesThe non zero values of the hessian
iRowThe row indices of the non zero values
jColThe column indices of the non zero values

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

template<int IN_DIM, int OUT_DIM>
virtual Eigen::VectorXd ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::sparseHessianValues ( const Eigen::VectorXd &  x,
const Eigen::VectorXd &  lambda 
)
inlinevirtual

Returns the non zero elements of the hessian of the problem.

Parameters
[in]xThe point of evaluation
[in]lambdaThe weights of the sum of the hessian
Returns
{ description_of_the_return_value }

Reimplemented from ct::core::Derivatives< IN_DIM, OUT_DIM, double >.

References x, and y.

Member Data Documentation

template<int IN_DIM, int OUT_DIM>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ADScalar ct::core::DerivativesCppad< IN_DIM, OUT_DIM >::AD_SCALAR

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