From eb331b7543ab69df4546984023b01ec3d0bb49c2 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Fri, 10 May 2019 22:35:49 +0200 Subject: [PATCH] Add AD number traits test for ADNumberType::none (floating point types) --- tests/sacado/ad_number_traits_02_none.cc | 113 +++++++++++++++++++ tests/sacado/ad_number_traits_02_none.output | 83 ++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 tests/sacado/ad_number_traits_02_none.cc create mode 100644 tests/sacado/ad_number_traits_02_none.output diff --git a/tests/sacado/ad_number_traits_02_none.cc b/tests/sacado/ad_number_traits_02_none.cc new file mode 100644 index 0000000000..7face0c4cf --- /dev/null +++ b/tests/sacado/ad_number_traits_02_none.cc @@ -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 +#include + +#include +#include +#include +#include + +#include "../tests.h" + +using namespace dealii; +namespace AD = Differentiation::AD; + +template +void +print_info() +{ + deallog << "type_code: " + << static_cast::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::value + << std::endl; + deallog << "is_sacado_number: " + << AD::is_sacado_number::value + << std::endl; + deallog << "is_taped_ad_number: " + << AD::is_taped_ad_number::value + << std::endl; + deallog + << "is_tapeless_ad_number: " + << AD::is_tapeless_ad_number::value + << std::endl; +} + +int +main() +{ + initlog(); + + deallog.push("NumberTraits"); + + deallog.push("float"); + print_info>(); + deallog.pop(); + + deallog.push("std::complex"); + print_info, AD::NumberTypes::none>>(); + deallog.pop(); + + deallog.push("double"); + print_info>(); + deallog.pop(); + + deallog.push("std::complex"); + print_info, AD::NumberTypes::none>>(); + deallog.pop(); + + deallog.pop(); // NumberTraits + + deallog << std::endl; + + deallog.push("ADNumberTraits"); + + deallog.push("float"); + print_info>(); + deallog.pop(); + + deallog.push("std::complex"); + print_info>>(); + deallog.pop(); + + deallog.push("double"); + print_info>(); + deallog.pop(); + + deallog.push("std::complex"); + print_info>>(); + 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 index 0000000000..3afabe524f --- /dev/null +++ b/tests/sacado/ad_number_traits_02_none.output @@ -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::type_code: 0 +DEAL:NumberTraits:std::complex::is_taped: 0 +DEAL:NumberTraits:std::complex::is_tapeless: 0 +DEAL:NumberTraits:std::complex::is_real_valued: 0 +DEAL:NumberTraits:std::complex::is_complex_valued: 1 +DEAL:NumberTraits:std::complex::n_supported_derivative_levels: 0 +DEAL:NumberTraits:std::complex::is_ad_number: 0 +DEAL:NumberTraits:std::complex::is_sacado_number: 0 +DEAL:NumberTraits:std::complex::is_taped_ad_number: 0 +DEAL:NumberTraits:std::complex::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::type_code: 0 +DEAL:NumberTraits:std::complex::is_taped: 0 +DEAL:NumberTraits:std::complex::is_tapeless: 0 +DEAL:NumberTraits:std::complex::is_real_valued: 0 +DEAL:NumberTraits:std::complex::is_complex_valued: 1 +DEAL:NumberTraits:std::complex::n_supported_derivative_levels: 0 +DEAL:NumberTraits:std::complex::is_ad_number: 0 +DEAL:NumberTraits:std::complex::is_sacado_number: 0 +DEAL:NumberTraits:std::complex::is_taped_ad_number: 0 +DEAL:NumberTraits:std::complex::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::type_code: 0 +DEAL:ADNumberTraits:std::complex::is_taped: 0 +DEAL:ADNumberTraits:std::complex::is_tapeless: 0 +DEAL:ADNumberTraits:std::complex::is_real_valued: 0 +DEAL:ADNumberTraits:std::complex::is_complex_valued: 1 +DEAL:ADNumberTraits:std::complex::n_supported_derivative_levels: 0 +DEAL:ADNumberTraits:std::complex::is_ad_number: 0 +DEAL:ADNumberTraits:std::complex::is_sacado_number: 0 +DEAL:ADNumberTraits:std::complex::is_taped_ad_number: 0 +DEAL:ADNumberTraits:std::complex::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::type_code: 0 +DEAL:ADNumberTraits:std::complex::is_taped: 0 +DEAL:ADNumberTraits:std::complex::is_tapeless: 0 +DEAL:ADNumberTraits:std::complex::is_real_valued: 0 +DEAL:ADNumberTraits:std::complex::is_complex_valued: 1 +DEAL:ADNumberTraits:std::complex::n_supported_derivative_levels: 0 +DEAL:ADNumberTraits:std::complex::is_ad_number: 0 +DEAL:ADNumberTraits:std::complex::is_sacado_number: 0 +DEAL:ADNumberTraits:std::complex::is_taped_ad_number: 0 +DEAL:ADNumberTraits:std::complex::is_tapeless_ad_number: 0 +DEAL::OK -- 2.39.5