30 #ifndef SACADO_FAD_EXP_STATICFIXEDSTORAGE_HPP
31 #define SACADO_FAD_EXP_STATICFIXEDSTORAGE_HPP
33 #include <type_traits>
49 template <
typename T,
int Num>
60 template <
typename TT>
72 #ifdef SACADO_SFAD_INIT_DEFAULT_CONSTRUCTOR
98 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ )
100 throw "StaticFixedStorage::StaticFixedStorage() Error: Supplied derivative dimension does not equal static length.";
127 for (
int i=0; i<Num; i++)
135 for (
int i=0; i<Num; i++)
136 dx_[i] = std::move(x.dx_[i]);
153 for (
int i=0; i<Num; i++)
163 val_ = std::move(x.val_);
164 for (
int i=0; i<Num; i++)
165 dx_[i] = std::move(x.dx_[i]);
172 constexpr
int size()
const {
return Num; }
176 constexpr
int length()
const {
return Num; }
181 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ )
182 if (sz != 0 && sz != Num)
183 throw "StaticFixedStorage::resize() Error: Cannot resize fixed storage length.";
195 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ )
196 if (sz != 0 && sz != Num)
197 throw "StaticFixedStorage::resize() Error: Cannot resize fixed storage length.";
205 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ )
207 throw "StaticFixedStorage::expand() Error: Cannot resize fixed storage length.";
255 #endif // SACADO_FAD_EXP_STATICFIXEDSTORAGE_HPP
StaticFixedStorage< TT, Num > type
Replace static derivative length.
Turn StaticFixedStorage into a meta-function class usable with mpl::apply.
KOKKOS_INLINE_FUNCTION StaticFixedStorage(const StaticFixedStorage &x)
Copy constructor.
T dx_[Num]
Derivative array.
KOKKOS_INLINE_FUNCTION const T * dx() const
Returns derivative array.
KOKKOS_INLINE_FUNCTION StaticFixedStorage(const T &x)
Constructor with value.
KOKKOS_INLINE_FUNCTION constexpr int size() const
Returns number of derivative components.
static constexpr bool is_view
KOKKOS_INLINE_FUNCTION StaticFixedStorage & operator=(StaticFixedStorage &&x)
Move assignment.
KOKKOS_INLINE_FUNCTION T dx(int i) const
Returns derivative component i with bounds checking.
static KOKKOS_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
KOKKOS_INLINE_FUNCTION constexpr int length() const
Returns array length.
#define KOKKOS_INLINE_FUNCTION
KOKKOS_INLINE_FUNCTION const T & fastAccessDx(int i) const
Returns derivative component i without bounds checking.
Derivative array storage class using static, fixed memory allocation.
#define KOKKOS_DEFAULTED_FUNCTION
KOKKOS_INLINE_FUNCTION T & fastAccessDx(int i)
Returns derivative component i without bounds checking.
KOKKOS_INLINE_FUNCTION StaticFixedStorage(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz.
KOKKOS_INLINE_FUNCTION void zero()
Zero out derivative array.
KOKKOS_INLINE_FUNCTION const T & val() const
Returns value.
KOKKOS_INLINE_FUNCTION StaticFixedStorage & operator=(const StaticFixedStorage &x)
Assignment.
StaticFixedStorage< T, N > type
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
KOKKOS_INLINE_FUNCTION void expand(int sz)
Expand derivative array to size sz.
Initialize the derivative array.
std::remove_cv< T >::type value_type
static constexpr bool is_statically_sized
KOKKOS_INLINE_FUNCTION StaticFixedStorage(const int sz, const int i, const value_type &x)
Constructor with size sz, index i, and value x.
static constexpr int static_size
KOKKOS_INLINE_FUNCTION StaticFixedStorage(StaticFixedStorage &&x)
Move constructor.
KOKKOS_INLINE_FUNCTION void resize(int sz)
Resize the derivative array to sz.
KOKKOS_INLINE_FUNCTION T & val()
Returns value.
KOKKOS_INLINE_FUNCTION void resizeAndZero(int sz)
Resize the derivative array to sz.
KOKKOS_DEFAULTED_FUNCTION StaticFixedStorage()=default
Default constructor.
KOKKOS_DEFAULTED_FUNCTION ~StaticFixedStorage()=default
Destructor.