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

Provides a view over a generic array container. More...

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

Inheritance diagram for axom::ArrayView< T, DIM, SPACE >:

Public Types

using value_type = T
 
using ArrayViewIterator = ArrayIteratorBase< ArrayView< T, DIM, SPACE > >
 

Public Member Functions

 ArrayView ()
 Default constructor. More...
 
AXOM_HOST_DEVICE IndexType size () const
 Return the number of elements stored in the data array. More...
 
ArrayViewIterator begin ()
 Returns an ArrayViewIterator to the first element of the Array. More...
 
ArrayViewIterator end ()
 Returns an ArrayViewIterator to the element following the last element of the Array. More...
 
int getAllocatorID () const
 Get the ID for the umpire allocator. More...
 
AXOM_HOST_DEVICE T & operator() (Args... args)
 Dimension-aware accessor, returns a reference to the given value. More...
 
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...
 
void insert (IndexType pos, const ArrayBase< T, DIM, OtherArrayType > &other)
 Appends an Array to the end of the calling object. More...
 
ArrayView to wrap a pointer and provide indexing semantics
template<typename... Args>
 ArrayView (T *data, Args... args)
 Generic constructor for an ArrayView of arbitrary dimension with external data. More...
 
template<typename OtherArrayType >
 ArrayView (ArrayBase< T, DIM, OtherArrayType > &other)
 Constructor for transferring between memory spaces. More...
 
AXOM_HOST_DEVICE T * data ()
 Return a pointer to the array of data. More...
 
AXOM_HOST_DEVICE const T * data () const
 
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
 

Static Public Attributes

static constexpr int dimension = DIM
 
static constexpr MemorySpace space = SPACE
 

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

Detailed Description

template<typename T, int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
class axom::ArrayView< T, DIM, SPACE >

Provides a view over a generic array container.

The ArrayView expresses a non-owning relationship over a pointer

Template Parameters
Tthe type of the values to hold.
DIMThe dimension of the array.

Member Typedef Documentation

◆ value_type

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
using axom::ArrayView< T, DIM, SPACE >::value_type = T

◆ ArrayViewIterator

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
using axom::ArrayView< T, DIM, SPACE >::ArrayViewIterator = ArrayIteratorBase<ArrayView<T, DIM, SPACE> >

Constructor & Destructor Documentation

◆ ArrayView() [1/3]

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
axom::ArrayView< T, DIM, SPACE >::ArrayView ( )
inline

Default constructor.

References axom::ArrayView< T, DIM, SPACE >::data().

◆ ArrayView() [2/3]

template<typename T , int DIM, MemorySpace SPACE>
template<typename... Args>
axom::ArrayView< T, DIM, SPACE >::ArrayView ( T *  data,
Args...  args 
)

Generic constructor for an ArrayView of arbitrary dimension with external data.

Parameters
[in]datathe external data this ArrayView will wrap.
[in]argsThe parameter pack containing the "shape" of the ArrayView
Precondition
sizeof...(Args) == DIM
Postcondition
size() == num_elements

References axom::Dynamic, and axom::detail::packProduct().

◆ ArrayView() [3/3]

template<typename T , int DIM, MemorySpace SPACE>
template<typename OtherArrayType>
axom::ArrayView< T, DIM, SPACE >::ArrayView ( ArrayBase< T, DIM, OtherArrayType > &  other)

Constructor for transferring between memory spaces.

Parameters
[in]otherThe array in a different memory space to copy from
Note
The parameter is non-const because other can be modified through the constructed View
This constructor is left implicit to allow for convenient function calls that convert from Array -> ArrayView or from dynamic memory spaces to an ArrayView of explicitly specified space.

References axom::Dynamic, and axom::utilities::processAbort().

Member Function Documentation

◆ size()

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
AXOM_HOST_DEVICE IndexType axom::ArrayView< T, DIM, SPACE >::size ( ) const
inline

Return the number of elements stored in the data array.

Referenced by axom::ArrayView< T, DIM, SPACE >::end().

◆ begin()

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
ArrayViewIterator axom::ArrayView< T, DIM, SPACE >::begin ( )
inline

Returns an ArrayViewIterator to the first element of the Array.

◆ end()

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
ArrayViewIterator axom::ArrayView< T, DIM, SPACE >::end ( )
inline

Returns an ArrayViewIterator to the element following the last element of the Array.

References axom::ArrayView< T, DIM, SPACE >::size().

◆ data() [1/2]

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
AXOM_HOST_DEVICE T* axom::ArrayView< T, DIM, SPACE >::data ( )
inline

Return a pointer to the array of data.

Referenced by axom::ArrayView< T, DIM, SPACE >::ArrayView().

◆ data() [2/2]

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
AXOM_HOST_DEVICE const T* axom::ArrayView< T, DIM, SPACE >::data ( ) const
inline

◆ getAllocatorID()

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
int axom::ArrayView< T, DIM, SPACE >::getAllocatorID ( ) const
inline

Get the ID for the umpire allocator.

◆ operator()() [1/2]

AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::operator() ( Args...  args)
inlineinherited

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]

AXOM_HOST_DEVICE const T& axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::operator() ( Args...  args) const
inlineinherited

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]

AXOM_HOST_DEVICE T& axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::operator[] ( const IndexType  idx)
inlineinherited

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]

AXOM_HOST_DEVICE const T& axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::operator[] ( const IndexType  idx) const
inlineinherited

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

◆ shape()

AXOM_HOST_DEVICE const StackArray<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::shape ( ) const
inlineinherited

Returns the dimensions of the Array.

◆ strides()

AXOM_HOST_DEVICE const StackArray<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::strides ( ) const
inlineinherited

Returns the strides of the Array.

◆ insert()

void axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::insert ( IndexType  pos,
const ArrayBase< T, DIM, OtherArrayType > &  other 
)
inlineinherited

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()

IndexType axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::blockSize ( ) const
inlineprotectedinherited

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()

void axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::updateStrides ( )
inlineprotectedinherited

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.

Member Data Documentation

◆ dimension

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
constexpr int axom::ArrayView< T, DIM, SPACE >::dimension = DIM
static

◆ space

template<typename T , int DIM = 1, MemorySpace SPACE = MemorySpace::Dynamic>
constexpr MemorySpace axom::ArrayView< T, DIM, SPACE >::space = SPACE
static

◆ m_dims

StackArray<IndexType, DIM> axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::m_dims
protectedinherited

The sizes (extents?) in each dimension.

◆ m_strides

StackArray<IndexType, DIM> axom::ArrayBase< T, DIM, ArrayView< T, DIM, SPACE > >::m_strides
protectedinherited

The strides in each dimension.


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