|
AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
For indexing multidimensional arrays. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/core/MDMapping.hpp>
Public Member Functions | |
| AXOM_HOST_DEVICE | MDMapping (const axom::StackArray< T, DIM > &shape, axom::ArrayStrideOrder arrayStrideOrder, int fastestStrideLength=1) |
| Constructor for row- or column-major indexing. More... | |
| template<typename DirType > | |
| AXOM_HOST_DEVICE | MDMapping (const axom::StackArray< T, DIM > &shape, const axom::StackArray< DirType, DIM > &slowestDirs, int fastestStrideLength=1) |
| Constructor for a given order permutation. More... | |
| AXOM_HOST_DEVICE | MDMapping (const axom::StackArray< T, DIM > &shape, const axom::MDMapping< DIM, T > &orderSource) |
| Constructor for a given shape with the ordering of an existing MDMapping. More... | |
| AXOM_HOST_DEVICE | MDMapping (const axom::StackArray< T, DIM > &strides) |
| Constructor for arbitrary-stride indexing. More... | |
| MDMapping ()=default | |
| Default constructor. More... | |
| AXOM_HOST_DEVICE | MDMapping (ArrayStrideOrder arrayStrideOrder) |
| Construct mapping for empty shape and the given stride order. 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... | |
| template<typename DirType > | |
| AXOM_HOST_DEVICE void | initializeShape (const axom::StackArray< T, DIM > &shape, const axom::StackArray< DirType, DIM > &slowestDirs, int fastestStrideLength=1) |
| Initialize for a given order permutation. More... | |
| AXOM_HOST_DEVICE void | initializeShape (const axom::StackArray< T, DIM > &shape, const axom::MDMapping< DIM, T > &orderSource) |
| Initialize for a given shape with the ordering of an existing MDMapping. More... | |
| AXOM_SUPPRESS_HD_WARN AXOM_HOST_DEVICE void | initializeStrides (const axom::StackArray< T, DIM > &strides) |
| Initialize for arbitrary-stride indexing. More... | |
| AXOM_SUPPRESS_HD_WARN 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 MDMapping &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 axom::IndexType | fastestStrideLength () const |
| Stride length in fastest direction. More... | |
| template<typename DirectionType > | |
| AXOM_HOST_DEVICE bool | isPermutation (const axom::StackArray< DirectionType, DIM > &v) const |
| 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 MDMapping &a) |
For indexing multidimensional arrays.
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 | An order indicator, either ROW or COLUMN or if DIM == 1, BOTH. |
| [in] | fastestStrideLength | Stride in the fastest-changing direction. |
References axom::MDMapping< DIM, T >::fastestStrideLength(), and axom::MDMapping< DIM, T >::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. |
| [in] | fastestStrideLength | Stride in the fastest-changing direction. |
References axom::MDMapping< DIM, T >::fastestStrideLength(), axom::MDMapping< DIM, T >::initializeShape(), and axom::MDMapping< DIM, T >::slowestDirs().
|
inline |
Constructor for a given shape with the ordering of an existing MDMapping.
| [in] | shape | Shape of the array |
| [in] | orderSource | ArrayIndex to copy stride order from. |
References axom::MDMapping< DIM, T >::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::MDMapping< DIM, T >::initializeStrides(), and axom::MDMapping< DIM, T >::strides().
|
default |
Default constructor.
Object must be initialized before use.
|
inline |
Construct mapping for empty shape and the given stride order.
The expected use case is when a stride order is known but the shape is to be determined. Initialize the mapping with its own slowestDirs() to preserve stride order as its shape changes.
References axom::MDMapping< DIM, T >::initializeShape().
|
inline |
Initialize for row- or column-major indexing.
| [in] | shape | Shape of the array |
| [in] | arrayStrideOrder | An order indicator other than ArrayStrideOrder::ARBITRARY. |
| [in] | fastestStrideLength | Stride in the fastest-changing direction. |
References axom::BOTH, axom::COLUMN, axom::MDMapping< DIM, T >::fastestStrideLength(), and axom::ROW.
|
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. |
| [in] | fastestStrideLength | Stride in the fastest-changing direction. |
References axom::MDMapping< DIM, T >::fastestStrideLength(), axom::MDMapping< DIM, T >::isPermutation(), and axom::MDMapping< DIM, T >::slowestDirs().
|
inline |
Initialize for a given shape with the ordering of an existing MDMapping.
| [in] | shape | Shape of the array |
| [in] | orderSource | ArrayIndex to copy stride order from. |
References axom::MDMapping< DIM, T >::initializeShape(), and axom::MDMapping< DIM, T >::slowestDirs().
|
inline |
Initialize for arbitrary-stride indexing.
| [i] | strides Strides. Values must be unique. If not unique, use one of the other initializers. |
References axom::utilities::processAbort(), axom::ROW, axom::MDMapping< DIM, T >::strides(), and axom::MDMapping< DIM, T >::stridesAreUnique().
|
inline |
Initialize for arbitrary-stride indexing, with ordering preference for non-unique strides.
| [i] | strides Strides. |
| [i] | orderPref ArrayStrideOrder::ROW or ArrayStrideOrder::COLUMN, to use where strides are non-unique. |
References axom::COLUMN, axom::ROW, axom::MDMapping< DIM, T >::strides(), and axom::utilities::swap().
|
inlinestatic |
References axom::MDMapping< DIM, T >::strides().
|
inline |
|
inline |
Index directions, ordered from slowest to fastest.
|
inline |
Strides.
|
inline |
Stride length in fastest direction.
|
inline |
Whether a StackArray represents a permutation.
References axom::utilities::insertionSort().
|
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 |