42 #ifndef SACADO_MP_VECTOR_TRAITS_HPP 43 #define SACADO_MP_VECTOR_TRAITS_HPP 45 #include "Sacado_Traits.hpp" 46 #include "Sacado_mpl_apply.hpp" 57 template <
typename S>
class Vector;
64 SACADO_AD_PROMOTE_SPEC( MP, Vector )
68 struct ScalarType< MP::Vector<S> > {
74 struct ValueType< MP::Vector<S> > {
80 struct IsADType< MP::Vector<S> > {
81 static const bool value =
true;
86 struct IsScalarType< MP::Vector<S> > {
87 static const bool value = S::is_static;
92 struct Value< MP::Vector<S> > {
93 typedef typename ValueType< MP::Vector<S> >::type
value_type;
94 KOKKOS_INLINE_FUNCTION
100 template <
typename S>
101 struct ScalarValue< MP::Vector<S> > {
102 typedef typename ValueType< MP::Vector<S> >::type
value_type;
104 KOKKOS_INLINE_FUNCTION
106 return ScalarValue<value_type>::eval(
x.val()); }
110 template <
typename S>
111 struct StringName< MP::Vector<S> > {
113 return std::string(
"Sacado::MP::Vector< ") +
114 StringName<S>::eval() +
" >"; }
118 template <
typename S>
119 struct IsEqual< MP::Vector<S> > {
120 KOKKOS_INLINE_FUNCTION
123 return x.isEqualTo(
y);
128 template <
typename S>
129 struct IsStaticallySized< MP::Vector<S> > {
130 static const bool value = S::is_static;
134 template <
typename S>
135 struct StaticSize< MP::Vector<S> > {
136 static const unsigned value = S::static_size;
142 #ifdef HAVE_SACADO_TEUCHOS 144 #include "Teuchos_PromotionTraits.hpp" 145 #include "Teuchos_ScalarTraits.hpp" 147 #include "Teuchos_SerializationTraits.hpp" 148 #include "Teuchos_as.hpp" 153 template <
typename S>
154 struct PromotionTraits<
Sacado::MP::Vector<S>,
156 typedef typename Sacado::Promote< Sacado::MP::Vector<S>,
162 template <
typename S,
typename R>
163 struct PromotionTraits<
Sacado::MP::Vector<S>, R > {
164 typedef typename Sacado::Promote< Sacado::MP::Vector<S>, R >::type
169 template <
typename L,
typename S>
170 struct PromotionTraits< L,
Sacado::MP::Vector<S> > {
172 typedef typename Sacado::Promote< L, Sacado::MP::Vector<S> >::type
177 #if defined(HAVE_STOKHOS_ENSEMBLE_REDUCT) 178 template <
typename S>
179 struct ScalarTraits<
Sacado::MP::Vector<S> > :
180 public Sacado::MP::ScalarTraitsImp<S,true> {};
182 template <
typename S>
183 struct ScalarTraits<
Sacado::MP::Vector<S> > :
184 public Sacado::MP::ScalarTraitsImp<S,false> {};
188 template <
typename Ordinal,
typename S>
189 struct SerializationTraits<
Ordinal,
Sacado::MP::Vector<S> > :
190 public Sacado::MP::SerializationTraitsImp< Ordinal,
191 Sacado::MP::Vector<S>,
195 template <
typename Ordinal,
typename S>
196 struct ValueTypeSerializer<
Ordinal,
Sacado::MP::Vector<S> > :
197 public Sacado::MP::SerializerImp< Ordinal,
198 Sacado::MP::Vector<S>,
199 ValueTypeSerializer<Ordinal,typename Sacado::MP::Vector<S>::value_type> >
203 typedef ValueTypeSerializer<Ordinal,value_type> ValueSerializer;
204 typedef Sacado::MP::SerializerImp< Ordinal,VecType,ValueSerializer> Base;
205 ValueTypeSerializer(
const Teuchos::RCP<const ValueSerializer>& vs,
211 template<
class TypeTo,
class StorageFrom>
212 class ValueTypeConversionTraits< TypeTo,
Sacado::MP::Vector<StorageFrom> > {
216 static TypeTo convert (
const TypeFrom& t) {
219 return Teuchos::as<TypeTo>(t.coeff(0));
223 static TypeTo safeConvert (
const TypeFrom& t) {
229 return Teuchos::as<TypeTo>(t.coeff(0));
233 template<
class TypeTo,
class ExprFrom>
234 class ValueTypeConversionTraits< TypeTo,
Sacado::MP::Expr<ExprFrom> > {
238 static TypeTo convert (
const TypeFrom& t) {
241 return Teuchos::as<TypeTo>(t.derived().coeff(0));
245 static TypeTo safeConvert (
const TypeFrom& t) {
251 return Teuchos::as<TypeTo>(t.derived().coeff(0));
260 #endif // HAVE_SACADO_TEUCHOS 262 #endif // SACADO_MP_VECTORTRAITS_HPP static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const MP::Vector< S > &x)
static std::string eval()
static KOKKOS_INLINE_FUNCTION const value_type & eval(const MP::Vector< S > &x)
MP::Vector< S >::value_type type
ValueType< MP::Vector< S > >::type value_type
ScalarType< typename MP::Vector< S >::value_type >::type type
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
ScalarType< MP::Vector< S > >::type scalar_type
static KOKKOS_INLINE_FUNCTION bool eval(const MP::Vector< S > &x, const MP::Vector< S > &y)
ValueType< MP::Vector< S > >::type value_type
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType ValueType * y