19 #ifdef DEAL_II_WITH_SYMENGINE
26 # include <symengine/real_double.h>
34 namespace SE = ::SymEngine;
85 if (SE::is_a<SE::Symbol>(entry))
93 if (SE::is_a<SE::FunctionSymbol>(entry))
99 if (SE::is_a<SE::Derivative>(entry))
106 if (SE::is_a<SE::Mul>(entry))
108 const SE::Mul &entry_mul = SE::down_cast<const SE::Mul &>(entry);
110 if (SE::eq(*(entry_mul.get_coef()), *SE::real_double(0.5)))
114 const SE::map_basic_basic &entry_mul_dict =
115 entry_mul.get_dict();
116 if (entry_mul_dict.size() == 1 &&
117 SE::is_a<SE::Derivative>(*(entry_mul_dict.begin()->first)))
129 const SymEngine::RCP<const SymEngine::Basic> &symbol,
130 const SymEngine::RCP<const SymEngine::Basic> &
value)
135 "Substitution with a number that does not represent a symbol or symbolic derivative"));
139 ExcMessage(
"Did not find this symbol in the map."));
141 it_sym->second = Expression(
value);
149 const Expression & symbol,
150 const Expression &
value)
162 for (
const auto &entry : symbol_values)
189 for (
const auto &entry : symb_map_in)
191 const typename types::substitution_map::const_iterator it_other =
192 symb_map_out.find(entry.first);
193 if (it_other == symb_map_out.end())
194 symb_map_out.insert(std::make_pair(entry.first, entry.second));
197 Assert(SE::eq(*(entry.second.get_RCP()),
198 *(it_other->second.get_RCP())),
199 ExcMessage(
"Key already in map, but values don't match"));
210 const bool force_cyclic_dependency_resolution)
213 const std::size_t size = symbol_values.size();
215 for (
auto &entry : symbol_values_resolved)
222 Expression & out = entry.second;
224 SE::hash_t hash_new = out.get_RCP()->hash();
225 unsigned int iter = 0;
230 if (force_cyclic_dependency_resolution)
237 out = out.substitute(symbol_values_resolved);
241 out = out.substitute(symbol_values);
246 hash_new = out.get_RCP()->hash();
250 "Unresolvable cyclic dependency detected in substitution map."));
253 while (hash_new != hash_old);
256 return symbol_values_resolved;
273 #endif // DEAL_II_WITH_SYMENGINE