CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::ExternalFunction< T_Tape > Struct Template Reference

User-defined evaluation functions for the taping process. More...

#include <externalFunction.hpp>

Inheritance diagram for codi::ExternalFunction< T_Tape >:

Public Types

using CallFunction
 Call function definition.
 
using DeleteFunction = void (*)(Tape* tape, void* data)
 Delete function definition.
 
using Identifier = typename Tape::Identifier
 See FullTapeInterface.
 
using IterateIdsFunction
 Iterate ids function definition.
 
using IterCallback
 Callback for iterate ids function.
 
using Real = typename Tape::Real
 See FullTapeInterface.
 
using Tape
 See ExternalFunction.
 
using VectorAccess = VectorAccessInterface<Real, Identifier>
 

Public Member Functions

void deleteData (Tape *tape)
 Calls the delete function if not nullptr.
 
void evaluateForward (Tape *tape, VectorAccess *adjointInterface) const
 Calls the forward function if not nullptr, otherwise throws a CODI_EXCEPTION.
 
void evaluatePrimal (Tape *tape, VectorAccess *adjointInterface) const
 Calls the primal function if not nullptr, otherwise throws a CODI_EXCEPTION.
 
void evaluateReverse (Tape *tape, VectorAccess *adjointInterface) const
 Calls the reverse function if not nullptr, otherwise throws a CODI_EXCEPTION.
 
 ExternalFunction (CallFunction funcReverse, CallFunction funcForward, CallFunction funcPrimal, void *data, DeleteFunction funcDelete, IterateIdsFunction funcIterIn, IterateIdsFunction funcIterOut)
 Any arguments can be nullptr if not required.
 
void iterateInputs (Tape *tape, IterCallback func, void *userData) const
 Calls the iterate inputs function if not nullptr, otherwise throws a CODI_EXCEPTION.
 
void iterateOutputs (Tape *tape, IterCallback func, void *userData) const
 Calls the iterate inputs function if not nullptr, otherwise throws a CODI_EXCEPTION.
 
- Public Member Functions inherited from codi::ExternalFunctionInternalData
 ExternalFunctionInternalData ()
 Constructor.
 

Static Public Member Functions

static ExternalFunction create (CallFunction funcReverse, void *data, DeleteFunction funcDelete, CallFunction funcForward=nullptr, CallFunction funcPrimal=nullptr, IterateIdsFunction funcIterIn=nullptr, IterateIdsFunction funcIterOut=nullptr)
 Helper function for the creation of an ExternalFunction object.
 

Additional Inherited Members

- Protected Types inherited from codi::ExternalFunctionInternalData
using CallFunctionUntyped
 Call function definition.
 
using DeleteFunctionUntyped = void (*)(void* tape, void* data)
 Delete function definition.
 
using IterateIdsFunctionUntyped
 Iterate ids function definition.
 
using IterCallbackUntyped = void (*)(void* id, void* userData)
 Untyped callback function for id iteration.
 
- Protected Member Functions inherited from codi::ExternalFunctionInternalData
 ExternalFunctionInternalData (CallFunctionUntyped funcReverse, CallFunctionUntyped funcForward, CallFunctionUntyped funcPrimal, DeleteFunctionUntyped funcDelete, IterateIdsFunctionUntyped funcIterIn, IterateIdsFunctionUntyped funcIterOut, void *data)
 Constructor.
 
- Protected Attributes inherited from codi::ExternalFunctionInternalData
void * data
 User data pointer.
 
DeleteFunctionUntyped funcDelete
 User data deletion function pointer.
 
CallFunctionUntyped funcForward
 Forward evaluation function pointer.
 
IterateIdsFunctionUntyped funcIterIn
 Iterate over inputs.
 
IterateIdsFunctionUntyped funcIterOut
 Iterate over outputs.
 
CallFunctionUntyped funcPrimal
 Primal evaluation function pointer.
 
CallFunctionUntyped funcReverse
 Reverse evaluation function pointer.
 

Detailed Description

template<typename T_Tape>
struct codi::ExternalFunction< T_Tape >

User-defined evaluation functions for the taping process.

See ExternalFunctionTapeInterface for details.

The user can provide call functions for the reverse, forward and primal evaluation of a tape. These need to be of the type CallFunction which has the tree arguments:

  • tape: The type of the tape on which this object was registered with registerExternalFunction (ExternalFunctionTapeInterface)
  • data: User-provided data, type is known by the user.
  • adjointInterface: VectorAccessInterface instantiated with <typename Tape::Real, typename Tape::Identifier>

The tape pointer can be used for general access to the tape. For each access to the gradient data, the adjointInterface should be used. If no custom adjoint vectors are used in the application, then the tape pointer can also be used for the gradient data access.

The delete function is called when the entry of the tape for the external function is deleted.

Template Parameters
T_TapeThe associated tape type.

Member Typedef Documentation

◆ CallFunction

template<typename T_Tape>
using codi::ExternalFunction< T_Tape >::CallFunction
Initial value:
void (*)(Tape* tape, void* data,
VectorAccess* adjointInterface)
void * data
User data pointer.
Definition externalFunction.hpp:67
T_Tape Tape
See ExternalFunction.
Definition externalFunction.hpp:121
VectorAccessInterface< Real, Identifier > VectorAccess
Definition externalFunction.hpp:126

Call function definition.

◆ IterateIdsFunction

template<typename T_Tape>
using codi::ExternalFunction< T_Tape >::IterateIdsFunction
Initial value:
void (*)(Tape* tape, void* data, IterCallback callback,
void* userData)
typename LowLevelFunctionEntry< Tape, Real, Identifier >::IterCallback IterCallback
Callback for iterate ids function.
Definition externalFunction.hpp:128

Iterate ids function definition.

◆ IterCallback

template<typename T_Tape>
using codi::ExternalFunction< T_Tape >::IterCallback
Initial value:
void(*)(Identifier *id, void *userData) IterCallback
Callback function for the identifier iteration.
Definition lowLevelFunctionEntry.hpp:81

Callback for iterate ids function.

◆ Tape

template<typename T_Tape>
using codi::ExternalFunction< T_Tape >::Tape
Initial value:
T_Tape

See ExternalFunction.

◆ VectorAccess

template<typename T_Tape>
using codi::ExternalFunction< T_Tape >::VectorAccess = VectorAccessInterface<Real, Identifier>

Shortcut for VectorAccessInterface.


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