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