CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
CppAD::cg::CGAtomicFun< Base > Class Template Reference

#include <atomic_fun.hpp>

Inheritance diagram for CppAD::cg::CGAtomicFun< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::CGAtomicFun< Base >:
Collaboration graph

Public Types

using Super = BaseAbstractAtomicFun< Base >
 
using Arg = Argument< Base >
 

Public Member Functions

 CGAtomicFun (atomic_base< Base > &atomicFun, const CppAD::vector< Base > &xSparsity, bool standAlone=false)
 
 CGAtomicFun (atomic_base< Base > &atomicFun, ArrayView< const Base > xSparsity, bool standAlone=false)
 
 CGAtomicFun (atomic_base< Base > &atomicFun, ArrayView< const CppAD::AD< Base > > xSparsity, bool standAlone=false)
 
template<class ADVector >
void operator() (const ADVector &ax, ADVector &ay, size_t id=0)
 
bool for_sparse_jac (size_t q, const CppAD::vector< std::set< size_t > > &r, CppAD::vector< std::set< size_t > > &s, const CppAD::vector< CGB > &x) override
 
bool for_sparse_jac (size_t q, const CppAD::vector< std::set< size_t > > &r, CppAD::vector< std::set< size_t > > &s) override
 
bool for_sparse_jac (size_t q, const CppAD::vector< bool > &r, CppAD::vector< bool > &s, const CppAD::vector< CGB > &x) override
 
bool for_sparse_jac (size_t q, const CppAD::vector< bool > &r, CppAD::vector< bool > &s) override
 
bool rev_sparse_jac (size_t q, const CppAD::vector< std::set< size_t > > &rt, CppAD::vector< std::set< size_t > > &st, const CppAD::vector< CGB > &x) override
 
bool rev_sparse_jac (size_t q, const CppAD::vector< std::set< size_t > > &rt, CppAD::vector< std::set< size_t > > &st) override
 
bool rev_sparse_jac (size_t q, const CppAD::vector< bool > &rt, CppAD::vector< bool > &st, const CppAD::vector< CGB > &x) override
 
bool rev_sparse_jac (size_t q, const CppAD::vector< bool > &rt, CppAD::vector< bool > &st) override
 
bool rev_sparse_hes (const CppAD::vector< bool > &vx, const CppAD::vector< bool > &s, CppAD::vector< bool > &t, size_t q, const CppAD::vector< std::set< size_t > > &r, const CppAD::vector< std::set< size_t > > &u, CppAD::vector< std::set< size_t > > &v, const CppAD::vector< CGB > &x) override
 
bool rev_sparse_hes (const CppAD::vector< bool > &vx, const CppAD::vector< bool > &s, CppAD::vector< bool > &t, size_t q, const CppAD::vector< std::set< size_t > > &r, const CppAD::vector< std::set< size_t > > &u, CppAD::vector< std::set< size_t > > &v) override
 
bool rev_sparse_hes (const CppAD::vector< bool > &vx, const CppAD::vector< bool > &s, CppAD::vector< bool > &t, size_t q, const CppAD::vector< bool > &r, const CppAD::vector< bool > &u, CppAD::vector< bool > &v, const CppAD::vector< CGB > &x) override
 
bool rev_sparse_hes (const CppAD::vector< bool > &vx, const CppAD::vector< bool > &s, CppAD::vector< bool > &t, size_t q, const CppAD::vector< bool > &r, const CppAD::vector< bool > &u, CppAD::vector< bool > &v) override
 
size_t getId () const
 
bool isStandAlone () const
 
bool forward (size_t q, size_t p, const CppAD::vector< bool > &vx, CppAD::vector< bool > &vy, const CppAD::vector< CGB > &tx, CppAD::vector< CGB > &ty) override
 
bool reverse (size_t p, const CppAD::vector< CGB > &tx, const CppAD::vector< CGB > &ty, CppAD::vector< CGB > &px, const CppAD::vector< CGB > &py) override
 
virtual CppAD::vector< std::set< size_t > > jacobianForwardSparsitySet (size_t m, const CppAD::vector< CGB > &x)
 
virtual CppAD::vector< std::set< size_t > > jacobianReverseSparsitySet (size_t m, const CppAD::vector< CGB > &x)
 
virtual CppAD::vector< std::set< size_t > > hessianSparsitySet (size_t m, const CppAD::vector< CGB > &x)
 
virtual CppAD::vector< std::set< size_t > > hessianSparsitySet (const CppAD::vector< bool > &s, const CppAD::vector< CGB > &x)
 

Static Public Member Functions

static size_t createNewAtomicFunctionID ()
 

Protected Types

using CGB = CG< Base >
 

Protected Member Functions

void zeroOrderDependency (const CppAD::vector< bool > &vx, CppAD::vector< bool > &vy, const CppAD::vector< CGB > &x) override
 
bool atomicForward (size_t q, size_t p, const CppAD::vector< Base > &tx, CppAD::vector< Base > &ty) override
 
bool atomicReverse (size_t p, const CppAD::vector< Base > &tx, const CppAD::vector< Base > &ty, CppAD::vector< Base > &px, const CppAD::vector< Base > &py) override
 

Static Protected Member Functions

static void appendAsArguments (typename std::vector< Arg >::iterator begin, const CppAD::vector< CGB > &tx)
 
static OperationNode< Base > * makeArray (CodeHandler< Base > &handler, const CppAD::vector< CGB > &tx)
 
static OperationNode< Base > * makeArray (CodeHandler< Base > &handler, const CppAD::vector< CGB > &tx, size_t p, size_t k)
 
static OperationNode< Base > * makeZeroArray (CodeHandler< Base > &handler, size_t size)
 
static OperationNode< Base > * makeEmptySparseArray (CodeHandler< Base > &handler, size_t size)
 
static OperationNode< Base > * makeSparseArray (CodeHandler< Base > &handler, const CppAD::vector< CGB > &py, size_t p, size_t k)
 
static bool isParameters (const CppAD::vector< CGB > &tx)
 
static bool isValuesDefined (const CppAD::vector< CGB > &tx)
 

Protected Attributes

atomic_base< Base > & atomicFun_
 
const CppAD::vector< Base > xSparsity_
 
const size_t id_
 
bool standAlone_
 

Detailed Description

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

An atomic function for source code generation

Author
Joao Leal

Definition at line 28 of file atomic_fun.hpp.

Member Typedef Documentation

◆ Arg

template<class Base >
using CppAD::cg::CGAbstractAtomicFun< Base >::Arg = Argument<Base>
inherited

Definition at line 32 of file abstract_atomic_fun.hpp.

◆ CGB

template<class Base >
using CppAD::cg::CGAtomicFun< Base >::CGB = CG<Base>
protected

Definition at line 30 of file atomic_fun.hpp.

◆ Super

template<class Base >
using CppAD::cg::CGAbstractAtomicFun< Base >::Super = BaseAbstractAtomicFun<Base>
inherited

Definition at line 30 of file abstract_atomic_fun.hpp.

Constructor & Destructor Documentation

◆ CGAtomicFun() [1/3]

template<class Base >
CppAD::cg::CGAtomicFun< Base >::CGAtomicFun ( atomic_base< Base > &  atomicFun,
const CppAD::vector< Base > &  xSparsity,
bool  standAlone = false 
)
inline

Creates a new atomic function wrapper that is responsible for defining the dependencies to calls of a user atomic function.

Parameters
atomicFunThe atomic function to the called by the compiled source.
xSparsityDefault independent vector used to determine sparsity patterns when the provided independent vector using the CG data type does not have all values defined.
standAloneWhether or not forward and reverse function calls do not require the Taylor coefficients for the dependent variables (ty) and the previous evaluation of other forward/reverse modes.

Definition at line 50 of file atomic_fun.hpp.

◆ CGAtomicFun() [2/3]

template<class Base >
CppAD::cg::CGAtomicFun< Base >::CGAtomicFun ( atomic_base< Base > &  atomicFun,
ArrayView< const Base >  xSparsity,
bool  standAlone = false 
)
inline

Definition at line 58 of file atomic_fun.hpp.

◆ CGAtomicFun() [3/3]

template<class Base >
CppAD::cg::CGAtomicFun< Base >::CGAtomicFun ( atomic_base< Base > &  atomicFun,
ArrayView< const CppAD::AD< Base > >  xSparsity,
bool  standAlone = false 
)
inline

Definition at line 64 of file atomic_fun.hpp.

Member Function Documentation

◆ appendAsArguments()

template<class Base >
static void CppAD::cg::BaseAbstractAtomicFun< Base >::appendAsArguments ( typename std::vector< Arg >::iterator  begin,
const CppAD::vector< CGB > &  tx 
)
inlinestaticprotectedinherited

Definition at line 58 of file base_abstract_atomic_fun.hpp.

◆ atomicForward()

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::atomicForward ( size_t  q,
size_t  p,
const CppAD::vector< Base > &  tx,
CppAD::vector< Base > &  ty 
)
inlineoverrideprotectedvirtual

Used to evaluate function values and forward mode function values and derivatives.

Parameters
qLowest order for this forward mode calculation.
pHighest order for this forward mode calculation.
vxIf size not zero, which components of x are variables
vyIf size not zero, which components of y are variables
txTaylor coefficients corresponding to x for this calculation
tyTaylor coefficient corresponding to y for this calculation
Returns
true on success, false otherwise

Implements CppAD::cg::CGAbstractAtomicFun< Base >.

Definition at line 202 of file atomic_fun.hpp.

◆ atomicReverse()

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::atomicReverse ( size_t  p,
const CppAD::vector< Base > &  tx,
const CppAD::vector< Base > &  ty,
CppAD::vector< Base > &  px,
const CppAD::vector< Base > &  py 
)
inlineoverrideprotectedvirtual

Used to evaluate reverse mode function derivatives.

Parameters
pHighest order for this forward mode calculation.
txTaylor coefficients corresponding to x for this calculation
tyTaylor coefficient corresponding to y for this calculation
pxPartials w.r.t. the x Taylor coefficients.
pyPartials w.r.t. the y Taylor coefficients
Returns
true on success, false otherwise

Implements CppAD::cg::CGAbstractAtomicFun< Base >.

Definition at line 210 of file atomic_fun.hpp.

◆ createNewAtomicFunctionID()

template<class Base >
static size_t CppAD::cg::CGAbstractAtomicFun< Base >::createNewAtomicFunctionID ( )
inlinestaticinherited

Uses an internal counter to produce IDs for atomic functions.

Definition at line 495 of file abstract_atomic_fun.hpp.

◆ for_sparse_jac() [1/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::for_sparse_jac ( size_t  q,
const CppAD::vector< bool > &  r,
CppAD::vector< bool > &  s 
)
inlineoverride

Definition at line 99 of file atomic_fun.hpp.

◆ for_sparse_jac() [2/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::for_sparse_jac ( size_t  q,
const CppAD::vector< bool > &  r,
CppAD::vector< bool > &  s,
const CppAD::vector< CGB > &  x 
)
inlineoverride

Definition at line 92 of file atomic_fun.hpp.

◆ for_sparse_jac() [3/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::for_sparse_jac ( size_t  q,
const CppAD::vector< std::set< size_t > > &  r,
CppAD::vector< std::set< size_t > > &  s 
)
inlineoverride

Definition at line 86 of file atomic_fun.hpp.

◆ for_sparse_jac() [4/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::for_sparse_jac ( size_t  q,
const CppAD::vector< std::set< size_t > > &  r,
CppAD::vector< std::set< size_t > > &  s,
const CppAD::vector< CGB > &  x 
)
inlineoverride

Definition at line 79 of file atomic_fun.hpp.

◆ forward()

template<class Base >
bool CppAD::cg::CGAbstractAtomicFun< Base >::forward ( size_t  q,
size_t  p,
const CppAD::vector< bool > &  vx,
CppAD::vector< bool > &  vy,
const CppAD::vector< CGB > &  tx,
CppAD::vector< CGB > &  ty 
)
inlineoverrideinherited

Use the jacobian sparsity to determine which elements will always be zero

Definition at line 94 of file abstract_atomic_fun.hpp.

◆ getId()

template<class Base >
size_t CppAD::cg::CGAbstractAtomicFun< Base >::getId ( ) const
inlineinherited

Provides a unique identifier for this atomic function type.

Returns
a unique identifier ID

Definition at line 81 of file abstract_atomic_fun.hpp.

◆ hessianSparsitySet() [1/2]

template<class Base >
virtual CppAD::vector< std::set< size_t > > CppAD::cg::CGAbstractAtomicFun< Base >::hessianSparsitySet ( const CppAD::vector< bool > &  s,
const CppAD::vector< CGB > &  x 
)
inlinevirtualinherited

Determine the sparsity pattern p for Hessian of w^T F

Definition at line 462 of file abstract_atomic_fun.hpp.

◆ hessianSparsitySet() [2/2]

template<class Base >
virtual CppAD::vector< std::set< size_t > > CppAD::cg::CGAbstractAtomicFun< Base >::hessianSparsitySet ( size_t  m,
const CppAD::vector< CGB > &  x 
)
inlinevirtualinherited

Definition at line 453 of file abstract_atomic_fun.hpp.

◆ isParameters()

template<class Base >
static bool CppAD::cg::BaseAbstractAtomicFun< Base >::isParameters ( const CppAD::vector< CGB > &  tx)
inlinestaticprotectedinherited

Definition at line 131 of file base_abstract_atomic_fun.hpp.

◆ isStandAlone()

template<class Base >
bool CppAD::cg::CGAbstractAtomicFun< Base >::isStandAlone ( ) const
inlineinherited

Whether or not forward and reverse function calls do not require the Taylor coefficients for the dependent variables (ty) and any previous evaluation of other forward/reverse modes.

Definition at line 90 of file abstract_atomic_fun.hpp.

◆ isValuesDefined()

template<class Base >
static bool CppAD::cg::BaseAbstractAtomicFun< Base >::isValuesDefined ( const CppAD::vector< CGB > &  tx)
inlinestaticprotectedinherited

Definition at line 140 of file base_abstract_atomic_fun.hpp.

◆ jacobianForwardSparsitySet()

template<class Base >
virtual CppAD::vector< std::set< size_t > > CppAD::cg::CGAbstractAtomicFun< Base >::jacobianForwardSparsitySet ( size_t  m,
const CppAD::vector< CGB > &  x 
)
inlinevirtualinherited

Definition at line 419 of file abstract_atomic_fun.hpp.

◆ jacobianReverseSparsitySet()

template<class Base >
virtual CppAD::vector< std::set< size_t > > CppAD::cg::CGAbstractAtomicFun< Base >::jacobianReverseSparsitySet ( size_t  m,
const CppAD::vector< CGB > &  x 
)
inlinevirtualinherited

Definition at line 435 of file abstract_atomic_fun.hpp.

◆ makeArray() [1/2]

template<class Base >
static OperationNode< Base > * CppAD::cg::BaseAbstractAtomicFun< Base >::makeArray ( CodeHandler< Base > &  handler,
const CppAD::vector< CGB > &  tx 
)
inlinestaticprotectedinherited

Definition at line 71 of file base_abstract_atomic_fun.hpp.

◆ makeArray() [2/2]

template<class Base >
static OperationNode< Base > * CppAD::cg::BaseAbstractAtomicFun< Base >::makeArray ( CodeHandler< Base > &  handler,
const CppAD::vector< CGB > &  tx,
size_t  p,
size_t  k 
)
inlinestaticprotectedinherited

Definition at line 79 of file base_abstract_atomic_fun.hpp.

◆ makeEmptySparseArray()

template<class Base >
static OperationNode< Base > * CppAD::cg::BaseAbstractAtomicFun< Base >::makeEmptySparseArray ( CodeHandler< Base > &  handler,
size_t  size 
)
inlinestaticprotectedinherited

Definition at line 101 of file base_abstract_atomic_fun.hpp.

◆ makeSparseArray()

template<class Base >
static OperationNode< Base > * CppAD::cg::BaseAbstractAtomicFun< Base >::makeSparseArray ( CodeHandler< Base > &  handler,
const CppAD::vector< CGB > &  py,
size_t  p,
size_t  k 
)
inlinestaticprotectedinherited

Definition at line 106 of file base_abstract_atomic_fun.hpp.

◆ makeZeroArray()

template<class Base >
static OperationNode< Base > * CppAD::cg::BaseAbstractAtomicFun< Base >::makeZeroArray ( CodeHandler< Base > &  handler,
size_t  size 
)
inlinestaticprotectedinherited

Definition at line 93 of file base_abstract_atomic_fun.hpp.

◆ operator()()

template<class Base >
template<class ADVector >
void CppAD::cg::CGAtomicFun< Base >::operator() ( const ADVector &  ax,
ADVector &  ay,
size_t  id = 0 
)
inline

Definition at line 73 of file atomic_fun.hpp.

◆ rev_sparse_hes() [1/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_hes ( const CppAD::vector< bool > &  vx,
const CppAD::vector< bool > &  s,
CppAD::vector< bool > &  t,
size_t  q,
const CppAD::vector< bool > &  r,
const CppAD::vector< bool > &  u,
CppAD::vector< bool > &  v 
)
inlineoverride

Definition at line 163 of file atomic_fun.hpp.

◆ rev_sparse_hes() [2/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_hes ( const CppAD::vector< bool > &  vx,
const CppAD::vector< bool > &  s,
CppAD::vector< bool > &  t,
size_t  q,
const CppAD::vector< bool > &  r,
const CppAD::vector< bool > &  u,
CppAD::vector< bool > &  v,
const CppAD::vector< CGB > &  x 
)
inlineoverride

Definition at line 152 of file atomic_fun.hpp.

◆ rev_sparse_hes() [3/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_hes ( const CppAD::vector< bool > &  vx,
const CppAD::vector< bool > &  s,
CppAD::vector< bool > &  t,
size_t  q,
const CppAD::vector< std::set< size_t > > &  r,
const CppAD::vector< std::set< size_t > > &  u,
CppAD::vector< std::set< size_t > > &  v 
)
inlineoverride

Definition at line 142 of file atomic_fun.hpp.

◆ rev_sparse_hes() [4/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_hes ( const CppAD::vector< bool > &  vx,
const CppAD::vector< bool > &  s,
CppAD::vector< bool > &  t,
size_t  q,
const CppAD::vector< std::set< size_t > > &  r,
const CppAD::vector< std::set< size_t > > &  u,
CppAD::vector< std::set< size_t > > &  v,
const CppAD::vector< CGB > &  x 
)
inlineoverride

Definition at line 131 of file atomic_fun.hpp.

◆ rev_sparse_jac() [1/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_jac ( size_t  q,
const CppAD::vector< bool > &  rt,
CppAD::vector< bool > &  st 
)
inlineoverride

Definition at line 125 of file atomic_fun.hpp.

◆ rev_sparse_jac() [2/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_jac ( size_t  q,
const CppAD::vector< bool > &  rt,
CppAD::vector< bool > &  st,
const CppAD::vector< CGB > &  x 
)
inlineoverride

Definition at line 118 of file atomic_fun.hpp.

◆ rev_sparse_jac() [3/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_jac ( size_t  q,
const CppAD::vector< std::set< size_t > > &  rt,
CppAD::vector< std::set< size_t > > &  st 
)
inlineoverride

Definition at line 112 of file atomic_fun.hpp.

◆ rev_sparse_jac() [4/4]

template<class Base >
bool CppAD::cg::CGAtomicFun< Base >::rev_sparse_jac ( size_t  q,
const CppAD::vector< std::set< size_t > > &  rt,
CppAD::vector< std::set< size_t > > &  st,
const CppAD::vector< CGB > &  x 
)
inlineoverride

Definition at line 105 of file atomic_fun.hpp.

◆ reverse()

template<class Base >
bool CppAD::cg::CGAbstractAtomicFun< Base >::reverse ( size_t  p,
const CppAD::vector< CGB > &  tx,
const CppAD::vector< CGB > &  ty,
CppAD::vector< CGB > &  px,
const CppAD::vector< CGB > &  py 
)
inlineoverrideinherited

Use the Jacobian sparsity to determine which elements will always be zero

Use the Hessian sparsity to determine which elements will always be zero

Definition at line 233 of file abstract_atomic_fun.hpp.

◆ zeroOrderDependency()

template<class Base >
void CppAD::cg::CGAtomicFun< Base >::zeroOrderDependency ( const CppAD::vector< bool > &  vx,
CppAD::vector< bool > &  vy,
const CppAD::vector< CGB > &  x 
)
inlineoverrideprotectedvirtual

Implements CppAD::cg::CGAbstractAtomicFun< Base >.

Definition at line 175 of file atomic_fun.hpp.

Member Data Documentation

◆ atomicFun_

template<class Base >
atomic_base<Base>& CppAD::cg::CGAtomicFun< Base >::atomicFun_
protected

Definition at line 32 of file atomic_fun.hpp.

◆ id_

template<class Base >
const size_t CppAD::cg::CGAbstractAtomicFun< Base >::id_
protectedinherited

◆ standAlone_

template<class Base >
bool CppAD::cg::CGAbstractAtomicFun< Base >::standAlone_
protectedinherited

Whether or not forward and reverse function calls do not require the Taylor coefficients for the dependent variables (ty) and any previous evaluation of other forward/reverse modes.

Definition at line 43 of file abstract_atomic_fun.hpp.

Referenced by CppAD::cg::CGAbstractAtomicFun< Base >::isStandAlone(), and CppAD::cg::CGAbstractAtomicFun< Base >::reverse().

◆ xSparsity_

template<class Base >
const CppAD::vector<Base> CppAD::cg::CGAtomicFun< Base >::xSparsity_
protected

Definition at line 33 of file atomic_fun.hpp.


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