#include <deal.II/differentiation/sd/symengine_number_visitor_internal.h>
|
void | init (const SymEngine::vec_basic &dependent_functions) |
|
void | call (ReturnType *output_values, const SymEngine::vec_basic &independent_symbols, const ReturnType *substitution_values) |
|
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.
- Author
- Jean-Paul Pelteret, Isuru Fernando, 2017, 2020
Definition at line 63 of file symengine_number_visitor_internal.h.
◆ symbol_vector_pair
template<typename ReturnType , typename ExpressionType >
◆ CSEDictionaryVisitor()
template<typename ReturnType , typename ExpressionType >
◆ ~CSEDictionaryVisitor()
template<typename ReturnType , typename ExpressionType >
◆ init() [1/2]
template<typename ReturnType , typename ExpressionType >
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_functions | A vector of expressions that represent the dependent functions that CSE will be performed on. |
◆ call() [1/2]
template<typename ReturnType , typename ExpressionType >
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_values | A 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_symbols | A vector of symbols that represent the independent variables that are arguments to the previously defined dependent functions. |
[in] | substitution_values | A 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 >
Write the data of this object to a stream for the purpose of serialization.
◆ load()
template<typename ReturnType , typename ExpressionType >
template<class Archive >
Read the data for this object from a stream for the purpose of serialization.
◆ serialize()
template<typename ReturnType , typename ExpressionType >
template<class Archive >
Write and read the data of this object from a stream for the purpose of serialization.
◆ print()
template<typename ReturnType , typename ExpressionType >
template<typename StreamType >
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 >
Return a flag stating whether we've performed CSE or not.
◆ n_intermediate_expressions()
template<typename ReturnType , typename ExpressionType >
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 >
The size of the final set of reduced expressions.
◆ init() [2/2]
template<typename ReturnType , typename ExpressionType >
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_functions | A vector of expressions that represent the dependent functions that CSE will be performed on. |
◆ call() [2/2]
template<typename ReturnType , typename ExpressionType >
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_values | A 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_symbols | A vector of symbols that represent the independent variables that are arguments to the previously defined dependent functions. |
[in] | substitution_values | A 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.
◆ intermediate_symbols_exprs
template<typename ReturnType , typename ExpressionType >
◆ reduced_exprs
template<typename ReturnType , typename ExpressionType >
The documentation for this class was generated from the following file: