10 #ifndef SACADO_FAD_EXP_VECTORDYNAMICSTORAGE_HPP
11 #define SACADO_FAD_EXP_VECTORDYNAMICSTORAGE_HPP
13 #include <type_traits>
25 template <
typename T,
typename U = T>
36 template <
typename TT,
typename UU = TT>
126 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
128 throw "Can\'t resize beyond original size when memory isn't owned!";
163 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
165 throw "Can\'t resize beyond original size when memory isn't owned!";
183 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
185 throw "Can\'t resize beyond original size when memory isn't owned!";
205 #if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
207 throw "Can\'t resize beyond original size when memory isn't owned!";
301 #endif // SACADO_FAD_VECTORDYNAMICSTORAGE_HPP
SACADO_INLINE_FUNCTION VectorDynamicStorage & operator=(const VectorDynamicStorage &x)
Assignment.
static SACADO_INLINE_FUNCTION void strided_copy(const T *src, int src_stride, T *dest, int dest_stride, int sz)
Copy array from src to dest of length sz.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const int sz, const int i, const value_type &x)
Constructor with size sz, index i, and value x.
SACADO_INLINE_FUNCTION VectorDynamicStorage()
Default constructor.
VectorDynamicStorage< T, U > type
Turn DynamicStorage into a meta-function class usable with mpl::apply.
SACADO_INLINE_FUNCTION const U * dx() const
Returns derivative array.
int stride_
Derivative array stride.
SACADO_INLINE_FUNCTION U & fastAccessDx(int i)
Returns derivative component i without bounds checking.
Replace static derivative length.
SACADO_INLINE_FUNCTION void setMemory(int sz, T *x, U *dx_p, int stride)
Set value/derivative array memory.
static constexpr int static_size
static constexpr bool is_statically_sized
SACADO_INLINE_FUNCTION void resizeAndZero(int sz)
Resize the derivative array to sz.
VectorDynamicStorage< TT, UU > type
SACADO_INLINE_FUNCTION const T & val() const
Returns value.
SACADO_INLINE_FUNCTION int length() const
Returns array length.
SACADO_INLINE_FUNCTION int size() const
Returns number of derivative components.
int len_
Derivative array length.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz.
SACADO_INLINE_FUNCTION void expand(int sz)
Expand derivative array to size sz.
SACADO_INLINE_FUNCTION void zero()
Zero out derivative array.
std::remove_cv< T >::type value_type
SACADO_INLINE_FUNCTION VectorDynamicStorage(const VectorDynamicStorage &x)
Copy constructor.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const int sz, T *x, U *dx_p, const int stride, bool zero_out)
Constructor with supplied memory.
static SACADO_INLINE_FUNCTION void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
SACADO_INLINE_FUNCTION T & val()
Returns value.
static constexpr bool is_view
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
static SACADO_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
SACADO_INLINE_FUNCTION ~VectorDynamicStorage()
Destructor.
Initialize the derivative array.
Derivative array storage class using dynamic memory allocation.
bool owns_mem
Do we own the val/dx storage.
static SACADO_INLINE_FUNCTION T * strided_get_and_fill(const T *src, int stride, int sz)
Get memory for new array of length sz and fill with entries from src.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const T &x)
Constructor with value.
static SACADO_INLINE_FUNCTION T * get(int sz)
Get memory for new array of length sz.
#define SACADO_INLINE_FUNCTION
SACADO_INLINE_FUNCTION const U & fastAccessDx(int i) const
Returns derivative component i without bounds checking.
static SACADO_INLINE_FUNCTION void strided_zero(T *dest, int stride, int sz)
Zero out array dest of length sz.
int sz_
Derivative array size.
static SACADO_INLINE_FUNCTION T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
SACADO_INLINE_FUNCTION void resize(int sz)
Resize the derivative array to sz.
SACADO_INLINE_FUNCTION U dx(int i) const
Returns derivative component i with bounds checking.