This class serves to provide a sliced multidimensional interface to the family of LvArray classes.
More...
#include <ArraySlice.hpp>
|
|
|
| ArraySlice ()=delete |
| | deleted default constructor
|
| |
| LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK | ArraySlice (T *const LVARRAY_RESTRICT inputData, INDEX_TYPE const *const LVARRAY_RESTRICT inputDimensions, INDEX_TYPE const *const LVARRAY_RESTRICT inputStrides) noexcept |
| | Construct a new ArraySlice. More...
|
| |
|
| LVARRAY_HOST_DEVICE constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > | toSliceConst () const noexcept |
| |
| template<typename U = T> |
| LVARRAY_HOST_DEVICE constexpr | operator std::enable_if_t< !std::is_const< U >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > > () const noexcept |
| |
|
| LVARRAY_HOST_DEVICE constexpr INDEX_TYPE | size () const noexcept |
| |
| LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE | size (int const dim) const noexcept |
| |
| LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE | stride (int const dim) const noexcept |
| |
| LVARRAY_HOST_DEVICE constexpr bool | isContiguous () const |
| | Check if the slice is contiguous in memory. More...
|
| |
| template<typename ... INDICES> |
| LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK INDEX_TYPE | linearIndex (INDICES... indices) const |
| |
|
| template<int NDIM_ = NDIM, int USD_ = USD> |
| LVARRAY_HOST_DEVICE constexpr | operator std::enable_if_t< NDIM_==1 &&USD_==0, T *const LVARRAY_RESTRICT > () const noexcept |
| |
| template<int U = NDIM> |
| LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t<(U > 1), ArraySlice< T, NDIM - 1, USD - 1, INDEX_TYPE > > | operator[] (INDEX_TYPE const index) const noexcept |
| |
| template<int U = NDIM> |
| LVARRAY_HOST_DEVICE CONSTEXPR_WITHOUT_BOUNDS_CHECK std::enable_if_t< U==1, T &> | operator[] (INDEX_TYPE const index) const noexcept |
| |
| template<typename ... INDICES> |
| LVARRAY_HOST_DEVICE constexpr T & | operator() (INDICES... indices) const |
| |
| template<int USD_ = USD> |
| LVARRAY_HOST_DEVICE T * | dataIfContiguous () const |
| |
| LVARRAY_HOST_DEVICE constexpr T * | begin () const |
| |
| LVARRAY_HOST_DEVICE constexpr T * | end () const |
| |
|
|
static constexpr int | NDIM = NDIM_TPARAM |
| | The number of dimensions.
|
| |
|
static constexpr int | USD = USD_TPARAM |
| | The unit stride dimension.
|
| |
|
|
T *const LVARRAY_RESTRICT | m_data |
| | pointer to beginning of data for this array, or sub-array.
|
| |
|
INDEX_TYPE const *const LVARRAY_RESTRICT | m_dims |
| | pointer to array of length NDIM that contains the lengths of each array dimension
|
| |
|
INDEX_TYPE const *const LVARRAY_RESTRICT | m_strides |
| | pointer to array of length NDIM that contains the strides of each array dimension
|
| |
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
class LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >
This class serves to provide a sliced multidimensional interface to the family of LvArray classes.
- Template Parameters
-
| T | type of data that is contained by the array |
| NDIM_TPARAM | The number of dimensions in array (e.g. NDIM=1->vector, NDIM=2->Matrix, etc. ). |
| USD | The dimension with a unit stride, in an Array with a standard layout this is the last dimension. |
| INDEX_TYPE | The integer to use for indexing the components of the array. This class serves as a sliced interface to an array. This is a lightweight class that contains only pointers, and provides an operator[] to create a lower dimensionsal slice and an operator() to access values given a multidimensional index. In general, instantiations of ArraySlice should only result either taking a slice of an an Array or an ArrayView via operator[] or from a direct creation via the toSlice/toSliceConst method. |
◆ ArraySlice()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
Construct a new ArraySlice.
- Parameters
-
| inputData | pointer to the beginning of the data for this slice of the array |
| inputDimensions | pointer to the beginning of the dimensions for this slice. |
| inputStrides | pointer to the beginning of the strides for this slice |
◆ begin()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
- Returns
- Return a pointer to the values.
- Precondition
- The slice must be contiguous.
◆ dataIfContiguous()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int USD_ = USD>
- Returns
- Return a pointer to the values.
- Template Parameters
-
| USD_ | Dummy template parameter, do not specify. |
- Precondition
- The slice must be contiguous.
◆ end()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
- Returns
- Return a pointer to the end values.
- Precondition
- The slice must be contiguous.
◆ isContiguous()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
Check if the slice is contiguous in memory.
- Returns
true if represented slice is contiguous in memory
◆ linearIndex()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<typename ... INDICES>
- Template Parameters
-
| INDICES | A variadic pack of integral types. |
- Returns
- Return the linear index from a multidimensional index.
- Parameters
-
| indices | The indices of the value to get the linear index of. |
◆ operator std::enable_if_t< !std::is_const< U >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > >()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<typename U = T>
- Returns
- Return a new immutable slice.
◆ operator std::enable_if_t< NDIM_==1 &&USD_==0, T *const LVARRAY_RESTRICT >()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int NDIM_ = NDIM, int USD_ = USD>
- Returns
- A raw pointer.
- Note
- This method is only active when NDIM == 1 and USD == 0.
◆ operator()()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<typename ... INDICES>
- Template Parameters
-
| INDICES | A variadic pack of integral types. |
- Returns
- Return a reference to the value at the given multidimensional index.
- Parameters
-
| indices | The indices of the value to access. |
◆ operator[]() [1/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int U = NDIM>
- Returns
- Return a lower dimensionsal slice of this ArrayView.
- Parameters
-
| index | The index of the slice to create. |
- Note
- This method is only active when NDIM > 1.
◆ operator[]() [2/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int U = NDIM>
- Returns
- Return a reference to the value at the given index.
- Parameters
-
| index | The index of the value to access. |
- Note
- This method is only active when NDIM == 1.
◆ size() [1/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
- Returns
- Return the total size of the slice.
◆ size() [2/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
- Returns
- Return the length of the given dimension.
- Parameters
-
| dim | the dimension to get the length of. |
◆ stride()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
- Returns
- Return the stride of the given dimension.
- Parameters
-
| dim | the dimension to get the stride of. |
◆ toSliceConst()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
- Returns
- Return a new immutable slice.
The documentation for this class was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/lvarray/checkouts/latest/src/ArraySlice.hpp