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.7.0/src/axom/core/ArrayBase.hpp>

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

Public Types

using RealConstT = typename std::conditional< is_array_view, T, const T >::type
 
template<int IdxDim>
using SliceType = typename std::conditional< DIM==IdxDim, T &, typename detail::SubsliceProxy< T, DIM - IdxDim, ArrayType >::type >::type
 
template<int IdxDim>
using ConstSliceType = typename std::conditional< DIM==IdxDim, RealConstT &, typename detail::SubsliceProxy< T, DIM - IdxDim, const ArrayType >::type >::type
 

Public Member Functions

AXOM_HOST_DEVICE ArrayBase ()
 
AXOM_HOST_DEVICE ArrayBase (const StackArray< IndexType, DIM > &args)
 Parameterized constructor that sets up the default strides. More...
 
template<typename OtherArrayType >
 ArrayBase (const ArrayBase< typename std::remove_const< T >::type, 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 OtherArrayType >
 ArrayBase (const ArrayBase< const typename std::remove_const< T >::type, DIM, OtherArrayType > &other)
 
template<typename... Args>
AXOM_HOST_DEVICE SliceType< sizeof...(Args)> operator() (Args... args)
 Dimension-aware accessor; with N=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index. More...
 
template<typename... Args>
AXOM_HOST_DEVICE ConstSliceType< sizeof...(Args)> operator() (Args... args) const
 
AXOM_HOST_DEVICE SliceType< 1 > operator[] (const IndexType idx)
 Scalar accessor; returns a sub-array referenced by the given sub- index, beginning at array(idx, 0...) More...
 
AXOM_HOST_DEVICE ConstSliceType< 1 > operator[] (const IndexType idx) const
 
template<int UDim>
AXOM_HOST_DEVICE SliceType< UDim > operator[] (const StackArray< IndexType, UDim > &idx)
 Dimension-aware accessor; with UDim=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index. More...
 
template<int UDim>
AXOM_HOST_DEVICE ConstSliceType< UDim > operator[] (const StackArray< IndexType, UDim > &idx) const
 
void swap (ArrayBase &other)
 Swaps two ArrayBases. More...
 
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...
 
AXOM_HOST_DEVICE T & flatIndex (const IndexType idx)
 Accessor, returns a reference to the given value. For multidimensional arrays, indexes into the (flat) raw data. More...
 
AXOM_HOST_DEVICE RealConstTflatIndex (const IndexType idx) const
 

Static Public Attributes

static constexpr int Dims = DIM
 

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...
 
AXOM_HOST_DEVICE 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...
 
void updateShapeOnInsert (const StackArray< IndexType, DIM > &range_shape)
 Updates the internal dimensions and striding based on the insertion of a range of elements. Intended to be called after the insertion of a multidimensional subslice. 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...
 

Member Typedef Documentation

◆ RealConstT

template<typename T, int DIM, typename ArrayType>
using axom::ArrayBase< T, DIM, ArrayType >::RealConstT = typename std::conditional<is_array_view, T, const T>::type

◆ SliceType

template<typename T, int DIM, typename ArrayType>
template<int IdxDim>
using axom::ArrayBase< T, DIM, ArrayType >::SliceType = typename std::conditional< DIM == IdxDim, T&, typename detail::SubsliceProxy<T, DIM - IdxDim, ArrayType>::type>::type

◆ ConstSliceType

template<typename T, int DIM, typename ArrayType>
template<int IdxDim>
using axom::ArrayBase< T, DIM, ArrayType >::ConstSliceType = typename std::conditional< DIM == IdxDim, RealConstT&, typename detail::SubsliceProxy<T, DIM - IdxDim, const ArrayType>::type>::type

Constructor & Destructor Documentation

◆ ArrayBase() [1/4]

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE axom::ArrayBase< T, DIM, ArrayType >::ArrayBase ( )
inline

◆ ArrayBase() [2/4]

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

Parameterized constructor that sets up the default strides.

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

◆ ArrayBase() [3/4]

template<typename T, int DIM, typename ArrayType>
template<typename OtherArrayType >
axom::ArrayBase< T, DIM, ArrayType >::ArrayBase ( const ArrayBase< typename std::remove_const< T >::type, 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.

◆ ArrayBase() [4/4]

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

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

Member Function Documentation

◆ operator()() [1/2]

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

Dimension-aware accessor; with N=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index.

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, sizeof...(Args))

◆ operator()() [2/2]

template<typename T, int DIM, typename ArrayType>
template<typename... Args>
AXOM_HOST_DEVICE ConstSliceType<sizeof...(Args)> 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/4]

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

Scalar accessor; returns a sub-array referenced by the given sub- index, beginning at array(idx, 0...)

Parameters
[in]idxthe index of the first dimension.
Precondition
0 <= idx < m_dims[0]

◆ operator[]() [2/4]

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE ConstSliceType<1> 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.

◆ operator[]() [3/4]

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

Dimension-aware accessor; with UDim=DIM indices, returns a reference to the given value at that index. Otherwise, returns a sub-array pointed to by the given sub-index.

Parameters
[in]argsa stack array of indices in each dimension.
Note
equivalent to *(array.data() + idx).
Precondition
UDim <= DIM
0 <= args[i] < m_dims[i] for i in [0, UDim)

◆ operator[]() [4/4]

template<typename T, int DIM, typename ArrayType>
template<int UDim>
AXOM_HOST_DEVICE ConstSliceType<UDim> axom::ArrayBase< T, DIM, ArrayType >::operator[] ( const StackArray< IndexType, UDim > &  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.

◆ flatIndex() [1/2]

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, ArrayType >::flatIndex ( 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

◆ flatIndex() [2/2]

template<typename T, int DIM, typename ArrayType>
AXOM_HOST_DEVICE RealConstT& axom::ArrayBase< T, DIM, ArrayType >::flatIndex ( 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.

◆ swap()

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

Swaps two ArrayBases.

◆ shape()

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

Returns the dimensions of the Array.

◆ 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.

◆ 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>
AXOM_HOST_DEVICE 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.

◆ updateShapeOnInsert()

template<typename T, int DIM, typename ArrayType>
void axom::ArrayBase< T, DIM, ArrayType >::updateShapeOnInsert ( const StackArray< IndexType, DIM > &  range_shape)
inlineprotected

Updates the internal dimensions and striding based on the insertion of a range of elements. Intended to be called after the insertion of a multidimensional subslice.

Member Data Documentation

◆ Dims

template<typename T, int DIM, typename ArrayType>
constexpr int axom::ArrayBase< T, DIM, ArrayType >::Dims = DIM
static

◆ m_dims

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

The sizes (extents?) in each dimension.

◆ m_strides

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

The strides in each dimension.


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