GEOSX
Public Types | Static Public Attributes | Protected Attributes | List of all members
LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE > Class Template Reference

This class serves to provide a sliced multidimensional interface to the family of LvArray classes. More...

#include <ArraySlice.hpp>

Public Types

using ValueType = T
 The type of the value in the ArraySlice.
 
using IndexType = INDEX_TYPE
 The integer type used for indexing.
 

Public Member Functions

Constructors, destructor and assignment operators.
 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...
 
ArraySlice creation methods and user defined conversions
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
 
Attribute querying methods
constexpr INDEX_TYPE size () const noexcept
 
constexpr INDEX_TYPE size (int const dim) const noexcept
 
constexpr INDEX_TYPE stride (int const dim) const noexcept
 
constexpr bool isContiguous () const
 Check if the slice is contiguous in memory. More...
 
template<typename ... INDICES>
constexpr INDEX_TYPE linearIndex (INDICES... indices) const
 
Methods that provide access to the data.
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
 
template<int USD_ = USD>
T * dataIfContiguous () const
 
constexpr T * begin () const
 
constexpr T * end () const
 

Static Public Attributes

static constexpr int NDIM = NDIM_TPARAM
 The number of dimensions.
 
static constexpr int USD = USD_TPARAM
 The unit stride dimension.
 

Protected Attributes

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
 

Detailed Description

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
Ttype of data that is contained by the array
NDIM_TPARAMThe number of dimensions in array (e.g. NDIM=1->vector, NDIM=2->Matrix, etc. ).
USDThe dimension with a unit stride, in an Array with a standard layout this is the last dimension.
INDEX_TYPEThe 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.

Constructor & Destructor Documentation

◆ 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
inputDatapointer to the beginning of the data for this slice of the array
inputDimensionspointer to the beginning of the dimensions for this slice.
inputStridespointer to the beginning of the strides for this slice

Definition at line 122 of file ArraySlice.hpp.

Member Function Documentation

◆ begin()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr T* LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::begin ( ) const
inline
Returns
Return a pointer to the values.
Precondition
The slice must be contiguous.

Definition at line 331 of file ArraySlice.hpp.

◆ dataIfContiguous()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
template<int USD_ = USD>
T* LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::dataIfContiguous ( ) const
inline
Returns
Return a pointer to the values.
Template Parameters
USD_Dummy template parameter, do not specify.
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>
constexpr T* LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::end ( ) const
inline
Returns
Return a pointer to the end values.
Precondition
The slice must be contiguous.

Definition at line 339 of file ArraySlice.hpp.

◆ isContiguous()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr bool LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::isContiguous ( ) const
inline

Check if the slice is contiguous in memory.

Returns
true if represented slice is contiguous in memory

Definition at line 216 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
INDICESA variadic pack of integral types.
Returns
Return the linear index from a multidimensional index.
Parameters
indicesThe indices of the value to get the linear index of.

Definition at line 242 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
Returns
Return a new immutable slice.

Definition at line 156 of file ArraySlice.hpp.

◆ 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 == 1 and USD == 0.

Definition at line 265 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
INDICESA variadic pack of integral types.
Returns
Return a reference to the value at the given multidimensional index.
Parameters
indicesThe indices of the value to access.

Definition at line 305 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
indexThe index of the slice to create.
Note
This method is only active when NDIM > 1.

Definition at line 276 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
indexThe index of the value to access.
Note
This method is only active when NDIM == 1.

Definition at line 292 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 170 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 const  dim) const
inlinenoexcept
Returns
Return the length of the given dimension.
Parameters
dimthe dimension to get the length of.

Definition at line 190 of file ArraySlice.hpp.

◆ stride()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr INDEX_TYPE LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::stride ( int const  dim) const
inlinenoexcept
Returns
Return the stride of the given dimension.
Parameters
dimthe dimension to get the stride of.

Definition at line 203 of file ArraySlice.hpp.

◆ toSliceConst()

template<typename T, int NDIM_TPARAM, int USD_TPARAM, typename INDEX_TYPE>
constexpr ArraySlice< T const, NDIM, USD, INDEX_TYPE > LvArray::ArraySlice< T, NDIM_TPARAM, USD_TPARAM, INDEX_TYPE >::toSliceConst ( ) const
inlinenoexcept
Returns
Return a new immutable slice.

Definition at line 146 of file ArraySlice.hpp.


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