// @HEADER // ***************************************************************************** // Stokhos Package // // Copyright 2009 NTESS and the Stokhos contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef SACADO_UQ_PCE_TRAITS_HPP #define SACADO_UQ_PCE_TRAITS_HPP #include "Sacado_Traits.hpp" #include "Sacado_mpl_apply.hpp" // Forward declarations namespace Sacado { namespace UQ { template class PCE; } } namespace Sacado { //! Specialization of %Promote to PCE types SACADO_AD_PROMOTE_SPEC( UQ, PCE ) //! Specialization of %ScalarType to PCE types template struct ScalarType< UQ::PCE > { typedef typename ScalarType::value_type>::type type; }; //! Specialization of %ValueType to PCE types template struct ValueType< UQ::PCE > { typedef typename UQ::PCE::value_type type; }; //! Specialization of %IsADType to PCE types template struct IsADType< UQ::PCE > { static const bool value = true; }; //! Specialization of %IsADType to PCE types template struct IsScalarType< UQ::PCE > { static const bool value = false; }; //! Specialization of %Value to PCE types template struct Value< UQ::PCE > { typedef typename ValueType< UQ::PCE >::type value_type; KOKKOS_INLINE_FUNCTION static const value_type& eval(const UQ::PCE& x) { return x.val(); } }; //! Specialization of %ScalarValue to PCE types template struct ScalarValue< UQ::PCE > { typedef typename ValueType< UQ::PCE >::type value_type; typedef typename ScalarType< UQ::PCE >::type scalar_type; KOKKOS_INLINE_FUNCTION static const scalar_type& eval(const UQ::PCE& x) { return ScalarValue::eval(x.val()); } }; //! Specialization of %StringName to PCE types template struct StringName< UQ::PCE > { static std::string eval() { return std::string("Sacado::UQ::PCE< ") + StringName::eval() + " >"; } }; //! Specialization of %IsEqual to PCE types template struct IsEqual< UQ::PCE > { KOKKOS_INLINE_FUNCTION static bool eval(const UQ::PCE& x, const UQ::PCE& y) { return x.isEqualTo(y); } }; //! Specialization of %IsStaticallySized to PCE types template struct IsStaticallySized< UQ::PCE > { static const bool value = S::is_static; }; } // namespace Sacado // Define Teuchos traits classes // Note Stokhos has required dependency on all Teuchos sub-packages #include "Teuchos_PromotionTraits.hpp" #include "Teuchos_ScalarTraits.hpp" #include "Sacado_UQ_PCE_ScalarTraitsImp.hpp" #include "Teuchos_SerializationTraits.hpp" namespace Teuchos { //! Specialization of %Teuchos::PromotionTraits to DFad types template struct PromotionTraits< Sacado::UQ::PCE, Sacado::UQ::PCE > { typedef typename Sacado::Promote< Sacado::UQ::PCE, Sacado::UQ::PCE >::type promote; }; //! Specialization of %Teuchos::PromotionTraits to DFad types template struct PromotionTraits< Sacado::UQ::PCE, R > { typedef typename Sacado::Promote< Sacado::UQ::PCE, R >::type promote; }; //! Specialization of %Teuchos::PromotionTraits to DFad types template struct PromotionTraits< L, Sacado::UQ::PCE > { public: typedef typename Sacado::Promote< L, Sacado::UQ::PCE >::type promote; }; //! Specializtion of %Teuchos::ScalarTraits template struct ScalarTraits< Sacado::UQ::PCE > : public Sacado::UQ::PCEScalarTraitsImp< Sacado::UQ::PCE > {}; //! Specializtion of %Teuchos::ValueTypeConversionTraits template struct ValueTypeConversionTraits< TypeTo, Sacado::UQ::PCE > : public Sacado::UQ::PCEValueTypeConversionTraitsImp< TypeTo, Sacado::UQ::PCE > {}; //! Specialization of %Teuchos::SerializationTraits template struct SerializationTraits > : public Sacado::UQ::PCESerializationTraitsImp< Ordinal, Sacado::UQ::PCE > {}; //! Specialization of %Teuchos::ValueTypeSerializer template struct ValueTypeSerializer > : public Sacado::UQ::PCESerializerImp< Ordinal, Sacado::UQ::PCE, ValueTypeSerializer > { typedef Sacado::UQ::PCE PCEType; typedef ValueTypeSerializer ValueSerializer; typedef Sacado::UQ::PCESerializerImp< Ordinal,PCEType,ValueSerializer> Base; typedef typename Base::cijk_type cijk_type; ValueTypeSerializer(const cijk_type& cijk, const Teuchos::RCP& vs) : Base(cijk,vs) {} }; // Should also do TypeTo, and TypeTo,TypeFrom as UQ::PCE, but the real way // to fix is to make sure it is never called at all (requires fixing // magnitudeType) } #endif // SACADO_UQ_PCE_TRAITS_HPP