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

Indexing into a multidimensional structured array. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/quest/ArrayIndexer.hpp>

Public Member Functions

 ArrayIndexer (const axom::StackArray< T, DIM > &shape, axom::ArrayStrideOrder arrayStrideOrder, int fastestStrideLength=1)
 Constructor for row- or column-major indexing. More...
 
 ArrayIndexer (const axom::StackArray< T, DIM > &shape, const axom::StackArray< std::uint16_t, DIM > &slowestDirs)
 Constructor for a given order permutation. More...
 
 ArrayIndexer (const axom::StackArray< T, DIM > &shape, const axom::ArrayIndexer< T, DIM > &orderSource)
 Constructor for a given shape with the ordering of an existing ArrayIndexer. More...
 
 ArrayIndexer (const axom::StackArray< T, DIM > &strides)
 Constructor for arbitrary-stride indexing. More...
 
 ArrayIndexer ()=default
 Default constructor. More...
 
AXOM_HOST_DEVICE void initializeShape (const axom::StackArray< T, DIM > &shape, ArrayStrideOrder arrayStrideOrder, int fastestStrideLength=1)
 Initialize for row- or column-major indexing. More...
 
AXOM_HOST_DEVICE void initializeShape (const axom::StackArray< T, DIM > &shape, const axom::StackArray< std::uint16_t, DIM > &slowestDirs)
 Initialize for a given order permutation. More...
 
AXOM_HOST_DEVICE void initializeShape (const axom::StackArray< T, DIM > &shape, const axom::ArrayIndexer< T, DIM > &orderSource)
 Initialize for a given shape with the ordering of an existing ArrayIndexer. More...
 
AXOM_HOST_DEVICE void initializeStrides (const axom::StackArray< T, DIM > &strides)
 Initialize for arbitrary-stride indexing. More...
 
AXOM_HOST_DEVICE void initializeStrides (const axom::StackArray< T, DIM > &strides, ArrayStrideOrder orderPref)
 Initialize for arbitrary-stride indexing, with ordering preference for non-unique strides. More...
 
AXOM_HOST_DEVICE bool operator== (const ArrayIndexer &other) const
 
AXOM_HOST_DEVICE const axom::StackArray< std::uint16_t, DIM > & slowestDirs () const
 Index directions, ordered from slowest to fastest. More...
 
AXOM_HOST_DEVICE const axom::StackArray< axom::IndexType, DIM > & strides () const
 Strides. More...
 
AXOM_HOST_DEVICE bool isPermutation (const axom::StackArray< std::uint16_t, DIM > &v)
 Whether a StackArray represents a permutation. More...
 
AXOM_HOST_DEVICE ArrayStrideOrder getStrideOrder () const
 Get the stride order (row- or column-major, or something else). More...
 
AXOM_HOST_DEVICEtoFlatIndex (const axom::StackArray< T, DIM > &multiIndex) const
 Convert multidimensional index to flat index. More...
 
AXOM_HOST_DEVICE axom::StackArray< T, DIM > toMultiIndex (T flatIndex) const
 Convert flat index to multidimensional index. More...
 

Static Public Member Functions

static AXOM_HOST_DEVICE bool stridesAreUnique (const axom::StackArray< T, DIM > &strides)
 

Friends

std::ostream & operator<< (std::ostream &os, const ArrayIndexer &a)
 

Detailed Description

template<typename T, int DIM>
class axom::ArrayIndexer< T, DIM >

Indexing into a multidimensional structured array.

Supports row-major and column-major ordering and arbitrary permutations of the ordering.

Constructor & Destructor Documentation

◆ ArrayIndexer() [1/5]

template<typename T , int DIM>
axom::ArrayIndexer< T, DIM >::ArrayIndexer ( const axom::StackArray< T, DIM > &  shape,
axom::ArrayStrideOrder  arrayStrideOrder,
int  fastestStrideLength = 1 
)
inline

Constructor for row- or column-major indexing.

Parameters
[in]shapeShape of the array
[in]arrayStrideOrderA order indicator from ArrayStrideOrder.
[in]fastestStrideLengthStride in the fastest direction.

References axom::ArrayIndexer< T, DIM >::initializeShape().

◆ ArrayIndexer() [2/5]

template<typename T , int DIM>
axom::ArrayIndexer< T, DIM >::ArrayIndexer ( const axom::StackArray< T, DIM > &  shape,
const axom::StackArray< std::uint16_t, DIM > &  slowestDirs 
)
inline

Constructor for a given order permutation.

Parameters
[in]shapeShape of the array
[in]slowestDirspermutation vector, where slowestDirs[0] is the slowest direction and slowestDirs[DIM-1] is the fastest.

References axom::ArrayIndexer< T, DIM >::initializeShape(), and axom::ArrayIndexer< T, DIM >::slowestDirs().

◆ ArrayIndexer() [3/5]

template<typename T , int DIM>
axom::ArrayIndexer< T, DIM >::ArrayIndexer ( const axom::StackArray< T, DIM > &  shape,
const axom::ArrayIndexer< T, DIM > &  orderSource 
)
inline

Constructor for a given shape with the ordering of an existing ArrayIndexer.

Parameters
[in]shapeShape of the array
[in]orderSourceArrayIndex to copy stride order from.

References axom::ArrayIndexer< T, DIM >::initializeShape().

◆ ArrayIndexer() [4/5]

template<typename T , int DIM>
axom::ArrayIndexer< T, DIM >::ArrayIndexer ( const axom::StackArray< T, DIM > &  strides)
inline

Constructor for arbitrary-stride indexing.

Parameters
[i]strides Strides. Must be unique when DIM > 1. If not unique, use default constructor and initializeStrides().

References axom::ArrayIndexer< T, DIM >::initializeStrides(), and axom::ArrayIndexer< T, DIM >::strides().

◆ ArrayIndexer() [5/5]

template<typename T , int DIM>
axom::ArrayIndexer< T, DIM >::ArrayIndexer ( )
default

Default constructor.

Object must be initialized before use.

Member Function Documentation

◆ initializeShape() [1/3]

template<typename T , int DIM>
AXOM_HOST_DEVICE void axom::ArrayIndexer< T, DIM >::initializeShape ( const axom::StackArray< T, DIM > &  shape,
ArrayStrideOrder  arrayStrideOrder,
int  fastestStrideLength = 1 
)
inline

Initialize for row- or column-major indexing.

Parameters
[in]shapeShape of the array
[in]arrayStrideOrderAn order indicator from ArrayStrideOrder.
[in]fastestStrideLengthStride in the fastest direction.

References axom::BOTH, axom::COLUMN, axom::ROW, and SLIC_ASSERT.

◆ initializeShape() [2/3]

template<typename T , int DIM>
AXOM_HOST_DEVICE void axom::ArrayIndexer< T, DIM >::initializeShape ( const axom::StackArray< T, DIM > &  shape,
const axom::StackArray< std::uint16_t, DIM > &  slowestDirs 
)
inline

Initialize for a given order permutation.

Parameters
[in]shapeShape of the array
[in]slowestDirspermutation vector, where slowestDirs[0] is the slowest direction and slowestDirs[DIM-1] is the fastest.

References axom::ArrayIndexer< T, DIM >::isPermutation(), SLIC_ASSERT, and axom::ArrayIndexer< T, DIM >::slowestDirs().

◆ initializeShape() [3/3]

template<typename T , int DIM>
AXOM_HOST_DEVICE void axom::ArrayIndexer< T, DIM >::initializeShape ( const axom::StackArray< T, DIM > &  shape,
const axom::ArrayIndexer< T, DIM > &  orderSource 
)
inline

Initialize for a given shape with the ordering of an existing ArrayIndexer.

Parameters
[in]shapeShape of the array
[in]orderSourceArrayIndex to copy stride order from.

References axom::ArrayIndexer< T, DIM >::initializeShape(), and axom::ArrayIndexer< T, DIM >::slowestDirs().

◆ initializeStrides() [1/2]

template<typename T , int DIM>
AXOM_HOST_DEVICE void axom::ArrayIndexer< T, DIM >::initializeStrides ( const axom::StackArray< T, DIM > &  strides)
inline

Initialize for arbitrary-stride indexing.

Parameters
[i]strides Strides. Must be unique when DIM > 1. If not satisfied, you must use one of the other initializers.

References axom::COLUMN, axom::utilities::processAbort(), axom::ArrayIndexer< T, DIM >::strides(), and axom::ArrayIndexer< T, DIM >::stridesAreUnique().

◆ initializeStrides() [2/2]

template<typename T , int DIM>
AXOM_HOST_DEVICE void axom::ArrayIndexer< T, DIM >::initializeStrides ( const axom::StackArray< T, DIM > &  strides,
ArrayStrideOrder  orderPref 
)
inline

Initialize for arbitrary-stride indexing, with ordering preference for non-unique strides.

Parameters
[i]strides Strides.
[i]orderPref Ordering preference value (from ArrayStrideOrder) if strides are non-unique.

References axom::COLUMN, axom::ROW, SLIC_ASSERT, and axom::ArrayIndexer< T, DIM >::strides().

◆ stridesAreUnique()

template<typename T , int DIM>
static AXOM_HOST_DEVICE bool axom::ArrayIndexer< T, DIM >::stridesAreUnique ( const axom::StackArray< T, DIM > &  strides)
inlinestatic

◆ operator==()

template<typename T , int DIM>
AXOM_HOST_DEVICE bool axom::ArrayIndexer< T, DIM >::operator== ( const ArrayIndexer< T, DIM > &  other) const
inline

◆ slowestDirs()

template<typename T , int DIM>
AXOM_HOST_DEVICE const axom::StackArray<std::uint16_t, DIM>& axom::ArrayIndexer< T, DIM >::slowestDirs ( ) const
inline

Index directions, ordered from slowest to fastest.

◆ strides()

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

Strides.

◆ isPermutation()

template<typename T , int DIM>
AXOM_HOST_DEVICE bool axom::ArrayIndexer< T, DIM >::isPermutation ( const axom::StackArray< std::uint16_t, DIM > &  v)
inline

Whether a StackArray represents a permutation.

◆ getStrideOrder()

template<typename T , int DIM>
AXOM_HOST_DEVICE ArrayStrideOrder axom::ArrayIndexer< T, DIM >::getStrideOrder ( ) const
inline

Get the stride order (row- or column-major, or something else).

Returns
Value from ArrayStrideOrder, indicating column order, row order, both column and row (1D only) or arbitrary order.

References axom::ARBITRARY, axom::BOTH, axom::COLUMN, and axom::ROW.

◆ toFlatIndex()

template<typename T , int DIM>
AXOM_HOST_DEVICE T axom::ArrayIndexer< T, DIM >::toFlatIndex ( const axom::StackArray< T, DIM > &  multiIndex) const
inline

Convert multidimensional index to flat index.

References axom::StackArray< T, N >::begin(), and axom::numerics::dot_product().

◆ toMultiIndex()

template<typename T , int DIM>
AXOM_HOST_DEVICE axom::StackArray<T, DIM> axom::ArrayIndexer< T, DIM >::toMultiIndex ( flatIndex) const
inline

Convert flat index to multidimensional index.

Friends And Related Function Documentation

◆ operator<<

template<typename T , int DIM>
std::ostream& operator<< ( std::ostream &  os,
const ArrayIndexer< T, DIM > &  a 
)
friend

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