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