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.
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. |
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.
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.