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.0/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... Args, typename SFINAE = typename std::enable_if<sizeof...(Args) == DIM>::type>
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>
const T & operator() (Args... args) const
 
const std::array< IndexType, DIM > & shape () const
 Returns the dimensions of the Array. More...
 
const std::array< 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...
 
T & operator[] (const IndexType idx)
 Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data. More...
 
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

std::array< IndexType, DIM > m_dims
 The sizes (extents?) in each dimension. More...
 
std::array< 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()

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.

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>
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>
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>
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>
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>
const std::array<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayType >::shape ( ) const
inline

Returns the dimensions of the Array.

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

◆ strides()

template<typename T, int DIM, typename ArrayType>
const std::array<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 > >::ArrayBase(), and axom::ArrayBase< T, DIM, Array< T, DIM > >::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

template<typename T, int DIM, typename ArrayType>
std::array<IndexType, DIM> axom::ArrayBase< T, DIM, ArrayType >::m_dims
protected

◆ m_strides

template<typename T, int DIM, typename ArrayType>
std::array<IndexType, DIM> axom::ArrayBase< T, DIM, ArrayType >::m_strides
protected

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