CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::EvaluationHelper Struct Reference

Evaluate the primal, Jacobian and Hessian of function objects. More...

#include <evaluationHelper.hpp>

Public Types

template<typename Func >
using DefaultHandle = EvaluationHandleForward<Func, JacobianComputationType>
 
template<typename Func >
using DefaultHandle2nd = EvaluationHandleForward<Func, HessianComputationType>
 
template<typename Func , size_t m, size_t n>
using DefaultHandleFixed
 
template<typename Func , size_t m, size_t n>
using DefaultHandleFixed2nd
 
template<typename VecIn , typename VecOut >
using FunctorInterface = void (*)(VecIn const& x, VecOut& y)
 
using HessianComputationType = RealForwardGen<RealForwardVec<4>, Direction<RealForwardVec<4>, 4>>
 
using JacobianComputationType = RealForwardVec<4>
 

Static Public Member Functions

template<typename Type , typename Func >
static EvaluationHandle< Func, Type > createHandle (Func &func, size_t m, size_t n)
 Helper function for the creation of an evaluation handle with the specified CoDiPack type and a variable vector size.
 
template<typename Func >
static DefaultHandle< Func > createHandleDefault (Func &func, size_t m, size_t n)
 Helper function for the creation of a default first order evaluation handle with a variable vector size.
 
template<typename Func >
static DefaultHandle2nd< Func > createHandleDefault2nd (Func &func, size_t m, size_t n)
 Helper function for the creation of a default second order evaluation handle with a variable vector size.
 
template<size_t m, size_t n, typename Func >
static DefaultHandleFixed< Func, m, n > createHandleDefaultFixed (Func &func)
 Helper function for the creation of a default first order evaluation handle with a compile time vector size.
 
template<size_t m, size_t n, typename Func >
static DefaultHandleFixed2nd< Func, m, n > createHandleDefaultFixed2nd (Func &func)
 Helper function for the creation of a default second order evaluation handle with a compile time vector size.
 
template<typename Type , size_t m, size_t n, typename Func >
static EvaluationHandle< Func, Type, std::array< Type, n >, std::array< Type, m > > createHandleFixed (Func &func)
 Helper function for the creation of an evaluation handle with the specified CoDiPack type and a compile time vector size.
 
template<typename Type , typename InputStore , typename OutputStore , typename Func >
static EvaluationHandle< Func, Type, InputStore, OutputStore > createHandleFull (Func &func, size_t m, size_t n)
 Helper function for the creation of an evaluation handle with the specified CoDiPack type and storage types.
 
template<typename T = double>
static Hessian< T > createHessian (size_t m, size_t n)
 Create a Hessian with the given size.
 
template<size_t m, size_t n, typename T = double>
static Hessian< T, std::array< T, m *n *n > > createHessianFixed ()
 Create a Hessian with a compile time size.
 
template<typename T = double>
static Jacobian< T > createJacobian (size_t m, size_t n)
 Create a Jacobian with the given size.
 
template<size_t m, size_t n, typename T = double>
static Jacobian< T, std::array< T, m *n > > createJacobianFixed ()
 Create a Jacobian with a compile time size.
 
template<typename Handle , typename VecX , typename Hes >
static void evalHandleHessian (Handle &handle, VecX const &x, Hes &hes)
 Compute the Hessian of the function object stored in the handle.
 
template<typename Handle , typename VecX , typename Jac >
static void evalHandleJacobian (Handle &handle, VecX const &x, Jac &jac)
 Compute the Jacobian of the function object stored in the handle.
 
template<typename Handle , typename VecX , typename Jac , typename Hes >
static void evalHandleJacobianAndHessian (Handle &handle, VecX const &x, Jac &jac, Hes &hes)
 Compute the Hessian of the evaluation procedure in the function object.
 
template<typename Handle , typename VecX , typename VecY >
static void evalHandlePrimal (Handle &handle, VecX const &x, VecY &y)
 Perform a primal evaluation of the function object stored in the handle.
 
template<typename Handle , typename VecX , typename VecY , typename Hes >
static void evalHandlePrimalAndHessian (Handle &handle, VecX const &x, VecY &y, Hes &hes)
 Compute the primal result and Hessian of the function object.
 
template<typename Handle , typename VecX , typename VecY , typename Jac >
static void evalHandlePrimalAndJacobian (Handle &handle, VecX const &x, VecY &y, Jac &jac)
 Compute the primal result and Jacobian of the function object stored in the handle.
 
template<typename Handle , typename VecX , typename VecY , typename Jac , typename Hes >
static void evalHandlePrimalAndJacobianAndHessian (Handle &handle, VecX const &x, VecY &y, Jac &jac, Hes &hes)
 Compute the primal result, Jacobian, and Hessian of the function object.
 
template<typename Func , typename VecX , typename Hes >
static void evalHessian (Func &func, VecX const &x, size_t const ySize, Hes &hes)
 Compute the Hessian of the function object.
 
template<typename Func , typename VecX , typename Jac >
static void evalJacobian (Func &func, VecX const &x, size_t const ySize, Jac &jac)
 Compute the Jacobian of the function object.
 
template<typename Func , typename VecX , typename Jac , typename Hes >
static void evalJacobianAndHessian (Func &func, VecX const &x, size_t ySize, Jac &jac, Hes &hes)
 Compute the Jacobian and Hessian of the function object.
 
template<typename Func , typename VecX , typename VecY >
static void evalPrimal (Func &func, VecX const &x, VecY &y)
 Perform a primal evaluation of the function object with the default first order type.
 
template<typename Func , typename VecX , typename VecY , typename Hes >
static void evalPrimalAndHessian (Func &func, VecX const &x, VecY &y, Hes &hes)
 Compute the primal result and Hessian of the function object.
 
template<typename Func , typename VecX , typename VecY , typename Jac >
static void evalPrimalAndJacobian (Func &func, VecX const &x, VecY &y, Jac &jac)
 Compute the primal result and Jacobian of the function object.
 
template<typename Func , typename VecX , typename VecY , typename Jac , typename Hes >
static void evalPrimalAndJacobianAndHessian (Func &func, VecX const &x, VecY &y, Jac &jac, Hes &hes)
 Compute the primal result, Jacobian, and Hessian of the function object.
 

Detailed Description

Evaluate the primal, Jacobian and Hessian of function objects.

This helper provides the means to easily evaluate derivatives of arbitrary function objects. These function objects can be regular functions, lambda functions or structures where operator() is implemented.

The nomenclature and mathematical definitions for the function, the Jacobian, and the Hessian can be found in the Mathematical naming conventions documentation. Function arguments in this class follow the same naming scheme.

The algorithms will call the function objects with the vector of inputs and with the vector of outputs as arguments. The function object has to resemble the interface defined by FunctorInterface. An example function definition is:

void func1(std::vector<ADType> const& x, std::vector<ADType>& y) { ... }
// or
void func1(std::array<ADType, n> const& x, std::array<ADType, m>& y) { ... }

x is the vector of input values and y is the vector of output values. ADType is the chosen CoDiPack type for the function. For most users, this definition will be enough. For more general examples please go to section Advanced function object definitions.

The CoDiPack type can be any ActiveType type from CoDiPack, for example all types that are defined in codi.hpp. The evaluation helper provides the default CoDiPack type definitions EvaluationHelper::JacobianComputationType and EvaluationHelper::HessianComputationType. These two use the forward mode of algorithmic differentiation and are more appropriate if $ m $ and $ n $ are small. They can also be used if $ n $ is smaller than $ m $. For cases in in which the dimensions are larger and $ m $ is smaller than $ n $, the types codi::JacobianComputationType and codi::HessianComputationType can be used. They use the reverse AD mode for the computation. Please refer to Advanced function object definitions to see how these types can be used.

The most simple example of using the EvaluationHelper is:

#include <codi.hpp>
#include "outputHelpers.hpp"
void func(std::vector<Real> const& x, std::vector<Real>& y) {
y[0] = x[0] + x[1];
y[1] = x[0] - x[1];
y[2] = x[0] * x[1];
y[3] = x[0] / x[1];
}
int main(int nargs, char** args) {
std::vector<double> x = {3.0, 4.0};
std::vector<double> y(4);
auto jac = eh.createJacobian(4,2);
auto hes = eh.createHessian(4,2);
eh.evalPrimalAndJacobianAndHessian(func, x, y, jac, hes);
std::cout << "Jacobian:" << std::endl;
std::cout << jac << std::endl;
printHesForOutput("Hessian with respect to y[0]: ", hes, 0);
printHesForOutput("Hessian with respect to y[1]: ", hes, 1);
printHesForOutput("Hessian with respect to y[2]: ", hes, 2);
printHesForOutput("Hessian with respect to y[3]: ", hes, 3);
return 0;
}
static void evalPrimalAndJacobianAndHessian(Func &func, VecX const &x, VecY &y, Jac &jac, Hes &hes)
Compute the primal result, Jacobian, and Hessian of the function object.
Definition evaluationHelper.hpp:901
static Jacobian< T > createJacobian(size_t m, size_t n)
Create a Jacobian with the given size.
Definition evaluationHelper.hpp:749
static Hessian< T > createHessian(size_t m, size_t n)
Create a Hessian with the given size.
Definition evaluationHelper.hpp:774
RealForwardGen< RealForwardVec< 4 >, Direction< RealForwardVec< 4 >, 4 > > HessianComputationType
Definition evaluationHelper.hpp:578

Since we want to evaluate the Hessian, we use the Hessian type of the EvaluationHelper. The function is defined with this type and the standard vector classes. In the main function, we create the vector on which we want to call the function and then use the helper to create the storage for the Jacobian and Hessian. With $ jac(j,i) $ the values can be accessed. For the Hessian the values can be accessed with $ hes(j,i,k) $ where $ j $ is the output dimension and $ i $ as well as $ k $ are the input dimensions.

The evaluation helper class provides all combinations of evaluation choices, that is: evalPrimal(), evalJacobian(), evalHessian(), evalPrimalAndJacobian(), evalPrimalAndHessian(), evalJacobianAndHessian() and evalPrimalAndJacobianAndHessian(). Each of these functions uses the default CoDiPack types in the evaluation helper. In the cases where the primal is not stored, the user has to provide the number of output values manually.

If the EvaluationHelper is used to evaluate the same function several times, a higher performance can be achieved if a handle for the evaluation is created up front and then used several times. The above example with the handle creation would look like this:

auto handle = eh.createHandleDefaultFixed2nd<4, 2>(func);
eh.evalHandlePrimalAndJacobianAndHessian(handle, x, y, jac, hes);

The evaluation logic nearly stayed the same, but instead of providing the function to the evaluation routine, we create a handle up front and then use this handle in the evalHandle method. Each of the above mentioned eval routines has a corresponding evalHandle method.

Each of the create methods has similar create..Fixed method which uses the std::array type instead of the std::vector type for the data management. These methods can be used if the size is known at compile time. An example with these methods would be:

#include <codi.hpp>
#include "outputHelpers.hpp"
void func(std::array<Real, 2> const& x, std::array<Real, 4>& y) {
y[0] = x[0] + x[1];
y[1] = x[0] - x[1];
y[2] = x[0] * x[1];
y[3] = x[0] / x[1];
}
int main(int nargs, char** args) {
std::array<double, 2> x = {3.0, 4.0};
std::array<double, 4> y;
auto jac = eh.createJacobianFixed<4,2>();
auto hes = eh.createHessianFixed<4,2>();
auto handle = eh.createHandleDefaultFixed2nd<4, 2>(func);
eh.evalHandlePrimalAndJacobianAndHessian(handle, x, y, jac, hes);
std::cout << "Jacobian:" << std::endl;
std::cout << jac << std::endl;
printHesForOutput("Hessian with respect to y[0]: ", hes, 0);
printHesForOutput("Hessian with respect to y[1]: ", hes, 1);
printHesForOutput("Hessian with respect to y[2]: ", hes, 2);
printHesForOutput("Hessian with respect to y[3]: ", hes, 3);
return 0;
}
static Hessian< T, std::array< T, m *n *n > > createHessianFixed()
Create a Hessian with a compile time size.
Definition evaluationHelper.hpp:786
static Jacobian< T, std::array< T, m *n > > createJacobianFixed()
Create a Jacobian with a compile time size.
Definition evaluationHelper.hpp:761

Until now, the default definition for the used CoDiPack types have been used. In order to use an arbitrary CoDiPack type, the createHandle(), createHandleFixed(), and createHandleFull() methods can be used. The first one uses std::vectors for the storage, the second method std::array, and in the third the user can provide the storage class as a template parameter. The use case for the createHandle() method would look like this:

auto handle = eh.createHandle<codi::RealReverse>(func, 4, 2);
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52

Advanced function object definitions

The function object can also have a template argument for the evaluation type, e.g.:

struct Func {
template<typename T>
void operator()(std::vector<T> const& x, std::vector<T>& y);
};

There is also no need to specify std::vector as the array class, e.g.:

struct Func {
template<typename InVec, typename OutVec>
void operator()(InVec const& x, OutVec& y);
};

Member Typedef Documentation

◆ DefaultHandle

Type for the default handle for first order derivative computations with a variable vector size.

Template Parameters
FuncSee FunctorInterface.

◆ DefaultHandle2nd

Type for the default handle for second order derivative computations with a variable vector size.

Template Parameters
FuncSee FunctorInterface.

◆ DefaultHandleFixed

template<typename Func , size_t m, size_t n>
using codi::EvaluationHelper::DefaultHandleFixed
Initial value:
EvaluationHandleForward<Func, JacobianComputationType, std::array<JacobianComputationType, n>,
std::array<JacobianComputationType, m>>

Type for the default handle for first order derivative computations with a compile time vector size.

Template Parameters
FuncSee FunctorInterface
mThe size of the output vector.
nThe size of the input vector.

◆ DefaultHandleFixed2nd

template<typename Func , size_t m, size_t n>
using codi::EvaluationHelper::DefaultHandleFixed2nd
Initial value:
EvaluationHandleForward<Func, HessianComputationType, std::array<HessianComputationType, n>,
std::array<HessianComputationType, m>>

Type for the default handle for second order derivative computations with a compile time vector size.

Template Parameters
FuncSee FunctorInterface
mThe size of the output vector.
nThe size of the input vector.

◆ FunctorInterface

template<typename VecIn , typename VecOut >
using codi::EvaluationHelper::FunctorInterface = void (*)(VecIn const& x, VecOut& y)

Function object syntax for all Func template arguments.

Template Parameters
VecInUser defined (default: std::vector).
VecOutUser defined (default: std::vector).

◆ HessianComputationType

The default type used for second order derivative computation. It is defined as forward vector over forward vector AD mode of size 4 and 4. *‍/

◆ JacobianComputationType

The default type used for first order derivative computation. It is defined as forward vector AD mode of size 4.

Member Function Documentation

◆ createHandle()

template<typename Type , typename Func >
static EvaluationHandle< Func, Type > codi::EvaluationHelper::createHandle ( Func & func,
size_t m,
size_t n )
inlinestatic

Helper function for the creation of an evaluation handle with the specified CoDiPack type and a variable vector size.

The CoDiPack type can be an arbitrary one:

auto handle = codi::EvaluationHelper::createHandle<codi::RealReverse>(func, m, n);
Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]mThe size of the output vector.
[in]nThe size of the input vector.
Template Parameters
CoDiTypeAn arbitrary CoDiPack type based on ActiveType. All definitions in codi.hpp are supported. For user developed tapes, EvaluationHandle has to be specialized.
FuncSee FunctorInterface.

◆ createHandleDefault()

template<typename Func >
static DefaultHandle< Func > codi::EvaluationHelper::createHandleDefault ( Func & func,
size_t m,
size_t n )
inlinestatic

Helper function for the creation of a default first order evaluation handle with a variable vector size.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]mThe size of the output vector.
[in]nThe size of the input vector.
Template Parameters
FuncSee FunctorInterface.

◆ createHandleDefault2nd()

template<typename Func >
static DefaultHandle2nd< Func > codi::EvaluationHelper::createHandleDefault2nd ( Func & func,
size_t m,
size_t n )
inlinestatic

Helper function for the creation of a default second order evaluation handle with a variable vector size.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]mThe size of the output vector.
[in]nThe size of the input vector.
Template Parameters
FuncSee FunctorInterface.

◆ createHandleDefaultFixed()

template<size_t m, size_t n, typename Func >
static DefaultHandleFixed< Func, m, n > codi::EvaluationHelper::createHandleDefaultFixed ( Func & func)
inlinestatic

Helper function for the creation of a default first order evaluation handle with a compile time vector size.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
Template Parameters
mThe size of the output vector.
nThe size of the input vector.
FuncSee FunctorInterface.

◆ createHandleDefaultFixed2nd()

template<size_t m, size_t n, typename Func >
static DefaultHandleFixed2nd< Func, m, n > codi::EvaluationHelper::createHandleDefaultFixed2nd ( Func & func)
inlinestatic

Helper function for the creation of a default second order evaluation handle with a compile time vector size.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
Template Parameters
mThe size of the output vector.
nThe size of the input vector.
FuncSee FunctorInterface.

◆ createHandleFixed()

template<typename Type , size_t m, size_t n, typename Func >
static EvaluationHandle< Func, Type, std::array< Type, n >, std::array< Type, m > > codi::EvaluationHelper::createHandleFixed ( Func & func)
inlinestatic

Helper function for the creation of an evaluation handle with the specified CoDiPack type and a compile time vector size.

The CoDiPack type can be an arbitrary one:

auto handle = codi::EvaluationHelper::createHandleFixed<codi::RealReverse, m, n>(func);
Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
Template Parameters
CoDiTypeAn arbitrary CoDiPack type based on ActiveType. All definitions in codi.hpp are supported. For user developed tapes, EvaluationHandle has to be specialized.
FuncSee FunctorInterface.
mThe size of the output vector.
nThe size of the input vector.

◆ createHandleFull()

template<typename Type , typename InputStore , typename OutputStore , typename Func >
static EvaluationHandle< Func, Type, InputStore, OutputStore > codi::EvaluationHelper::createHandleFull ( Func & func,
size_t m,
size_t n )
inlinestatic

Helper function for the creation of an evaluation handle with the specified CoDiPack type and storage types.

The CoDiPack type can be an arbitrary one and the storage types must use it for their elements.

std::vector<codi::RealReverse>,
std::array<<codi::RealReverse, m>>(func, m, n);
RealReverseGen< double > RealReverse
Definition codi.hpp:120
static EvaluationHandle< Func, Type, InputStore, OutputStore > createHandleFull(Func &func, size_t m, size_t n)
Helper function for the creation of an evaluation handle with the specified CoDiPack type and storage...
Definition evaluationHelper.hpp:735
Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]mThe size of the output vector.
[in]nThe size of the input vector.
Template Parameters
CoDiTypeAn arbitrary CoDiPack type based on ActiveType. All definitions in codi.hpp are supported. For user developed tapes, EvaluationHandle has to be specialized.
FuncSee FunctorInterface
InputStoreThe storage type for vectors of input variables.
OutputStoreThe storage type for vectors of output variables.

◆ createHessian()

template<typename T = double>
static Hessian< T > codi::EvaluationHelper::createHessian ( size_t m,
size_t n )
inlinestatic

Create a Hessian with the given size.

Parameters
[in]mThe size of the output vector.
[in]nThe size of the input vector.
Template Parameters
TThe storage type of the Hessian.

◆ createHessianFixed()

template<size_t m, size_t n, typename T = double>
static Hessian< T, std::array< T, m *n *n > > codi::EvaluationHelper::createHessianFixed ( )
inlinestatic

Create a Hessian with a compile time size.

Template Parameters
TThe storage type of the Hessian.
mThe size of the output vector.
nThe size of the input vector.

◆ createJacobian()

template<typename T = double>
static Jacobian< T > codi::EvaluationHelper::createJacobian ( size_t m,
size_t n )
inlinestatic

Create a Jacobian with the given size.

Parameters
[in]mThe size of the output vector.
[in]nThe size of the input vector.
Template Parameters
TThe storage type of the Jacobian.

◆ createJacobianFixed()

template<size_t m, size_t n, typename T = double>
static Jacobian< T, std::array< T, m *n > > codi::EvaluationHelper::createJacobianFixed ( )
inlinestatic

Create a Jacobian with a compile time size.

Template Parameters
TThe storage type of the Jacobian.
mThe size of the output vector.
nThe size of the input vector.

◆ evalHandleHessian()

template<typename Handle , typename VecX , typename Hes >
static void codi::EvaluationHelper::evalHandleHessian ( Handle & handle,
VecX const & x,
Hes & hes )
inlinestatic

Compute the Hessian of the function object stored in the handle.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]hesThe Hessian in which the values are stored.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalHandleJacobian()

template<typename Handle , typename VecX , typename Jac >
static void codi::EvaluationHelper::evalHandleJacobian ( Handle & handle,
VecX const & x,
Jac & jac )
inlinestatic

Compute the Jacobian of the function object stored in the handle.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]jacThe Jacobian in which the values are stored.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.

◆ evalHandleJacobianAndHessian()

template<typename Handle , typename VecX , typename Jac , typename Hes >
static void codi::EvaluationHelper::evalHandleJacobianAndHessian ( Handle & handle,
VecX const & x,
Jac & jac,
Hes & hes )
inlinestatic

Compute the Hessian of the evaluation procedure in the function object.

In this method the Jacobian is also stored.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]jacThe Jacobian in which the values are stored.
[out]hesThe Hessian in which the values are stored.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalHandlePrimal()

template<typename Handle , typename VecX , typename VecY >
static void codi::EvaluationHelper::evalHandlePrimal ( Handle & handle,
VecX const & x,
VecY & y )
inlinestatic

Perform a primal evaluation of the function object stored in the handle.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.

◆ evalHandlePrimalAndHessian()

template<typename Handle , typename VecX , typename VecY , typename Hes >
static void codi::EvaluationHelper::evalHandlePrimalAndHessian ( Handle & handle,
VecX const & x,
VecY & y,
Hes & hes )
inlinestatic

Compute the primal result and Hessian of the function object.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
[out]hesThe Hessian in which the values are stored.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalHandlePrimalAndJacobian()

template<typename Handle , typename VecX , typename VecY , typename Jac >
static void codi::EvaluationHelper::evalHandlePrimalAndJacobian ( Handle & handle,
VecX const & x,
VecY & y,
Jac & jac )
inlinestatic

Compute the primal result and Jacobian of the function object stored in the handle.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
[out]jacThe Jacobian in which the values are stored.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.

◆ evalHandlePrimalAndJacobianAndHessian()

template<typename Handle , typename VecX , typename VecY , typename Jac , typename Hes >
static void codi::EvaluationHelper::evalHandlePrimalAndJacobianAndHessian ( Handle & handle,
VecX const & x,
VecY & y,
Jac & jac,
Hes & hes )
inlinestatic

Compute the primal result, Jacobian, and Hessian of the function object.

Parameters
[in]handleThe handle with all data for the evaluation.
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
[out]jacThe Jacobian in which the values are stored.
[out]hesThe Hessian in which the values are stored.
Template Parameters
HandleThe handle type for the data storage and the evaluation.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalHessian()

template<typename Func , typename VecX , typename Hes >
static void codi::EvaluationHelper::evalHessian ( Func & func,
VecX const & x,
size_t const ySize,
Hes & hes )
inlinestatic

Compute the Hessian of the function object.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[in]ySizeThe size of the output vector.
[out]hesThe Hessian in which the values are stored.
Template Parameters
FuncSee FunctorInterface.
VecXThe vector type for the input values. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalJacobian()

template<typename Func , typename VecX , typename Jac >
static void codi::EvaluationHelper::evalJacobian ( Func & func,
VecX const & x,
size_t const ySize,
Jac & jac )
inlinestatic

Compute the Jacobian of the function object.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[in]ySizeThe size of the output vector.
[out]jacThe Jacobian in which the values are stored.
Template Parameters
FuncSee FunctorInterface.
VecXThe vector type for the input values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.

◆ evalJacobianAndHessian()

template<typename Func , typename VecX , typename Jac , typename Hes >
static void codi::EvaluationHelper::evalJacobianAndHessian ( Func & func,
VecX const & x,
size_t ySize,
Jac & jac,
Hes & hes )
inlinestatic

Compute the Jacobian and Hessian of the function object.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[in]ySizeThe size of the output vector.
[out]jacThe Jacobian in which the values are stored.
[out]hesThe Hessian in which the values are stored.
Template Parameters
FuncSee FunctorInterface
VecXThe vector type for the input values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalPrimal()

template<typename Func , typename VecX , typename VecY >
static void codi::EvaluationHelper::evalPrimal ( Func & func,
VecX const & x,
VecY & y )
inlinestatic

Perform a primal evaluation of the function object with the default first order type.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
Template Parameters
FuncSee FunctorInterface.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.

◆ evalPrimalAndHessian()

template<typename Func , typename VecX , typename VecY , typename Hes >
static void codi::EvaluationHelper::evalPrimalAndHessian ( Func & func,
VecX const & x,
VecY & y,
Hes & hes )
inlinestatic

Compute the primal result and Hessian of the function object.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
[out]hesThe Hessian in which the values are stored.
Template Parameters
FuncSee FunctorInterface.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

◆ evalPrimalAndJacobian()

template<typename Func , typename VecX , typename VecY , typename Jac >
static void codi::EvaluationHelper::evalPrimalAndJacobian ( Func & func,
VecX const & x,
VecY & y,
Jac & jac )
inlinestatic

Compute the primal result and Jacobian of the function object.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
[out]jacThe Jacobian in which the values are stored.
Template Parameters
FuncSee FunctorInterface.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.

◆ evalPrimalAndJacobianAndHessian()

template<typename Func , typename VecX , typename VecY , typename Jac , typename Hes >
static void codi::EvaluationHelper::evalPrimalAndJacobianAndHessian ( Func & func,
VecX const & x,
VecY & y,
Jac & jac,
Hes & hes )
inlinestatic

Compute the primal result, Jacobian, and Hessian of the function object.

Parameters
[in]funcThe function object for the evaluation (see FunctorInterface).
[in]xThe vector with the primal values where the function object is evaluated.
[out]yThe vector for the result of the primal function evaluation. The vector must have the correct size allocated.
[out]jacThe Jacobian in which the values are stored.
[out]hesThe Hessian in which the values are stored.
Template Parameters
FuncSee FunctorInterface.
VecXThe vector type for the input values. Element type is e.g. double.
VecYThe vector type for the output values. Element type is e.g. double.
JacThe storage type of the Jacobian. Element type is e.g. double.
HesThe storage type of the Hessian. Element type is e.g. double.

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