]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add traits for SD numbers
authorJean-Paul Pelteret <jppelteret@gmail.com>
Sat, 30 Mar 2019 10:18:46 +0000 (11:18 +0100)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Tue, 2 Apr 2019 16:29:08 +0000 (18:29 +0200)
include/deal.II/differentiation/sd.h [new file with mode: 0644]
include/deal.II/differentiation/sd/symengine_number_traits.h [new file with mode: 0644]

diff --git a/include/deal.II/differentiation/sd.h b/include/deal.II/differentiation/sd.h
new file mode 100644 (file)
index 0000000..f2707cb
--- /dev/null
@@ -0,0 +1,46 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii_differentiation_sd_h
+#define dealii_differentiation_sd_h
+
+#include <deal.II/base/config.h>
+
+#ifdef DEAL_II_WITH_SYMENGINE
+
+#  include <deal.II/differentiation/sd/symengine_number_traits.h>
+#  include <deal.II/differentiation/sd/symengine_number_types.h>
+#  include <deal.II/differentiation/sd/symengine_types.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace Differentiation
+{
+  /**
+   * Wrappers for symbolic differentiation libraries. Currently there is support
+   * for the following libraries:
+   *   - SymEngine
+   *
+   * @ingroup auto_symb_diff
+   */
+  namespace SD
+  {}
+} // namespace Differentiation
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif // DEAL_II_WITH_SYMENGINE
+
+#endif // dealii_differentiation_sd_h
diff --git a/include/deal.II/differentiation/sd/symengine_number_traits.h b/include/deal.II/differentiation/sd/symengine_number_traits.h
new file mode 100644 (file)
index 0000000..295584a
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii_differentiation_sd_symengine_number_traits_h
+#define dealii_differentiation_sd_symengine_number_traits_h
+
+#include <deal.II/base/config.h>
+
+#ifdef DEAL_II_WITH_SYMENGINE
+
+#  include <symengine/expression.h>
+
+#  include <type_traits>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+
+namespace Differentiation
+{
+  namespace SD
+  {
+    /**
+     * A struct to indicate whether a given @p NumberType is a supported
+     * symbolically differentiable number or not. By default, numbers are not
+     * considered to have the necessary characteristics to fulfill this
+     * condition.
+     *
+     * @author Jean-Paul Pelteret, 2019
+     */
+    template <typename NumberType>
+    struct is_sd_number : std::false_type
+    {};
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a supported
+     * SymEngine number or not. By default, numbers are not
+     * considered to have the necessary characteristics to fulfill this
+     * condition.
+     *
+     * @author Jean-Paul Pelteret, 2019
+     */
+    template <typename NumberType>
+    struct is_symengine_number : std::false_type
+    {};
+
+
+    /*--- SymEngine Expression class ---*/
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a supported
+     * symbolically differentiable number or not.
+     * This is a specialization for the SymEngine Expression class.
+     *
+     * @author Jean-Paul Pelteret, 2019
+     */
+    template <>
+    struct is_symengine_number<SymEngine::Expression> : std::true_type
+    {};
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a supported
+     * symbolically differentiable number or not.
+     * This is a specialization for the SymEngine Expression class.
+     *
+     * @author Jean-Paul Pelteret, 2019
+     */
+    template <>
+    struct is_sd_number<SymEngine::Expression> : std::true_type
+    {};
+
+  } // namespace SD
+} // namespace Differentiation
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif // DEAL_II_WITH_SYMENGINE
+
+#endif // dealii_differentiation_sd_symengine_number_traits_h

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.