30 #if defined(HAVE_SACADO_KOKKOSCORE)
31 #include "Kokkos_Atomic.hpp"
32 #include "impl/Kokkos_Error.hpp"
46 template <
typename ValueT,
int Num>
48 public Expr< SFadExprTag<ValueT,Num > > {
53 typedef Expr< SFadExprTag<ValueT,Num > >
ExprType;
113 SFad(
const int sz,
const int i,
const ValueT & x) :
122 template <
typename S>
134 template <
typename S>
137 ExprType::operator=(v);
144 ExprType::operator=(static_cast<const ExprType&>(x));
149 template <
typename S>
153 ExprType::operator=(x);
158 template <
typename S>
161 ExprType::operator+=(x);
166 template <
typename S>
169 ExprType::operator-=(x);
174 template <
typename S>
177 ExprType::operator*=(x);
182 template <
typename S>
185 ExprType::operator/=(x);
192 ExprType::operator+=(static_cast<const ExprType&>(x));
199 ExprType::operator-=(static_cast<const ExprType&>(x));
206 ExprType::operator*=(static_cast<const ExprType&>(x));
213 ExprType::operator/=(static_cast<const ExprType&>(x));
218 template <
typename S>
221 ExprType::operator+=(x);
226 template <
typename S>
229 ExprType::operator-=(x);
234 template <
typename S>
237 ExprType::operator*=(x);
242 template <
typename S>
245 ExprType::operator/=(x);
251 template <
typename T,
int Num>
253 const Expr< SFadExprTag<T,Num> >& x) {
254 os << x.val() <<
" [";
256 for (
int i=0; i< x.size(); i++) {
257 os <<
" " << x.dx(i);
264 template <
typename T,
int N>
266 static const unsigned value =
267 ExprLevel< typename SFad<T,N>::value_type >::value + 1;
270 template <
typename T,
int N>
272 static const bool value =
true;
277 template <
typename T,
int N>
282 template <
typename T,
int N>
287 template <
typename T,
int N>
292 template <
typename T,
unsigned,
unsigned>
struct ViewFadType;
294 template <
typename,
unsigned,
unsigned,
typename>
class ViewFad;
298 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
307 template<
class ValueType,
int N,
unsigned length,
unsigned str
ide >
314 #if defined(HAVE_SACADO_KOKKOSCORE)
323 template <
typename T,
int N>
325 void atomic_add(SFad<T,N>* dst,
const SFad<T,N>& x) {
326 using Kokkos::atomic_add;
328 const int xsz = x.size();
329 const int sz = dst->size();
335 "Sacado error: Fad resize within atomic_add() not supported!");
337 if (xsz != sz && sz > 0 && xsz > 0)
339 "Sacado error: Fad assignment of incompatiable sizes!");
342 if (sz > 0 && xsz > 0) {
344 atomic_add(&(dst->fastAccessDx(i)), x.fastAccessDx(i));
347 atomic_add(&(dst->val()), x.val());
354 #endif // HAVE_SACADO_KOKKOSCORE
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
KOKKOS_INLINE_FUNCTION SFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
KOKKOS_INLINE_FUNCTION SFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
#define SACADO_FAD_THREAD_SINGLE
KOKKOS_INLINE_FUNCTION ~SFad()
Destructor.
#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)
FAD_NS::SFad< T, N >::base_expr_type type
#define KOKKOS_INLINE_FUNCTION
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
#define SACADO_FAD_DERIV_LOOP(I, SZ)
Get the base Fad type from a view/expression.
KOKKOS_INLINE_FUNCTION SFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
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.
KOKKOS_INLINE_FUNCTION SFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
Forward-mode AD class using static memory allocation.
Initialize the derivative array.
KOKKOS_INLINE_FUNCTION SFad(const SFad &x)
Copy constructor.
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::SFad< ValueType, N > > type
GeneralFad< ViewStorage< T, static_length, static_stride, U > > ViewFad
GeneralFad< StaticFixedStorage< T, Num > > SFad
KOKKOS_INLINE_FUNCTION SFad()
Default constructor.
Get view type for any Fad type.