From 606ecdce1d341da8fa2a784c364beb57db346b07 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Wed, 17 Apr 2019 22:28:16 +0200 Subject: [PATCH] Specialize some functions in the numbers namespace for SD::Expression. Also required for support of SD::Expression within the Tensor and SymmetricTensor classes. --- .../sd/symengine_number_types.h | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/deal.II/differentiation/sd/symengine_number_types.h b/include/deal.II/differentiation/sd/symengine_number_types.h index b3a487dcb2..23db60cd6e 100644 --- a/include/deal.II/differentiation/sd/symengine_number_types.h +++ b/include/deal.II/differentiation/sd/symengine_number_types.h @@ -30,6 +30,7 @@ # include # include # include +# include # include // Number operations @@ -1292,6 +1293,42 @@ namespace Differentiation } // namespace Differentiation +// Specializations from numbers.h +// These are required in order to make the SD::Expression class a compatible +// number for the Tensor and SymmetricTensor classes +namespace numbers +{ + template <> + inline bool + value_is_zero(const Differentiation::SD::Expression &value) + { + if (SymEngine::is_a_Number(value.get_value())) + { + const SymEngine::RCP number_rcp = + SymEngine::rcp_static_cast(value.get_RCP()); + return number_rcp->is_zero(); + } + + return false; + } + + template <> + inline bool + values_are_equal(const Differentiation::SD::Expression &value_1, + const Differentiation::SD::Expression &value_2) + { + return (value_1.get_value().__cmp__(value_2.get_value()) == 0); + } + + template <> + inline bool + value_is_less_than(const Differentiation::SD::Expression &value_1, + const Differentiation::SD::Expression &value_2) + { + return (value_1.get_value().__cmp__(value_2.get_value()) == -1); + } +} // namespace numbers + DEAL_II_NAMESPACE_CLOSE -- 2.39.5