// @HEADER // ***************************************************************************** // Sacado Package // // Copyright 2006 NTESS and the Sacado contributors. // SPDX-License-Identifier: LGPL-2.1-or-later // // *********************************************************************** // // The forward-mode AD classes in Sacado are a derivative work of the // expression template classes in the Fad package by Nicolas Di Cesare. // The following banner is included in the original Fad source code: // // ************ DO NOT REMOVE THIS BANNER **************** // // Nicolas Di Cesare // http://www.ann.jussieu.fr/~dicesare // // CEMRACS 98 : C++ courses, // templates : new C++ techniques // for scientific computing // //******************************************************** // // NumericalTraits class to illustrate TRAITS // //******************************************************** // @HEADER #ifndef SACADO_FAD_DVFADTRAITS_HPP #define SACADO_FAD_DVFADTRAITS_HPP #include "Sacado_ConfigDefs.h" #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT #include "Sacado_Fad_Exp_GeneralFadTraits.hpp" #else #include "Sacado_Traits.hpp" // Forward declarations namespace Sacado { namespace Fad { template class DVFad; } } namespace Sacado { //! Specialization of %Promote to DVFad types SACADO_FAD_PROMOTE_SPEC( Fad, DVFad ) //! Specialization of %ScalarType to DVFad types template struct ScalarType< Fad::DVFad > { typedef typename Fad::DVFad::ScalarT type; }; //! Specialization of %ValueType to DVFad types template struct ValueType< Fad::DVFad > { typedef ValueT type; }; //! Specialization of %IsADType to DVFad types template struct IsADType< Fad::DVFad > { static const bool value = true; }; //! Specialization of %IsScalarType to DVFad types template struct IsScalarType< Fad::DVFad > { static const bool value = false; }; //! Specialization of %IsSimdType to DVFad types template struct IsSimdType< Fad::DVFad > { static const bool value = IsSimdType::value; }; //! Specialization of %Value to DVFad types template struct Value< Fad::DVFad > { typedef typename ValueType< Fad::DVFad >::type value_type; static const value_type& eval(const Fad::DVFad& x) { return x.val(); } }; //! Specialization of %ScalarValue to DVFad types template struct ScalarValue< Fad::DVFad > { typedef typename ValueType< Fad::DVFad >::type value_type; typedef typename ScalarType< Fad::DVFad >::type scalar_type; static const scalar_type& eval(const Fad::DVFad& x) { return ScalarValue::eval(x.val()); } }; //! Specialization of %StringName to DVFad types template struct StringName< Fad::DVFad > { static std::string eval() { return std::string("Sacado::Fad::DVFad< ") + StringName::eval() + " >"; } }; //! Specialization of %IsEqual to DVFad types template struct IsEqual< Fad::DVFad > { static bool eval(const Fad::DVFad& x, const Fad::DVFad& y) { return x.isEqualTo(y); } }; //! Specialization of %IsStaticallySized to DVFad types template struct IsStaticallySized< Fad::DVFad > { static const bool value = false; }; template struct IsFad< Fad::DVFad > { static const bool value = true; }; } // namespace Sacado // // Define Teuchos traits classes // // Promotion traits #ifdef HAVE_SACADO_TEUCHOSNUMERICS #include "Teuchos_PromotionTraits.hpp" namespace Teuchos { template struct PromotionTraits< Sacado::Fad::DVFad, Sacado::Fad::DVFad > { typedef typename Sacado::Promote< Sacado::Fad::DVFad, Sacado::Fad::DVFad >::type promote; }; template struct PromotionTraits< Sacado::Fad::DVFad, R > { typedef typename Sacado::Promote< Sacado::Fad::DVFad, R >::type promote; }; template struct PromotionTraits< L, Sacado::Fad::DVFad > { public: typedef typename Sacado::Promote< L, Sacado::Fad::DVFad >::type promote; }; } #endif // Scalar traits #ifdef HAVE_SACADO_TEUCHOSCORE #include "Sacado_Fad_ScalarTraitsImp.hpp" namespace Teuchos { template struct ScalarTraits< Sacado::Fad::DVFad > : public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::DVFad > {}; } #endif #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT #endif // SACADO_FAD_DVFADTRAITS_HPP