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>
267 ExprLevel< typename SFad<T,N>::value_type >
::value + 1;
270 template <
typename T,
int N>
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());
#define SACADO_INLINE_FUNCTION
#define SACADO_FAD_THREAD_SINGLE
#define SACADO_FAD_DERIV_LOOP(I, SZ)
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
#define SACADO_ENABLE_VALUE_CTOR_DECL
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
#define SACADO_ENABLE_EXPR_CTOR_DECL
Forward-mode AD class using static memory allocation.
SACADO_INLINE_FUNCTION SFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
SACADO_INLINE_FUNCTION SFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
SACADO_INLINE_FUNCTION SFad()
Default constructor.
Expr< SFadExprTag< ValueT, Num > > ExprType
Base classes.
SACADO_INLINE_FUNCTION SFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
SACADO_INLINE_FUNCTION SFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
ExprType::value_type value_type
Typename of values.
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
SACADO_INLINE_FUNCTION ~SFad()
Destructor.
SACADO_INLINE_FUNCTION SFad(const SFad &x)
Copy constructor.
Forward-mode AD class using dynamic memory allocation and expression templates.
std::ostream & operator<<(std::ostream &os, const Expr< SFadExprTag< T, Num > > &x)
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors.
@ InitDerivArray
Initialize the derivative array.
FAD_NS::SFad< T, N >::base_expr_type type
Get the base Fad type from a view/expression.
Replace static derivative length.
Turn SFad into a meta-function class usable with mpl::apply.
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
Sacado::FAD_NS::ViewFad< const ValueType, length, stride, Sacado::FAD_NS::SFad< ValueType, N > > type
Get view type for any Fad type.