12 #ifndef HAMMER_MATH_MULTIDIM_SEQUENTIALINDEXING
13 #define HAMMER_MATH_MULTIDIM_SEQUENTIALINDEXING
21 namespace MultiDimensional {
37 using StrideMap = std::vector<std::tuple<PositionType, long, bool>>;
81 bool checkValidIndices(IndexList::const_iterator first, IndexList::const_iterator last)
const;
116 bool flipSecond =
false)
const;
128 template<
typename BasicIndexing>
145 template <
typename BasicIndexing>
PositionPairList getOuterStrides2nd(const IndexPairList &positions) const
Get the Outer Strides2nd object.
SequentialIndexing & operator=(const SequentialIndexing &)=default
StrideMap buildStrideMap(const std::map< IndexType, long > innerMap) const
std::vector< IndexPair > IndexPairList
PositionList _strides
the strides for each tensor index (necessary to convert coordinates to position in _data) ...
const IndexList & dims() const
get the dimensions of all the indices at once
std::pair< PositionType, PositionType > PositionPair
PositionType extendPosition(PositionType position, IndexType indexPosition, IndexType indexValue) const
extends an absolute position from a rank N-1 tensor to the corresponding position for this rank N ten...
std::vector< std::tuple< PositionType, long, bool >> StrideMap
PositionPair splitPosition(PositionType position, const StrideMap &conversion) const
PositionType indicesToPos(const IndexList &indices) const
convert the indices into the position indicizing a sparse tensor container organized as row-major ...
Forward declarations of types used in the tensor classes.
void posToIndices(PositionType position, IndexList &result) const
convert the absolute position (in row-major convention) into the list of indices
size_t rank() const
rank of the tensor
bool isSameShape(const BasicIndexing &other) const
PositionType reducedNumValues(const IndexPairList &indices) const
std::vector< IndexType > IndexList
IndexType ithIndexInPos(PositionType position, IndexType indexPosition) const
extract the value of the i-th index from an absolute position
~SequentialIndexing() noexcept=default
IndexType dim(IndexType index) const
dimension of a specific component
PositionType numValues() const
the number of elements (product of all the dimensions)
std::vector< PositionPair > PositionPairList
const PositionList & strides() const
list of strides, i.e.
StrideMap getInnerOuterStrides(const IndexPairList &positions, const PositionList &secondStrides, bool flipSecond=false) const
Get the Inner Outer Strides object.
bool checkValidIndices(const IndexList &indices) const
check that the indices are within range for each component
PositionType build2ndPosition(PositionType reducedPosition, PositionType innerPosition, const PositionPairList &conversion) const
PositionType stride(IndexType index) const
stride of a specific component, i.e.
IndexList _dimensions
the dimensions of each tensor index
std::vector< PositionType > PositionList