GEOSX
Classes | Functions
LvArray::indexing Namespace Reference

Contains functions to aid in multidimensional indexing. More...

Classes

struct  ConditionalMultiply
 A helper struct to multiply two numbers. More...
 
struct  ConditionalMultiply< true >
 A specialization of ConditionalMultiply that skips the multiplication. More...
 

Functions

template<int SIZE, typename T >
constexpr std::enable_if_t<(SIZE==1), T > multiplyAll (T const *const LVARRAY_RESTRICT values)
 
template<int SIZE, typename T >
constexpr std::enable_if_t<(SIZE > 1), T > multiplyAll (T const *const LVARRAY_RESTRICT values)
 
template<int USD, typename INDEX_TYPE , typename INDEX >
constexpr INDEX_TYPE getLinearIndex (INDEX_TYPE const *const LVARRAY_RESTRICT strides, INDEX const index)
 Get the index into a one dimensional space. More...
 
template<int USD, typename INDEX_TYPE , typename INDEX , typename ... REMAINING_INDICES>
constexpr INDEX_TYPE getLinearIndex (INDEX_TYPE const *const LVARRAY_RESTRICT strides, INDEX const index, REMAINING_INDICES const ... indices)
 Get the index into a a multidimensional space. More...
 
std::string getIndexString ()
 
template<typename INDEX , typename ... REMAINING_INDICES>
std::string getIndexString (INDEX const index, REMAINING_INDICES const ... indices)
 
template<typename INDEX_TYPE , typename ... INDICES>
std::string printDimsAndIndices (INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
 
template<typename INDEX_TYPE , typename ... INDICES>
constexpr bool invalidIndices (INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
 
template<typename INDEX_TYPE , typename ... INDICES>
void checkIndices (INDEX_TYPE const *const LVARRAY_RESTRICT dims, INDICES const ... indices)
 Check that the indices are with dims , if not the program is aborted. More...
 

Detailed Description

Contains functions to aid in multidimensional indexing.

Function Documentation

◆ checkIndices()

template<typename INDEX_TYPE , typename ... INDICES>
void LvArray::indexing::checkIndices ( INDEX_TYPE const *const LVARRAY_RESTRICT  dims,
INDICES const ...  indices 
)
inline

Check that the indices are with dims , if not the program is aborted.

Template Parameters
INDEX_TYPEThe integral type used for the dimensions of the space.
INDICESA variadic pack of the integral types of the indices.
Parameters
dimsA pointer to the dimensions of the space.
indicesA variadic pack of the indices.

Definition at line 208 of file indexing.hpp.

◆ getIndexString() [1/2]

std::string LvArray::indexing::getIndexString ( )
inline
Returns
A string representing an empty set of indices.

Definition at line 131 of file indexing.hpp.

◆ getIndexString() [2/2]

template<typename INDEX , typename ... REMAINING_INDICES>
std::string LvArray::indexing::getIndexString ( INDEX const  index,
REMAINING_INDICES const ...  indices 
)
Template Parameters
INDEXThe integral type of the first index.
REMAINING_INDICESA variadic pack of the integral types of the remaining indices.
Returns
A string representing the indices.
Parameters
indexThe first index.
indicesA variadic pack of indices to the remaining dimensions.

Definition at line 142 of file indexing.hpp.

◆ getLinearIndex() [1/2]

template<int USD, typename INDEX_TYPE , typename INDEX >
constexpr INDEX_TYPE LvArray::indexing::getLinearIndex ( INDEX_TYPE const *const LVARRAY_RESTRICT  strides,
INDEX const  index 
)
inline

Get the index into a one dimensional space.

Template Parameters
USDThe unit stride dimension of strides.
INDEX_TYPEThe integral type of the strides and the type to return.
INDEXThe integral type of the index.
Parameters
stridesA pointer to the stride of the dimension.
indexThe index into the dimension.
Note
If USD == 0 then strides[ 0 ] is assumed to equal 1.
Returns
The product of index with strides[ 0 ].

Definition at line 106 of file indexing.hpp.

◆ getLinearIndex() [2/2]

template<int USD, typename INDEX_TYPE , typename INDEX , typename ... REMAINING_INDICES>
constexpr INDEX_TYPE LvArray::indexing::getLinearIndex ( INDEX_TYPE const *const LVARRAY_RESTRICT  strides,
INDEX const  index,
REMAINING_INDICES const ...  indices 
)
inline

Get the index into a a multidimensional space.

Template Parameters
USDThe unit stride dimension of strides.
INDEX_TYPEThe integral type of the strides and the type to return.
INDEXThe integral type of the first index.
REMAINING_INDICESA variadic pack of the integral types of the remaining indices.
Parameters
stridesA pointer to the strides of the dimension.
indexThe index into the first dimension.
indicesA variadic pack of the indices to the remaining dimensions.
Note
If 0 <= USD < the number of dimensions then strides[ USD ] is assumed to equal 1.
Returns
The dot product of strides with ( index, indices ... ).

Definition at line 123 of file indexing.hpp.

◆ invalidIndices()

template<typename INDEX_TYPE , typename ... INDICES>
constexpr bool LvArray::indexing::invalidIndices ( INDEX_TYPE const *const LVARRAY_RESTRICT  dims,
INDICES const ...  indices 
)
inline
Template Parameters
INDEX_TYPEThe integral type used for the dimensions of the space.
INDICESA variadic pack of the integral types of the indices.
Returns
If the indices into the multidimensional space are invalid.
Parameters
dimsA pointer to the dimensions of the space.
indicesA variadic pack of the indices.

Definition at line 186 of file indexing.hpp.

◆ multiplyAll() [1/2]

template<int SIZE, typename T >
constexpr std::enable_if_t< (SIZE == 1), T > LvArray::indexing::multiplyAll ( T const *const LVARRAY_RESTRICT  values)
inline
Template Parameters
SIZEThe number of values to multiply together.
TThe type of the values.
Returns
The product of the values in [ values, values + SIZE )
Parameters
valuesA pointer to the values to multiply together.

Definition at line 79 of file indexing.hpp.

◆ multiplyAll() [2/2]

template<int SIZE, typename T >
constexpr std::enable_if_t< (SIZE > 1), T > LvArray::indexing::multiplyAll ( T const *const LVARRAY_RESTRICT  values)
inline
Template Parameters
SIZEThe number of values to multiply together.
TThe type of the values.
Returns
The product of the values in [ values, values + SIZE )
Parameters
valuesA pointer to the values to multiply together.

Definition at line 91 of file indexing.hpp.

◆ printDimsAndIndices()

template<typename INDEX_TYPE , typename ... INDICES>
std::string LvArray::indexing::printDimsAndIndices ( INDEX_TYPE const *const LVARRAY_RESTRICT  dims,
INDICES const ...  indices 
)
Template Parameters
INDEX_TYPEThe integral type of the dimensions.
INDICESA variadic pack of the integral types of the indices.
Returns
A string representing the dimensions of the multidimensional space and the indices into it.
Parameters
dimsA pointer to the dimensions of the space.
indicesA variadic pack of indices.

Definition at line 162 of file indexing.hpp.