]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Specialize some functions in the numbers namespace for SD::Expression.
authorJean-Paul Pelteret <jppelteret@gmail.com>
Wed, 17 Apr 2019 20:28:16 +0000 (22:28 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Mon, 22 Apr 2019 08:10:25 +0000 (10:10 +0200)
Also required for support of SD::Expression within the Tensor and
SymmetricTensor classes.

include/deal.II/differentiation/sd/symengine_number_types.h

index b3a487dcb2c689a7ac0df332fbf59ca16a3ac9cb..23db60cd6ec96a00efba107e5f949cf594b411bb 100644 (file)
@@ -30,6 +30,7 @@
 #  include <symengine/expression.h>
 #  include <symengine/integer.h>
 #  include <symengine/logic.h>
+#  include <symengine/number.h>
 #  include <symengine/rational.h>
 
 // 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<const SymEngine::Number> number_rcp =
+          SymEngine::rcp_static_cast<const SymEngine::Number>(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
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.