From: Jean-Paul Pelteret Date: Wed, 17 Apr 2019 20:28:16 +0000 (+0200) Subject: Specialize some functions in the numbers namespace for SD::Expression. X-Git-Tag: v9.1.0-rc1~191^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=606ecdce1d341da8fa2a784c364beb57db346b07;p=dealii.git Specialize some functions in the numbers namespace for SD::Expression. Also required for support of SD::Expression within the Tensor and SymmetricTensor classes. --- 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