Reference documentation for deal.II version Git 4e8af90f34 2022-01-22 18:32:44 +0100
Differentiation::SD::internal Namespace Reference

## Classes

class  CSEDictionaryVisitor

struct  DictionaryOptimizer

class  DictionarySubstitutionVisitor

struct  LambdaOptimizer

struct  OptimizerHelper

## Functions

bool use_symbolic_CSE (const enum OptimizationFlags &flags)

int get_LLVM_optimization_level (const enum OptimizationFlags &flags)

template<typename NumberType , int rank, int dim, template< int, int, typename > class TensorType>
TensorType< rank, dim, NumberTypetensor_evaluate_optimized (const TensorType< rank, dim, Expression > &symbol_tensor, const std::vector< NumberType > &cached_evaluation, const BatchOptimizer< NumberType > &optimizer)

template<typename NumberType , int dim>
SymmetricTensor< 4, dim, NumberTypetensor_evaluate_optimized (const SymmetricTensor< 4, dim, Expression > &symbol_tensor, const std::vector< NumberType > &cached_evaluation, const BatchOptimizer< NumberType > &optimizer)

template<typename NumberType , typename T >
void register_functions (BatchOptimizer< NumberType > &optimizer, const T &function)

template<typename NumberType , typename T >
void register_functions (BatchOptimizer< NumberType > &optimizer, const std::vector< T > &functions)

template<typename NumberType , typename T , typename... Args>
void register_functions (BatchOptimizer< NumberType > &optimizer, const T &function, const Args &...other_functions)

template<int rank, int dim, template< int, int, typename > class TensorType>
types::symbol_vector unroll_to_expression_vector (const TensorType< rank, dim, Expression > &symbol_tensor)

template<int dim>
types::symbol_vector unroll_to_expression_vector (const SymmetricTensor< 4, dim, Expression > &symbol_tensor)

bool is_valid_substitution_symbol (const SymEngine::Basic &entry)

void set_value_in_symbol_map (types::substitution_map &substitution_map, const SymEngine::RCP< const SymEngine::Basic > &symbol, const SymEngine::RCP< const SymEngine::Basic > &value)

template<bool ignore_invalid_symbols = false>
void add_to_substitution_map (types::substitution_map &substitution_map, const SymEngine::RCP< const SymEngine::Basic > &symbol, const SymEngine::RCP< const SymEngine::Basic > &value)

## Detailed Description

This namespace defines the classes and functions that help provide a structured interface to symbolic numbers and operations.

## ◆ use_symbolic_CSE()

 bool Differentiation::SD::internal::use_symbolic_CSE ( const enum OptimizationFlags & flags )
inline

A utility function that checks whether or not CSE has been selected as an optimization flag.

Definition at line 238 of file symengine_optimizer.h.

## ◆ get_LLVM_optimization_level()

 int Differentiation::SD::internal::get_LLVM_optimization_level ( const enum OptimizationFlags & flags )
inline

A utility function that returns the optimization level that is to be employed when the LLVM optimizer is invoked.

Definition at line 248 of file symengine_optimizer.h.

## ◆ tensor_evaluate_optimized() [1/2]

template<typename NumberType , int rank, int dim, template< int, int, typename > class TensorType>
 TensorType Differentiation::SD::internal::tensor_evaluate_optimized ( const TensorType< rank, dim, Expression > & symbol_tensor, const std::vector< NumberType > & cached_evaluation, const BatchOptimizer< NumberType > & optimizer )

A convenience function that returns the numeric equivalent of an input symbol_tensor, computed through the optimizer.

Template Parameters
 NumberType The number type that is returned as a result of operations performed by the optimizer. rank The rank of the output tensor. dim The dimension of the output tensor. TensorType The type of tensor to be evaluated and returned (i.e. Tensor or SymmetricTensor).
Parameters
 [in] symbol_tensor The symbolic tensor that is to be evaluated. [in] cached_evaluation A vector that stores the numerical values of all dependent variables referenced by the optimizer. This vector is, most typically, first attained by a call to the BatchOptimizer::evaluate() variant that takes no arguments. [in] optimizer The optimizer that can evaluate the input symbol_tensor.
Returns
TensorType<rank, dim, NumberType> The numeric result that the input symbol_tensor evaluates to.

Definition at line 1143 of file symengine_optimizer.h.

## ◆ tensor_evaluate_optimized() [2/2]

template<typename NumberType , int dim>
 SymmetricTensor<4, dim, NumberType> Differentiation::SD::internal::tensor_evaluate_optimized ( const SymmetricTensor< 4, dim, Expression > & symbol_tensor, const std::vector< NumberType > & cached_evaluation, const BatchOptimizer< NumberType > & optimizer )

A convenience function that returns the numeric equivalent of an input symbol_tensor, computed through the optimizer. This is a specialization for rank-4 symmetric tensors.

Template Parameters
 NumberType The number type that is returned as a result of operations performed by the optimizer. rank The rank of the output tensor. dim The dimension of the output tensor. TensorType The type of tensor to be evaluated and returned (i.e. Tensor or SymmetricTensor).
Parameters
 [in] symbol_tensor The symbolic tensor that is to be evaluated. [in] cached_evaluation A vector that stores the numerical values of all dependent variables referenced by the optimizer. This vector is, most typically, first attained by a call to the BatchOptimizer::evaluate() variant that takes no arguments. [in] optimizer The optimizer that can evaluate the input symbol_tensor.
Returns
TensorType<rank, dim, NumberType> The numeric result that the input symbol_tensor evaluates to.

Definition at line 1184 of file symengine_optimizer.h.

## ◆ register_functions() [1/3]

template<typename NumberType , typename T >
 void Differentiation::SD::internal::register_functions ( BatchOptimizer< NumberType > & optimizer, const T & function )

A helper function to register a single function with the optimizer.

Template Parameters
 NumberType The number type that is returned as a result of operations performed by the optimizer. T A compatible type that may be used to represent a single dependent variable. This includes scalar Expressions, Tensors of Expressions and SymmetricTensors of Expressions.
Parameters
 optimizer The instance of the BatchOptimizer to register the function with. function A symbolic expression (scalar or tensor) that represents a dependent variable.
Note
This is the end-point for all recursive template functions with the same name.

Definition at line 1225 of file symengine_optimizer.h.

## ◆ register_functions() [2/3]

template<typename NumberType , typename T >
 void Differentiation::SD::internal::register_functions ( BatchOptimizer< NumberType > & optimizer, const std::vector< T > & functions )

A helper function to register a vector of functions with the optimizer.

Template Parameters
 NumberType The number type that is returned as a result of operations performed by the optimizer. T A compatible type that may be used to represent a single dependent variable. This includes scalar Expressions, Tensors of Expressions and SymmetricTensors of Expressions.
Parameters
 optimizer The instance of the BatchOptimizer to register the function with. functions A vector of symbolic expressions (scalar or tensor) that each represent a dependent variable.
Note
This is the end-point for all recursive template functions with the same name.

Definition at line 1251 of file symengine_optimizer.h.

## ◆ register_functions() [3/3]

template<typename NumberType , typename T , typename... Args>
 void Differentiation::SD::internal::register_functions ( BatchOptimizer< NumberType > & optimizer, const T & function, const Args &... other_functions )

A helper function to register the symbolic dependent variables collectively given by function and other_functions with the optimizer.

Template Parameters
 NumberType The number type that is returned as a result of operations performed by the optimizer. T A compatible type that may be used to represent a single dependent variable. This includes scalar Expressions, Tensors of Expressions and SymmetricTensors of Expressions. Args The parameter pack that collects all other types of dependent variables to be registered.
Parameters
 optimizer The instance of the BatchOptimizer to register the function with. function A valid symbolic expression (or collection of symbolic expression) that represents one (or more) dependent variable. other_functions One or more other valid symbolic expression(s) that represent dependent variable(s).

Definition at line 1280 of file symengine_optimizer.h.

## ◆ unroll_to_expression_vector() [1/2]

template<int rank, int dim, template< int, int, typename > class TensorType>
 types::symbol_vector Differentiation::SD::internal::unroll_to_expression_vector ( const TensorType< rank, dim, Expression > & symbol_tensor )

A utility function that unrolls the input symbol_tensor into a vector of Expressions.

Template Parameters
 rank The rank of the input tensor. dim The dimension of the input tensor. TensorType The type of tensor to be evaluated and returned (i.e. Tensor or SymmetricTensor).
Parameters
 symbol_tensor
Returns
A vector of Expressions, with a consistent ordering.

Definition at line 1305 of file symengine_optimizer.h.

## ◆ unroll_to_expression_vector() [2/2]

template<int dim>
 types::symbol_vector Differentiation::SD::internal::unroll_to_expression_vector ( const SymmetricTensor< 4, dim, Expression > & symbol_tensor )

A utility function that unrolls the input symbol_tensor into a vector of Expressions. This is a specialization for rank-4 symmetric tensors.

Template Parameters
 dim The dimension of the input tensor.
Parameters
 symbol_tensor
Returns
A vector of Expressions, with a consistent ordering.

Definition at line 1332 of file symengine_optimizer.h.

## ◆ is_valid_substitution_symbol()

 bool Differentiation::SD::internal::is_valid_substitution_symbol ( const SymEngine::Basic & entry )

Return whether or not an entry is a valid symbol that we can expect to perform substitution on.

## ◆ set_value_in_symbol_map()

 void Differentiation::SD::internal::set_value_in_symbol_map ( types::substitution_map & substitution_map, const SymEngine::RCP< const SymEngine::Basic > & symbol, const SymEngine::RCP< const SymEngine::Basic > & value )

A convenience function to set the value associated with the symbol in the substitution_map.

Using this function ensures that the symbol is one that is valid specifically for the purpose of symbolic substitution. It must therefore represent a symbol or symbolic derivative, otherwise an error will be thrown.

A convenience function to add an entry to the substitution_map. The new entry will have the key given by symbol with its paired value. Such maps are required to perform substitution of symbolic expressions, where all entries given as keys in the map are substituted by their value counterparts.
 ignore_invalid_symbols A template parameter that enforces whether or not the symbol has to be a valid one or not. In the overwhelming majority of cases, the default value of false should be selected, with the result that an exception will be thrown if the input symbolic is, in fact, not a symbolic value or expression.