30 #if defined(HAVE_SACADO_KOKKOSCORE)
31 #include "Kokkos_Atomic.hpp"
32 #include "impl/Kokkos_Error.hpp"
40 template <
typename T,
int Num>
56 template <
typename ValueT,
int Num>
58 public Expr< GeneralFad<ValueT,Fad::StaticStorage<ValueT,Num> > > {
108 template <
typename S>
128 SLFad(
const int sz,
const int i,
const ValueT & x) :
137 template <
typename S>
149 template <
typename S>
152 GeneralFadType::operator=(v);
159 GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
164 template <
typename S>
168 GeneralFadType::operator=(x);
173 template <
typename S>
176 GeneralFadType::operator+=(x);
181 template <
typename S>
184 GeneralFadType::operator-=(x);
189 template <
typename S>
192 GeneralFadType::operator*=(x);
197 template <
typename S>
200 GeneralFadType::operator/=(x);
207 GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
214 GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
221 GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
228 GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
233 template <
typename S>
236 GeneralFadType::operator+=(x);
242 template <
typename S>
245 GeneralFadType::operator-=(x);
250 template <
typename S>
253 GeneralFadType::operator*=(x);
258 template <
typename S>
261 GeneralFadType::operator/=(x);
267 template <
typename T,
int N>
272 template <
typename T,
int N>
274 static const unsigned value =
275 ExprLevel< typename SLFad<T,N>::value_type >::value + 1;
278 template <
typename T,
int N>
280 static const bool value =
true;
285 template <
typename T,
int N>
290 template <
typename T,
int N>
295 template <
typename T,
int N>
300 template <
typename T,
unsigned,
unsigned>
struct ViewFadType;
302 template <
typename,
unsigned,
unsigned,
typename>
class ViewFad;
306 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
315 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
322 #if defined(HAVE_SACADO_KOKKOSCORE)
331 template <
typename T,
int N>
333 void atomic_add(SLFad<T,N>* dst,
const SLFad<T,N>& x) {
334 using Kokkos::atomic_add;
336 const int xsz = x.size();
337 const int sz = dst->size();
343 "Sacado error: Fad resize within atomic_add() not supported!");
345 if (xsz != sz && sz > 0 && xsz > 0)
347 "Sacado error: Fad assignment of incompatiable sizes!");
350 if (sz > 0 && xsz > 0) {
352 atomic_add(&(dst->fastAccessDx(i)), x.fastAccessDx(i));
355 atomic_add(&(dst->val()), x.val());
362 #endif // HAVE_SACADO_KOKKOSCORE
Turn SLFad into a meta-function class usable with mpl::apply.
SLFad< ValueT, Num > type
KOKKOS_INLINE_FUNCTION SLFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
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.
KOKKOS_INLINE_FUNCTION SLFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
KOKKOS_INLINE_FUNCTION SLFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
Forward-mode AD class using dynamic memory allocation and expression templates.
GeneralFad< StaticStorage< T, Num > > SLFad
KOKKOS_INLINE_FUNCTION SLFad(const SLFad &x)
Copy constructor.
#define SACADO_ENABLE_EXPR_CTOR_DECL
KOKKOS_INLINE_FUNCTION SLFad()
Default constructor.
KOKKOS_INLINE_FUNCTION ~SLFad()
Destructor.
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::SLFad< ValueType, N > > type
#define KOKKOS_INLINE_FUNCTION
ExprType::value_type value_type
Typename of values.
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
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)
#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
KOKKOS_INLINE_FUNCTION SLFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
SLFad< typename GeneralFad< T, Fad::StaticStorage< T, N > >::value_type, N > type
Get view type for any Fad type.