Reference documentation for deal.II version 9.5.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
Public Member Functions | Private Attributes | List of all members
Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType > Class Template Reference

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

Inheritance diagram for Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >:
[legend]

Public Member Functions

 DictionarySubstitutionVisitor ()=default
 
virtual ~DictionarySubstitutionVisitor () override=default
 
void init (const types::symbol_vector &independent_symbols, const Expression &dependent_function, const bool use_cse=false)
 
void init (const SymEngine::vec_basic &independent_symbols, const SymEngine::Basic &dependent_function, const bool use_cse=false)
 
void init (const types::symbol_vector &independent_symbols, const types::symbol_vector &dependent_functions, const bool use_cse=false)
 
void init (const SymEngine::vec_basic &independent_symbols, const SymEngine::vec_basic &dependent_functions, const bool use_cse=false)
 
void call (ReturnType *output_values, const ReturnType *substitution_values)
 
ReturnType call (const std::vector< 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 print_independent_symbols=false, const bool print_dependent_functions=false, const bool print_cse_reductions=false) const
 

Private Attributes

SD::types::symbol_vector independent_symbols
 
SD::types::symbol_vector dependent_functions
 
CSEDictionaryVisitor< ReturnType, ExpressionType > cse
 

Detailed Description

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

A class to perform dictionary-based substitution as if it were an optimizer of the "lambda" or "LLVM" variety.

This class is only really useful to assist in the easy switching between different optimizers and, more importantly, for integrating CSE into a dictionary substitution scheme. It is therefore only intended to be created and used by a BatchOptimizer.

Definition at line 263 of file symengine_number_visitor_internal.h.

Constructor & Destructor Documentation

◆ DictionarySubstitutionVisitor()

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

◆ ~DictionarySubstitutionVisitor()

template<typename ReturnType , typename ExpressionType >
virtual Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::~DictionarySubstitutionVisitor ( )
overridevirtualdefault

Member Function Documentation

◆ init() [1/4]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::init ( const types::symbol_vector independent_symbols,
const Expression dependent_function,
const bool  use_cse = false 
)

Initialization, and registration of the independent and dependent variables.

This variation of the initialization function registers a single dependent expression. If the use_cse is set to true, then common subexpression elimination is also performed at the time of initialization.

Parameters
independent_symbolsA vector of symbols that represent the independent variables that are arguments to the dependent_function.
dependent_functionA single symbolic expression that represents a dependent variable.
use_cseA flag to indicate whether or not to use common subexpression elimination.
Note
After this function is called, no further registration of dependent functions can be performed. If it is desired that multiple dependent expressions be registered, then the other variant of this function that takes in a vector of dependent expressions should be used.

◆ init() [2/4]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::init ( const SymEngine::vec_basic &  independent_symbols,
const SymEngine::Basic &  dependent_function,
const bool  use_cse = false 
)

Initialization, and registration of the independent and dependent variables.

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

Parameters
independent_symbolsA vector of symbols that represent the independent variables that are arguments to the dependent_function.
dependent_functionA single symbolic expression that represents a dependent variable.
use_cseA flag to indicate whether or not to use common subexpression elimination.
Note
The caveats described in the documentation of the other init() function apply here as well.

◆ init() [3/4]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::init ( const types::symbol_vector independent_symbols,
const types::symbol_vector dependent_functions,
const bool  use_cse = false 
)

Initialization, and registration of the independent and dependent variables.

This variation of the initialization function registers a vector of dependent expressions. If the use_cse is set to true, then common subexpression elimination is also performed at the time of initialization.

Parameters
independent_symbolsA vector of symbols that represent the independent variables that are arguments to the dependent_functions.
dependent_functionsA vector of symbolic expressions that represent the dependent variables.
use_cseA flag to indicate whether or not to use common subexpression elimination.
Note
After this function is called, no further registration of dependent functions can be performed.

◆ init() [4/4]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::init ( const SymEngine::vec_basic &  independent_symbols,
const SymEngine::vec_basic &  dependent_functions,
const bool  use_cse = false 
)

Initialization, and registration of the independent and dependent variables.

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

Parameters
independent_symbolsA vector of symbols that represent the independent variables that are arguments to the dependent_functions.
dependent_functionsA vector of symbolic expressions that represent the dependent variables.
use_cseA flag to indicate whether or not to use common subexpression elimination.
Note
The caveats described in the documentation of the other init() function apply here as well.

◆ call() [1/2]

template<typename ReturnType , typename ExpressionType >
void Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::call ( ReturnType *  output_values,
const ReturnType *  substitution_values 
)

Evaluate the dependent functions that were registered at initializtion time.

The output_values are the numerical result of substituting each of the substitution_values for their corresponding entry of the pre-registered independent variables.

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]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 there were independent variables that were registered at the time of initialization.
It is expected that there be a 1-1 correspondence between the entries in independent variables 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.

◆ call() [2/2]

template<typename ReturnType , typename ExpressionType >
ReturnType Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::call ( const std::vector< ReturnType > &  substitution_values)

Evaluate the dependent function that were registered at initializtion time.

The purpose of this function is the same as the other call() functions, but

Parameters
substitution_valuesA vector that stores the numerical values that each independent variable that was registered with the class instance is to take for the purpose of value substitution.
Returns
ReturnType The numerical value associated with the single dependent function that is registered with this class.
Note
It is expected that there be a 1-1 correspondence between the entries in independent variables and substitution_values.

◆ save()

template<typename ReturnType , typename ExpressionType >
template<class Archive >
void Differentiation::SD::internal::DictionarySubstitutionVisitor< 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::DictionarySubstitutionVisitor< 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::DictionarySubstitutionVisitor< 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::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::print ( StreamType &  stream,
const bool  print_independent_symbols = false,
const bool  print_dependent_functions = false,
const bool  print_cse_reductions = false 
) const

Print some information on state of the internal data structures stored in the class.

Template Parameters
StreamThe type for the output stream.
Parameters
streamThe output stream to print to.
print_independent_symbolsA flag to indicate if the independent variables should be outputted to the stream.
print_dependent_functionsA flag to indicate if the dependent expressions should be outputted to the stream.
print_cse_reductionsA flag to indicate whether or not all common subexpressions should be printed to the stream.

Member Data Documentation

◆ independent_symbols

template<typename ReturnType , typename ExpressionType >
SD::types::symbol_vector Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::independent_symbols
private

A vector of symbols that represent the independent variables.

Definition at line 564 of file symengine_number_visitor_internal.h.

◆ dependent_functions

template<typename ReturnType , typename ExpressionType >
SD::types::symbol_vector Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::dependent_functions
private

A vector of expressions that represent dependent functions.

Definition at line 569 of file symengine_number_visitor_internal.h.

◆ cse

template<typename ReturnType , typename ExpressionType >
CSEDictionaryVisitor<ReturnType, ExpressionType> Differentiation::SD::internal::DictionarySubstitutionVisitor< ReturnType, ExpressionType >::cse
private

A data structure that may be used to invoke common subexpression elimination on the dependent functions, with the aim to decrease the time taken to evaluate them.

Definition at line 576 of file symengine_number_visitor_internal.h.


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