Reference documentation for deal.II version 9.6.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType > Class Template Reference

#include <deal.II/differentiation/sd/symengine_number_visitor_internal.h>

Public Member Functions

 CSEDictionaryVisitor ()=default
 
virtual ~CSEDictionaryVisitor ()=default
 
void init (const types::symbol_vector &dependent_functions)
 
void call (ReturnType *output_values, const types::symbol_vector &independent_symbols, const ReturnType *substitution_values)
 
template<class Archive >
void save (Archive &archive, const unsigned int version) const
 
template<class Archive >
void load (Archive &archive, const unsigned int version)
 
template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 
template<typename StreamType >
void print (StreamType &stream) const
 
bool executed () const
 
unsigned int n_intermediate_expressions () const
 
unsigned int n_reduced_expressions () const
 

Protected Member Functions

void init (const SymEngine::vec_basic &dependent_functions)
 
void call (ReturnType *output_values, const SymEngine::vec_basic &independent_symbols, const ReturnType *substitution_values)
 

Private Types

using symbol_vector_pair
 

Private Attributes

symbol_vector_pair intermediate_symbols_exprs
 
types::symbol_vector reduced_exprs
 

Detailed Description

template<typename ReturnType, typename ExpressionType>
class Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >

A class that implements common subexpression elimination for dictionary visitor classes.

It is intended that this class only be used in conjunction with the DictionarySubstitutionVisitor.

Definition at line 54 of file symengine_number_visitor_internal.h.

Member Typedef Documentation

◆ symbol_vector_pair

template<typename ReturnType , typename ExpressionType >
using Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::symbol_vector_pair
private
Initial value:
std::vector<std::pair<SD::Expression, SD::Expression>>

Definition at line 56 of file symengine_number_visitor_internal.h.

Constructor & Destructor Documentation

◆ CSEDictionaryVisitor()

template<typename ReturnType , typename ExpressionType >
Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::CSEDictionaryVisitor ( )
default

◆ ~CSEDictionaryVisitor()

template<typename ReturnType , typename ExpressionType >
virtual Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::~CSEDictionaryVisitor ( )
virtualdefault

Member Function Documentation

◆ init() [1/2]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::init ( const types::symbol_vector & dependent_functions)

Initialize and perform common subexpression elimination.

Here we build the reduced expressions for the dependent_functions as well as a list of intermediate, repeating symbolic expressions that are extracted dependent_functions. This operation leads to the elimination of repeated expressions, so they only have to be evaluated once.

Parameters
dependent_functionsA vector of expressions that represent the dependent functions that CSE will be performed on.

◆ call() [1/2]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::call ( ReturnType * output_values,
const types::symbol_vector & independent_symbols,
const ReturnType * substitution_values )

Evaluate the (reduced) dependent functions using the common subexpressions generated during the call to init().

The output_values are the numerical result of substituting each of the substitution_values for their corresponding entry of the independent_symbols. Specifically, we first calculate the numerical values of each reduced subexpression, and feed those into a reduced equivalent of the dependent variables. The result of this is then written into the output_values array.

Parameters
[out]output_valuesA pointer to the first element in an array of type ReturnType. After this call, the underlying array will hold the numerical result of substituting the substitution_values into the pre-registered dependent functions.
[in]independent_symbolsA vector of symbols that represent the independent variables that are arguments to the previously defined dependent functions.
[in]substitution_valuesA pointer to the first element in an array of type ReturnType. Each entry in this array stores the numerical value that an independent variable is to take for the purpose of value substitution.
Note
It is expected that both the output_values and substitution_values arrays be correctly dimensioned, as there is no range checking performed on these data structures. The output_values array should have the same number of elements as the dependent functions first passed to this class in the call to init(). Similarly, the substitution_values array should have the same number of elements as the independent_symbols vector has.
It is expected that there be a 1-1 correspondence between the entries in independent_symbols and substitution_values. This is not checked within this function, so it is up to the user to ensure that the relationships between the independent variables and their numerical value be correctly set up and maintained.

◆ save()

template<typename ReturnType , typename ExpressionType >
template<class Archive >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::save ( Archive & archive,
const unsigned int version ) const

Write the data of this object to a stream for the purpose of serialization using the BOOST serialization library.

◆ load()

template<typename ReturnType , typename ExpressionType >
template<class Archive >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::load ( Archive & archive,
const unsigned int version )

Read the data for this object from a stream for the purpose of serialization using the BOOST serialization library.

◆ serialize()

template<typename ReturnType , typename ExpressionType >
template<class Archive >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::serialize ( Archive & archive,
const unsigned int version )

Write and read the data of this object from a stream for the purpose of serialization using the BOOST serialization library.

◆ print()

template<typename ReturnType , typename ExpressionType >
template<typename StreamType >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::print ( StreamType & stream) const

Print all of the intermediate reduced expressions, as well as the final reduced expressions for dependent variables to the stream.

◆ executed()

template<typename ReturnType , typename ExpressionType >
bool Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::executed ( ) const

Return a flag stating whether we've performed CSE or not.

◆ n_intermediate_expressions()

template<typename ReturnType , typename ExpressionType >
unsigned int Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::n_intermediate_expressions ( ) const

The number of intermediate expressions that must be evaluated as part of the collection of common subexpressions.

◆ n_reduced_expressions()

template<typename ReturnType , typename ExpressionType >
unsigned int Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::n_reduced_expressions ( ) const

The size of the final set of reduced expressions.

◆ init() [2/2]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::init ( const SymEngine::vec_basic & dependent_functions)
protected

Initialize and perform common subexpression elimination.

This function performs the same action as the other init() function, except that it works with native SymEngine data types; the single argument is a vector of SymEngine::RCP<const SymEngine::Basic>.

Parameters
dependent_functionsA vector of expressions that represent the dependent functions that CSE will be performed on.

◆ call() [2/2]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::call ( ReturnType * output_values,
const SymEngine::vec_basic & independent_symbols,
const ReturnType * substitution_values )
protected

Evaluate the (reduced) dependent functions using the common subexpressions generated during the call to init().

This function performs the same action as the other init() function, except that it works with native SymEngine data types. The independent_symbols is represented by a vector of SymEngine::RCP<const SymEngine::Basic>.

Parameters
[out]output_valuesA pointer to the first element in an array of type ReturnType. After this call, the underlying array will hold the numerical result of substituting the substitution_values into the pre-registered dependent functions.
[in]independent_symbolsA vector of symbols that represent the independent variables that are arguments to the previously defined dependent functions.
[in]substitution_valuesA pointer to the first element in an array of type ReturnType. Each entry in this array stores the numerical value that an independent variable is to take for the purpose of value substitution.
Note
The caveats described in the documentation of the other call() function apply here as well.

Member Data Documentation

◆ intermediate_symbols_exprs

template<typename ReturnType , typename ExpressionType >
symbol_vector_pair Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::intermediate_symbols_exprs
private

Intermediate symbols and their definition.

Definition at line 242 of file symengine_number_visitor_internal.h.

◆ reduced_exprs

template<typename ReturnType , typename ExpressionType >
types::symbol_vector Differentiation::SD::internal::CSEDictionaryVisitor< ReturnType, ExpressionType >::reduced_exprs
private

Final reduced expressions.

Definition at line 247 of file symengine_number_visitor_internal.h.


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