AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Indexing into a multidimensional structured array. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/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_DEVICE T | toFlatIndex (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) |
Indexing into a multidimensional structured array.
Supports row-major and column-major ordering and arbitrary permutations of the ordering.
|
inline |
Constructor for row- or column-major indexing.
[in] | shape | Shape of the array |
[in] | arrayStrideOrder | A order indicator from ArrayStrideOrder. |
[in] | fastestStrideLength | Stride in the fastest direction. |
References axom::ArrayIndexer< T, DIM >::initializeShape().
|
inline |
Constructor for a given order permutation.
[in] | shape | Shape of the array |
[in] | slowestDirs | permutation 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().
|
inline |
Constructor for a given shape with the ordering of an existing ArrayIndexer.
[in] | shape | Shape of the array |
[in] | orderSource | ArrayIndex to copy stride order from. |
References axom::ArrayIndexer< T, DIM >::initializeShape().
|
inline |
Constructor for arbitrary-stride indexing.
[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().
|
default |
Default constructor.
Object must be initialized before use.
|
inline |
Initialize for row- or column-major indexing.
[in] | shape | Shape of the array |
[in] | arrayStrideOrder | An order indicator from ArrayStrideOrder. |
[in] | fastestStrideLength | Stride in the fastest direction. |
References axom::BOTH, axom::COLUMN, axom::ROW, and SLIC_ASSERT.
|
inline |
Initialize for a given order permutation.
[in] | shape | Shape of the array |
[in] | slowestDirs | permutation 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().
|
inline |
Initialize for a given shape with the ordering of an existing ArrayIndexer.
[in] | shape | Shape of the array |
[in] | orderSource | ArrayIndex to copy stride order from. |
References axom::ArrayIndexer< T, DIM >::initializeShape(), and axom::ArrayIndexer< T, DIM >::slowestDirs().
|
inline |
Initialize for arbitrary-stride indexing.
[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().
|
inline |
Initialize for arbitrary-stride indexing, with ordering preference for non-unique strides.
[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().
|
inlinestatic |
References axom::ArrayIndexer< T, DIM >::strides().
|
inline |
|
inline |
Index directions, ordered from slowest to fastest.
|
inline |
Strides.
|
inline |
Whether a StackArray represents a permutation.
|
inline |
Get the stride order (row- or column-major, or something else).
References axom::ARBITRARY, axom::BOTH, axom::COLUMN, and axom::ROW.
|
inline |
Convert multidimensional index to flat index.
References axom::StackArray< T, N >::begin(), and axom::numerics::dot_product().
|
inline |
Convert flat index to multidimensional index.
|
friend |