Hammer
1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
|
#include <SequentialIndexing.hh>
Public Types | |
using | StrideMap = std::vector< std::tuple< PositionType, long, bool >> |
Public Member Functions | |
SequentialIndexing () | |
SequentialIndexing (IndexList dimensions) | |
SequentialIndexing (const SequentialIndexing &)=default | |
SequentialIndexing (SequentialIndexing &&)=default | |
SequentialIndexing & | operator= (const SequentialIndexing &)=default |
SequentialIndexing & | operator= (SequentialIndexing &&)=default |
~SequentialIndexing () noexcept=default | |
size_t | rank () const |
rank of the tensor More... | |
IndexType | dim (IndexType index) const |
dimension of a specific component More... | |
const IndexList & | dims () const |
get the dimensions of all the indices at once More... | |
PositionType | stride (IndexType index) const |
stride of a specific component, i.e. More... | |
const PositionList & | strides () const |
list of strides, i.e. More... | |
PositionType | numValues () const |
the number of elements (product of all the dimensions) More... | |
PositionType | indicesToPos (const IndexList &indices) const |
convert the indices into the position indicizing a sparse tensor container organized as row-major More... | |
PositionType | indicesToPos (IndexList::const_iterator first, IndexList::const_iterator last) const |
bool | checkValidIndices (const IndexList &indices) const |
check that the indices are within range for each component More... | |
bool | checkValidIndices (IndexList::const_iterator first, IndexList::const_iterator last) const |
void | posToIndices (PositionType position, IndexList &result) const |
convert the absolute position (in row-major convention) into the list of indices More... | |
IndexType | ithIndexInPos (PositionType position, IndexType indexPosition) const |
extract the value of the i-th index from an absolute position More... | |
PositionType | build2ndPosition (PositionType reducedPosition, PositionType innerPosition, const PositionPairList &conversion) const |
PositionPair | splitPosition (PositionType position, const StrideMap &conversion) const |
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 tensor given the missing index and its value. More... | |
StrideMap | getInnerOuterStrides (const IndexPairList &positions, const PositionList &secondStrides, bool flipSecond=false) const |
Get the Inner Outer Strides object. More... | |
PositionPairList | getOuterStrides2nd (const IndexPairList &positions) const |
Get the Outer Strides2nd object. More... | |
PositionType | reducedNumValues (const IndexPairList &indices) const |
template<typename BasicIndexing > | |
bool | isSameShape (const BasicIndexing &other) const |
bool | isSameShape (const IndexList &indices) const |
Protected Member Functions | |
StrideMap | buildStrideMap (const std::map< IndexType, long > innerMap) const |
Private Member Functions | |
void | calcPadding () |
Private Attributes | |
IndexList | _dimensions |
the dimensions of each tensor index More... | |
PositionList | _strides |
the strides for each tensor index (necessary to convert coordinates to position in _data ) More... | |
PositionType | _maxIndex |
Definition at line 23 of file SequentialIndexing.hh.
using Hammer::MultiDimensional::SequentialIndexing::StrideMap = std::vector<std::tuple<PositionType, long, bool>> |
Definition at line 37 of file SequentialIndexing.hh.
Hammer::MultiDimensional::SequentialIndexing::SequentialIndexing | ( | ) |
Definition at line 28 of file SequentialIndexing.cc.
Hammer::MultiDimensional::SequentialIndexing::SequentialIndexing | ( | IndexList | dimensions | ) |
Definition at line 31 of file SequentialIndexing.cc.
|
default |
|
default |
|
defaultnoexcept |
PositionType Hammer::MultiDimensional::SequentialIndexing::build2ndPosition | ( | PositionType | reducedPosition, |
PositionType | innerPosition, | ||
const PositionPairList & | conversion | ||
) | const |
Definition at line 132 of file SequentialIndexing.cc.
|
protected |
Definition at line 187 of file SequentialIndexing.cc.
|
private |
Definition at line 258 of file SequentialIndexing.cc.
bool Hammer::MultiDimensional::SequentialIndexing::checkValidIndices | ( | const IndexList & | indices | ) | const |
check that the indices are within range for each component
[in] | indices | the element indices |
Definition at line 55 of file SequentialIndexing.cc.
bool Hammer::MultiDimensional::SequentialIndexing::checkValidIndices | ( | IndexList::const_iterator | first, |
IndexList::const_iterator | last | ||
) | const |
Definition at line 64 of file SequentialIndexing.cc.
dimension of a specific component
[in] | index | the component index |
Definition at line 39 of file SequentialIndexing.cc.
const IndexList & Hammer::MultiDimensional::SequentialIndexing::dims | ( | ) | const |
get the dimensions of all the indices at once
Definition at line 47 of file SequentialIndexing.cc.
PositionType Hammer::MultiDimensional::SequentialIndexing::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 tensor given the missing index and its value.
Used in AddAt
position | the sub-tensor position |
indexPosition | the missing index coordinate |
indexValue | the missing index value |
Definition at line 124 of file SequentialIndexing.cc.
SequentialIndexing::StrideMap Hammer::MultiDimensional::SequentialIndexing::getInnerOuterStrides | ( | const IndexPairList & | positions, |
const PositionList & | secondStrides, | ||
bool | flipSecond = false |
||
) | const |
Get the Inner Outer Strides object.
positions | |
secondStrides | |
flipSecond |
Definition at line 173 of file SequentialIndexing.cc.
PositionPairList Hammer::MultiDimensional::SequentialIndexing::getOuterStrides2nd | ( | const IndexPairList & | positions | ) | const |
Get the Outer Strides2nd object.
positions |
Definition at line 219 of file SequentialIndexing.cc.
PositionType Hammer::MultiDimensional::SequentialIndexing::indicesToPos | ( | const IndexList & | indices | ) | const |
convert the indices into the position indicizing a sparse tensor container organized as row-major
[in] | indices | the element indices |
Definition at line 73 of file SequentialIndexing.cc.
PositionType Hammer::MultiDimensional::SequentialIndexing::indicesToPos | ( | IndexList::const_iterator | first, |
IndexList::const_iterator | last | ||
) | const |
Definition at line 80 of file SequentialIndexing.cc.
bool Hammer::MultiDimensional::SequentialIndexing::isSameShape | ( | const BasicIndexing & | other | ) | const |
Definition at line 146 of file SequentialIndexing.hh.
bool Hammer::MultiDimensional::SequentialIndexing::isSameShape | ( | const IndexList & | indices | ) | const |
Definition at line 268 of file SequentialIndexing.cc.
IndexType Hammer::MultiDimensional::SequentialIndexing::ithIndexInPos | ( | PositionType | position, |
IndexType | indexPosition | ||
) | const |
extract the value of the i-th index from an absolute position
[in] | position | the absolute position |
[in] | indexPosition | the index coordinate i |
Definition at line 115 of file SequentialIndexing.cc.
PositionType Hammer::MultiDimensional::SequentialIndexing::numValues | ( | ) | const |
the number of elements (product of all the dimensions)
Definition at line 51 of file SequentialIndexing.cc.
|
default |
|
default |
void Hammer::MultiDimensional::SequentialIndexing::posToIndices | ( | PositionType | position, |
IndexList & | result | ||
) | const |
convert the absolute position (in row-major convention) into the list of indices
[in] | position | the absolute position |
[out] | result | the indices |
Definition at line 93 of file SequentialIndexing.cc.
size_t Hammer::MultiDimensional::SequentialIndexing::rank | ( | ) | const |
rank of the tensor
Definition at line 35 of file SequentialIndexing.cc.
PositionType Hammer::MultiDimensional::SequentialIndexing::reducedNumValues | ( | const IndexPairList & | indices | ) | const |
Definition at line 144 of file SequentialIndexing.cc.
PositionPair Hammer::MultiDimensional::SequentialIndexing::splitPosition | ( | PositionType | position, |
const StrideMap & | conversion | ||
) | const |
Definition at line 153 of file SequentialIndexing.cc.
PositionType Hammer::MultiDimensional::SequentialIndexing::stride | ( | IndexType | index | ) | const |
stride of a specific component, i.e.
the product of the dimension of the indices to right of the given one (row-major convention). The last index has stride equal to 1.
[in] | index | the component index |
Definition at line 250 of file SequentialIndexing.cc.
const PositionList & Hammer::MultiDimensional::SequentialIndexing::strides | ( | ) | const |
list of strides, i.e.
the product of the dimension of the indices to right of the given one (row-major convention). The last index has stride equal to 1.
Definition at line 254 of file SequentialIndexing.cc.
|
private |
the dimensions of each tensor index
Definition at line 139 of file SequentialIndexing.hh.
|
private |
Definition at line 141 of file SequentialIndexing.hh.
|
private |
the strides for each tensor index (necessary to convert coordinates to position in _data
)
Definition at line 140 of file SequentialIndexing.hh.