17#ifdef DEAL_II_WITH_SYMENGINE
25# include <symengine/complex_double.h>
26# include <symengine/logic.h>
27# include <symengine/number.h>
28# include <symengine/parser.h>
29# include <symengine/real_double.h>
30# include <symengine/symbol.h>
31# include <symengine/symengine_exception.h>
41 namespace SE = ::SymEngine;
53 : expression(SE::boolean(value))
73 "The conditional expression must return a boolean type."));
75 const SE::RCP<const SE::Boolean> condition_rcp =
76 SE::rcp_static_cast<const SE::Boolean>(condition.
get_RCP());
78 SE::piecewise({{expression_if_true.
get_RCP(), condition_rcp},
79 {expression_if_false.
get_RCP(), SE::boolTrue}});
84 &condition_expression,
87 SE::PiecewiseVec piecewise_function;
88 piecewise_function.reserve(condition_expression.size() + 1);
91 for (
const auto &entry : condition_expression)
93 Assert(SE::is_a_Boolean(entry.first.get_value()),
95 "The conditional expression must return a boolean type."));
96 piecewise_function.emplace_back(
97 entry.second.get_RCP(),
98 SE::rcp_static_cast<const SE::Boolean>(entry.first.get_RCP()));
102 piecewise_function.emplace_back(expression_otherwise.
get_RCP(),
107 expression = SE::piecewise(std::move(piecewise_function));
112 &condition_expression)
123 : expression(SE::symbol(symbol))
128 const bool parse_as_expression)
135 SE::rcp_static_cast<const SE::Basic>(SE::symbol(
147 : expression(SE::function_symbol(
149 Utilities::convert_expression_vector_to_basic_vector(arguments)))
203 std::getline(is, expr);
212 const SE::Expression &
233 const SE::RCP<const SE::Basic> &
245 const SymEngine::RCP<const SymEngine::Symbol> &symbol)
const
253 const SymEngine::RCP<const SymEngine::Basic> &symbol)
const
270 Expression::operator
const SymEngine::Expression &()
const
272 return get_expression();
276 Expression::operator
const SymEngine::RCP<const SymEngine::Basic> &()
const
278 return get_expression().get_basic();
287 const SymEngine::map_basic_basic &substitution_values)
const
308 "Substitution with a number that does not represent a symbol."));
311 sub_vals[symbol] = value;
333 this->expression = std::move(rhs.expression);
442 ExcMessage(
"The expression must return a boolean type."));
444 const SE::RCP<const SE::Boolean> expression_rcp =
445 SE::rcp_static_cast<const SE::Boolean>(expression.
get_RCP());
447 return Expression(SE::logical_not(expression_rcp));
455 ExcMessage(
"The lhs expression must return a boolean type."));
457 ExcMessage(
"The rhs expression must return a boolean type."));
459 const SE::RCP<const SE::Boolean> lhs_rcp =
460 SE::rcp_static_cast<const SE::Boolean>(lhs.
get_RCP());
461 const SE::RCP<const SE::Boolean> rhs_rcp =
462 SE::rcp_static_cast<const SE::Boolean>(rhs.
get_RCP());
464 return Expression(SE::logical_and({lhs_rcp, rhs_rcp}));
472 ExcMessage(
"The lhs expression must return a boolean type."));
474 ExcMessage(
"The rhs expression must return a boolean type."));
476 const SE::RCP<const SE::Boolean> lhs_rcp =
477 SE::rcp_static_cast<const SE::Boolean>(lhs.
get_RCP());
478 const SE::RCP<const SE::Boolean> rhs_rcp =
479 SE::rcp_static_cast<const SE::Boolean>(rhs.
get_RCP());
481 return Expression(SE::logical_or({lhs_rcp, rhs_rcp}));
489 ExcMessage(
"The lhs expression must return a boolean type."));
491 ExcMessage(
"The rhs expression must return a boolean type."));
493 const SE::RCP<const SE::Boolean> lhs_rcp =
494 SE::rcp_static_cast<const SE::Boolean>(lhs.
get_RCP());
495 const SE::RCP<const SE::Boolean> rhs_rcp =
496 SE::rcp_static_cast<const SE::Boolean>(rhs.
get_RCP());
498 return Expression(SE::logical_xor({lhs_rcp, rhs_rcp}));
Expression & operator/=(const Expression &rhs)
Expression & parse(const std::string &expression)
Expression operator-() const
Expression & operator=(const Expression &rhs)
const SymEngine::RCP< const SymEngine::Basic > & get_RCP() const
void load(std::istream &stream)
Expression & operator*=(const Expression &rhs)
std::ostream & print(std::ostream &stream) const
Expression substitute(const types::substitution_map &substitution_values) const
void save(std::ostream &stream) const
Expression & operator-=(const Expression &rhs)
const SymEngine::Basic & get_value() const
const SymEngine::Expression & get_expression() const
Expression & operator+=(const Expression &rhs)
SymEngine::Expression expression
Expression differentiate(const Expression &symbol) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcSymEngineParserError(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
SymEngine::map_basic_basic convert_expression_map_to_basic_map(const SD::types::substitution_map &substitution_map)
std::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map
std::vector< SD::Expression > symbol_vector
Expression operator*(Expression lhs, const Expression &rhs)
Expression operator<(const Expression &lhs, const Expression &rhs)
Expression operator-(Expression lhs, const Expression &rhs)
Expression operator+(Expression lhs, const Expression &rhs)
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)
Expression operator>(const Expression &lhs, const Expression &rhs)
Expression operator&(const Expression &lhs, const Expression &rhs)
Expression operator/(Expression lhs, const Expression &rhs)
Expression operator<=(const Expression &lhs, const Expression &rhs)
Expression operator&&(const Expression &lhs, const Expression &rhs)
std::ostream & operator<<(std::ostream &stream, const Expression &expression)
Expression operator==(const Expression &lhs, const Expression &rhs)
std::istream & operator>>(std::istream &stream, Expression &expression)