// @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_SFADTRAITS_HPP #define SACADO_FAD_SFADTRAITS_HPP #include "Sacado_ConfigDefs.h" #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT #include "Sacado_Fad_Exp_GeneralFadTraits.hpp" #else #include "Sacado_Traits.hpp" #include // Forward declarations namespace Sacado { namespace Fad { template class SFad; } } namespace Sacado { //! Specialization of %Promote to SFad types SACADO_SFAD_PROMOTE_SPEC( Fad, SFad ) //! Specialization of %ScalarType to SFad types template struct ScalarType< Fad::SFad > { typedef typename Fad::SFad::ScalarT type; }; //! Specialization of %ValueType to SFad types template struct ValueType< Fad::SFad > { typedef ValueT type; }; //! Specialization of %IsADType to SFad types template struct IsADType< Fad::SFad > { static const bool value = true; }; //! Specialization of %IsScalarType to SFad types template struct IsScalarType< Fad::SFad > { static const bool value = false; }; //! Specialization of %IsSimdType to SFad types template struct IsSimdType< Fad::SFad > { static const bool value = IsSimdType::value; }; //! Specialization of %Value to SFad types template struct Value< Fad::SFad > { typedef typename ValueType< Fad::SFad >::type value_type; SACADO_INLINE_FUNCTION static const value_type& eval(const Fad::SFad& x) { return x.val(); } }; //! Specialization of %ScalarValue to SFad types template struct ScalarValue< Fad::SFad > { typedef typename ValueType< Fad::SFad >::type value_type; typedef typename ScalarType< Fad::SFad >::type scalar_type; SACADO_INLINE_FUNCTION static const scalar_type& eval(const Fad::SFad& x) { return ScalarValue::eval(x.val()); } }; //! Specialization of %StringName to SFad types template struct StringName< Fad::SFad > { static std::string eval() { std::stringstream ss; ss << "Sacado::Fad::SFad< " << StringName::eval() << ", " << Num << " >"; return ss.str(); } }; //! Specialization of %IsEqual to SFad types template struct IsEqual< Fad::SFad > { SACADO_INLINE_FUNCTION static bool eval(const Fad::SFad& x, const Fad::SFad& y) { return x.isEqualTo(y); } }; //! Specialization of %IsStaticallySized to SFad types template struct IsStaticallySized< Fad::SFad > { static const bool value = true; }; //! Specialization of %IsStaticallySized to SFad types template struct IsStaticallySized< const Fad::SFad > { static const bool value = true; }; //! Specialization of %StaticSize to SFad types template struct StaticSize< Fad::SFad > { static const unsigned value = Num; }; //! Specialization of %StaticSize to SFad types template struct StaticSize< const Fad::SFad > { static const unsigned value = Num; }; } // namespace Sacado // // Define Teuchos traits classes // // Promotion traits #ifdef HAVE_SACADO_TEUCHOSNUMERICS #include "Teuchos_PromotionTraits.hpp" namespace Teuchos { template struct PromotionTraits< Sacado::Fad::SFad, Sacado::Fad::SFad > { typedef typename Sacado::Promote< Sacado::Fad::SFad, Sacado::Fad::SFad >::type promote; }; template struct PromotionTraits< Sacado::Fad::SFad, R > { typedef typename Sacado::Promote< Sacado::Fad::SFad, R >::type promote; }; template struct PromotionTraits< L, Sacado::Fad::SFad > { public: typedef typename Sacado::Promote< L, Sacado::Fad::SFad >::type promote; }; } #endif // Scalar traits #ifdef HAVE_SACADO_TEUCHOSCORE #include "Sacado_Fad_ScalarTraitsImp.hpp" namespace Teuchos { template struct ScalarTraits< Sacado::Fad::SFad > : public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::SFad > {}; } #endif // Serialization traits #ifdef HAVE_SACADO_TEUCHOSCOMM #include "Sacado_Fad_SerializationTraitsImp.hpp" namespace Teuchos { template struct SerializationTraits > : public Sacado::Fad::SerializationTraitsImp< Ordinal, Sacado::Fad::SFad > {}; template struct ValueTypeSerializer > : public Sacado::Fad::SerializerImp< Ordinal, Sacado::Fad::SFad, ValueTypeSerializer > { typedef Sacado::Fad::SFad 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_SFADTRAITS_HPP