CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs > Struct Template Reference

Represents an operator or function with an arbitrary number of arguments in the expression tree. More...

#include <computeExpression.hpp>

Inheritance diagram for codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >:

Public Types

using ArgExprs = std::tuple<T_ArgExprs...>
 See ComputeExpression.
 
using ArgReals = std::tuple<typename T_ArgExprs::Real...>
 Real type of all arguments.
 
using ArgStores = TupleMemory<typename T_ArgExprs::StoreAs...>
 Store type of all arguments.
 
using ArgStoresTypes
 Store types of all arguments as regular tuple.
 
template<typename T>
using Operation = T_Operation<T>
 See ComputeExpression.
 
using Real = T_Real
 See ComputeExpression.
 
- Public Types inherited from codi::ExpressionInterface< T_Real, ComputeExpression< T_Real, T_Operation, T_ArgExprs... > >
using ADLogic
 AD logic that governs the expression. Needs to be the same for all inputs of the expression.
 
using Impl
 See ExpressionInterface.
 
using Real
 See ExpressionInterface.
 
using StoreAs
 Defines how this expression is stored in an expression tree.
 
- Public Types inherited from codi::NodeInterface< ComputeExpression< T_Real, T_Operation, T_ArgExprs... > >
using Impl
 See NodeInterface.
 
- Public Types inherited from codi::ExpressionMemberOperations< T_Real, ComputeExpression< T_Real, T_Operation, T_ArgExprs... > >
using Impl
 See ExpressionMemberOperations.
 
using Real
 See ExpressionMemberOperations.
 

Public Member Functions

inlineexplicit ComputeExpression (ExpressionInterface< typename T_ArgExprs::Real, T_ArgExprs > const &... args)
 Constructor.
 
 inlineComputeExpression (ComputeExpression const &v)=default
 Constructor.
 
- Public Member Functions inherited from codi::ExpressionInterface< T_Real, ComputeExpression< T_Real, T_Operation, T_ArgExprs... > >
inlineImpl const & cast () const
 Cast to the implementation.
 
 ExpressionInterface ()=default
 Constructor.
 
 ExpressionInterface (ExpressionInterface const &)=default
 Constructor.
 
inlineReal const getValue () const
 Compute the primal value that is usually evaluated by the statement/expression.
 
inlineauto applyTangent (Tangent const &tangent) const
 
inlineauto applyAdjoint (Adjoint const &adjoint) const
 
- Public Member Functions inherited from codi::NodeInterface< ComputeExpression< T_Real, T_Operation, T_ArgExprs... > >
inlineImpl const & cast () const
 Cast to the implementation.
 
char const & getLink () const
 an expression.
 

Public Attributes

ArgStores args
 Tuple of all expression arguments.
 
Real result
 Precomputed result.
 

Implementation of ExpressionInterface

using StoreAs = ComputeExpression
 See ExpressionInterface.
 
using ADLogic
 See ExpressionInterface.
 
inlinestd::string getMathRep () const
 Get the math symbol of the operation. E.g. + for operators and pow() for functions.
 
inlineReal const & getValue () const
 Compute the primal value that is usually evaluated by the statement/expression.
 
template<size_t argNumber, typename Tangent>
inlineReal applyTangent (Tangent const &tangent) const
 
template<size_t argNumber, typename Adjoint>
inlineauto applyAdjoint (Adjoint const &adjoint) const
 

Implementation of NodeInterface

static size_t constexpr LinkCount = std::tuple_size<ArgReals>::value
 See NodeInterface.
 
template<size_t argNumber>
inlinestd::tuple_element_t< argNumber, ArgStoresTypes > const & getLink () const
 an expression.
 

Additional Inherited Members

static size_t constexpr LinkCount
 handle the expression as a leaf node.
 
- Protected Member Functions inherited from codi::ExpressionMemberOperations< T_Real, ComputeExpression< T_Real, T_Operation, T_ArgExprs... > >
inlineImpl const & cast () const
 Cast to implementation.
 

Detailed Description

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
struct codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >

Represents an operator or function with an arbitrary number of arguments in the expression tree.

See Expression design documentation for details about the expression system in CoDiPack.

Template Parameters
T_RealOriginal primal value of the statement/expression.
T_OperationThe logic for computing the primal value and Jacobians. Must implement BinaryOperation.
T_ArgExprsThe ExpressionInterface types of the arguments.

Member Typedef Documentation

◆ ADLogic

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
using codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::ADLogic
Initial value:
typename T_ArgExprs::ADLogic...>::ADLogic
ValidateADLogicImpl< Results... > ValidateADLogic
Validates if the AD logic of an arbitrary amount of expressions are the same or compatible....
Definition expressionTraits.hpp:119
typename ExpressionTraits::ValidateADLogic< typename T_ArgExprs::ADLogic... >::ADLogic ADLogic
See ExpressionInterface.
Definition computeExpression.hpp:409

See ExpressionInterface.

◆ ArgStoresTypes

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
using codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::ArgStoresTypes
Initial value:
std::tuple<typename T_ArgExprs::StoreAs...>

Store types of all arguments as regular tuple.

Member Function Documentation

◆ applyAdjoint()

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
template<size_t argNumber, typename Adjoint>
inlineauto codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::applyAdjoint ( Adjoint const & adjoint) const
inline

Apply the AD reverse mode on the expression with respect to the given parameter.

This is just the local reverse mode application and not the one for the whole expression tree.

Does not need to be implemented for expressions with NodeInterface::LinkCount = 0 .

Returns
The type is the Real type of the selected argument or a compatible vector type. E.g. for Real f(complex<Real>, Real) the type with argNumber=0 is complex<Real> or Direction<complex<Real>> , with argNumber=1 it is Real or Direction<Real> .
Template Parameters
AdjointThe type of the result or a compatible vector type. E.g. Real or Direction<Real>.

Forwards to the operator implementation.

◆ applyTangent()

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
template<size_t argNumber, typename Tangent>
inlineReal codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::applyTangent ( Tangent const & tangent) const
inline

Apply the AD forward mode on the expression with respect to the given parameter.

This is just the local forward mode application and not the one for the whole expression tree.

Does not need to be implemented for expressions with NodeInterface::LinkCount = 0 .

Returns
The type of the result or a compatible vector type. E.g. Real or Direction<Real>.
Template Parameters
TangentThe type is the Real type of the selected argument or a compatible vector type. E.g. for Real f(complex<Real>, Real) the type with argNumber=0 is complex<Real> or Direction<complex<Real>> , with argNumber=1 it is Real or Direction<Real> .

Forwards to the operator implementation.

◆ getLink()

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
template<size_t argNumber>
inlinestd::tuple_element_t< argNumber, ArgStoresTypes > const & codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::getLink ( ) const
inline

an expression.

Get the argument for the specific link. Usually

◆ getMathRep()

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
inlinestd::string codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::getMathRep ( ) const
inline

Get the math symbol of the operation. E.g. + for operators and pow() for functions.

◆ getValue()

template<typename T_Real, template< typename > class T_Operation, typename... T_ArgExprs>
inlineReal const & codi::ComputeExpression< T_Real, T_Operation, T_ArgExprs >::getValue ( ) const
inline

Compute the primal value that is usually evaluated by the statement/expression.


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