// @HEADER // ***************************************************************************** // Sacado Package // // Copyright 2006 NTESS and the Sacado contributors. // SPDX-License-Identifier: LGPL-2.1-or-later // ***************************************************************************** // @HEADER #ifndef SACADO_TRAD2_TRAITS_HPP #define SACADO_TRAD2_TRAITS_HPP #include "Sacado_Traits.hpp" // Forward declarations namespace Sacado { namespace Rad2 { template class ADvar; template class ADvari; } } namespace Sacado { //! Specialization of %Promote to ADvar types SACADO_RAD_PROMOTE_SPEC( Rad2 ) //! Specialization of %ScalarType to ADvar types template struct ScalarType< Rad2::ADvar > { typedef typename ScalarType::type type; }; //! Specialization of %ScalarType to ADvari types template struct ScalarType< Rad2::ADvari > { typedef typename ScalarType::type type; }; //! Specialization of %ValueType to ADvar types template struct ValueType< Rad2::ADvar > { typedef T type; }; //! Specialization of %ValueType to ADvari types template struct ValueType< Rad2::ADvari > { typedef T type; }; //! Specialization of %IsADType to ADvar types template struct IsADType< Rad2::ADvar > { static const bool value = true; }; //! Specialization of %IsADType to ADvari types template struct IsADType< Rad2::ADvari > { static const bool value = true; }; //! Specialization of %IsADType to ADvar types template struct IsScalarType< Rad2::ADvar > { static const bool value = false; }; //! Specialization of %IsADType to ADvari types template struct IsScalarType< Rad2::ADvari > { static const bool value = false; }; //! Specialization of %Value to ADvar types template struct Value< Rad2::ADvar > { typedef typename ValueType< Rad2::ADvar >::type value_type; static value_type eval(const Rad2::ADvar& x) { return x.val(); } }; //! Specialization of %MarkConstant to ADvar types template struct MarkConstant< Rad2::ADvar > { static void eval(Rad2::ADvar& x) { AD_Const(x); } }; //! Specialization of %MarkConstant to ADvari types template struct MarkConstant< Rad2::ADvari > { static void eval(Rad2::ADvari& x) { AD_Const(x); } }; //! Specialization of %ScalarValue to ADvar types template struct ScalarValue< Rad2::ADvar > { typedef typename ValueType< Rad2::ADvar >::type value_type; typedef typename ScalarType< Rad2::ADvar >::type scalar_type; static scalar_type eval(const Rad2::ADvar& x) { return ScalarValue::eval(x.val()); } }; //! Specialization of %StringName to ADvar types template struct StringName< Rad2::ADvar > { static std::string eval() { return std::string("Sacado::Rad2::ADvar< ") + StringName::eval() + " >"; } }; } // namespace Sacado #endif // SACADO_TRAD_TRAITS_HPP