10 #if defined(HAVE_SACADO_KOKKOS)
11 #include "Kokkos_Atomic.hpp"
12 #include "impl/Kokkos_Error.hpp"
29 template <
typename ValueT>
31 public Expr< GeneralFad<ValueT,Fad::DynamicStorage<ValueT> > > {
98 DFad(
const int sz,
const int i,
const ValueT &
x) :
107 template <
typename S>
119 template <
typename S>
122 GeneralFadType::operator=(v);
129 GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
134 template <
typename S>
138 GeneralFadType::operator=(x);
143 template <
typename S>
146 GeneralFadType::operator+=(x);
151 template <
typename S>
154 GeneralFadType::operator-=(x);
159 template <
typename S>
162 GeneralFadType::operator*=(x);
167 template <
typename S>
170 GeneralFadType::operator/=(x);
177 GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
184 GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
191 GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
198 GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
203 template <
typename S>
206 GeneralFadType::operator+=(x);
211 template <
typename S>
214 GeneralFadType::operator-=(x);
219 template <
typename S>
222 GeneralFadType::operator*=(x);
227 template <
typename S>
230 GeneralFadType::operator/=(x);
236 template <
typename T>
237 struct BaseExpr< GeneralFad<
T,Fad::DynamicStorage<T> > > {
241 template <
typename T>
244 ExprLevel< typename DFad<T>::value_type >
::value + 1;
247 template <
typename T>
254 template <
typename T>
259 template <
typename T>
264 template <
typename T>
269 template <
typename,
unsigned,
unsigned>
struct ViewFadType;
271 template <
typename,
unsigned,
unsigned,
typename>
class ViewFad;
275 template<
class ValueType,
unsigned length,
unsigned str
ide >
284 template<
class ValueType,
unsigned length,
unsigned str
ide >
291 #if defined(HAVE_SACADO_KOKKOS)
300 template <
typename T>
302 void atomic_add(DFad<T>* dst,
const DFad<T>& x) {
303 using Kokkos::atomic_add;
305 const int xsz = x.size();
306 const int sz = dst->size();
312 "Sacado error: Fad resize within atomic_add() not supported!");
314 if (xsz != sz && sz > 0 && xsz > 0)
316 "Sacado error: Fad assignment of incompatiable sizes!");
319 if (sz > 0 && xsz > 0) {
321 atomic_add(&(dst->fastAccessDx(
i)), x.fastAccessDx(
i));
324 atomic_add(&(dst->val()), x.val());
331 #endif // HAVE_SACADO_KOKKOS
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::DFad< ValueType > > type
SACADO_INLINE_FUNCTION DFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
Replace static derivative length.
SACADO_INLINE_FUNCTION ~DFad()
Destructor.
#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.
SACADO_INLINE_FUNCTION DFad(const DFad &x)
Copy constructor.
#define SACADO_ENABLE_EXPR_CTOR_DECL
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
SACADO_INLINE_FUNCTION DFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
SACADO_INLINE_FUNCTION DFad()
Default constructor.
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.
SACADO_INLINE_FUNCTION DFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
Fad::DynamicStorage< ValueT > StorageType
Base classes.
ExprType::value_type value_type
Typename of values.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
SACADO_INLINE_FUNCTION DFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
Expr< GeneralFadType > ExprType
Initialize the derivative array.
#define SACADO_INLINE_FUNCTION
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.