10 #ifndef SACADO_FAD_EXP_STATICFIXEDSTORAGE_HPP
11 #define SACADO_FAD_EXP_STATICFIXEDSTORAGE_HPP
13 #include <type_traits>
29 template <
typename T,
int Num>
40 template <
typename TT>
52 #ifdef SACADO_SFAD_INIT_DEFAULT_CONSTRUCTOR
78 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
80 throw "StaticFixedStorage::StaticFixedStorage() Error: Supplied derivative dimension does not equal static length.";
107 for (
int i=0;
i<Num;
i++)
115 for (
int i=0;
i<Num;
i++)
116 dx_[
i] = std::move(
x.dx_[
i]);
133 for (
int i=0;
i<Num;
i++)
143 val_ = std::move(
x.val_);
144 for (
int i=0;
i<Num;
i++)
145 dx_[
i] = std::move(
x.dx_[
i]);
152 constexpr
int size()
const {
return Num; }
156 constexpr
int length()
const {
return Num; }
161 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
162 if (sz != 0 && sz != Num)
163 throw "StaticFixedStorage::resize() Error: Cannot resize fixed storage length.";
175 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
176 if (sz != 0 && sz != Num)
177 throw "StaticFixedStorage::resize() Error: Cannot resize fixed storage length.";
185 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
187 throw "StaticFixedStorage::expand() Error: Cannot resize fixed storage length.";
235 #endif // SACADO_FAD_EXP_STATICFIXEDSTORAGE_HPP
SACADO_INLINE_FUNCTION StaticFixedStorage(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz.
StaticFixedStorage< TT, Num > type
Replace static derivative length.
Turn StaticFixedStorage into a meta-function class usable with mpl::apply.
#define SACADO_DEFAULTED_FUNCTION
T dx_[Num]
Derivative array.
SACADO_INLINE_FUNCTION StaticFixedStorage & operator=(const StaticFixedStorage &x)
Assignment.
SACADO_INLINE_FUNCTION StaticFixedStorage(const int sz, const int i, const value_type &x)
Constructor with size sz, index i, and value x.
static constexpr bool is_view
SACADO_INLINE_FUNCTION T dx(int i) const
Returns derivative component i with bounds checking.
SACADO_INLINE_FUNCTION StaticFixedStorage(StaticFixedStorage &&x)
Move constructor.
SACADO_INLINE_FUNCTION T & val()
Returns value.
SACADO_INLINE_FUNCTION StaticFixedStorage & operator=(StaticFixedStorage &&x)
Move assignment.
SACADO_DEFAULTED_FUNCTION ~StaticFixedStorage()=default
Destructor.
SACADO_INLINE_FUNCTION T & fastAccessDx(int i)
Returns derivative component i without bounds checking.
SACADO_INLINE_FUNCTION StaticFixedStorage(const T &x)
Constructor with value.
Derivative array storage class using static, fixed memory allocation.
SACADO_INLINE_FUNCTION constexpr int length() const
Returns array length.
SACADO_INLINE_FUNCTION const T * dx() const
Returns derivative array.
SACADO_INLINE_FUNCTION void resize(int sz)
Resize the derivative array to sz.
StaticFixedStorage< T, N > type
SACADO_INLINE_FUNCTION const T & fastAccessDx(int i) const
Returns derivative component i without bounds checking.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
SACADO_DEFAULTED_FUNCTION StaticFixedStorage()=default
Default constructor.
static SACADO_INLINE_FUNCTION void zero(T *dest, int sz)
Zero out array dest of length sz.
Initialize the derivative array.
SACADO_INLINE_FUNCTION const T & val() const
Returns value.
std::remove_cv< T >::type value_type
SACADO_INLINE_FUNCTION void expand(int sz)
Expand derivative array to size sz.
static constexpr bool is_statically_sized
static constexpr int static_size
SACADO_INLINE_FUNCTION StaticFixedStorage(const StaticFixedStorage &x)
Copy constructor.
#define SACADO_INLINE_FUNCTION
SACADO_INLINE_FUNCTION constexpr int size() const
Returns number of derivative components.
SACADO_INLINE_FUNCTION void resizeAndZero(int sz)
Resize the derivative array to sz.
SACADO_INLINE_FUNCTION void zero()
Zero out derivative array.