AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::ArrayBase< T, DIM, ArrayType > Class Template Reference

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.6.1/src/axom/core/ArrayBase.hpp>

Inheritance diagram for axom::ArrayBase< T, DIM, ArrayType >:

Public Member Functions

template<typename... Args>
 ArrayBase (Args... args)
 Parameterized constructor that sets up the default strides. More...
 
template<typename OtherArrayType >
 ArrayBase (const ArrayBase< T, DIM, OtherArrayType > &other)
 Copy constructor for arrays of different type Because the element type (T) and dimension (DIM) are still locked down, this function is nominally used for copying ArrayBase metadata from Array <-> ArrayView and/or Array-like objects whose data are in different memory spaces. More...
 
template<typename... Args, typename SFINAE = typename std::enable_if<sizeof...(Args) == DIM>::type>
AXOM_HOST_DEVICE T & operator() (Args... args)
 Dimension-aware accessor, returns a reference to the given value. More...
 
template<typename... Args, typename SFINAE = typename std::enable_if<sizeof...(Args) == DIM>::type>
AXOM_HOST_DEVICE const T & operator() (Args... args) const
 
AXOM_HOST_DEVICE const StackArray< IndexType, DIM > & shape () const
 Returns the dimensions of the Array. More...
 
AXOM_HOST_DEVICE const StackArray< IndexType, DIM > & strides () const
 Returns the strides of the Array. More...
 
template<typename OtherArrayType >
void insert (IndexType pos, const ArrayBase< T, DIM, OtherArrayType > &other)
 Appends an Array to the end of the calling object. More...
 
AXOM_HOST_DEVICE T & operator[] (const IndexType idx)
 Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data. More...
 
AXOM_HOST_DEVICE const T & operator[] (const IndexType idx) const
 

Protected Member Functions

IndexType blockSize () const
 Returns the minimum "chunk size" that should be allocated For example, 2 would be the chunk size of a 2D array whose second dimension is of size 2. This is used when resizing/reallocating; it wouldn't make sense to have a capacity of 3 in the array described above. More...
 
void updateStrides ()
 Updates the internal striding information to a row-major format Intended to be called after m_dims is updated. In the future, this class will support different striding schemes (e.g., column-major) and/or user-provided striding. More...
 

Protected Attributes

StackArray< IndexType, DIM > m_dims
 The sizes (extents?) in each dimension. More...
 
StackArray< IndexType, DIM > m_strides
 The strides in each dimension. More...
 

Friends

void swap (ArrayBase &lhs, ArrayBase &rhs)
 Swaps two ArrayBases. More...
 

Constructor & Destructor Documentation

◆ ArrayBase() [1/2]

template<typename T, int DIM, typename ArrayType>
template<typename... Args>
axom::ArrayBase< T, DIM, ArrayType >::ArrayBase ( Args...  args)
inline

Parameterized constructor that sets up the default strides.

Parameters
[in]argsthe parameter pack of sizes in each dimension.

◆ ArrayBase() [2/2]

template<typename T, int DIM, typename ArrayType>
template<typename OtherArrayType >
axom::ArrayBase< T, DIM, ArrayType >::ArrayBase ( const ArrayBase< T, DIM, OtherArrayType > &  other)
inline

Copy constructor for arrays of different type Because the element type (T) and dimension (DIM) are still locked down, this function is nominally used for copying ArrayBase metadata from Array <-> ArrayView and/or Array-like objects whose data are in different memory spaces.

Member Function Documentation

◆ operator()() [1/2]

template<typename T, int DIM, typename ArrayType>
template<typename... Args, typename SFINAE = typename std::enable_if<sizeof...(Args) == DIM>::type>
AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, ArrayType >::operator() ( Args...  args)
inline

Dimension-aware accessor, returns a reference to the given value.

Parameters
[in]argsthe parameter pack of indices in each dimension.
Note
equivalent to *(array.data() + idx).
Precondition
sizeof...(Args) == DIM
0 <= args[i] < m_dims[i] for i in [0, DIM)

◆ operator()() [2/2]

template<typename T, int DIM, typename ArrayType>
template<typename... Args, typename SFINAE = typename std::enable_if<sizeof...(Args) == DIM>::type>
AXOM_HOST_DEVICE const T& axom::ArrayBase< T, DIM, ArrayType >::operator() ( Args...  args) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ operator[]() [1/2]

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, ArrayType >::operator[] ( const IndexType  idx)
inline

Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data.

Parameters
[in]idxthe position of the value to return.
Note
equivalent to *(array.data() + idx).
Precondition
0 <= idx < m_num_elements

◆ operator[]() [2/2]

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE const T& axom::ArrayBase< T, DIM, ArrayType >::operator[] ( const IndexType  idx) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ shape()

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE const StackArray<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayType >::shape ( ) const
inline

◆ strides()

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE const StackArray<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayType >::strides ( ) const
inline

Returns the strides of the Array.

◆ insert()

template<typename T, int DIM, typename ArrayType>
template<typename OtherArrayType >
void axom::ArrayBase< T, DIM, ArrayType >::insert ( IndexType  pos,
const ArrayBase< T, DIM, OtherArrayType > &  other 
)
inline

Appends an Array to the end of the calling object.

Parameters
[in]otherThe Array to append
Precondition
The shapes of the calling Array and other are the same (excluding the leading dimension), i.e., shape()[1:] == other.shape()[1:]
Note
Reallocation is done if the new size will exceed the capacity.

◆ blockSize()

template<typename T, int DIM, typename ArrayType>
IndexType axom::ArrayBase< T, DIM, ArrayType >::blockSize ( ) const
inlineprotected

Returns the minimum "chunk size" that should be allocated For example, 2 would be the chunk size of a 2D array whose second dimension is of size 2. This is used when resizing/reallocating; it wouldn't make sense to have a capacity of 3 in the array described above.

◆ updateStrides()

template<typename T, int DIM, typename ArrayType>
void axom::ArrayBase< T, DIM, ArrayType >::updateStrides ( )
inlineprotected

Updates the internal striding information to a row-major format Intended to be called after m_dims is updated. In the future, this class will support different striding schemes (e.g., column-major) and/or user-provided striding.

Referenced by axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::ArrayBase(), and axom::ArrayBase< T, DIM, Array< T, DIM, MemorySpace::Dynamic > >::insert().

Friends And Related Function Documentation

◆ swap

template<typename T, int DIM, typename ArrayType>
void swap ( ArrayBase< T, DIM, ArrayType > &  lhs,
ArrayBase< T, DIM, ArrayType > &  rhs 
)
friend

Swaps two ArrayBases.

Member Data Documentation

◆ m_dims

◆ m_strides


The documentation for this class was generated from the following file: