|
Sacado Package Browser (Single Doxygen Collection)
Version of the Day
|
Go to the documentation of this file.
32 #ifndef SACADO_FAD_MEMPOOLSTORAGE_HPP
33 #define SACADO_FAD_MEMPOOLSTORAGE_HPP
37 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
45 using MemPoolStorage = Exp::MemPoolStorage<T>;
65 template <typename T, bool isScalar = IsScalarType<T>::value>
71 T* m = static_cast<T*>(pool->
alloc());
73 for (
int i=0; i<sz; ++i)
84 T* m = static_cast<T*>(pool->
alloc());
86 for (
int i=0; i<sz; ++i)
100 T* m = static_cast<T*>(pool->
alloc());
102 for (
int i=0; i<sz; ++i)
103 new (p++)
T(*(src++));
111 static inline void copy(
const T* src,
T* dest,
int sz) {
112 for (
int i=0; i<sz; ++i)
113 *(dest++) = *(src++);
117 static inline void zero(
T* dest,
int sz) {
118 for (
int i=0; i<sz; ++i)
125 for (
T* b = m; b!=e; b++)
127 pool->
free((
void*) m);
135 template <
typename T>
141 T* m = static_cast<T*>(pool->
alloc());
151 T* m = static_cast<T*>(pool->
alloc());
152 std::memset(m,0,sz*
sizeof(
T));
165 T* m = static_cast<T*>(pool->
alloc());
167 for (
int i=0; i<sz; ++i)
168 new (p++)
T(*(src++));
176 static inline void copy(
const T* src,
T* dest,
int sz) {
177 std::memcpy(dest,src,sz*
sizeof(
T));
181 static inline void zero(
T* dest,
int sz) {
183 std::memset(dest,0,sz*
sizeof(
T));
188 pool->
free((
void*) m);
193 template <
typename T>
201 template <
typename S>
359 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
361 #endif // SACADO_FAD_MEMPOOLSTORAGE_HPP
void resizeAndZero(int sz)
Resize the derivative array to sz.
static void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
MemPoolStorage & operator=(const MemPoolStorage &x)
Assignment.
MemPoolStorage(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz.
const T & fastAccessDx(int i) const
Returns derivative component i without bounds checking.
static void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
MemPoolStorage(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Default constructor.
const T * dx() const
Returns derivative array.
~MemPoolStorage()
Destructor.
static void destroy_and_release(T *m, int sz, MemPool *pool)
Destroy array elements and release memory.
static T * get_and_fill(const T *src, int sz, MemPool *pool)
Get memory for new array of length sz and fill with entries from src.
static void zero(T *dest, int sz)
Zero out array dest of length sz.
T & fastAccessDx(int i)
Returns derivative component i without bounds checking.
#define SACADO_ENABLE_VALUE_CTOR_DECL
static T * get_and_fill(int sz, MemPool *pool)
Get memory for new array of length sz and fill with zeros.
void * alloc()
Allocate a new element.
static T * get(int sz, MemPool *pool)
Get memory for new array of length sz.
static MemPool * defaultPool_
Default memory pool.
int sz_
Derivative array size.
static T * get_and_fill(int sz, MemPool *pool)
Get memory for new array of length sz and fill with zeros.
Dynamic array allocation class that works for any type.
static T * get_and_fill(const T *src, int sz, MemPool *pool)
Get memory for new array of length sz and fill with entries from src.
Derivative array storage class using dynamic memory allocation.
Sacado::Fad::MemPool * defaultPool_
static void zero(T *dest, int sz)
Zero out array dest of length sz.
MemPool * myPool_
Memory pool.
static T * get(int sz, MemPool *pool)
Get memory for new array of length sz.
MemPoolStorage(const MemPoolStorage &x)
Copy constructor.
T dx(int i) const
Returns derivative component i with bounds checking.
int size() const
Returns number of derivative components.
void free(void *b)
Free an element.
void resize(int sz)
Resize the derivative array to sz.
void expand(int sz)
Expand derivative array to size sz.
void zero()
Zero out derivative array.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors.
static void destroy_and_release(T *m, int sz, MemPool *pool)
Destroy array elements and release memory.
const T & val() const
Returns value.
int len_
Derivative array length.
Initialize the derivative array.