]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Update Adol-C number types.
authorJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 12 Apr 2018 12:41:19 +0000 (14:41 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 12 Apr 2018 16:43:10 +0000 (18:43 +0200)
Default definitions for helper functions are now given irrespective of
whether deal.II is compiled with Adol-C or not. This assists in generic
programming.

include/deal.II/differentiation/ad/adolc_number_types.h

index 240730c5bf00ae98f989d7940b292bd2a0ed39e5..dd75c8e67dcf1824ac5a9eec7918aa6e87598511 100644 (file)
 #define dealii_differentiation_ad_adolc_number_types_h
 
 #include <deal.II/base/config.h>
-
-#ifdef DEAL_II_WITH_ADOLC
-
-#include <adolc/internal/adolc_settings.h>
-#include <adolc/internal/adubfunc.h> // Taped double math functions
-
-#include <adolc/adouble.h> // Taped double
-#include <adolc/adtl.h>    // Tapeless double
-
-#include <deal.II/base/numbers.h>
-#include <deal.II/base/exceptions.h>
-
-#include <deal.II/differentiation/ad/ad_number_types.h>
-#include <deal.II/differentiation/ad/ad_number_traits.h>
-
-#include <complex>
 #include <type_traits>
 
 DEAL_II_NAMESPACE_OPEN
@@ -50,11 +34,62 @@ namespace Differentiation
      * @author Jean-Paul Pelteret, 2017
      */
     template <typename NumberType, typename = void>
-    struct is_adolc_number;
+    struct is_adolc_number
+      : std::false_type
+    {};
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a taped
+     * Adol-C number or not. By default, numbers are not considered to
+     * have the necessary characteristics to fulfill this condition.
+     *
+     * @author Jean-Paul Pelteret, 2017
+     */
+    template <typename NumberType, typename = void>
+    struct is_adolc_taped_number
+      : std::false_type
+    {};
+
+
+    /**
+     * A struct to indicate whether a given @p NumberType is a tapeless
+     * Adol-C number or not. By default, numbers are not considered to
+     * have the necessary characteristics to fulfill this condition.
+     *
+     * @author Jean-Paul Pelteret, 2017
+     */
+    template <typename NumberType, typename = void>
+    struct is_adolc_tapeless_number
+      : std::false_type
+    {};
   }
 }
 
 
+DEAL_II_NAMESPACE_CLOSE
+
+
+#ifdef DEAL_II_WITH_ADOLC
+
+#include <adolc/internal/adolc_settings.h>
+#include <adolc/internal/adubfunc.h> // Taped double math functions
+
+#include <adolc/adouble.h> // Taped double
+#include <adolc/adtl.h>    // Tapeless double
+
+#include <deal.II/base/numbers.h>
+#include <deal.II/base/exceptions.h>
+
+#include <deal.II/differentiation/ad/ad_number_types.h>
+#include <deal.II/differentiation/ad/ad_number_traits.h>
+
+#include <complex>
+#include <type_traits>
+
+DEAL_II_NAMESPACE_OPEN
+
+
 /* --------------------------- inline and template functions and specializations ------------------------- */
 
 
@@ -435,18 +470,29 @@ namespace Differentiation
     {};
 
 
-
     /**
-     * A struct to indicate whether a given @p NumberType is an
-     * Adol-C number or not. By default, numbers are not considered to
-     * have the necessary characteristics to fulfill this condition.
+     * Specialization of the struct for the case when the input template
+     * parameter is a (real or complex) taped Adol-C number.
      */
-    template <typename NumberType, typename>
-    struct is_adolc_number
-      : std::false_type
+    template <typename NumberType>
+    struct is_adolc_taped_number<NumberType, typename std::enable_if<
+      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_taped
+      >::type>
+      : std::true_type
     {};
 
 
+    /**
+     * Specialization of the struct for the case when the input template
+     * parameter is a (real or complex) tapeless Adol-C number.
+     */
+    template <typename NumberType>
+    struct is_adolc_tapeless_number<NumberType, typename std::enable_if<
+      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_tapeless
+      >::type>
+      : std::true_type
+    {};
+
 
     /**
      * Specialization of the struct for the case when the input template
@@ -454,8 +500,8 @@ namespace Differentiation
      */
     template <typename NumberType>
     struct is_adolc_number<NumberType, typename std::enable_if<
-      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_taped ||
-      ADNumberTraits<typename std::decay<NumberType>::type>::type_code == NumberTypes::adolc_tapeless
+      is_adolc_taped_number<NumberType>::value ||
+      is_adolc_tapeless_number<NumberType>::value
       >::type>
       : std::true_type
     {};

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.