30#ifndef SACADO_FAD_EXP_VECTORDYNAMICSTORAGE_HPP
31#define SACADO_FAD_EXP_VECTORDYNAMICSTORAGE_HPP
45 template <
typename T,
typename U = T>
56 template <
typename TT,
typename UU = TT>
146#if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
148 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!";
203#if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
205 throw "Can\'t resize beyond original size when memory isn't owned!";
225#if defined(SACADO_DEBUG) && !defined(__CUDA_ARCH__ ) && !defined(__HIP_DEVICE_COMPILE__)
227 throw "Can\'t resize beyond original size when memory isn't owned!";
#define SACADO_INLINE_FUNCTION
Fad specializations for Teuchos::BLAS wrappers.
Derivative array storage class using dynamic memory allocation.
static constexpr bool is_statically_sized
SACADO_INLINE_FUNCTION const U & fastAccessDx(int i) const
Returns derivative component i without bounds checking.
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 void resizeAndZero(int sz)
Resize the derivative array to sz.
int len_
Derivative array length.
std::remove_cv< T >::type value_type
SACADO_INLINE_FUNCTION int size() const
Returns number of derivative components.
SACADO_INLINE_FUNCTION T & val()
Returns value.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz.
SACADO_INLINE_FUNCTION U & fastAccessDx(int i)
Returns derivative component i without bounds checking.
SACADO_INLINE_FUNCTION const U * dx() const
Returns derivative array.
int stride_
Derivative array stride.
SACADO_INLINE_FUNCTION ~VectorDynamicStorage()
Destructor.
SACADO_INLINE_FUNCTION void expand(int sz)
Expand derivative array to size sz.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const T &x)
Constructor with value.
static constexpr bool is_view
SACADO_INLINE_FUNCTION U dx(int i) const
Returns derivative component i with bounds checking.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const VectorDynamicStorage &x)
Copy constructor.
SACADO_INLINE_FUNCTION VectorDynamicStorage & operator=(const VectorDynamicStorage &x)
Assignment.
SACADO_INLINE_FUNCTION VectorDynamicStorage(const int sz, T *x, U *dx_p, const int stride, bool zero_out)
Constructor with supplied memory.
SACADO_INLINE_FUNCTION void resize(int sz)
Resize the derivative array to sz.
SACADO_INLINE_FUNCTION VectorDynamicStorage()
Default constructor.
SACADO_INLINE_FUNCTION int length() const
Returns array length.
int sz_
Derivative array size.
SACADO_INLINE_FUNCTION void zero()
Zero out derivative array.
bool owns_mem
Do we own the val/dx storage.
static constexpr int static_size
SACADO_INLINE_FUNCTION void setMemory(int sz, T *x, U *dx_p, int stride)
Set value/derivative array memory.
SACADO_INLINE_FUNCTION const T & val() const
Returns value.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors.
@ InitDerivArray
Initialize the derivative array.
Replace static derivative length.
VectorDynamicStorage< T, U > type
Turn DynamicStorage into a meta-function class usable with mpl::apply.
VectorDynamicStorage< TT, UU > type
static SACADO_INLINE_FUNCTION T * get(int sz)
Get memory for new array of length sz.
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.
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.
static SACADO_INLINE_FUNCTION T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
static SACADO_INLINE_FUNCTION void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
static SACADO_INLINE_FUNCTION void strided_zero(T *dest, int stride, int sz)
Zero out array dest of length sz.
static SACADO_INLINE_FUNCTION void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.