]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add AD number traits test for ADNumberType::none (floating point types)
authorJean-Paul Pelteret <jppelteret@gmail.com>
Fri, 10 May 2019 20:35:49 +0000 (22:35 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Fri, 10 May 2019 20:37:43 +0000 (22:37 +0200)
tests/sacado/ad_number_traits_02_none.cc [new file with mode: 0644]
tests/sacado/ad_number_traits_02_none.output [new file with mode: 0644]

diff --git a/tests/sacado/ad_number_traits_02_none.cc b/tests/sacado/ad_number_traits_02_none.cc
new file mode 100644 (file)
index 0000000..7face0c
--- /dev/null
@@ -0,0 +1,113 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 - 2017 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Test that all of the floating point number traits return the correct
+// information
+
+#include <deal.II/differentiation/ad/ad_number_types.h>
+#include <deal.II/differentiation/ad/sacado_number_types.h>
+
+#include <complex>
+#include <fstream>
+#include <iomanip>
+#include <type_traits>
+
+#include "../tests.h"
+
+using namespace dealii;
+namespace AD = Differentiation::AD;
+
+template <typename NumberTraitsType>
+void
+print_info()
+{
+  deallog << "type_code: "
+          << static_cast<std::underlying_type<AD::NumberTypes>::type>(
+               NumberTraitsType::type_code)
+          << std::endl;
+  deallog << "is_taped: " << NumberTraitsType::is_taped << std::endl;
+  deallog << "is_tapeless: " << NumberTraitsType::is_tapeless << std::endl;
+  deallog << "is_real_valued: " << NumberTraitsType::is_real_valued
+          << std::endl;
+  deallog << "is_complex_valued: " << NumberTraitsType::is_complex_valued
+          << std::endl;
+  deallog << "n_supported_derivative_levels: "
+          << NumberTraitsType::n_supported_derivative_levels << std::endl;
+
+  deallog << "is_ad_number: "
+          << AD::is_ad_number<typename NumberTraitsType::ad_type>::value
+          << std::endl;
+  deallog << "is_sacado_number: "
+          << AD::is_sacado_number<typename NumberTraitsType::ad_type>::value
+          << std::endl;
+  deallog << "is_taped_ad_number: "
+          << AD::is_taped_ad_number<typename NumberTraitsType::ad_type>::value
+          << std::endl;
+  deallog
+    << "is_tapeless_ad_number: "
+    << AD::is_tapeless_ad_number<typename NumberTraitsType::ad_type>::value
+    << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  deallog.push("NumberTraits");
+
+  deallog.push("float");
+  print_info<AD::NumberTraits<float, AD::NumberTypes::none>>();
+  deallog.pop();
+
+  deallog.push("std::complex<float>");
+  print_info<AD::NumberTraits<std::complex<float>, AD::NumberTypes::none>>();
+  deallog.pop();
+
+  deallog.push("double");
+  print_info<AD::NumberTraits<double, AD::NumberTypes::none>>();
+  deallog.pop();
+
+  deallog.push("std::complex<double>");
+  print_info<AD::NumberTraits<std::complex<double>, AD::NumberTypes::none>>();
+  deallog.pop();
+
+  deallog.pop(); // NumberTraits
+
+  deallog << std::endl;
+
+  deallog.push("ADNumberTraits");
+
+  deallog.push("float");
+  print_info<AD::ADNumberTraits<float>>();
+  deallog.pop();
+
+  deallog.push("std::complex<float>");
+  print_info<AD::ADNumberTraits<std::complex<float>>>();
+  deallog.pop();
+
+  deallog.push("double");
+  print_info<AD::ADNumberTraits<double>>();
+  deallog.pop();
+
+  deallog.push("std::complex<double>");
+  print_info<AD::ADNumberTraits<std::complex<double>>>();
+  deallog.pop();
+
+  deallog.pop(); // ADNumberTraits
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/sacado/ad_number_traits_02_none.output b/tests/sacado/ad_number_traits_02_none.output
new file mode 100644 (file)
index 0000000..3afabe5
--- /dev/null
@@ -0,0 +1,83 @@
+
+DEAL:NumberTraits:float::type_code: 0
+DEAL:NumberTraits:float::is_taped: 0
+DEAL:NumberTraits:float::is_tapeless: 0
+DEAL:NumberTraits:float::is_real_valued: 1
+DEAL:NumberTraits:float::is_complex_valued: 0
+DEAL:NumberTraits:float::n_supported_derivative_levels: 0
+DEAL:NumberTraits:float::is_ad_number: 0
+DEAL:NumberTraits:float::is_sacado_number: 0
+DEAL:NumberTraits:float::is_taped_ad_number: 0
+DEAL:NumberTraits:float::is_tapeless_ad_number: 0
+DEAL:NumberTraits:std::complex<float>::type_code: 0
+DEAL:NumberTraits:std::complex<float>::is_taped: 0
+DEAL:NumberTraits:std::complex<float>::is_tapeless: 0
+DEAL:NumberTraits:std::complex<float>::is_real_valued: 0
+DEAL:NumberTraits:std::complex<float>::is_complex_valued: 1
+DEAL:NumberTraits:std::complex<float>::n_supported_derivative_levels: 0
+DEAL:NumberTraits:std::complex<float>::is_ad_number: 0
+DEAL:NumberTraits:std::complex<float>::is_sacado_number: 0
+DEAL:NumberTraits:std::complex<float>::is_taped_ad_number: 0
+DEAL:NumberTraits:std::complex<float>::is_tapeless_ad_number: 0
+DEAL:NumberTraits:double::type_code: 0
+DEAL:NumberTraits:double::is_taped: 0
+DEAL:NumberTraits:double::is_tapeless: 0
+DEAL:NumberTraits:double::is_real_valued: 1
+DEAL:NumberTraits:double::is_complex_valued: 0
+DEAL:NumberTraits:double::n_supported_derivative_levels: 0
+DEAL:NumberTraits:double::is_ad_number: 0
+DEAL:NumberTraits:double::is_sacado_number: 0
+DEAL:NumberTraits:double::is_taped_ad_number: 0
+DEAL:NumberTraits:double::is_tapeless_ad_number: 0
+DEAL:NumberTraits:std::complex<double>::type_code: 0
+DEAL:NumberTraits:std::complex<double>::is_taped: 0
+DEAL:NumberTraits:std::complex<double>::is_tapeless: 0
+DEAL:NumberTraits:std::complex<double>::is_real_valued: 0
+DEAL:NumberTraits:std::complex<double>::is_complex_valued: 1
+DEAL:NumberTraits:std::complex<double>::n_supported_derivative_levels: 0
+DEAL:NumberTraits:std::complex<double>::is_ad_number: 0
+DEAL:NumberTraits:std::complex<double>::is_sacado_number: 0
+DEAL:NumberTraits:std::complex<double>::is_taped_ad_number: 0
+DEAL:NumberTraits:std::complex<double>::is_tapeless_ad_number: 0
+DEAL::
+DEAL:ADNumberTraits:float::type_code: 0
+DEAL:ADNumberTraits:float::is_taped: 0
+DEAL:ADNumberTraits:float::is_tapeless: 0
+DEAL:ADNumberTraits:float::is_real_valued: 1
+DEAL:ADNumberTraits:float::is_complex_valued: 0
+DEAL:ADNumberTraits:float::n_supported_derivative_levels: 0
+DEAL:ADNumberTraits:float::is_ad_number: 0
+DEAL:ADNumberTraits:float::is_sacado_number: 0
+DEAL:ADNumberTraits:float::is_taped_ad_number: 0
+DEAL:ADNumberTraits:float::is_tapeless_ad_number: 0
+DEAL:ADNumberTraits:std::complex<float>::type_code: 0
+DEAL:ADNumberTraits:std::complex<float>::is_taped: 0
+DEAL:ADNumberTraits:std::complex<float>::is_tapeless: 0
+DEAL:ADNumberTraits:std::complex<float>::is_real_valued: 0
+DEAL:ADNumberTraits:std::complex<float>::is_complex_valued: 1
+DEAL:ADNumberTraits:std::complex<float>::n_supported_derivative_levels: 0
+DEAL:ADNumberTraits:std::complex<float>::is_ad_number: 0
+DEAL:ADNumberTraits:std::complex<float>::is_sacado_number: 0
+DEAL:ADNumberTraits:std::complex<float>::is_taped_ad_number: 0
+DEAL:ADNumberTraits:std::complex<float>::is_tapeless_ad_number: 0
+DEAL:ADNumberTraits:double::type_code: 0
+DEAL:ADNumberTraits:double::is_taped: 0
+DEAL:ADNumberTraits:double::is_tapeless: 0
+DEAL:ADNumberTraits:double::is_real_valued: 1
+DEAL:ADNumberTraits:double::is_complex_valued: 0
+DEAL:ADNumberTraits:double::n_supported_derivative_levels: 0
+DEAL:ADNumberTraits:double::is_ad_number: 0
+DEAL:ADNumberTraits:double::is_sacado_number: 0
+DEAL:ADNumberTraits:double::is_taped_ad_number: 0
+DEAL:ADNumberTraits:double::is_tapeless_ad_number: 0
+DEAL:ADNumberTraits:std::complex<double>::type_code: 0
+DEAL:ADNumberTraits:std::complex<double>::is_taped: 0
+DEAL:ADNumberTraits:std::complex<double>::is_tapeless: 0
+DEAL:ADNumberTraits:std::complex<double>::is_real_valued: 0
+DEAL:ADNumberTraits:std::complex<double>::is_complex_valued: 1
+DEAL:ADNumberTraits:std::complex<double>::n_supported_derivative_levels: 0
+DEAL:ADNumberTraits:std::complex<double>::is_ad_number: 0
+DEAL:ADNumberTraits:std::complex<double>::is_sacado_number: 0
+DEAL:ADNumberTraits:std::complex<double>::is_taped_ad_number: 0
+DEAL:ADNumberTraits:std::complex<double>::is_tapeless_ad_number: 0
+DEAL::OK

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.