CppADCodeGen  2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::FunctorGenericModel< Base > Class Template Referenceabstract
Inheritance diagram for CppAD::cg::FunctorGenericModel< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::FunctorGenericModel< Base >:
Collaboration graph

Public Member Functions

 FunctorGenericModel (const FunctorGenericModel &)=delete
 
FunctorGenericModeloperator= (const FunctorGenericModel &)=delete
 
const std::string & getName () const override
 
const std::vector< std::string > & getAtomicFunctionNames () override
 
bool addAtomicFunction (atomic_base< Base > &atomic) override
 
bool addExternalModel (GenericModel< Base > &atomic) override
 
bool isJacobianSparsityAvailable () override
 
std::vector< bool > JacobianSparsityBool () override
 
std::vector< std::set< size_t > > JacobianSparsitySet () override
 
void JacobianSparsity (std::vector< size_t > &equations, std::vector< size_t > &variables) override
 
bool isHessianSparsityAvailable () override
 
std::vector< bool > HessianSparsityBool () override
 
std::vector< std::set< size_t > > HessianSparsitySet () override
 
void HessianSparsity (std::vector< size_t > &rows, std::vector< size_t > &cols) override
 
bool isEquationHessianSparsityAvailable () override
 
std::vector< bool > HessianSparsityBool (size_t i) override
 
std::vector< std::set< size_t > > HessianSparsitySet (size_t i) override
 
void HessianSparsity (size_t i, std::vector< size_t > &rows, std::vector< size_t > &cols) override
 
size_t Domain () const override
 number of independent variables
 
size_t Range () const override
 number of dependent variables
 
bool isForwardZeroAvailable () override
 
void ForwardZero (ArrayView< const Base > x, ArrayView< Base > dep) override
 calculate the dependent values (zero order)
 
void ForwardZero (const std::vector< const Base * > &x, ArrayView< Base > dep) override
 
void ForwardZero (const CppAD::vector< bool > &vx, CppAD::vector< bool > &vy, ArrayView< const Base > tx, ArrayView< Base > ty) override
 
bool isJacobianAvailable () override
 
void Jacobian (ArrayView< const Base > x, ArrayView< Base > jac) override
 calculate entire Jacobian
 
bool isHessianAvailable () override
 
void Hessian (ArrayView< const Base > x, ArrayView< const Base > w, ArrayView< Base > hess) override
 calculate Hessian for one component of f
 
bool isForwardOneAvailable () override
 
void ForwardOne (ArrayView< const Base > tx, ArrayView< Base > ty) override
 
bool isSparseForwardOneAvailable () override
 
void ForwardOne (ArrayView< const Base > x, size_t tx1Nnz, const size_t idx[], const Base tx1[], ArrayView< Base > ty1) override
 
bool isReverseOneAvailable () override
 
void ReverseOne (ArrayView< const Base > tx, ArrayView< const Base > ty, ArrayView< Base > px, ArrayView< const Base > py) override
 
bool isSparseReverseOneAvailable () override
 
void ReverseOne (ArrayView< const Base > x, ArrayView< Base > px, size_t pyNnz, const size_t idx[], const Base py[]) override
 
bool isReverseTwoAvailable () override
 
void ReverseTwo (ArrayView< const Base > tx, ArrayView< const Base > ty, ArrayView< Base > px, ArrayView< const Base > py) override
 
bool isSparseReverseTwoAvailable () override
 
void ReverseTwo (ArrayView< const Base > x, size_t tx1Nnz, const size_t idx[], const Base tx1[], ArrayView< Base > px2, ArrayView< const Base > py2) override
 
bool isSparseJacobianAvailable () override
 
void SparseJacobian (ArrayView< const Base > x, ArrayView< Base > jac) override
 calculate sparse Jacobians
 
void SparseJacobian (const std::vector< Base > &x, std::vector< Base > &jac, std::vector< size_t > &row, std::vector< size_t > &col) override
 
void SparseJacobian (ArrayView< const Base > x, ArrayView< Base > jac, size_t const **row, size_t const **col) override
 
void SparseJacobian (const std::vector< const Base * > &x, ArrayView< Base > jac, size_t const **row, size_t const **col) override
 
bool isSparseHessianAvailable () override
 
void SparseHessian (ArrayView< const Base > x, ArrayView< const Base > w, ArrayView< Base > hess) override
 calculate sparse Hessians
 
void SparseHessian (const std::vector< Base > &x, const std::vector< Base > &w, std::vector< Base > &hess, std::vector< size_t > &row, std::vector< size_t > &col) override
 
void SparseHessian (ArrayView< const Base > x, ArrayView< const Base > w, ArrayView< Base > hess, size_t const **row, size_t const **col) override
 
void SparseHessian (const std::vector< const Base * > &x, ArrayView< const Base > w, ArrayView< Base > hess, size_t const **row, size_t const **col) override
 

Protected Member Functions

 FunctorGenericModel (std::string name)
 
virtual void init ()
 
virtual void * loadFunction (const std::string &functionName, bool required=true)=0
 
virtual void validate ()
 
virtual void loadFunctions ()
 
template<class VectorSet >
void loadSparsity (bool set_type, VectorSet &s, unsigned long nrows, unsigned long ncols, unsigned long const *rows, unsigned long const *cols, unsigned long nnz)
 
template<class VectorSet >
void loadSparsity (const std::set< size_t > &set_type, VectorSet &s, unsigned long nrows, unsigned long ncols, unsigned long const *rows, unsigned long const *cols, unsigned long nnz)
 
void createDenseFromSparse (const CppAD::vector< Base > &compressed, unsigned long nrows, unsigned long ncols, unsigned long const *rows, unsigned long const *cols, unsigned long nnz, ArrayView< Base > mat) const
 
virtual void modelLibraryClosed ()
 

Protected Attributes

bool _isLibraryReady
 
const std::string _name
 the model name
 
size_t _m
 
size_t _n
 
std::vector< const Base * > _in
 
std::vector< const Base * > _inHess
 
std::vector< Base * > _out
 
LangCAtomicFun _atomicFuncArg
 
std::vector< std::string > _atomicNames
 
std::vector< ExternalFunctionWrapper< Base > * > _atomic
 
size_t _missingAtomicFunctions
 
CppAD::vector< Base > _tx
 
CppAD::vector< Base > _ty
 
CppAD::vector< Base > _px
 
CppAD::vector< Base > _py
 
void(* _zero )(Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _forwardOne )(Base const tx[], Base ty[], LangCAtomicFun)
 
int(* _reverseOne )(Base const tx[], Base const ty[], Base px[], Base const py[], LangCAtomicFun)
 
int(* _reverseTwo )(Base const tx[], Base const ty[], Base px[], Base const py[], LangCAtomicFun)
 
void(* _jacobian )(Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _hessian )(Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _sparseForwardOne )(unsigned long, Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _sparseReverseOne )(unsigned long, Base const *const *, Base *const *, LangCAtomicFun)
 
int(* _sparseReverseTwo )(unsigned long, Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _sparseJacobian )(Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _sparseHessian )(Base const *const *, Base *const *, LangCAtomicFun)
 
void(* _forwardOneSparsity )(unsigned long, unsigned long const **, unsigned long *)
 
void(* _reverseOneSparsity )(unsigned long, unsigned long const **, unsigned long *)
 
void(* _reverseTwoSparsity )(unsigned long, unsigned long const **, unsigned long *)
 
void(* _jacobianSparsity )(unsigned long const **row, unsigned long const **col, unsigned long *nnz)
 
void(* _hessianSparsity )(unsigned long const **row, unsigned long const **col, unsigned long *nnz)
 
void(* _hessianSparsity2 )(unsigned long i, unsigned long const **row, unsigned long const **col, unsigned long *nnz)
 
void(* _atomicFunctions )(const char ***names, unsigned long *n)
 

Static Protected Attributes

static constexpr const char * ERROR_LIBRARY_NOT_READY
 

Friends

class AtomicExternalFunctionWrapper< Base >
 

Detailed Description

template<class Base>
class CppAD::cg::FunctorGenericModel< Base >

A model which can be accessed through function pointers. This class is not thread-safe and it should not be used simultaneously in different threads. Multiple instances of this class for the same model from the same model library object can be used simultaneously in different threads.

Author
Joao Leal

Definition at line 147 of file declare_cg.hpp.

Constructor & Destructor Documentation

◆ FunctorGenericModel()

template<class Base >
CppAD::cg::FunctorGenericModel< Base >::FunctorGenericModel ( std::string  name)
inlineexplicitprotected

Creates a new model

Parameters
nameThe model name

Definition at line 856 of file functor_generic_model.hpp.

Member Function Documentation

◆ loadFunctions()

template<class Base >
virtual void CppAD::cg::FunctorGenericModel< Base >::loadFunctions ( )
inlineprotectedvirtual

Prepare the atomic functions argument

Definition at line 927 of file functor_generic_model.hpp.

◆ validate()

template<class Base >
virtual void CppAD::cg::FunctorGenericModel< Base >::validate ( )
inlineprotectedvirtual

Check the data type

Definition at line 895 of file functor_generic_model.hpp.

Member Data Documentation

◆ ERROR_LIBRARY_NOT_READY

template<class Base >
constexpr const char* CppAD::cg::FunctorGenericModel< Base >::ERROR_LIBRARY_NOT_READY
staticconstexprprotected
Initial value:
= "The model library is not ready. The model library that"
" provided this model might have been closed or deleted."

Definition at line 36 of file functor_generic_model.hpp.


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