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
Classes | Functions
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, NumberType > tensor_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, NumberType > tensor_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.

Function Documentation

◆ 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 236 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 246 of file symengine_optimizer.h.

◆ tensor_evaluate_optimized() [1/2]

template<typename NumberType , int rank, int dim, template< int, int, typename > class TensorType>
TensorType< rank, dim, NumberType > 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
NumberTypeThe number type that is returned as a result of operations performed by the optimizer.
rankThe rank of the output tensor.
dimThe dimension of the output tensor.
TensorTypeThe type of tensor to be evaluated and returned (i.e. Tensor or SymmetricTensor).
Parameters
[in]symbol_tensorThe symbolic tensor that is to be evaluated.
[in]cached_evaluationA 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]optimizerThe 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 1137 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
NumberTypeThe number type that is returned as a result of operations performed by the optimizer.
rankThe rank of the output tensor.
dimThe dimension of the output tensor.
TensorTypeThe type of tensor to be evaluated and returned (i.e. Tensor or SymmetricTensor).
Parameters
[in]symbol_tensorThe symbolic tensor that is to be evaluated.
[in]cached_evaluationA 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]optimizerThe 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 1178 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
NumberTypeThe number type that is returned as a result of operations performed by the optimizer.
TA compatible type that may be used to represent a single dependent variable. This includes scalar Expressions, Tensors of Expressions and SymmetricTensors of Expressions.
Parameters
optimizerThe instance of the BatchOptimizer to register the function with.
functionA 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 1219 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
NumberTypeThe number type that is returned as a result of operations performed by the optimizer.
TA compatible type that may be used to represent a single dependent variable. This includes scalar Expressions, Tensors of Expressions and SymmetricTensors of Expressions.
Parameters
optimizerThe instance of the BatchOptimizer to register the function with.
functionsA 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 1245 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
NumberTypeThe number type that is returned as a result of operations performed by the optimizer.
TA compatible type that may be used to represent a single dependent variable. This includes scalar Expressions, Tensors of Expressions and SymmetricTensors of Expressions.
ArgsThe parameter pack that collects all other types of dependent variables to be registered.
Parameters
optimizerThe instance of the BatchOptimizer to register the function with.
functionA valid symbolic expression (or collection of symbolic expression) that represents one (or more) dependent variable.
other_functionsOne or more other valid symbolic expression(s) that represent dependent variable(s).

Definition at line 1274 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
rankThe rank of the input tensor.
dimThe dimension of the input tensor.
TensorTypeThe 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 1299 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
dimThe dimension of the input tensor.
Parameters
symbol_tensor
Returns
A vector of Expressions, with a consistent ordering.

Definition at line 1326 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.

◆ add_to_substitution_map()

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

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.

There are cases where it is convenient to simply ignore the fact that we may be trying to add invalid symbols. For example, one may wish to add a tensor where only some entries are symbols and the others are zero'd. In this case we ensure that the user knows what they're doing by forcing them to override this safety mechanism with a template parameter. These types of functions are typically called in a manner indicating that the user knows exactly what they're passing into it.

Template Parameters
ignore_invalid_symbolsA 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.