10 #if defined(HAVE_SACADO_KOKKOS)
11 #include "Kokkos_Atomic.hpp"
12 #include "impl/Kokkos_Error.hpp"
20 template <
typename T,
int Num>
36 template <
typename ValueT,
int Num>
38 public Expr< GeneralFad<ValueT,Fad::StaticStorage<ValueT,Num> > > {
108 SLFad(
const int sz,
const int i,
const ValueT &
x) :
117 template <
typename S>
129 template <
typename S>
132 GeneralFadType::operator=(v);
139 GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
144 template <
typename S>
148 GeneralFadType::operator=(x);
153 template <
typename S>
156 GeneralFadType::operator+=(x);
161 template <
typename S>
164 GeneralFadType::operator-=(x);
169 template <
typename S>
172 GeneralFadType::operator*=(x);
177 template <
typename S>
180 GeneralFadType::operator/=(x);
187 GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
194 GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
201 GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
208 GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
213 template <
typename S>
216 GeneralFadType::operator+=(x);
222 template <
typename S>
225 GeneralFadType::operator-=(x);
230 template <
typename S>
233 GeneralFadType::operator*=(x);
238 template <
typename S>
241 GeneralFadType::operator/=(x);
247 template <
typename T,
int N>
252 template <
typename T,
int N>
255 ExprLevel< typename SLFad<T,N>::value_type >
::value + 1;
258 template <
typename T,
int N>
265 template <
typename T,
int N>
270 template <
typename T,
int N>
275 template <
typename T,
int N>
280 template <
typename T,
unsigned,
unsigned>
struct ViewFadType;
282 template <
typename,
unsigned,
unsigned,
typename>
class ViewFad;
286 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
295 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
302 #if defined(HAVE_SACADO_KOKKOS)
311 template <
typename T,
int N>
313 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x) {
314 using Kokkos::atomic_add;
316 const int xsz = x.size();
317 const int sz = dst->size();
323 "Sacado error: Fad resize within atomic_add() not supported!");
325 if (xsz != sz && sz > 0 && xsz > 0)
327 "Sacado error: Fad assignment of incompatiable sizes!");
330 if (sz > 0 && xsz > 0) {
332 atomic_add(&(dst->fastAccessDx(
i)), x.fastAccessDx(
i));
335 atomic_add(&(dst->val()), x.val());
342 #endif // HAVE_SACADO_KOKKOS
SACADO_INLINE_FUNCTION SLFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
Turn SLFad into a meta-function class usable with mpl::apply.
SLFad< ValueT, Num > type
Derivative array storage class using static memory allocation.
#define SACADO_FAD_THREAD_SINGLE
#define SACADO_ENABLE_VALUE_CTOR_DECL
Base template specification for whether a type is a Fad type.
Forward-mode AD class using dynamic memory allocation and expression templates.
GeneralFad< StaticStorage< T, Num > > SLFad
#define SACADO_ENABLE_EXPR_CTOR_DECL
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::SLFad< ValueType, N > > type
SACADO_INLINE_FUNCTION SLFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
ExprType::value_type value_type
Typename of values.
SACADO_INLINE_FUNCTION SLFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
SACADO_INLINE_FUNCTION SLFad()
Default constructor.
FAD_NS::SLFad< T, N >::base_expr_type type
Fad::StaticStorage< ValueT, Num > StorageType
Base classes.
#define SACADO_FAD_DERIV_LOOP(I, SZ)
Get the base Fad type from a view/expression.
Replace static derivative length.
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
SACADO_INLINE_FUNCTION SLFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
Expr< GeneralFadType > ExprType
Sacado::FAD_NS::ViewFad< ValueType, length, stride, Sacado::FAD_NS::SLFad< ValueType, N > > type
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
GeneralFad< ValueT, StorageType > GeneralFadType
Forward-mode AD class using static memory allocation with long arrays and expression templates...
Initialize the derivative array.
GeneralFad< ViewStorage< T, static_length, static_stride, U > > ViewFad
#define SACADO_INLINE_FUNCTION
SACADO_INLINE_FUNCTION SLFad(const SLFad &x)
Copy constructor.
SACADO_INLINE_FUNCTION ~SLFad()
Destructor.
SLFad< typename GeneralFad< T, Fad::StaticStorage< T, N > >::value_type, N > type
Get view type for any Fad type.