18#ifdef DEAL_II_WITH_SYMENGINE
26# include <symengine/complex_double.h>
27# include <symengine/logic.h>
28# include <symengine/number.h>
29# include <symengine/parser.h>
30# include <symengine/real_double.h>
31# include <symengine/symbol.h>
32# include <symengine/symengine_exception.h>
42 namespace SE = ::SymEngine;
54 : expression(SE::boolean(value))
74 "The conditional expression must return a boolean type."));
76 const SE::RCP<const SE::Boolean> condition_rcp =
77 SE::rcp_static_cast<const SE::Boolean>(condition.
get_RCP());
79 SE::piecewise({{expression_if_true.
get_RCP(), condition_rcp},
80 {expression_if_false.
get_RCP(), SE::boolTrue}});
85 & condition_expression,
88 SE::PiecewiseVec piecewise_function;
89 piecewise_function.reserve(condition_expression.size() + 1);
92 for (
const auto &entry : condition_expression)
94 Assert(SE::is_a_Boolean(entry.first.get_value()),
96 "The conditional expression must return a boolean type."));
97 piecewise_function.push_back(
98 {entry.second.get_RCP(),
99 SE::rcp_static_cast<const SE::Boolean>(entry.first.get_RCP())});
103 piecewise_function.push_back(
104 {expression_otherwise.
get_RCP(), SE::boolTrue});
107 expression = SE::piecewise(std::move(piecewise_function));
112 &condition_expression)
118 Expression(numbers::signaling_nan<double>()));
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(
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);
441 ExcMessage(
"The expression must return a boolean type."));
443 const SE::RCP<const SE::Boolean> expression_rcp =
444 SE::rcp_static_cast<const SE::Boolean>(expression.
get_RCP());
446 return Expression(SE::logical_not(expression_rcp));
453 ExcMessage(
"The lhs expression must return a boolean type."));
455 ExcMessage(
"The rhs expression must return a boolean type."));
457 const SE::RCP<const SE::Boolean> lhs_rcp =
458 SE::rcp_static_cast<const SE::Boolean>(lhs.
get_RCP());
459 const SE::RCP<const SE::Boolean> rhs_rcp =
460 SE::rcp_static_cast<const SE::Boolean>(rhs.
get_RCP());
462 return Expression(SE::logical_and({lhs_rcp, rhs_rcp}));
470 ExcMessage(
"The lhs expression must return a boolean type."));
472 ExcMessage(
"The rhs expression must return a boolean type."));
474 const SE::RCP<const SE::Boolean> lhs_rcp =
475 SE::rcp_static_cast<const SE::Boolean>(lhs.
get_RCP());
476 const SE::RCP<const SE::Boolean> rhs_rcp =
477 SE::rcp_static_cast<const SE::Boolean>(rhs.
get_RCP());
487 ExcMessage(
"The lhs expression must return a boolean type."));
489 ExcMessage(
"The rhs expression must return a boolean type."));
491 const SE::RCP<const SE::Boolean> lhs_rcp =
492 SE::rcp_static_cast<const SE::Boolean>(lhs.
get_RCP());
493 const SE::RCP<const SE::Boolean> rhs_rcp =
494 SE::rcp_static_cast<const SE::Boolean>(rhs.
get_RCP());
496 return Expression(SE::logical_xor({lhs_rcp, rhs_rcp}));
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
Expression & operator/=(const Expression &rhs)
Expression & parse(const std::string &expression)
Expression operator*(Expression lhs, const Expression &rhs)
Expression operator-() const
Expression operator<(const Expression &lhs, const Expression &rhs)
Expression operator-(Expression lhs, const Expression &rhs)
static ::ExceptionBase & ExcIO()
Expression & operator=(const Expression &rhs)
Expression operator+(Expression lhs, const Expression &rhs)
const SymEngine::RCP< const SymEngine::Basic > & get_RCP() const
void load(std::istream &stream)
Expression & operator*=(const Expression &rhs)
Expression operator!(const Expression &expression)
Expression operator||(const Expression &lhs, const Expression &rhs)
static ::ExceptionBase & ExcSymEngineParserError(std::string arg1)
Expression operator^(const Expression &lhs, const Expression &rhs)
#define Assert(cond, exc)
Expression operator>=(const Expression &lhs, const Expression &rhs)
std::ostream & print(std::ostream &stream) const
Expression substitute(const types::substitution_map &substitution_values) const
Expression operator!=(const Expression &lhs, const Expression &rhs)
Expression operator|(const Expression &lhs, const Expression &rhs)
void save(std::ostream &stream) const
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 &rhs)
Expression operator&&(const Expression &lhs, const Expression &rhs)
const SymEngine::Basic & get_value() const
const SymEngine::Expression & get_expression() const
std::ostream & operator<<(std::ostream &stream, const Expression &expression)
Expression operator==(const Expression &lhs, const Expression &rhs)
Expression & operator+=(const Expression &rhs)
static ::ExceptionBase & ExcMessage(std::string arg1)
SymEngine::Expression expression
Expression differentiate(const Expression &symbol) const
std::istream & operator>>(std::istream &stream, Expression &expression)
#define AssertThrow(cond, exc)
SymEngine::map_basic_basic convert_expression_map_to_basic_map(const SD::types::substitution_map &substitution_map)
SymEngine::vec_basic convert_expression_vector_to_basic_vector(const SD::types::symbol_vector &symbol_vector)
std::vector< SD::Expression > symbol_vector
std::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map
T logical_or(const T &t, const MPI_Comm &mpi_communicator)