Reference documentation for deal.II version 9.4.1
\(\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
Namespaces | Classes | Enumerations | Functions
Differentiation::SD Namespace Reference

Namespaces

namespace  internal
 
namespace  types
 
namespace  Utilities
 

Classes

class  BatchOptimizer
 
class  Expression
 
struct  is_sd_number
 
struct  is_sd_number< Expression >
 
struct  is_sd_number< SymEngine::Expression >
 
struct  is_symengine_number
 
struct  is_symengine_number< Expression >
 
struct  is_symengine_number< SymEngine::Expression >
 

Enumerations

enum class  OptimizerType { OptimizerType::dictionary , OptimizerType::lambda , OptimizerType::llvm }
 
enum class  OptimizationFlags : unsigned char { OptimizationFlags::optimize_default = 0 , OptimizationFlags::optimize_cse = 0x0001 , OptimizationFlags::optimize_aggressive = 0x0002 , OptimizationFlags::optimize_all = optimize_cse | optimize_aggressive }
 

Functions

static ::ExceptionBaseExcSymEngineParserError (std::string arg1)
 
static ::ExceptionBaseExcSymEngineLLVMNotAvailable ()
 
static ::ExceptionBaseExcSymEngineLLVMReturnTypeNotSupported ()
 
template<class StreamType >
StreamType & operator<< (StreamType &s, OptimizerType o)
 
OptimizationFlags operator| (const OptimizationFlags f1, const OptimizationFlags f2)
 
OptimizationFlagsoperator|= (OptimizationFlags &f1, const OptimizationFlags f2)
 
OptimizationFlags operator& (const OptimizationFlags f1, const OptimizationFlags f2)
 
OptimizationFlagsoperator&= (OptimizationFlags &f1, const OptimizationFlags f2)
 
template<class StreamType >
StreamType & operator<< (StreamType &s, OptimizationFlags o)
 
 Expression::operator const SymEngine::RCP< const SymEngine::Basic > & () const
 
Power functions
Expression pow (const Expression &base, const Expression &exponent)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression pow (const Expression &base, const NumberType &exponent)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression pow (const NumberType &base, const Expression &exponent)
 
Expression sqrt (const Expression &x)
 
Expression cbrt (const Expression &x)
 
Expression exp (const Expression &exponent)
 
Expression log (const Expression &x)
 
Expression log (const Expression &x, const Expression &base)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression log (const Expression &x, const NumberType &base)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression log (const NumberType &x, const Expression &base)
 
Expression log10 (const Expression &x)
 
Trigonometric functions
Expression sin (const Expression &x)
 
Expression cos (const Expression &x)
 
Expression tan (const Expression &x)
 
Expression csc (const Expression &x)
 
Expression sec (const Expression &x)
 
Expression cot (const Expression &x)
 
Expression asin (const Expression &x)
 
Expression acos (const Expression &x)
 
Expression atan (const Expression &x)
 
Expression atan2 (const Expression &y, const Expression &x)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression atan2 (const NumberType &y, const Expression &x)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression atan2 (const Expression &y, const NumberType &x)
 
Expression acsc (const Expression &x)
 
Expression asec (const Expression &x)
 
Expression acot (const Expression &x)
 
Hyperbolic trigonometric functions
Expression sinh (const Expression &x)
 
Expression cosh (const Expression &x)
 
Expression tanh (const Expression &x)
 
Expression csch (const Expression &x)
 
Expression sech (const Expression &x)
 
Expression coth (const Expression &x)
 
Expression asinh (const Expression &x)
 
Expression acosh (const Expression &x)
 
Expression atanh (const Expression &x)
 
Expression acsch (const Expression &x)
 
Expression asech (const Expression &x)
 
Expression acoth (const Expression &x)
 
Other functions
Expression abs (const Expression &x)
 
Expression fabs (const Expression &x)
 
Expression sign (const Expression &x)
 
Expression copysign (const Expression &value, const Expression &sign)
 
Expression floor (const Expression &x)
 
Expression ceil (const Expression &x)
 
Expression max (const Expression &a, const Expression &b)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression max (const Expression &a, const NumberType &b)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression max (const NumberType &a, const Expression &b)
 
Expression min (const Expression &a, const Expression &b)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression min (const Expression &a, const NumberType &b)
 
template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression min (const NumberType &a, const Expression &b)
 
Expression erf (const Expression &x)
 
Expression erfc (const Expression &x)
 
Bitwise operators
std::ostream & operator<< (std::ostream &stream, const Expression &expression)
 
std::istream & operator>> (std::istream &stream, Expression &expression)
 
Comparison operators
Expression operator== (const Expression &lhs, const Expression &rhs)
 
Expression operator!= (const Expression &lhs, const Expression &rhs)
 
Expression operator< (const Expression &lhs, const Expression &rhs)
 
Expression operator> (const Expression &lhs, const Expression &rhs)
 
Expression operator<= (const Expression &lhs, const Expression &rhs)
 
Expression operator>= (const Expression &lhs, const Expression &rhs)
 
Logical operators
Expression operator! (const Expression &expression)
 
Expression operator& (const Expression &lhs, const Expression &rhs)
 
Expression operator| (const Expression &lhs, const Expression &rhs)
 
Expression operator^ (const Expression &lhs, const Expression &rhs)
 
Expression operator&& (const Expression &lhs, const Expression &rhs)
 
Expression operator|| (const Expression &lhs, const Expression &rhs)
 
Mathematical operators
Expression operator+ (Expression lhs, const Expression &rhs)
 
Expression operator- (Expression lhs, const Expression &rhs)
 
Expression operator* (Expression lhs, const Expression &rhs)
 
Expression operator/ (Expression lhs, const Expression &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator+ (const NumberType &lhs, const Expression &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator+ (const Expression &lhs, const NumberType &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator- (const NumberType &lhs, const Expression &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator- (const Expression &lhs, const NumberType &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator* (const NumberType &lhs, const Expression &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator* (const Expression &lhs, const NumberType &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator/ (const NumberType &lhs, const Expression &rhs)
 
template<typename NumberType , typename = typename std::enable_if< std::is_constructible<Expression, NumberType>::value>::type>
Expression operator/ (const Expression &lhs, const NumberType &rhs)
 
Symbolic variable creation
Expression make_symbol (const std::string &symbol)
 
Expression make_symbolic_function (const std::string &symbol, const types::symbol_vector &arguments)
 
Expression make_symbolic_function (const std::string &symbol, const types::substitution_map &arguments)
 
template<int dim>
Tensor< 1, dim, Expressionmake_vector_of_symbols (const std::string &symbol)
 
template<int rank, int dim>
Tensor< rank, dim, Expressionmake_tensor_of_symbols (const std::string &symbol)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressionmake_symmetric_tensor_of_symbols (const std::string &symbol)
 
template<int dim>
Tensor< 1, dim, Expressionmake_vector_of_symbolic_functions (const std::string &symbol, const types::substitution_map &arguments)
 
template<int rank, int dim>
Tensor< rank, dim, Expressionmake_tensor_of_symbolic_functions (const std::string &symbol, const types::substitution_map &arguments)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressionmake_symmetric_tensor_of_symbolic_functions (const std::string &symbol, const types::substitution_map &arguments)
 
Symbolic differentiation
Expression differentiate (const Expression &f, const Expression &x)
 
template<int rank, int dim>
Tensor< rank, dim, Expressiondifferentiate (const Expression &f, const Tensor< rank, dim, Expression > &T)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressiondifferentiate (const Expression &f, const SymmetricTensor< rank, dim, Expression > &S)
 
template<int rank, int dim>
Tensor< rank, dim, Expressiondifferentiate (const Tensor< 0, dim, Expression > &f, const Tensor< rank, dim, Expression > &T)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressiondifferentiate (const Tensor< 0, dim, Expression > &f, const SymmetricTensor< rank, dim, Expression > &S)
 
template<int rank, int dim>
Tensor< rank, dim, Expressiondifferentiate (const Tensor< rank, dim, Expression > &T, const Expression &x)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressiondifferentiate (const SymmetricTensor< rank, dim, Expression > &S, const Expression &x)
 
template<int rank, int dim>
Tensor< rank, dim, Expressiondifferentiate (const Tensor< rank, dim, Expression > &T, const Tensor< 0, dim, Expression > &x)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressiondifferentiate (const SymmetricTensor< rank, dim, Expression > &S, const Tensor< 0, dim, Expression > &x)
 
template<int rank_1, int rank_2, int dim>
Tensor< rank_1+rank_2, dim, Expressiondifferentiate (const Tensor< rank_1, dim, Expression > &T1, const Tensor< rank_2, dim, Expression > &T2)
 
template<int rank_1, int rank_2, int dim>
SymmetricTensor< rank_1+rank_2, dim, Expressiondifferentiate (const SymmetricTensor< rank_1, dim, Expression > &S1, const SymmetricTensor< rank_2, dim, Expression > &S2)
 
template<int rank_1, int rank_2, int dim>
Tensor< rank_1+rank_2, dim, Expressiondifferentiate (const Tensor< rank_1, dim, Expression > &T, const SymmetricTensor< rank_2, dim, Expression > &S)
 
template<int rank_1, int rank_2, int dim>
Tensor< rank_1+rank_2, dim, Expressiondifferentiate (const SymmetricTensor< rank_1, dim, Expression > &S, const Tensor< rank_2, dim, Expression > &T)
 
Symbol map creation and manipulation
template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType >
types::substitution_map make_symbol_map (const SymbolicType &symbol)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType , typename... Args>
types::substitution_map make_symbol_map (const SymbolicType &symbol, const Args &...other_symbols)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double>
void add_to_symbol_map (types::substitution_map &symbol_map, const Expression &symbol)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType , typename T = typename std::enable_if< !std::is_base_of<Expression, SymbolicType>::value && ::internal::is_explicitly_convertible< SymbolicType, const SymEngine::RCP<const SymEngine::Basic> &>::value>::type>
void add_to_symbol_map (types::substitution_map &symbol_map, const SymbolicType &symbol)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType >
void add_to_symbol_map (types::substitution_map &symbol_map, const std::vector< SymbolicType > &symbols)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double>
void add_to_symbol_map (types::substitution_map &symbol_map, const types::substitution_map &other_symbols)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType , typename... Args>
void add_to_symbol_map (types::substitution_map &symbol_map, const SymbolicType &symbol, const Args &...other_symbols)
 
void set_value_in_symbol_map (types::substitution_map &substitution_map, const Expression &symbol, const Expression &value)
 
template<typename SymbolicType , typename ValueType , typename T = typename std::enable_if< ::internal::is_explicitly_convertible< SymbolicType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<SymbolicType, ValueType>::value>::type>
void set_value_in_symbol_map (types::substitution_map &substitution_map, const SymbolicType &symbol, const ValueType &value)
 
template<typename SymbolicType , typename ValueType >
void set_value_in_symbol_map (types::substitution_map &substitution_map, const std::vector< SymbolicType > &symbols, const std::vector< ValueType > &values)
 
template<typename SymbolicType , typename ValueType >
void set_value_in_symbol_map (types::substitution_map &substitution_map, const std::pair< SymbolicType, ValueType > &symbol_value)
 
template<typename SymbolicType , typename ValueType , typename... Args>
void set_value_in_symbol_map (types::substitution_map &substitution_map, const std::pair< SymbolicType, ValueType > &symbol_value, const Args &...other_symbol_values)
 
template<typename SymbolicType , typename ValueType >
void set_value_in_symbol_map (types::substitution_map &substitution_map, const std::vector< std::pair< SymbolicType, ValueType > > &symbol_values)
 
void set_value_in_symbol_map (types::substitution_map &substitution_map, const types::substitution_map &symbol_values)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double, int rank, int dim, typename SymbolicType >
void add_to_symbol_map (types::substitution_map &symbol_map, const Tensor< rank, dim, SymbolicType > &symbol_tensor)
 
template<bool ignore_invalid_symbols = false, typename ValueType = double, int rank, int dim, typename SymbolicType >
void add_to_symbol_map (types::substitution_map &symbol_map, const SymmetricTensor< rank, dim, SymbolicType > &symbol_tensor)
 
template<int rank, int dim, typename SymbolicType , typename ValueType >
void set_value_in_symbol_map (types::substitution_map &substitution_map, const Tensor< rank, dim, SymbolicType > &symbol_tensor, const Tensor< rank, dim, ValueType > &value_tensor)
 
template<int rank, int dim, typename SymbolicType , typename ValueType >
void set_value_in_symbol_map (types::substitution_map &substitution_map, const SymmetricTensor< rank, dim, SymbolicType > &symbol_tensor, const SymmetricTensor< rank, dim, ValueType > &value_tensor)
 
Symbol substitution map creation
types::substitution_map make_substitution_map (const Expression &symbol, const Expression &value)
 
template<typename ExpressionType , typename ValueType , typename T = typename std::enable_if< ::internal::is_explicitly_convertible< ExpressionType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<ExpressionType, ValueType>::value>::type>
types::substitution_map make_substitution_map (const ExpressionType &symbol, const ValueType &value)
 
template<typename ExpressionType , typename ValueType >
types::substitution_map make_substitution_map (const std::vector< ExpressionType > &symbols, const std::vector< ValueType > &values)
 
template<typename ExpressionType , typename ValueType >
types::substitution_map make_substitution_map (const std::pair< ExpressionType, ValueType > &symbol_value)
 
template<typename ExpressionType , typename ValueType >
types::substitution_map make_substitution_map (const std::vector< std::pair< ExpressionType, ValueType > > &symbol_values)
 
template<typename ExpressionType , typename ValueType , typename... Args>
types::substitution_map make_substitution_map (const std::pair< ExpressionType, ValueType > &symbol_value, const Args &...other_symbol_values)
 
template<int rank, int dim, typename ExpressionType , typename ValueType >
types::substitution_map make_substitution_map (const Tensor< rank, dim, ExpressionType > &symbol_tensor, const Tensor< rank, dim, ValueType > &value_tensor)
 
template<int rank, int dim, typename ExpressionType , typename ValueType >
types::substitution_map make_substitution_map (const SymmetricTensor< rank, dim, ExpressionType > &symbol_tensor, const SymmetricTensor< rank, dim, ValueType > &value_tensor)
 
Symbol substitution map enlargement
template<bool ignore_invalid_symbols = false>
void add_to_substitution_map (types::substitution_map &substitution_map, const Expression &symbol, const Expression &value)
 
template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType , typename = typename std::enable_if< ::internal::is_explicitly_convertible< ExpressionType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<ExpressionType, ValueType>::value>::type>
void add_to_substitution_map (types::substitution_map &substitution_map, const ExpressionType &symbol, const ValueType &value)
 
template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType , typename = typename std::enable_if< ::internal::is_explicitly_convertible< ExpressionType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<ExpressionType, ValueType>::value>::type>
void add_to_substitution_map (types::substitution_map &substitution_map, const std::vector< ExpressionType > &symbols, const std::vector< ValueType > &values)
 
template<bool ignore_invalid_symbols = false>
void add_to_substitution_map (types::substitution_map &substitution_map, const types::substitution_map &symbol_values)
 
template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType >
void add_to_substitution_map (types::substitution_map &substitution_map, const std::pair< ExpressionType, ValueType > &symbol_value)
 
template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType >
void add_to_substitution_map (types::substitution_map &substitution_map, const std::vector< std::pair< ExpressionType, ValueType > > &symbol_values)
 
template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType , typename... Args>
void add_to_substitution_map (types::substitution_map &substitution_map, const std::pair< ExpressionType, ValueType > &symbol_value, const Args &...other_symbol_values)
 
void merge_substitution_maps (types::substitution_map &substitution_map_out, const types::substitution_map &substitution_map_in)
 
template<typename... Args>
void merge_substitution_maps (types::substitution_map &substitution_map_out, const types::substitution_map &substitution_map_in, const Args &...other_substitution_maps_in)
 
template<typename... Args>
types::substitution_map merge_substitution_maps (const types::substitution_map &substitution_map_in, const Args &...other_substitution_maps_in)
 
template<bool ignore_invalid_symbols = false, int rank, int dim, typename ExpressionType , typename ValueType >
void add_to_substitution_map (types::substitution_map &substitution_map, const Tensor< rank, dim, ExpressionType > &symbol_tensor, const Tensor< rank, dim, ValueType > &value_tensor)
 
template<bool ignore_invalid_symbols = false, int rank, int dim, typename ExpressionType , typename ValueType >
void add_to_substitution_map (types::substitution_map &substitution_map, const SymmetricTensor< rank, dim, ExpressionType > &symbol_tensor, const SymmetricTensor< rank, dim, ValueType > &value_tensor)
 
Symbol substitution and evaluation
types::substitution_map resolve_explicit_dependencies (const types::substitution_map &substitution_map, const bool force_cyclic_dependency_resolution=false)
 
template<typename ExpressionType , typename ValueType >
types::substitution_map resolve_explicit_dependencies (const std::vector< std::pair< ExpressionType, ValueType > > &symbol_values, const bool force_cyclic_dependency_resolution=false)
 
Expression substitute (const Expression &expression, const types::substitution_map &substitution_map)
 
template<typename ValueType >
Expression substitute (const Expression &expression, const Expression &symbol, const ValueType &value)
 
template<typename ExpressionType , typename... Args>
ExpressionType substitute (const ExpressionType &expression, const Args &...symbol_values)
 
template<typename ValueType >
ValueType substitute_and_evaluate (const Expression &expression, const types::substitution_map &substitution_map)
 
template<typename ValueType , typename... Args>
ValueType substitute_and_evaluate (const Expression &expression, const Args &...symbol_values)
 
template<int rank, int dim>
Tensor< rank, dim, Expressionsubstitute (const Tensor< rank, dim, Expression > &expression_tensor, const types::substitution_map &substitution_map)
 
template<int rank, int dim>
SymmetricTensor< rank, dim, Expressionsubstitute (const SymmetricTensor< rank, dim, Expression > &expression_tensor, const types::substitution_map &substitution_map)
 
template<typename ValueType , int rank, int dim>
Tensor< rank, dim, ValueType > substitute_and_evaluate (const Tensor< rank, dim, Expression > &expression_tensor, const types::substitution_map &substitution_map)
 
template<typename ValueType , int rank, int dim>
SymmetricTensor< rank, dim, ValueType > substitute_and_evaluate (const SymmetricTensor< rank, dim, Expression > &expression_tensor, const types::substitution_map &substitution_map)
 

Detailed Description

Wrappers for symbolic differentiation libraries. Currently there is support for the following libraries:

Function Documentation

◆ pow() [1/3]

Expression Differentiation::SD::pow ( const Expression base,
const Expression exponent 
)

Return a symbolic number that represents a base value raised to the power of an exponent.

Mimics the function std::pow(base,exponent) using the standard math library.

Definition at line 42 of file symengine_math.cc.

◆ pow() [2/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::pow ( const Expression base,
const NumberType &  exponent 
)

Return a symbolic number that represents a base value raised to the power of an exponent.

Mimics the function std::pow(base,exponent) using the standard math library.

This variant is used when the exponent is not a Expression.

Definition at line 74 of file symengine_math.h.

◆ pow() [3/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::pow ( const NumberType &  base,
const Expression exponent 
)

Return a symbolic number that represents a base value raised to the power of an exponent.

Mimics the function std::pow(base,exponent) using the standard math library.

This variant is used when the base is not a Expression.

Definition at line 93 of file symengine_math.h.

◆ sqrt()

Expression Differentiation::SD::sqrt ( const Expression x)

Return a symbolic number that represents the square root of some value x.

Mimics the function std::sqrt(x) using the standard math library.

Definition at line 49 of file symengine_math.cc.

◆ cbrt()

Expression Differentiation::SD::cbrt ( const Expression x)

Return a symbolic number that represents the cubic root of some value x.

Mimics the function std::cbrt(x) using the standard math library.

Definition at line 56 of file symengine_math.cc.

◆ exp()

Expression Differentiation::SD::exp ( const Expression exponent)

Return a symbolic number that represents the Euler constant \(e \approx 2.71828\) raised to the given exponent.

Mimics the function std::exp(exponent) using the standard math library.

Definition at line 63 of file symengine_math.cc.

◆ log() [1/4]

Expression Differentiation::SD::log ( const Expression x)

Return a symbolic number that represents the natural logarithm of a value x.

Mimics the function std::log(x) using the standard math library.

Definition at line 70 of file symengine_math.cc.

◆ log() [2/4]

Expression Differentiation::SD::log ( const Expression x,
const Expression base 
)

Return a symbolic number that represents the logarithm of a value x taken with respect to a base number.

Mimics the function std::log(x,base) using the standard math library.

Definition at line 77 of file symengine_math.cc.

◆ log() [3/4]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::log ( const Expression x,
const NumberType &  base 
)

Return a symbolic number that represents the logarithm of a value x taken with respect to a base number.

Mimics the function std::log(x,base) using the standard math library.

This variant is used when the base is not a Expression.

Definition at line 159 of file symengine_math.h.

◆ log() [4/4]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::log ( const NumberType &  x,
const Expression base 
)

Return a symbolic number that represents the logarithm of a value x taken with respect to a base number.

Mimics the function std::log(x,base) using the standard math library.

This variant is used when the value is not a Expression.

Definition at line 178 of file symengine_math.h.

◆ log10()

Expression Differentiation::SD::log10 ( const Expression x)

Return a symbolic number that represents the base 10 logarithm of a value x.

Mimics the function std::log10(x) using the standard math library.

Definition at line 84 of file symengine_math.cc.

◆ sin()

Expression Differentiation::SD::sin ( const Expression x)

Return a symbolic number that represents the sine function with the given argument x.

Mimics the function std::sin(x) using the standard math library.

Definition at line 91 of file symengine_math.cc.

◆ cos()

Expression Differentiation::SD::cos ( const Expression x)

Return a symbolic number that represents the cosine function with the given argument x.

Mimics the function std::cos(x) using the standard math library.

Definition at line 98 of file symengine_math.cc.

◆ tan()

Expression Differentiation::SD::tan ( const Expression x)

Return a symbolic number that represents the tangent function with the given argument x.

Mimics the function std::tan(x) using the standard math library.

Definition at line 105 of file symengine_math.cc.

◆ csc()

Expression Differentiation::SD::csc ( const Expression x)

Return a symbolic number that represents the cosecant function with the given argument x.

Mimics the function 1.0/std::sin(x) using the standard math library.

Definition at line 112 of file symengine_math.cc.

◆ sec()

Expression Differentiation::SD::sec ( const Expression x)

Return a symbolic number that represents the secant function with the given argument x.

Mimics the function 1.0/std::cos(x) using the standard math library.

Definition at line 119 of file symengine_math.cc.

◆ cot()

Expression Differentiation::SD::cot ( const Expression x)

Return a symbolic number that represents the cotangent function with the given argument x.

Mimics the function 1.0/std::tan(x) using the standard math library.

Definition at line 126 of file symengine_math.cc.

◆ asin()

Expression Differentiation::SD::asin ( const Expression x)

Return a symbolic number that represents the inverse sine function with the given argument x.

Mimics the function std::asin(x) using the standard math library.

Definition at line 133 of file symengine_math.cc.

◆ acos()

Expression Differentiation::SD::acos ( const Expression x)

Return a symbolic number that represents the inverse cosine function with the given argument x.

Mimics the function std::acos(x) using the standard math library.

Definition at line 140 of file symengine_math.cc.

◆ atan()

Expression Differentiation::SD::atan ( const Expression x)

Return a symbolic number that represents the inverse tangent function with the given argument x.

Mimics the function std::atan(x) using the standard math library.

Definition at line 147 of file symengine_math.cc.

◆ atan2() [1/3]

Expression Differentiation::SD::atan2 ( const Expression y,
const Expression x 
)

Return a symbolic number that represents the inverse tangent function with the given arguments x and y.

Mimics the function std::atan2(y,x) using the standard math library.

Definition at line 154 of file symengine_math.cc.

◆ atan2() [2/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::atan2 ( const NumberType &  y,
const Expression x 
)

Return a symbolic number that represents the inverse tangent function with the given arguments x and y.

Mimics the function std::atan2(y,x) using the standard math library.

This variant is used when the numerator y is not a Expression.

Definition at line 318 of file symengine_math.h.

◆ atan2() [3/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::atan2 ( const Expression y,
const NumberType &  x 
)

Return a symbolic number that represents the inverse tangent function with the given arguments x and y.

Mimics the function std::atan2(y,x) using the standard math library.

This variant is used when the denominator x is not a Expression.

Definition at line 338 of file symengine_math.h.

◆ acsc()

Expression Differentiation::SD::acsc ( const Expression x)

Return a symbolic number that represents the inverse cosecant function with the given argument x.

Mimics the function 1.0/std::asin(x) using the standard math library.

Definition at line 161 of file symengine_math.cc.

◆ asec()

Expression Differentiation::SD::asec ( const Expression x)

Return a symbolic number that represents the inverse secant function with the given argument x.

Mimics the function 1.0/std::acos(x) using the standard math library.

Definition at line 168 of file symengine_math.cc.

◆ acot()

Expression Differentiation::SD::acot ( const Expression x)

Return a symbolic number that represents the inverse cotangent function with the given argument x.

Mimics the function 1.0/std::atan(x) using the standard math library.

Definition at line 175 of file symengine_math.cc.

◆ sinh()

Expression Differentiation::SD::sinh ( const Expression x)

Return a symbolic number that represents the hyperbolic sine function with the given argument x.

Mimics the function std::sinh(x) using the standard math library.

Definition at line 182 of file symengine_math.cc.

◆ cosh()

Expression Differentiation::SD::cosh ( const Expression x)

Return a symbolic number that represents the hyperbolic cosine function with the given argument x.

Mimics the function std::cosh(x) using the standard math library.

Definition at line 189 of file symengine_math.cc.

◆ tanh()

Expression Differentiation::SD::tanh ( const Expression x)

Return a symbolic number that represents the hyperbolic tangent function with the given argument x.

Mimics the function std::tanh(x) using the standard math library.

Definition at line 196 of file symengine_math.cc.

◆ csch()

Expression Differentiation::SD::csch ( const Expression x)

Return a symbolic number that represents the hyperbolic cosecant function with the given argument x.

Mimics the function 1.0/std::sinh(x) using the standard math library.

Definition at line 203 of file symengine_math.cc.

◆ sech()

Expression Differentiation::SD::sech ( const Expression x)

Return a symbolic number that represents the hyperbolic secant function with the given argument x.

Mimics the function 1.0/std::cosh(x) using the standard math library.

Definition at line 210 of file symengine_math.cc.

◆ coth()

Expression Differentiation::SD::coth ( const Expression x)

Return a symbolic number that represents the hyperbolic cotangent function with the given argument x.

Mimics the function 1.0/std::tanh(x) using the standard math library.

Definition at line 217 of file symengine_math.cc.

◆ asinh()

Expression Differentiation::SD::asinh ( const Expression x)

Return a symbolic number that represents the inverse hyperbolic sine function with the given argument x.

Mimics the function std::asinh(x) using the standard math library.

Definition at line 224 of file symengine_math.cc.

◆ acosh()

Expression Differentiation::SD::acosh ( const Expression x)

Return a symbolic number that represents the inverse hyperbolic cosine function with the given argument x.

Mimics the function std::acosh(x) using the standard math library.

Definition at line 231 of file symengine_math.cc.

◆ atanh()

Expression Differentiation::SD::atanh ( const Expression x)

Return a symbolic number that represents the inverse hyperbolic tangent function with the given argument x.

Mimics the function std::atanh(x) using the standard math library.

Definition at line 238 of file symengine_math.cc.

◆ acsch()

Expression Differentiation::SD::acsch ( const Expression x)

Return a symbolic number that represents the inverse hyperbolic cosecant function with the given argument x.

Mimics the function 1.0/std::asin(x) using the standard math library.

Definition at line 245 of file symengine_math.cc.

◆ asech()

Expression Differentiation::SD::asech ( const Expression x)

Return a symbolic number that represents the inverse hyperbolic secant function with the given argument x.

Mimics the function 1.0/std::acos(x) using the standard math library.

Definition at line 252 of file symengine_math.cc.

◆ acoth()

Expression Differentiation::SD::acoth ( const Expression x)

Return a symbolic number that represents the inverse hyperbolic cotangent function with the given argument x.

Mimics the function 1.0/std::atan(x) using the standard math library.

Definition at line 259 of file symengine_math.cc.

◆ abs()

Expression Differentiation::SD::abs ( const Expression x)

Return a symbolic number that represents the absolute value of value x.

Mimics the function std::abs(x) using the standard math library.

Definition at line 266 of file symengine_math.cc.

◆ fabs()

Expression Differentiation::SD::fabs ( const Expression x)

Return a symbolic number that represents the absolute value of value x.

Mimics the function std::fabs(x) using the standard math library.

Definition at line 273 of file symengine_math.cc.

◆ sign()

Expression Differentiation::SD::sign ( const Expression x)

Return a symbolic number that represents the sign of value x.

Although there is no such function in the standard library, it mimics the function boost::sign(x) using the boost math library.

Definition at line 280 of file symengine_math.cc.

◆ copysign()

Expression Differentiation::SD::copysign ( const Expression value,
const Expression sign 
)

Return a symbolic number that represents the value of the first argument that takes the sign of the second argument.

Mimics the function std::copysign(value, sign) using the standard math library.

Definition at line 287 of file symengine_math.cc.

◆ floor()

Expression Differentiation::SD::floor ( const Expression x)

Return a symbolic number that represents the floor of value x.

Mimics the function std::floor(x) using the standard math library.

Definition at line 294 of file symengine_math.cc.

◆ ceil()

Expression Differentiation::SD::ceil ( const Expression x)

Return a symbolic number that represents the ceiling of value x.

Mimics the function std::ceil(x) using the standard math library.

Definition at line 301 of file symengine_math.cc.

◆ max() [1/3]

Expression Differentiation::SD::max ( const Expression a,
const Expression b 
)

Return a symbolic number that represents the maximum of two values a and b.

Mimics the function std::max(a,b) using the standard math library.

Definition at line 308 of file symengine_math.cc.

◆ max() [2/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::max ( const Expression a,
const NumberType &  b 
)

Return a symbolic number that represents the maximum of two values a and b.

Mimics the function std::max(a,b) using the standard math library.

This variant is used when b is not a Expression.

Definition at line 607 of file symengine_math.h.

◆ max() [3/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::max ( const NumberType &  a,
const Expression b 
)

Return a symbolic number that represents the maximum of two values a and b.

Mimics the function std::max(a,b) using the standard math library.

This variant is used when a is not a Expression.

Definition at line 626 of file symengine_math.h.

◆ min() [1/3]

Expression Differentiation::SD::min ( const Expression a,
const Expression b 
)

Return a symbolic number that represents the minimum of two values a and b.

Mimics the function std::min(a,b) using the standard math library.

Definition at line 315 of file symengine_math.cc.

◆ min() [2/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::min ( const Expression a,
const NumberType &  b 
)

Return a symbolic number that represents the minimum of two values a and b.

Mimics the function std::min(a,b) using the standard math library.

This variant is used when b is not a Expression.

Definition at line 655 of file symengine_math.h.

◆ min() [3/3]

template<typename NumberType , typename = typename std::enable_if< !std::is_same<NumberType, Expression>::value>::type>
Expression Differentiation::SD::min ( const NumberType &  a,
const Expression b 
)

Return a symbolic number that represents the minimum of two values a and b.

Mimics the function std::min(a,b) using the standard math library.

This variant is used when a is not a Expression.

Definition at line 674 of file symengine_math.h.

◆ erf()

Expression Differentiation::SD::erf ( const Expression x)

Return a symbolic number that represents error function with the given argument x.

Mimics the function std::erf(x) using the standard math library.

Definition at line 322 of file symengine_math.cc.

◆ erfc()

Expression Differentiation::SD::erfc ( const Expression x)

Return a symbolic number that represents complimentary error function with the given argument x.

Mimics the function std::erfc(x) using the standard math library.

Definition at line 329 of file symengine_math.cc.

◆ make_symbol()

Expression Differentiation::SD::make_symbol ( const std::string &  symbol)

Return an Expression representing a scalar symbolic variable with the identifier specified by symbol.

For example, if the symbol is the string "x" then the scalar symbolic variable that is returned represents the scalar \(x\).

Parameters
[in]symbolAn identifier (or name) for the returned symbolic variable.
Returns
A scalar symbolic variable with the name symbol.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

Definition at line 41 of file symengine_scalar_operations.cc.

◆ make_symbolic_function() [1/2]

Expression Differentiation::SD::make_symbolic_function ( const std::string &  symbol,
const types::symbol_vector arguments 
)

Return an Expression representing a scalar symbolic function with the identifier specified by symbol. The function's symbolic dependencies are specified by the input arguments.

For example, if the symbol is the string "f", and the arguments to the function that is generated are the symbolic variable x and the symbolic expression y+z, then the generic symbolic function that is returned represents \(f(x, y+z)\).

Parameters
[in]symbolAn identifier (or name) for the returned symbolic function.
[in]argumentsA vector of input arguments to the returned symbolic function.
Returns
A generic symbolic function with the identifier symbolic and the number of input arguments equal to the length of arguments.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

Definition at line 48 of file symengine_scalar_operations.cc.

◆ make_symbolic_function() [2/2]

Expression Differentiation::SD::make_symbolic_function ( const std::string &  symbol,
const types::substitution_map arguments 
)

Return an Expression representing a scalar symbolic function with the identifier specified by symbol. The function's symbolic dependencies are specified by the keys to the input arguments map; the values stored in the map are ignored.

For example, if the symbol is the string "f", and the arguments to the function that is generated are the symbolic variable x and the symbolic expression y+z, then the generic symbolic function that is returned represents \(f(x, y+z)\).

Parameters
[in]symbolAn identifier (or name) for the returned symbolic function.
[in]argumentsA map of input arguments to the returned symbolic function.
Returns
A generic symbolic function with the identifier symbolic and the number of input arguments equal to the length of arguments.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

Definition at line 56 of file symengine_scalar_operations.cc.

◆ differentiate() [1/13]

Expression Differentiation::SD::differentiate ( const Expression f,
const Expression x 
)

Return the symbolic result of computing the partial derivative of the scalar f with respect to the scalar x. In most use cases the function or variable f would be called the dependent variable, and x the independent variable.

Parameters
[in]fA scalar symbolic function or (dependent) expression.
[in]xA scalar symbolic (independent) variable.
Returns
The symbolic function or expression representing the result \(\frac{\partial f}{\partial x}\).

Definition at line 68 of file symengine_scalar_operations.cc.

◆ make_symbol_map() [1/2]

template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType >
types::substitution_map Differentiation::SD::make_symbol_map ( const SymbolicType &  symbol)

Return a symbolic map that has a single entry with the key given by the symbol. It is expected that all entries to be added to the symbolic map are valid symbols or symbolic expressions.

Template Parameters
ignore_invalid_symbolsSee the add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeAny symbolic type that is understood by the add_to_symbol_map() functions. This includes individual Expression, std::vector<Expression>, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.

◆ make_symbol_map() [2/2]

template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType , typename... Args>
types::substitution_map Differentiation::SD::make_symbol_map ( const SymbolicType &  symbol,
const Args &...  other_symbols 
)

Return a symbolic map that has the entry keys given by symbol and all other_symbols. It is expected that all entries to be added to the symbolic map are valid symbols or symbolic expressions.

With this function it is possible to construct a symbolic map from different types. An example may be as follows:

const types::substitution_map symbol_map
Expression(...),
Definition: tensor.h:503
std::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map
types::substitution_map make_symbol_map(const SymbolicType &symbol)
Template Parameters
ignore_invalid_symbolsSee the add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeAny symbolic type that is understood by the add_to_symbol_map() functions. This includes individual Expression, std::vector<Expression>, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.
ArgsA type associated with the parameter pack that contains any number of other SymbolicTypes. All types held by the parameter pack share the same restriction as the SymbolicType documented above.

◆ add_to_symbol_map() [1/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double>
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const Expression symbol 
)

A convenience function for adding an empty entry, with the key value given by symbol, to the symbolic map symbol_map.

This function is guaranteed to create an ordering that is identical to the typical add_to_substitution_map() call that is used when constructing a map to perform symbol substitution. It exists primarily to create an initial map that can be used in the optimize() call to a BatchOptimizer, specifically if the values that are to be substituted into the map are not known at the time that the symbols used to construct symbolic expressions are defined. This helps one conform to the requirement that the arguments sent into lambda and LLVM JIT compiled functions (created by optimizing symbolic expressions) (i) be the same, and (ii) have a constant ordering.

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. An exceptional case is, for example, when performing symbolic assembly on a finite element level. When extracting the symbolic equivalent of the shape function gradients using FEExtractors, the returned tensor will have some a priori determined zero-valued components. These trivial components are not valid symbols (as they are not symbolic expressions), and we would typically wish to guard against their (erroneous) inclusion. In this scenario, for convenience, one could set ignore_invalid_symbols to true and these zero-valued entries would be skipped over and ignored.
Note
In this function, the ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.

◆ add_to_symbol_map() [2/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType , typename T = typename std::enable_if< !std::is_base_of<Expression, SymbolicType>::value && ::internal::is_explicitly_convertible< SymbolicType, const SymEngine::RCP<const SymEngine::Basic> &>::value>::type>
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const SymbolicType &  symbol 
)

A convenience function for adding an empty entry, with the key value given by symbol, to the symbolic map symbol_map.

For more context which this function is used, see the other add_to_symbol_map(types::substitution_map &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.
TAn arbitrary type resulting from the application of the SFINAE idiom to selectively specialize this class. The required condition is fulfilled when the SymbolicType can be explicitly converted to a const SymEngine::RCP<const SymEngine::Basic> &.

◆ add_to_symbol_map() [3/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType >
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const std::vector< SymbolicType > &  symbols 
)

A convenience function for adding empty entries, with the key values equal to the entries in symbols, to the symbolic map symbol_map. It is expected that all entries in the input vector symbols be of SymbolicType, compatible with the other add_to_symbol_map() functions.

For more context which this function is used, see the other add_to_symbol_map(types::substitution_map &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeAny symbolic type that is understood by the add_to_symbol_map() functions. This includes an individual Expression, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.

◆ add_to_symbol_map() [4/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double>
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const types::substitution_map other_symbols 
)

A convenience function for adding empty entries, with the key values equal to the key entries in other_symbols, to the symbolic map symbol_map.

For more context which this function is used, see the other add_to_symbol_map(types::substitution_map &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.

◆ add_to_symbol_map() [5/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double, typename SymbolicType , typename... Args>
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const SymbolicType &  symbol,
const Args &...  other_symbols 
)

A convenience function for adding empty entries, with the key values equal to the entries in symbol plus other_symbols, to the symbolic map symbol_map. It is expected that all entries in symbol and other_symbols be of a SymbolicType, compatible with the other add_to_symbol_map() functions.

For more context which this function is used, see the other add_to_symbol_map(types::substitution_map &, const Expression &) function.

With this function it is possible to add entries from different types to a symbolic map. An example may be as follows:

types::substitution_map symbol_map = ...;
symbol_map,
Expression(...),
void add_to_symbol_map(types::substitution_map &symbol_map, const Expression &symbol)
Template Parameters
ignore_invalid_symbolsSee the other add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeAny symbolic type that is understood by the add_to_symbol_map() functions. This includes individual Expression, std::vector<Expression>, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.
ArgsA type associated with the parameter pack that contains any number of other SymbolicTypes. All types held by the parameter pack share the same restriction as the SymbolicType documented above.

◆ set_value_in_symbol_map() [1/9]

void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const Expression symbol,
const Expression value 
)

Find the entry for symbol in the substitution_map and set its corresponding value.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

◆ set_value_in_symbol_map() [2/9]

template<typename SymbolicType , typename ValueType , typename T = typename std::enable_if< ::internal::is_explicitly_convertible< SymbolicType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<SymbolicType, ValueType>::value>::type>
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const SymbolicType &  symbol,
const ValueType &  value 
)

Find the entry for symbol in the substitution_map and set its corresponding value.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.
TAn arbitrary type resulting from the application of the SFINAE idiom to selectively specialize this class. The required condition is fulfilled when the SymbolicType can be explicitly converted to a const SymEngine::RCP<const SymEngine::Basic> &, and it is possible to construct an SymbolicType directly from the ValueType.

◆ set_value_in_symbol_map() [3/9]

template<typename SymbolicType , typename ValueType >
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const std::vector< SymbolicType > &  symbols,
const std::vector< ValueType > &  values 
)

Find the entries for symbols in the substitution_map and set their corresponding values.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined SymbolicType can be constructed from.

◆ set_value_in_symbol_map() [4/9]

template<typename SymbolicType , typename ValueType >
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const std::pair< SymbolicType, ValueType > &  symbol_value 
)

Find the entry for symbols in the substitution_map and set their corresponding values. The modified symbol will have the key given by the first element of symbol_value and the value given by its second element.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined SymbolicType can be constructed from.

◆ set_value_in_symbol_map() [5/9]

template<typename SymbolicType , typename ValueType , typename... Args>
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const std::pair< SymbolicType, ValueType > &  symbol_value,
const Args &...  other_symbol_values 
)

Find the entries for symbols in the substitution_map and set their corresponding values, followed by the same operation for the other_symbol_values.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined SymbolicType can be constructed from.
ArgsA type associated with the parameter pack that contains any number of other pairs of SymbolicTypes and ValueTypes. All types held by the parameter pack share the same restriction as the SymbolicType and ValueType documented above.

◆ set_value_in_symbol_map() [6/9]

template<typename SymbolicType , typename ValueType >
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const std::vector< std::pair< SymbolicType, ValueType > > &  symbol_values 
)

Find the entries for symbols in the substitution_map and set their corresponding values. The modified symbol will have the key given by the first element of each paired entry in the symbol_values vector and the value given by its respective second element.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined SymbolicType can be constructed from.

◆ set_value_in_symbol_map() [7/9]

void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const types::substitution_map symbol_values 
)

Find the entries for symbols in the substitution_map and set their corresponding values. The modified symbol will have the key given by the each element the symbol_values map and the value given by its respective mapped element.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

◆ make_substitution_map() [1/8]

types::substitution_map Differentiation::SD::make_substitution_map ( const Expression symbol,
const Expression value 
)

Return a substitution map that has the entry key given by symbol and the value given by value. It is expected that the key entry be valid symbol or symbolic expression.

The values that map to a symbol would typically be of an arithmetic type. However, in some instances is may be useful to map a symbolic type to another symbolic type (i.e. perform partial substitution). In such a situation the resolve_explicit_dependencies() function may be useful to simplify the final substitution map by resolving all explicit interdependencies between entries in the substitution map.

Definition at line 172 of file symengine_scalar_operations.cc.

◆ make_substitution_map() [2/8]

template<typename ExpressionType , typename ValueType , typename T = typename std::enable_if< ::internal::is_explicitly_convertible< ExpressionType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<ExpressionType, ValueType>::value>::type>
types::substitution_map Differentiation::SD::make_substitution_map ( const ExpressionType &  symbol,
const ValueType &  value 
)

Return a substitution map that has the entry key given by symbol and the value given by value. It is expected that the key entry be valid symbol or symbolic expression.

The values that map to a symbol would typically be of a ValueType (i.e., an arithmetic type). However, in some instances is may be useful to map a symbolic type to another symbolic type (i.e. perform partial substitution). In such a situation the resolve_explicit_dependencies() function may be useful to simplify the final substitution map by resolving all explicit interdependencies between entries in the substitution map.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.
TAn arbitrary type resulting from the application of the SFINAE idiom to selectively specialize this class. The required condition is fulfilled when the ExpressionType can be explicitly converted to a const SymEngine::RCP<const SymEngine::Basic> &, and it is possible to construct an ExpressionType directly from the ValueType.

◆ make_substitution_map() [3/8]

template<typename ExpressionType , typename ValueType >
types::substitution_map Differentiation::SD::make_substitution_map ( const std::vector< ExpressionType > &  symbols,
const std::vector< ValueType > &  values 
)

Return a substitution map that has the entry keys given by symbols and the values given by values. It is expected that all key entries be valid symbols or symbolic expressions.

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &, const ValueType &) function.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ make_substitution_map() [4/8]

template<typename ExpressionType , typename ValueType >
types::substitution_map Differentiation::SD::make_substitution_map ( const std::pair< ExpressionType, ValueType > &  symbol_value)

Return a substitution map that has the key given by the first entry in symbol_value, and the value of its second entry. It is expected that the key entry be a valid symbol or symbolic expression.

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &, const ValueType &) function.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ make_substitution_map() [5/8]

template<typename ExpressionType , typename ValueType >
types::substitution_map Differentiation::SD::make_substitution_map ( const std::vector< std::pair< ExpressionType, ValueType > > &  symbol_values)

Return a substitution map that has the keys given by the first entry of each element of symbol_values, and the values given its second entry. It is expected that all key entries be valid symbols or symbolic expressions.

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &, const ValueType &) function.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ make_substitution_map() [6/8]

template<typename ExpressionType , typename ValueType , typename... Args>
types::substitution_map Differentiation::SD::make_substitution_map ( const std::pair< ExpressionType, ValueType > &  symbol_value,
const Args &...  other_symbol_values 
)

Return a substitution map that has the key given by the first entry in symbol_value, and the value of its second entry, followed by the addition of the other_symbol_values. It is expected that all key entries be valid symbols or symbolic expressions.

With this function it is possible to construct a symbolic substitution map from different types, so long as there exists a add_to_substitution_map() function with the signature corresponding to the pair types. An example may be as follows:

const types::substitution_map substitution_map
std::make_pair(Expression(...), 3),
std::make_pair(Tensor<1,dim,Expression>(...),
std::make_pair(SymmetricTensor<2,dim,Expression>(...),
types::substitution_map make_substitution_map(const Expression &symbol, const Expression &value)

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &, const ValueType &) function.

Template Parameters
ExpressionTypeAny symbolic expression type that is understood by the make_substitution_map() functions. This includes individual Expression, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.
ArgsA type associated with the parameter pack that contains any number of other ExpressionTypes. All types held by the parameter pack share the same restriction as the ExpressionType documented above.

◆ add_to_substitution_map() [1/9]

template<bool ignore_invalid_symbols = false>
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const Expression symbol,
const Expression 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, with key entries being exchanges with their pair values.

This function is guaranteed to create an ordering that is identical to the typical add_to_symbol_map() call that may be used when initially configuring a BatchOptimizer. This helps one conform to the requirement that the arguments sent into lambda and LLVM JIT compiled functions (created by optimizing symbolic expressions) (i) be the same, and (ii) have a constant ordering.

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. An exceptional case is, for example, when performing symbolic assembly on a finite element level. When extracting the symbolic equivalent of the shape function gradients using FEExtractors, the returned tensor will have some a priori determined zero-valued components. These trivial components are not valid symbols (as they are not symbolic expressions), and we would typically wish to guard against their (erroneous) inclusion. In this scenario, for convenience, one could set ignore_invalid_symbols to true and these zero-valued entries would be skipped over and ignored.

◆ add_to_substitution_map() [2/9]

template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType , typename = typename std::enable_if< ::internal::is_explicitly_convertible< ExpressionType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<ExpressionType, ValueType>::value>::type>
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const ExpressionType &  symbol,
const ValueType &  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.

The ExpressionType will be used to convert the value to a compatible SymEngine number type. It is therefore required that the ExpressionType

  1. can be constructed from a ValueType, and that
  2. it is convertible to a const SymEngine::RCP<const SymEngine::Basic> &.

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ add_to_substitution_map() [3/9]

template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType , typename = typename std::enable_if< ::internal::is_explicitly_convertible< ExpressionType, const SymEngine::RCP<const SymEngine::Basic> &>::value && std::is_constructible<ExpressionType, ValueType>::value>::type>
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const std::vector< ExpressionType > &  symbols,
const std::vector< ValueType > &  values 
)

A convenience function for adding multiple entries to the substitution_map. The new entries will have the keys given in the symbols vector, each of which will be paired index-wise with its corresponding element in the values vector.

The class represented by the ExpressionType template parameter will be used to convert the p value to a compatible SymEngine number type. It is therefore required that the ExpressionType

  1. can be constructed from a ValueType, and that
  2. it is convertible to a const SymEngine::RCP<const SymEngine::Basic> &.

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ add_to_substitution_map() [4/9]

template<bool ignore_invalid_symbols = false>
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const types::substitution_map symbol_values 
)

A convenience function for adding multiple entries to the substitution_map. The new entries will have the keys given in the symbols vector, each of which will be paired index-wise with its corresponding element in the values vector. It is expected that there are no duplicate entries between the two maps.

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.

◆ add_to_substitution_map() [5/9]

template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType >
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const std::pair< ExpressionType, ValueType > &  symbol_value 
)

A convenience function to add an entry to the substitution_map. The new entry will have the key given by the first element of symbol_value and the value given by its second element. It is expected that the key entry be a valid symbol or symbolic expression, and that the paired symbol_value elements are compatible with the other add_to_substitution_map() functions.

The ExpressionType and its associated ValueType need not be scalar types. So, for example, this function could be used to add tensor-valued data to the map in the following way:

types::substitution_map substitution_map = ...;
substitution_map,
std::make_pair(Tensor<1,dim,Expression>(...),
);
void add_to_substitution_map(types::substitution_map &substitution_map, const Expression &symbol, const Expression &value)

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.
ExpressionTypeAny symbolic expression type that is understood by the add_to_substitution_map() functions. This includes individual Expression, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ add_to_substitution_map() [6/9]

template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType >
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const std::vector< std::pair< ExpressionType, ValueType > > &  symbol_values 
)

A convenience function for adding multiple entries to the substitution_map. The new entries will have the keys given by first entry of each element of symbol_values, and the values given its second entry. It is expected that the key entry be a valid symbols or symbolic expressions, and that the paired symbol_value elements are compatible with the other add_to_substitution_map() functions.

The ExpressionType and its associated ValueType need not be scalar types. So, for example, this function could be used to add tensor-valued data to the map in the following way:

types::substitution_map substitution_map = ...;
using vector_entry_t = std::vector<std::pair<
>>;
substitution_map,
vector_entry_t{
});

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.
ExpressionTypeAny symbolic expression type that is understood by the add_to_substitution_map() functions. This includes individual Expression, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ add_to_substitution_map() [7/9]

template<bool ignore_invalid_symbols = false, typename ExpressionType , typename ValueType , typename... Args>
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const std::pair< ExpressionType, ValueType > &  symbol_value,
const Args &...  other_symbol_values 
)

A convenience function for adding multiple entries to the substitution_map. The new entries will have the keys given by first entry of each element of symbol_values, and the values given its second entry, along with the addition of the other_symbol_values. It is expected that the key entry be a valid symbols or symbolic expressions, and that the paired symbol_value elements are compatible with the other add_to_substitution_map() functions.

With this function it is possible to construct a symbolic substitution map from different types, so long as there exists a add_to_substitution_map() function with the signature corresponding to the pair types. An example may be as follows:

types::substitution_map substitution_map = ...;
substitution_map,
std::make_pair(Expression(...), 3),
std::make_pair(Tensor<1,dim,Expression>(...),
std::make_pair(SymmetricTensor<2,dim,Expression>(...),

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &, const ValueType &) function.

Template Parameters
ExpressionTypeAny symbolic expression type that is understood by the add_to_substitution_map() functions. This includes individual Expression, as well as Tensors and SymmetricTensors of Expressions.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.
ArgsA type associated with the parameter pack that contains any number of other ExpressionTypes. All types held by the parameter pack share the same restriction as the ExpressionType documented above.

◆ merge_substitution_maps() [1/3]

void Differentiation::SD::merge_substitution_maps ( types::substitution_map substitution_map_out,
const types::substitution_map substitution_map_in 
)

Concatenate two symbolic maps, merging a second map substitution_map_in in-place into the initial and resultant map substitution_map_out. The map substitution_map_out need not initially be empty.

Note
Duplicate symbols (keys) in the maps are permitted, so long as their values are equal. If this is not the case then an error will be thrown.

◆ merge_substitution_maps() [2/3]

template<typename... Args>
void Differentiation::SD::merge_substitution_maps ( types::substitution_map substitution_map_out,
const types::substitution_map substitution_map_in,
const Args &...  other_substitution_maps_in 
)

Concatenate multiple symbolic maps, merging the maps substitution_map_in and other_substitution_maps_in, a collection of other maps, in-place into the resultant map substitution_map_out. The map substitution_map_out need not initially be empty.

Note
Duplicate symbols (keys) in the maps are permitted, so long as their values are equal. If this is not the case then an error will be thrown.

◆ merge_substitution_maps() [3/3]

template<typename... Args>
types::substitution_map Differentiation::SD::merge_substitution_maps ( const types::substitution_map substitution_map_in,
const Args &...  other_substitution_maps_in 
)

Concatenate multiple symbolic maps, merging the maps substitution_map_in and other_substitution_maps_in and returning the result.

Note
Duplicate symbols (keys) in the maps are permitted, so long as their values are equal. If this is not the case then an error will be thrown.

◆ resolve_explicit_dependencies() [1/2]

types::substitution_map Differentiation::SD::resolve_explicit_dependencies ( const types::substitution_map substitution_map,
const bool  force_cyclic_dependency_resolution = false 
)

Return a substitution map that has any explicit interdependencies between the entries of the input substitution_map resolved.

The force_cyclic_dependency_resolution flag exists to ensure, if desired, that no cyclic dependencies can exist in the returned map. If a cyclic dependency exists in the input substitution map, substitution_map, then with this flag set to true the dependency cycle is broken by a dictionary-ordered substitution. For example, if the substitution map contains two entries map["a"] -> "b" and map["b"] -> "a", then the result of calling this function would be a map with the elements map["a"] -> "a" and map["b"] -> "a".

If one symbol is an explicit function of another, and it is desired that all their values are completely resolved, then it may be necessary to perform substitution a number of times before the result is finalized. This function performs substitution sweeps for a set of symbolic variables until all explicit relationships between the symbols in the map have been resolved. Whether each entry returns a symbolic or real value depends on the nature of the values stored in the substitution map. If the values associated with a key are also symbolic then the returned result may still be symbolic in nature. The terminal result of using the input substitution map, symbol_values, is then guaranteed to be rendered by a single substitition of the returned dependency-resolved map.

Example: If map["a"] -> 1 and map["b"] -> "a"+ 2, then the function \(f(a,b(a)) = a+b\) will be evaluated and the result \(f\vert_{a=1,b=a+2} = 3+a\) is determined upon the completion of the first sweep. A second sweep is therefore necessary to resolve the final symbol, and the returned value is ultimately \(f = [3+a]_{a=1} = 4\). By resolving the explicit relationships between all symbols in the map, we determine that map["a"] -> 1 and map["b"] -> 1 + 2 = 3 and thus, using only one substitution, that \(f = a+b = 1 + 3 = 4\).

◆ resolve_explicit_dependencies() [2/2]

template<typename ExpressionType , typename ValueType >
types::substitution_map Differentiation::SD::resolve_explicit_dependencies ( const std::vector< std::pair< ExpressionType, ValueType > > &  symbol_values,
const bool  force_cyclic_dependency_resolution = false 
)

Return a substitution map that has any explicit interdependencies between the entries of the map generated by the paired elements in the symbol_values vector resolved. The force_cyclic_dependency_resolution exists to ensure, if desired, that no cyclic dependencies can exist in the returned map.

This function performs substitution sweeps for a set of symbolic variables until all explicit relationships between the symbols in the map have been resolved. Whether each entry returns a symbolic or real value depends on the chosen ValueType and the values represented therein. If the ValueType is another Expression, and they contain symbols then the returned result may still be symbolic in nature.

For an example of what this function does, see the documentation for the other resolve_explicit_dependencies(const types::substitution_map &) function.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ substitute() [1/5]

Expression Differentiation::SD::substitute ( const Expression expression,
const types::substitution_map substitution_map 
)

Perform a single substitution sweep of a set of symbols into the given symbolic expression. The symbols in the expression that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function may be used to give a set of symbolic variables either a numeric interpretation or some symbolic definition.

Note
It is not required that all symbolic expressions be fully resolved when using this function. In other words, partial substitutions are valid.
This function call is typically expensive, as by default it performs a dictionary substitution for the symbols in the symbolic expression. Should the numerical value of some symbolic expression be desired, then this performance deficit may be mitigated through the use of the BatchOptimizer class. Situation dependent, the overhead of using a typical dictionary based substitution may be on par with that of a substitution performed using a BatchOptimizer. This is because there is an overhead to setting up the optimizer, so this should be taken into consideration if substitution is to occur for the given symbolic expression only a few times.
If the symbols stored in the map are explicitly dependent on one another, then the returned result depends on the order in which the map is traversed. It is recommended to first resolve all interdependencies in the map using the resolve_explicit_dependencies() function.

Examples:

  1. If map["a"] == 1 and map["b"] == "a" + 2, then the function \(f(a,b(a)) := a+b\) will be evaluated and the result \(f\vert_{a=1,b=a+2} = 3+a\) is returned. This return is because the symbol "a" is substituted throughout the function first, and only then is the symbol "b(a)" substituted, by which time its explicit dependency on "a" cannot be resolved.

  2. If map["a"] == "b"+2 and map["b"] == 1, then the function \(f(a(b),b): = a+b\) will be evaluated and the result \(f\vert_{a=b+2, b} = [b+2+b]_{b=1} = 4\) is returned. This is because the explicitly dependent symbol "a(b)" is substituted first followed by the symbol "b".

◆ substitute() [2/5]

template<typename ValueType >
Expression Differentiation::SD::substitute ( const Expression expression,
const Expression symbol,
const ValueType &  value 
)

Perform a substitution of the symbol into the given expression. All matches are assigned the corresponding value. This substitution function may be used to give a set of symbolic variables either a numeric interpretation or some symbolic definition.

For more information regarding the performance of symbolic substitution, see the other substitute(const Expression &, const types::substitution_map &) function.

Note
It is not required that all symbolic expressions be fully resolved when using this function. In other words, partial substitutions are valid.
Template Parameters
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type.

◆ substitute() [3/5]

template<typename ExpressionType , typename... Args>
ExpressionType Differentiation::SD::substitute ( const ExpressionType &  expression,
const Args &...  symbol_values 
)

Perform a single substitution sweep of a set of symbols into the given symbolic expression. The symbols in the expression that correspond to a matching entry key of the symbol_values vector entry are substituted by the entry's associated value. This substitution function may be used to give a set of symbolic variables either a numeric interpretation or some symbolic definition.

For more information regarding the performance of symbolic substitution, see the other substitute(const Expression &, const types::substitution_map &) function.

Note
It is not required that all symbolic expressions be fully resolved when using this function. In other words, partial substitutions are valid.
Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, but this may also represent Tensors and SymmetricTensors of Expressions.
ArgsAny symbolic type and value combination that is understood by the make_substitution_map() functions. This includes arguments involving individual Expressions, std::vector<Expression>, as well as Tensors and SymmetricTensors of Expressions.

◆ substitute_and_evaluate() [1/4]

template<typename ValueType >
ValueType Differentiation::SD::substitute_and_evaluate ( const Expression expression,
const types::substitution_map substitution_map 
)

Perform a single substitution sweep of a set of symbols into the given symbolic function, and immediately evaluate the result. The symbols in the expression that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function is used to give a set of symbolic variables a numeric interpretation, with the returned result being of the type specified by the ValueType template argument.

For more information regarding the performance of symbolic substitution, and the outcome of evaluation using a substitution map with cyclic dependencies, see the substitute(const Expression &, const types::substitution_map &) function.

Note
It is required that all symbols in the expression be successfully resolved by the substitution_map. If only partial substitution is performed, then an error is thrown.
Template Parameters
ValueTypeA type that corresponds to the value that the symbol is to represent. In the context of this particular function, this template parameter is typically arithmetic in nature.

◆ substitute_and_evaluate() [2/4]

template<typename ValueType , typename... Args>
ValueType Differentiation::SD::substitute_and_evaluate ( const Expression expression,
const Args &...  symbol_values 
)

Perform a single substitution sweep of a set of symbols into the given symbolic function, and immediately evaluate the result. The symbols in the expression that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function is used to give a set of symbolic variables a numeric interpretation with the returned result being of the type specified by the ValueType template argument.

For more information regarding the performance of symbolic substitution, and the outcome of evaluation using a substitution map with cyclic dependencies, see the substitute(const Expression &, const types::substitution_map &) function.

Note
It is required that all symbols in the expression be successfully resolved by the substitution map that is generated with the input collection of symbol_values. If only partial substitution is performed, then an error is thrown.
Template Parameters
ValueTypeA type that corresponds to the value that the symbol is to represent. In the context of this particular function, this template parameter is typically arithmetic in nature.
ArgsAny symbolic type and value combination that is understood by the make_substitution_map() functions. This includes arguments involving individual Expressions, std::vector<Expression>, as well as Tensors and SymmetricTensors of Expressions.

◆ make_vector_of_symbols()

template<int dim>
Tensor< 1, dim, Expression > Differentiation::SD::make_vector_of_symbols ( const std::string &  symbol)

Return a vector of Expressions representing a vectorial symbolic variable with the identifier specified by symbol.

For example, if the symbol is the string "v" then the vectorial symbolic variable that is returned represents the vector \(v\). Each component of \(v\) is prefixed by the given symbol, and has a suffix that indicates its component index.

Template Parameters
dimThe dimension of the returned tensor.
Parameters
[in]symbolAn identifier (or name) for the vector of returned symbolic variables.
Returns
A vector (a rank-1 tensor) of symbolic variables with the name of each individual component prefixed by symbol.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

Definition at line 237 of file symengine_tensor_operations.cc.

◆ make_tensor_of_symbols()

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::make_tensor_of_symbols ( const std::string &  symbol)

Return a tensor of Expressions representing a tensorial symbolic variable with the identifier specified by symbol.

For example, if the symbol is the string "T" then the tensorial symbolic variable that is returned represents the vector \(T\). Each component of \(T\) is prefixed by the given symbol, and has a suffix that indicates its component indices.

Template Parameters
rankThe rank of the returned tensor.
dimThe dimension of the returned tensor.
Parameters
[in]symbolAn identifier (or name) for the tensor of returned symbolic variables.
Returns
A tensor of symbolic variables with the name of each individual component prefixed by symbol.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

Definition at line 256 of file symengine_tensor_operations.cc.

◆ make_symmetric_tensor_of_symbols()

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::make_symmetric_tensor_of_symbols ( const std::string &  symbol)

Return a symmetric tensor of Expressions representing a tensorial symbolic variable with the identifier specified by symbol.

For example, if the symbol is the string "S" then the tensorial symbolic variable that is returned represents the vector \(S\). Each component of \(S\) is prefixed by the given symbol, and has a suffix that indicates its component indices.

Template Parameters
rankThe rank of the returned tensor.
dimThe dimension of the returned tensor.
Parameters
[in]symbolAn identifier (or name) for the tensor of returned symbolic variables.
Returns
A tensor of symbolic variables with the name of each individual component prefixed by symbol.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

Definition at line 264 of file symengine_tensor_operations.cc.

◆ make_vector_of_symbolic_functions()

template<int dim>
Tensor< 1, dim, Expression > Differentiation::SD::make_vector_of_symbolic_functions ( const std::string &  symbol,
const types::substitution_map arguments 
)

Return a vector of Expression representing a vectorial symbolic function with the identifier specified by symbol. The functions' symbolic dependencies are specified by the keys to the input arguments map; the values stored in the map are ignored.

Template Parameters
dimThe dimension of the returned tensor.
Parameters
[in]symbolAn identifier (or name) for the vector of returned symbolic functions.
[in]argumentsA map of input arguments to the returned symbolic functions.
Returns
A vector (a rank-1 tensor) of generic symbolic functions with the name of each individual component prefixed by symbol, a suffix that indicates its component index, and the number of input arguments equal to the length of arguments.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

◆ make_tensor_of_symbolic_functions()

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::make_tensor_of_symbolic_functions ( const std::string &  symbol,
const types::substitution_map arguments 
)

Return a tensor of Expression representing a tensorial symbolic function with the identifier specified by symbol. The functions' symbolic dependencies are specified by the keys to the input arguments map; the values stored in the map are ignored.

Template Parameters
rankThe rank of the returned tensor.
dimThe dimension of the returned tensor.
Parameters
[in]symbolAn identifier (or name) for the tensor of returned symbolic functions.
[in]argumentsA map of input arguments to the returned symbolic functions.
Returns
A tensor of generic symbolic functions with the name of each individual component prefixed by symbol, a suffix that indicates its component indeices, and the number of input arguments equal to the length of arguments.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

◆ make_symmetric_tensor_of_symbolic_functions()

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::make_symmetric_tensor_of_symbolic_functions ( const std::string &  symbol,
const types::substitution_map arguments 
)

Return a symmetric tensor of Expression representing a tensorial symbolic function with the identifier specified by symbol. The functions' symbolic dependencies are specified by the keys to the input arguments map; the values stored in the map are ignored.

Template Parameters
rankThe rank of the returned tensor.
dimThe dimension of the returned tensor.
Parameters
[in]symbolAn identifier (or name) for the tensor of returned symbolic functions.
[in]argumentsA map of input arguments to the returned symbolic functions.
Returns
A symmetric tensor of generic symbolic functions with the name of each individual component prefixed by symbol, a suffix that indicates its component indeices, and the number of input arguments equal to the length of arguments.
Warning
It is up to the user to ensure that there is no ambiguity in the symbols used within a section of code.

◆ differentiate() [2/13]

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::differentiate ( const Expression f,
const Tensor< rank, dim, Expression > &  T 
)

Return the symbolic result of computing the partial derivative of the scalar f with respect to the tensor T.

Parameters
[in]fA scalar symbolic function or (dependent) expression.
[in]TA tensor of symbolic (independent) variables.
Returns
The tensor of symbolic functions or expressions representing the result \(\frac{\partial f}{\partial \mathbf{T}}\).

◆ differentiate() [3/13]

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::differentiate ( const Expression f,
const SymmetricTensor< rank, dim, Expression > &  S 
)

Return the symbolic result of computing the partial derivative of the scalar f with respect to the symmetric tensor S.

Parameters
[in]fA scalar symbolic function or (dependent) expression.
[in]SA symmetric tensor of symbolic (independent) variables.
Returns
The symmetric tensor of symbolic functions or expressions representing the result \(\frac{\partial f}{\partial \mathbf{S}}\).

◆ differentiate() [4/13]

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::differentiate ( const Tensor< 0, dim, Expression > &  f,
const Tensor< rank, dim, Expression > &  T 
)

Return the symbolic result of computing the partial derivative of the rank-0 tensor (or scalar) f with respect to the tensor T.

Parameters
[in]fA rank-0 tensor symbolic function or (dependent) expression.
[in]TA tensor of symbolic (independent) variables.
Returns
The tensor of symbolic functions or expressions representing the result \(\frac{\partial f}{\partial \mathbf{T}}\).

◆ differentiate() [5/13]

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::differentiate ( const Tensor< 0, dim, Expression > &  f,
const SymmetricTensor< rank, dim, Expression > &  S 
)

Return the symbolic result of computing the partial derivative of the rank-0 tensor (or scalar) f with respect to the symmetric tensor S.

Parameters
[in]fA rank-0 tensor symbolic function or (dependent) expression.
[in]SA symmetric tensor of symbolic (independent) variables.
Returns
The symmetric tensor of symbolic functions or expressions representing the result \(\frac{\partial f}{\partial \mathbf{S}}\).

◆ differentiate() [6/13]

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::differentiate ( const Tensor< rank, dim, Expression > &  T,
const Expression x 
)

Return the symbolic result of computing the partial derivative of the tensor T with respect to the scalar x.

Parameters
[in]TA tensor of symbolic functions or (dependent) expressions.
[in]xA scalar symbolic (independent) variable.
Returns
The tensor of symbolic functions or expressions representing the result \(\frac{\partial \mathbf{T}}{\partial x}\).

◆ differentiate() [7/13]

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::differentiate ( const SymmetricTensor< rank, dim, Expression > &  S,
const Expression x 
)

Return the symbolic result of computing the partial derivative of the symmetric tensor S with respect to the scalar x.

Parameters
[in]SA symmetric tensor of symbolic functions or (dependent) expressions.
[in]xA scalar symbolic (independent) variable.
Returns
The symmetric tensor of symbolic functions or expressions representing the result \(\frac{\partial \mathbf{S}}{\partial x}\).

◆ differentiate() [8/13]

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::differentiate ( const Tensor< rank, dim, Expression > &  T,
const Tensor< 0, dim, Expression > &  x 
)

Return the symbolic result of computing the partial derivative of the tensor T with respect to the rank-0 tensor x.

Parameters
[in]TA tensor of symbolic functions or (dependent) expressions.
[in]xA rank-0 tensor containing a symbolic (independent) variable.
Returns
The tensor of symbolic functions or expressions representing the result \(\frac{\partial \mathbf{T}}{\partial x}\).

◆ differentiate() [9/13]

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::differentiate ( const SymmetricTensor< rank, dim, Expression > &  S,
const Tensor< 0, dim, Expression > &  x 
)

Return the symbolic result of computing the partial derivative of the symmetric tensor S with respect to the rank-0 tensor x.

Parameters
[in]SA symmetric tensor of symbolic functions or (dependent) expressions.
[in]xA rank-0 tensor containing a symbolic (independent) variable.
Returns
The symmetric tensor of symbolic functions or expressions representing the result \(\frac{\partial \mathbf{S}}{\partial x}\).

◆ differentiate() [10/13]

template<int rank_1, int rank_2, int dim>
Tensor< rank_1+rank_2, dim, Expression > Differentiation::SD::differentiate ( const Tensor< rank_1, dim, Expression > &  T1,
const Tensor< rank_2, dim, Expression > &  T2 
)

Return the symbolic result of computing the partial derivative of the tensor T1 with respect to the tensor T2.

Parameters
[in]T1A tensor of symbolic functions or (dependent) expressions.
[in]T2A tensor of symbolic (independent) variables.
Returns
The tensor of symbolic functions or variables representing the result \(\frac{\partial \mathbf{T}_{1}}{\partial \mathbf{T}_{2}}\).

◆ differentiate() [11/13]

template<int rank_1, int rank_2, int dim>
SymmetricTensor< rank_1+rank_2, dim, Expression > Differentiation::SD::differentiate ( const SymmetricTensor< rank_1, dim, Expression > &  S1,
const SymmetricTensor< rank_2, dim, Expression > &  S2 
)

Return the symbolic result of computing the partial derivative of the symmetric tensor S1 with respect to the symmetric tensor S2.

Parameters
[in]S1A symmetric tensor of symbolic functions or (dependent) expressions.
[in]S2A symmetric tensor of symbolic (independent) variables.
Returns
The symmetric tensor of symbolic functions or variables representing the result \(\frac{\partial \mathbf{S}_{1}}{\partial \mathbf{S}_{2}}\).

◆ differentiate() [12/13]

template<int rank_1, int rank_2, int dim>
Tensor< rank_1+rank_2, dim, Expression > Differentiation::SD::differentiate ( const Tensor< rank_1, dim, Expression > &  T,
const SymmetricTensor< rank_2, dim, Expression > &  S 
)

Return the symbolic result of computing the partial derivative of the tensor T with respect to the symmetric tensor S.

Parameters
[in]TA tensor of symbolic functions or (dependent) expressions.
[in]SA symmetric tensor of symbolic (independent) variables.
Returns
The tensor of symbolic functions or variables representing the result \(\frac{\partial \mathbf{T}}{\partial \mathbf{S}}\).

◆ differentiate() [13/13]

template<int rank_1, int rank_2, int dim>
Tensor< rank_1+rank_2, dim, Expression > Differentiation::SD::differentiate ( const SymmetricTensor< rank_1, dim, Expression > &  S,
const Tensor< rank_2, dim, Expression > &  T 
)

Return the symbolic result of computing the partial derivative of the symmetric tensor S with respect to the tensor T.

Parameters
[in]SA symmetric tensor of symbolic functions or (dependent) expressions.
[in]TA tensor of symbolic (independent) variables.
Returns
The tensor of symbolic functions or variables representing the result \(\frac{\partial \mathbf{S}}{\partial \mathbf{T}}\).

◆ add_to_symbol_map() [6/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double, int rank, int dim, typename SymbolicType >
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const Tensor< rank, dim, SymbolicType > &  symbol_tensor 
)

A convenience function for adding empty entries, with the key values equal to the entries in the symbol_tensor, to the symbolic map symbol_map.

For more context which this function is used, see the other add_to_symbol_map(types::substitution_map &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.

◆ add_to_symbol_map() [7/7]

template<bool ignore_invalid_symbols = false, typename ValueType = double, int rank, int dim, typename SymbolicType >
void Differentiation::SD::add_to_symbol_map ( types::substitution_map symbol_map,
const SymmetricTensor< rank, dim, SymbolicType > &  symbol_tensor 
)

A convenience function for adding empty entries, with the key values equal to the entries in the symbol_tensor, to the symbolic map symbol_map.

For more context which this function is used, see the other add_to_symbol_map(types::substitution_map &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_symbol_map(types::substitution_map &, const Expression &) function for a detailed discussion on the role of this template argument.
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. This ValueType is somewhat arbitrary as it is only used to create default-constructed values as entries in the map.

◆ set_value_in_symbol_map() [8/9]

template<int rank, int dim, typename SymbolicType , typename ValueType >
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const Tensor< rank, dim, SymbolicType > &  symbol_tensor,
const Tensor< rank, dim, ValueType > &  value_tensor 
)

Find the input symbols in the substitution_map and set the entries corresponding to the key values given by symbol_tensor to the values given by value_tensor.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ set_value_in_symbol_map() [9/9]

template<int rank, int dim, typename SymbolicType , typename ValueType >
void Differentiation::SD::set_value_in_symbol_map ( types::substitution_map substitution_map,
const SymmetricTensor< rank, dim, SymbolicType > &  symbol_tensor,
const SymmetricTensor< rank, dim, ValueType > &  value_tensor 
)

Find the input symbols in the substitution_map and set the entries corresponding to the key values given by symbol_tensor to the values given by value_tensor.

This function may be used to safely transform an existing or null symbolic map (one with uninitialized entries) into one that can be used to conduct symbolic substitution operations (i.e., a substitution map).

Template Parameters
SymbolicTypeA type that represents a symbolic variable. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined SymbolicType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ make_substitution_map() [7/8]

template<int rank, int dim, typename ExpressionType , typename ValueType >
types::substitution_map Differentiation::SD::make_substitution_map ( const Tensor< rank, dim, ExpressionType > &  symbol_tensor,
const Tensor< rank, dim, ValueType > &  value_tensor 
)

Return a substitution map that has the entry keys given by the symbol_tensor and the values given by the value_tensor. It is expected that all key entries be valid symbols or symbolic expressions.

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &,const ValueType &) function.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ make_substitution_map() [8/8]

template<int rank, int dim, typename ExpressionType , typename ValueType >
types::substitution_map Differentiation::SD::make_substitution_map ( const SymmetricTensor< rank, dim, ExpressionType > &  symbol_tensor,
const SymmetricTensor< rank, dim, ValueType > &  value_tensor 
)

Return a substitution map that has the entry keys given by the symbol_tensor and the values given by the value_tensor. It is expected that all key entries be valid symbols or symbolic expressions.

It is possible to map symbolic types to other symbolic types using this function. For more details on this, see the other make_substitution_map(const Expression &,const ValueType &) function.

Template Parameters
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ add_to_substitution_map() [8/9]

template<bool ignore_invalid_symbols = false, int rank, int dim, typename ExpressionType , typename ValueType >
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const Tensor< rank, dim, ExpressionType > &  symbol_tensor,
const Tensor< rank, dim, ValueType > &  value_tensor 
)

A convenience function for adding an entry to the substitution_map. The new entries will have the keys given in the symbol_tensor with their paired values extracted from the corresponding elements of the value_tensor.

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ add_to_substitution_map() [9/9]

template<bool ignore_invalid_symbols = false, int rank, int dim, typename ExpressionType , typename ValueType >
void Differentiation::SD::add_to_substitution_map ( types::substitution_map substitution_map,
const SymmetricTensor< rank, dim, ExpressionType > &  symbol_tensor,
const SymmetricTensor< rank, dim, ValueType > &  value_tensor 
)

A convenience function for adding an entry to the substitution_map. The new entries will have the keys given in the symbol_tensor with their paired values extracted from the corresponding elements of the value_tensor.

For more context which this function is used, see the other add_to_substitution_map(types::substitution_map &,const Expression &, const Expression &) function.

Template Parameters
ignore_invalid_symbolsSee the other add_to_substitution_map(types::substitution_map &, const Expression &, const Expression &) function for a detailed discussion on the role of this template argument.
ExpressionTypeA type that represents a symbolic expression. The Differentiation::SD::Expression class is often suitable for this purpose, although if the ValueType is not supported by this class then a user-defined ExpressionType should be used.
ValueTypeA type that corresponds to the value that the symbol is to represent. Although it is typically arithmetic in nature, it may also represent another symbolic expression type or be a special type that a user-defined ExpressionType can be constructed from.

◆ substitute() [4/5]

template<int rank, int dim>
Tensor< rank, dim, Expression > Differentiation::SD::substitute ( const Tensor< rank, dim, Expression > &  expression_tensor,
const types::substitution_map substitution_map 
)

Perform a single substitution sweep of a set of symbols into the given tensor of symbolic expressions. The symbols in the expression_tensor that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function may be used to give a set of symbolic variables either a numeric interpretation or some symbolic definition.

For more information regarding the performance of symbolic substitution, and the outcome of evaluation using a substitution map with cyclic dependencies, see the substitute(const Expression &, const types::substitution_map &) function.

Note
It is not required that all symbolic expressions be fully resolved when using this function. In other words, partial substitutions are valid.

◆ substitute() [5/5]

template<int rank, int dim>
SymmetricTensor< rank, dim, Expression > Differentiation::SD::substitute ( const SymmetricTensor< rank, dim, Expression > &  expression_tensor,
const types::substitution_map substitution_map 
)

Perform a single substitution sweep of a set of symbols into the given symmetric tensor of symbolic expressions. The symbols in the expression_tensor that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function may be used to give a set of symbolic variables either a numeric interpretation or some symbolic definition.

For more information regarding the performance of symbolic substitution, and the outcome of evaluation using a substitution map with cyclic dependencies, see the substitute(const Expression &, const types::substitution_map &) function.

Note
It is not required that all symbolic expressions be fully resolved when using this function. In other words, partial substitutions are valid.

◆ substitute_and_evaluate() [3/4]

template<typename ValueType , int rank, int dim>
Tensor< rank, dim, ValueType > Differentiation::SD::substitute_and_evaluate ( const Tensor< rank, dim, Expression > &  expression_tensor,
const types::substitution_map substitution_map 
)

Perform a single substitution sweep of a set of symbols into the given tensor of symbolic expressions, and immediately evaluate the tensorial result. The symbols in the expression_tensor that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function is used to give a set of symbolic variables a numeric interpretation with the returned result being of the type specified by the ValueType template argument.

For more information regarding the performance of symbolic substitution, and the outcome of evaluation using a substitution map with cyclic dependencies, see the substitute(const Expression &, const types::substitution_map &) function.

Note
It is required that all symbols in expression_tensor be successfully resolved by the substitution_map. If only partial substitution is performed, then an error is thrown.
Template Parameters
ValueTypeA type that corresponds to the value that the symbol is to represent. In the context of this particular function, this template parameter is typically arithmetic in nature.

◆ substitute_and_evaluate() [4/4]

template<typename ValueType , int rank, int dim>
SymmetricTensor< rank, dim, ValueType > Differentiation::SD::substitute_and_evaluate ( const SymmetricTensor< rank, dim, Expression > &  expression_tensor,
const types::substitution_map substitution_map 
)

Perform a single substitution sweep of a set of symbols into the given symmetric tensor of symbolic expressions, and immediately evaluate the tensorial result. The symbols in the expression_tensor that correspond to the entry keys of the substitution_map are substituted with the map entry's associated value. This substitution function is used to give a set of symbolic variables a numeric interpretation, with the returned result being of the type specified by the ValueType template argument.

For more information regarding the performance of symbolic substitution, and the outcome of evaluation using a substitution map with cyclic dependencies, see the substitute(const Expression &, const types::substitution_map &) function.

Note
It is required that all symbols in expression_tensor be successfully resolved by the substitution_map. If only partial substitution is performed, then an error is thrown.
Template Parameters
ValueTypeA type that corresponds to the value that the symbol is to represent. In the context of this particular function, this template parameter is typically arithmetic in nature.

◆ Expression::operator const SymEngine::RCP< const SymEngine::Basic > &()

Differentiation::SD::Expression::operator const SymEngine::RCP< const SymEngine::Basic > & ( ) const

Definition at line 276 of file symengine_number_types.cc.