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

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

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

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

Public Types

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

Public Member Functions

 ArrayView ()=default
 Default constructor. More...
 
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...
 
T & operator() (Args... args)
 Dimension-aware accessor, returns a reference to the given value. More...
 
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...
 
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...
 
T * data ()
 Return a pointer to the array of data. More...
 
const T * data () const
 
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
 

Static Public Attributes

static constexpr int dimension = 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...
 
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...
 

Detailed Description

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

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>
using axom::ArrayView< T, DIM >::value_type = T

◆ ArrayViewIterator

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

Constructor & Destructor Documentation

◆ ArrayView() [1/2]

template<typename T , int DIM = 1>
axom::ArrayView< T, DIM >::ArrayView ( )
default

Default constructor.

◆ ArrayView() [2/2]

template<typename T , int DIM>
template<typename... Args>
axom::ArrayView< T, DIM >::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::detail::packProduct().

Member Function Documentation

◆ size()

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

Return the number of elements stored in the data array.

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

◆ begin()

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

Returns an ArrayViewIterator to the first element of the Array.

◆ end()

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

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

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

◆ data() [1/2]

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

Return a pointer to the array of data.

◆ data() [2/2]

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

◆ getAllocatorID()

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

Get the ID for the umpire allocator.

FIXME: This is just a stand-in impl, extend this class to support wrapping of GPU pointers

References axom::getDefaultAllocatorID().

◆ operator()() [1/2]

T& axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::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]

const T& axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::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]

T& axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::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]

const T& axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::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()

const std::array<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::shape ( ) const
inlineinherited

Returns the dimensions of the Array.

◆ strides()

const std::array<IndexType, DIM>& axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::strides ( ) const
inlineinherited

Returns the strides of the Array.

◆ insert()

void axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::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 > >::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 > >::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>
constexpr int axom::ArrayView< T, DIM >::dimension = DIM
static

◆ m_dims

std::array<IndexType, DIM> axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::m_dims
protectedinherited

The sizes (extents?) in each dimension.

◆ m_strides

std::array<IndexType, DIM> axom::ArrayBase< T, DIM, ArrayView< T, DIM > >::m_strides
protectedinherited

The strides in each dimension.


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