Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_UQ_PCE_Traits.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Stokhos Package
5// Copyright (2009) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef SACADO_UQ_PCE_TRAITS_HPP
43#define SACADO_UQ_PCE_TRAITS_HPP
44
45#include "Sacado_Traits.hpp"
46#include "Sacado_mpl_apply.hpp"
47
48// Forward declarations
49namespace Sacado {
50 namespace UQ {
51 template <typename S> class PCE;
52 }
53}
54
55namespace Sacado {
56
58 SACADO_AD_PROMOTE_SPEC( UQ, PCE )
59
60
61 template <typename S>
62 struct ScalarType< UQ::PCE<S> > {
63 typedef typename ScalarType<typename UQ::PCE<S>::value_type>::type type;
64 };
65
67 template <typename S>
68 struct ValueType< UQ::PCE<S> > {
69 typedef typename UQ::PCE<S>::value_type type;
70 };
71
73 template <typename S>
74 struct IsADType< UQ::PCE<S> > {
75 static const bool value = true;
76 };
77
79 template <typename S>
80 struct IsScalarType< UQ::PCE<S> > {
81 static const bool value = false;
82 };
83
85 template <typename S>
86 struct Value< UQ::PCE<S> > {
87 typedef typename ValueType< UQ::PCE<S> >::type value_type;
88 KOKKOS_INLINE_FUNCTION
89 static const value_type& eval(const UQ::PCE<S>& x) {
90 return x.val(); }
91 };
92
94 template <typename S>
95 struct ScalarValue< UQ::PCE<S> > {
96 typedef typename ValueType< UQ::PCE<S> >::type value_type;
97 typedef typename ScalarType< UQ::PCE<S> >::type scalar_type;
98 KOKKOS_INLINE_FUNCTION
99 static const scalar_type& eval(const UQ::PCE<S>& x) {
100 return ScalarValue<value_type>::eval(x.val()); }
101 };
102
104 template <typename S>
105 struct StringName< UQ::PCE<S> > {
106 static std::string eval() {
107 return std::string("Sacado::UQ::PCE< ") +
108 StringName<S>::eval() + " >"; }
109 };
110
112 template <typename S>
113 struct IsEqual< UQ::PCE<S> > {
114 KOKKOS_INLINE_FUNCTION
115 static bool eval(const UQ::PCE<S>& x,
116 const UQ::PCE<S>& y) {
117 return x.isEqualTo(y);
118 }
119 };
120
122 template <typename S>
123 struct IsStaticallySized< UQ::PCE<S> > {
124 static const bool value = S::is_static;
125 };
126
127} // namespace Sacado
128
129// Define Teuchos traits classes
130// Note Stokhos has required dependency on all Teuchos sub-packages
131#include "Teuchos_PromotionTraits.hpp"
132#include "Teuchos_ScalarTraits.hpp"
134#include "Teuchos_SerializationTraits.hpp"
135
136namespace Teuchos {
137
139 template <typename S>
140 struct PromotionTraits< Sacado::UQ::PCE<S>,
141 Sacado::UQ::PCE<S> > {
142 typedef typename Sacado::Promote< Sacado::UQ::PCE<S>,
143 Sacado::UQ::PCE<S> >::type
145 };
146
148 template <typename S, typename R>
149 struct PromotionTraits< Sacado::UQ::PCE<S>, R > {
150 typedef typename Sacado::Promote< Sacado::UQ::PCE<S>, R >::type
152 };
153
155 template <typename L, typename S>
156 struct PromotionTraits< L, Sacado::UQ::PCE<S> > {
157 public:
158 typedef typename Sacado::Promote< L, Sacado::UQ::PCE<S> >::type
160 };
161
163 template <typename S>
164 struct ScalarTraits< Sacado::UQ::PCE<S> > :
165 public Sacado::UQ::PCEScalarTraitsImp< Sacado::UQ::PCE<S> > {};
166
168 template <typename TypeTo, typename S>
169 struct ValueTypeConversionTraits< TypeTo, Sacado::UQ::PCE<S> > :
171 Sacado::UQ::PCE<S> > {};
172
174 template <typename Ordinal, typename S>
175 struct SerializationTraits<Ordinal, Sacado::UQ::PCE<S> > :
177 Sacado::UQ::PCE<S> >
178 {};
179
181 template <typename Ordinal, typename S>
182 struct ValueTypeSerializer<Ordinal, Sacado::UQ::PCE<S> > :
183 public Sacado::UQ::PCESerializerImp< Ordinal,
184 Sacado::UQ::PCE<S>,
185 ValueTypeSerializer<Ordinal,typename S::value_type> >
186 {
188 typedef ValueTypeSerializer<Ordinal,typename S::value_type> ValueSerializer;
190 typedef typename Base::cijk_type cijk_type;
192 const Teuchos::RCP<const ValueSerializer>& vs) :
193 Base(cijk,vs) {}
194 };
195
196// Should also do TypeTo, and TypeTo,TypeFrom as UQ::PCE, but the real way
197// to fix is to make sure it is never called at all (requires fixing
198// magnitudeType)
199
200}
201
202#endif // SACADO_UQ_PCE_TRAITS_HPP
Implementation of Teuchos::SerializationTraits for all PCE types.
Serializer object for all PCE types.
PCEType::cijk_type cijk_type
Typename of cijk.
static KOKKOS_INLINE_FUNCTION bool eval(const UQ::PCE< S > &x, const UQ::PCE< S > &y)
ScalarType< typenameUQ::PCE< S >::value_type >::type type
static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const UQ::PCE< S > &x)
ValueType< UQ::PCE< S > >::type value_type
ScalarType< UQ::PCE< S > >::type scalar_type
Implementation for Teuchos::ScalarTraits for all PCE types.
Implementation for Teuchos::ValueTypeConversionTraits for all PCE types.
static KOKKOS_INLINE_FUNCTION const value_type & eval(const UQ::PCE< S > &x)
ValueType< UQ::PCE< S > >::type value_type
Sacado::Promote< L, Sacado::UQ::PCE< S > >::type promote
Sacado::Promote< Sacado::UQ::PCE< S >, R >::type promote
Sacado::Promote< Sacado::UQ::PCE< S >, Sacado::UQ::PCE< S > >::type promote
ValueTypeSerializer(const cijk_type &cijk, const Teuchos::RCP< const ValueSerializer > &vs)
Sacado::UQ::PCESerializerImp< Ordinal, PCEType, ValueSerializer > Base
ValueTypeSerializer< Ordinal, typename S::value_type > ValueSerializer