30 #if defined(HAVE_SACADO_KOKKOSCORE)
31 #include "Kokkos_Atomic.hpp"
32 #include "impl/Kokkos_Error.hpp"
49 template <
typename ValueT>
51 public Expr< GeneralFad<ValueT,Fad::DynamicStorage<ValueT> > > {
118 DFad(
const int sz,
const int i,
const ValueT & x) :
127 template <
typename S>
139 template <
typename S>
142 GeneralFadType::operator=(v);
149 GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
154 template <
typename S>
158 GeneralFadType::operator=(x);
163 template <
typename S>
166 GeneralFadType::operator+=(x);
171 template <
typename S>
174 GeneralFadType::operator-=(x);
179 template <
typename S>
182 GeneralFadType::operator*=(x);
187 template <
typename S>
190 GeneralFadType::operator/=(x);
197 GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
204 GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
211 GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
218 GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
223 template <
typename S>
226 GeneralFadType::operator+=(x);
231 template <
typename S>
234 GeneralFadType::operator-=(x);
239 template <
typename S>
242 GeneralFadType::operator*=(x);
247 template <
typename S>
250 GeneralFadType::operator/=(x);
256 template <
typename T>
257 struct BaseExpr< GeneralFad<
T,Fad::DynamicStorage<T> > > {
261 template <
typename T>
263 static const unsigned value =
264 ExprLevel< typename DFad<T>::value_type >::value + 1;
267 template <
typename T>
269 static const bool value =
true;
274 template <
typename T>
279 template <
typename T>
284 template <
typename T>
289 template <
typename,
unsigned,
unsigned>
struct ViewFadType;
291 template <
typename,
unsigned,
unsigned,
typename>
class ViewFad;
295 template<
class ValueType,
unsigned length,
unsigned str
ide >
304 template<
class ValueType,
unsigned length,
unsigned str
ide >
311 #if defined(HAVE_SACADO_KOKKOSCORE)
320 template <
typename T>
322 void atomic_add(DFad<T>* dst,
const DFad<T>& x) {
323 using Kokkos::atomic_add;
325 const int xsz = x.size();
326 const int sz = dst->size();
332 "Sacado error: Fad resize within atomic_add() not supported!");
334 if (xsz != sz && sz > 0 && xsz > 0)
336 "Sacado error: Fad assignment of incompatiable sizes!");
339 if (sz > 0 && xsz > 0) {
341 atomic_add(&(dst->fastAccessDx(i)), x.fastAccessDx(i));
344 atomic_add(&(dst->val()), x.val());
351 #endif // HAVE_SACADO_KOKKOSCORE
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::DFad< ValueType > > type
KOKKOS_INLINE_FUNCTION DFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
Replace static derivative length.
#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.
KOKKOS_INLINE_FUNCTION DFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
#define SACADO_ENABLE_EXPR_CTOR_DECL
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
KOKKOS_INLINE_FUNCTION DFad()
Default constructor.
KOKKOS_INLINE_FUNCTION DFad(const DFad &x)
Copy constructor.
KOKKOS_INLINE_FUNCTION DFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
#define KOKKOS_INLINE_FUNCTION
FAD_NS::DFad< T >::base_expr_type type
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
DFad< typename GeneralFad< T, Fad::DynamicStorage< T > >::value_type > type
GeneralFad< DynamicStorage< T > > DFad
#define SACADO_FAD_DERIV_LOOP(I, SZ)
Get the base Fad type from a view/expression.
Forward-mode AD class using dynamic memory allocation and expression templates.
Fad::DynamicStorage< ValueT > StorageType
Base classes.
ExprType::value_type value_type
Typename of values.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
Expr< GeneralFadType > ExprType
Initialize the derivative array.
KOKKOS_INLINE_FUNCTION ~DFad()
Destructor.
KOKKOS_INLINE_FUNCTION DFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
Sacado::FAD_NS::ViewFad< ValueType, length, stride, Sacado::FAD_NS::DFad< ValueType > > type
Turn DFad into a meta-function class usable with mpl::apply.
GeneralFad< ValueT, StorageType > GeneralFadType
Get view type for any Fad type.