This class serves to provide a sliced multidimensional interface to the family of LvArray classes.
More...
#include <ArraySlice.hpp>
|
|
| ArraySlice ()=delete |
| deleted default constructor
|
|
constexpr | 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...
|
|
|
template<typename U = T> |
constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > | toSliceConst () const noexcept |
|
template<typename U = T> |
constexpr | operator std::enable_if_t< !std::is_const< U >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > > () const noexcept |
|
|
constexpr INDEX_TYPE | size () const noexcept |
|
constexpr INDEX_TYPE | size (int dim) const noexcept |
|
template<int _USD = USD> |
constexpr std::enable_if_t<(_USD >=0), bool > | isContiguous () const |
| Check if the slice is contiguous in memory. More...
|
|
template<int USD_ = USD> |
constexpr std::enable_if_t<(USD_< 0), bool > | isContiguous () const |
| Check if the slice is contiguous in memory. More...
|
|
template<typename ... INDICES> |
constexpr INDEX_TYPE | linearIndex (INDICES... indices) const |
|
|
template<int _NDIM = NDIM, int _USD = USD> |
constexpr | operator std::enable_if_t< _NDIM==1 &&_USD==0, T *const LVARRAY_RESTRICT > () const noexcept |
|
template<int U = NDIM> |
constexpr 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> |
constexpr std::enable_if_t< U==1, T &> | operator[] (INDEX_TYPE const index) const noexcept |
|
template<typename ... INDICES> |
constexpr T & | operator() (INDICES... indices) const |
|
T * | dataIfContiguous () const |
|
constexpr T * | begin () const |
|
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. |
Definition at line 89 of file ArraySlice.hpp.
◆ ArraySlice()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::ArraySlice |
( |
T *const LVARRAY_RESTRICT |
inputData, |
|
|
INDEX_TYPE const *const LVARRAY_RESTRICT |
inputDimensions, |
|
|
INDEX_TYPE const *const LVARRAY_RESTRICT |
inputStrides |
|
) |
| |
|
inlineexplicitnoexcept |
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 |
Definition at line 122 of file ArraySlice.hpp.
◆ 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.
Definition at line 329 of file ArraySlice.hpp.
◆ dataIfContiguous()
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.
Definition at line 318 of file ArraySlice.hpp.
◆ 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.
Definition at line 337 of file ArraySlice.hpp.
◆ isContiguous() [1/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int _USD = USD>
constexpr std::enable_if_t< ( _USD >= 0), bool > LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::isContiguous |
( |
| ) |
const |
|
inline |
Check if the slice is contiguous in memory.
- Template Parameters
-
_USD | dummy template parameter equal to USD; do not replace |
- Returns
true
if represented slice is contiguous in memory
Definition at line 207 of file ArraySlice.hpp.
◆ isContiguous() [2/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int USD_ = USD>
constexpr std::enable_if_t< (USD_ < 0), bool > LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::isContiguous |
( |
| ) |
const |
|
inline |
Check if the slice is contiguous in memory.
- Template Parameters
-
USD_ | dummy template parameter equal to USD; do not replace |
- Returns
false
, this overload is enabled for slices that have already lost its unit stride dimension
Definition at line 234 of file ArraySlice.hpp.
◆ linearIndex()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<typename ... INDICES>
constexpr INDEX_TYPE LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::linearIndex |
( |
INDICES... |
indices | ) |
const |
|
inline |
- 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. |
Definition at line 244 of file ArraySlice.hpp.
◆ 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>
constexpr LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::operator std::enable_if_t< !std::is_const< U >::value, ArraySlice< T const, NDIM, USD, INDEX_TYPE > > |
( |
| ) |
const |
|
inlinenoexcept |
◆ 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>
constexpr LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::operator std::enable_if_t< _NDIM==1 &&_USD==0, T *const LVARRAY_RESTRICT > |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- A raw pointer.
- Note
- This method is only active when NDIM == 0 and USD == 0.
Definition at line 267 of file ArraySlice.hpp.
◆ operator()()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<typename ... INDICES>
constexpr T& LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::operator() |
( |
INDICES... |
indices | ) |
const |
|
inline |
- 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. |
Definition at line 307 of file ArraySlice.hpp.
◆ operator[]() [1/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int U = NDIM>
constexpr std::enable_if_t< (U > 1), ArraySlice< T, NDIM - 1, USD - 1, INDEX_TYPE > > LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::operator[] |
( |
INDEX_TYPE const |
index | ) |
const |
|
inlinenoexcept |
- 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.
Definition at line 278 of file ArraySlice.hpp.
◆ operator[]() [2/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int U = NDIM>
constexpr std::enable_if_t< U == 1, T & > LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::operator[] |
( |
INDEX_TYPE const |
index | ) |
const |
|
inlinenoexcept |
- 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.
Definition at line 294 of file ArraySlice.hpp.
◆ size() [1/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr INDEX_TYPE LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::size |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Return the total size of the slice.
Definition at line 171 of file ArraySlice.hpp.
◆ size() [2/2]
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr INDEX_TYPE LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::size |
( |
int |
dim | ) |
const |
|
inlinenoexcept |
- Returns
- Return the length of the given dimension.
- Parameters
-
dim | the dimension to get the length of. |
Definition at line 191 of file ArraySlice.hpp.
◆ toSliceConst()
template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<typename U = T>
The documentation for this class was generated from the following file: