10 #if defined(HAVE_SACADO_KOKKOS)
11 #include "Kokkos_Atomic.hpp"
12 #include "impl/Kokkos_Error.hpp"
26 template <
typename ValueT,
int Num>
28 public Expr< SFadExprTag<ValueT,Num > > {
33 typedef Expr< SFadExprTag<ValueT,Num > >
ExprType;
93 SFad(
const int sz,
const int i,
const ValueT &
x) :
102 template <
typename S>
114 template <
typename S>
117 ExprType::operator=(v);
124 ExprType::operator=(static_cast<const ExprType&>(x));
129 template <
typename S>
133 ExprType::operator=(x);
138 template <
typename S>
141 ExprType::operator+=(x);
146 template <
typename S>
149 ExprType::operator-=(x);
154 template <
typename S>
157 ExprType::operator*=(x);
162 template <
typename S>
165 ExprType::operator/=(x);
172 ExprType::operator+=(static_cast<const ExprType&>(x));
179 ExprType::operator-=(static_cast<const ExprType&>(x));
186 ExprType::operator*=(static_cast<const ExprType&>(x));
193 ExprType::operator/=(static_cast<const ExprType&>(x));
198 template <
typename S>
201 ExprType::operator+=(x);
206 template <
typename S>
209 ExprType::operator-=(x);
214 template <
typename S>
217 ExprType::operator*=(x);
222 template <
typename S>
225 ExprType::operator/=(x);
231 template <
typename T,
int Num>
233 const Expr< SFadExprTag<T,Num> >& x) {
234 os << x.val() <<
" [";
236 for (
int i=0;
i< x.size();
i++) {
237 os <<
" " << x.dx(
i);
244 template <
typename T,
int N>
247 ExprLevel< typename SFad<T,N>::value_type >
::value + 1;
250 template <
typename T,
int N>
257 template <
typename T,
int N>
262 template <
typename T,
int N>
267 template <
typename T,
int N>
272 template <
typename T,
unsigned,
unsigned>
struct ViewFadType;
274 template <
typename,
unsigned,
unsigned,
typename>
class ViewFad;
278 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
287 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
294 #if defined(HAVE_SACADO_KOKKOS)
303 template <
typename T,
int N>
305 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x) {
306 using Kokkos::atomic_add;
308 const int xsz = x.size();
309 const int sz = dst->size();
315 "Sacado error: Fad resize within atomic_add() not supported!");
317 if (xsz != sz && sz > 0 && xsz > 0)
319 "Sacado error: Fad assignment of incompatiable sizes!");
322 if (sz > 0 && xsz > 0) {
324 atomic_add(&(dst->fastAccessDx(
i)), x.fastAccessDx(
i));
327 atomic_add(&(dst->val()), x.val());
334 #endif // HAVE_SACADO_KOKKOS
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
SACADO_INLINE_FUNCTION SFad()
Default constructor.
#define SACADO_FAD_THREAD_SINGLE
SACADO_INLINE_FUNCTION SFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
SACADO_INLINE_FUNCTION SFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
#define SACADO_ENABLE_VALUE_CTOR_DECL
Base template specification for whether a type is a Fad type.
Sacado::FAD_NS::ViewFad< ValueType, length, stride, Sacado::FAD_NS::SFad< ValueType, N > > type
Forward-mode AD class using dynamic memory allocation and expression templates.
Turn SFad into a meta-function class usable with mpl::apply.
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
#define SACADO_ENABLE_EXPR_CTOR_DECL
std::ostream & operator<<(std::ostream &os, const Expr< SFadExprTag< T, Num > > &x)
SACADO_INLINE_FUNCTION SFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
SACADO_INLINE_FUNCTION SFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
FAD_NS::SFad< T, N >::base_expr_type type
SACADO_INLINE_FUNCTION SFad(const SFad &x)
Copy constructor.
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
#define SACADO_FAD_DERIV_LOOP(I, SZ)
Get the base Fad type from a view/expression.
Expr< SFadExprTag< ValueT, Num > > ExprType
Base classes.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
Replace static derivative length.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
ExprType::value_type value_type
Typename of values.
Forward-mode AD class using static memory allocation.
Initialize the derivative array.
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::SFad< ValueType, N > > type
GeneralFad< ViewStorage< T, static_length, static_stride, U > > ViewFad
#define SACADO_INLINE_FUNCTION
GeneralFad< StaticFixedStorage< T, Num > > SFad
SACADO_INLINE_FUNCTION ~SFad()
Destructor.
Get view type for any Fad type.