// @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_DFADTRAITS_HPP #define SACADO_FAD_DFADTRAITS_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 DFad; } } namespace Sacado { //! Specialization of %Promote to DFad types SACADO_FAD_PROMOTE_SPEC( Fad, DFad ) //! Specialization of %ScalarType to DFad types template struct ScalarType< Fad::DFad > { typedef typename Fad::DFad::ScalarT type; }; //! Specialization of %ValueType to DFad types template struct ValueType< Fad::DFad > { typedef ValueT type; }; //! Specialization of %IsADType to DFad types template struct IsADType< Fad::DFad > { static const bool value = true; }; //! Specialization of %IsScalarType to DFad types template struct IsScalarType< Fad::DFad > { static const bool value = false; }; //! Specialization of %IsSimdType to DFad types template struct IsSimdType< Fad::DFad > { static const bool value = IsSimdType::value; }; //! Specialization of %Value to DFad types template struct Value< Fad::DFad > { typedef typename ValueType< Fad::DFad >::type value_type; SACADO_INLINE_FUNCTION static const value_type& eval(const Fad::DFad& x) { return x.val(); } }; //! Specialization of %ScalarValue to DFad types template struct ScalarValue< Fad::DFad > { typedef typename ValueType< Fad::DFad >::type value_type; typedef typename ScalarType< Fad::DFad >::type scalar_type; SACADO_INLINE_FUNCTION static const scalar_type& eval(const Fad::DFad& x) { return ScalarValue::eval(x.val()); } }; //! Specialization of %StringName to DFad types template struct StringName< Fad::DFad > { static std::string eval() { return std::string("Sacado::Fad::DFad< ") + StringName::eval() + " >"; } }; //! Specialization of %IsEqual to DFad types template struct IsEqual< Fad::DFad > { SACADO_INLINE_FUNCTION static bool eval(const Fad::DFad& x, const Fad::DFad& y) { return x.isEqualTo(y); } }; //! Specialization of %IsStaticallySized to DFad types template struct IsStaticallySized< Fad::DFad > { static const bool value = false; }; //! Specialization of %IsStaticallySized to DFad types template struct IsStaticallySized< const Fad::DFad > { static const bool value = false; }; } // namespace Sacado // // Define Teuchos traits classes // // Promotion traits #ifdef HAVE_SACADO_TEUCHOSNUMERICS #include "Teuchos_PromotionTraits.hpp" namespace Teuchos { template struct PromotionTraits< Sacado::Fad::DFad, Sacado::Fad::DFad > { typedef typename Sacado::Promote< Sacado::Fad::DFad, Sacado::Fad::DFad >::type promote; }; template struct PromotionTraits< Sacado::Fad::DFad, R > { typedef typename Sacado::Promote< Sacado::Fad::DFad, R >::type promote; }; template struct PromotionTraits< L, Sacado::Fad::DFad > { public: typedef typename Sacado::Promote< L, Sacado::Fad::DFad >::type promote; }; } #endif // Scalar traits #ifdef HAVE_SACADO_TEUCHOSCORE #include "Sacado_Fad_ScalarTraitsImp.hpp" namespace Teuchos { template struct ScalarTraits< Sacado::Fad::DFad > : public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::DFad > {}; } #endif // Serialization traits #ifdef HAVE_SACADO_TEUCHOSCOMM #include "Sacado_Fad_SerializationTraitsImp.hpp" namespace Teuchos { template struct SerializationTraits > : public Sacado::Fad::SerializationTraitsImp< Ordinal, Sacado::Fad::DFad > {}; template struct ValueTypeSerializer > : public Sacado::Fad::SerializerImp< Ordinal, Sacado::Fad::DFad, ValueTypeSerializer > { typedef Sacado::Fad::DFad FadType; typedef ValueTypeSerializer ValueSerializer; typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base; ValueTypeSerializer(const Teuchos::RCP& vs, Ordinal sz = 0) : Base(vs, sz) {} }; } #endif // KokkosComm #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC) #include "KokkosExp_View_Fad.hpp" #endif #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT #endif // SACADO_FAD_DFADTRAITS_HPP