Hammer
1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
|
#include <AlignedIndexing.hh>
Public Member Functions | |
AlignedIndexing () | |
AlignedIndexing (IndexList dimensions) | |
AlignedIndexing (const AlignedIndexing &)=default | |
AlignedIndexing (AlignedIndexing &&)=default | |
AlignedIndexing & | operator= (const AlignedIndexing &)=default |
AlignedIndexing & | operator= (AlignedIndexing &&)=default |
~AlignedIndexing ()=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 | numValues () const |
the number of elements (product of all the dimensions) More... | |
PositionType | indicesToPos (const IndexList &indices) const |
convert the indices into the (aligned) position indicizing a sparse tensor container organized as row-major More... | |
PositionType | indicesToPos (IndexList::const_iterator first, IndexList::const_iterator last) const |
PositionType | alignedPosToPos (PositionType alignedPosition) const |
convert the absolute aligned position to the absolute unaligned position that can be used with a SequentialIndexing object More... | |
PositionType | posToAlignedPos (PositionType position) const |
convert the absolute unaligned position (e.g. More... | |
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 alignedPosition, IndexList &result) const |
convert the absolute aligned position (in row-major convention) into the list of indices More... | |
IndexType | ithIndexInPos (PositionType alignedPosition, IndexType indexPosition) const |
extract the value of the i-th index from an absolute aligned position More... | |
PositionType | splitPosition (PositionType alignedPosition, const IndexList &outerShiftsInnerPositions, const std::vector< bool > &isOuter, IndexList &innerList, std::vector< bool > &innerAdded, bool shouldCompare=false) const |
split an absolute aligned position by separating contracted and uncontracted indices and returning the absolute position made of uncontracted indices and the coordinates of the contracted ones properly reordered. More... | |
std::tuple< IndexList, std::vector< bool > , PositionType > | processShifts (const IndexPairList &pairs, IndexPairMember which) const |
build the input lists necessary for calling splitPosition based on which indices are being contracted and whether the tensor indexed by this class is the on left or right of Dot or it is the argument of Trace More... | |
PositionType | maxIndex (bool aligned=true) const |
get the maximum allowed value for the absolute position More... | |
PositionType | extendPosition (PositionType position, PositionType stride, IndexType indexPosition, IndexType indexValue) const |
extends an unaligned absolute position from a rank N-1 tensor to the corresponding aligned position for this rank N tensor given the missing index and its value. More... | |
PositionType | extendAlignedPosition (PositionType alignedPosition, IndexType indexPosition, IndexType indexValue) const |
extends an aligned absolute position from a rank N-1 tensor to the corresponding aligned position for this rank N tensor given the missing index and its value. More... | |
template<typename BasicIndexing > | |
bool | isSameShape (const BasicIndexing &other) const |
bool | isSameShape (const IndexList &indices) const |
Private Member Functions | |
void | calc () |
PositionType | calcPadding (const IndexList &dimensions, IndexList &pads) const |
void | calcMasks (const IndexList &dimensions, IndexList &masks) const |
void | calcUnaligned (const IndexList &dimensions, const IndexList &pads, PosIndexPairList &unaligned) const |
Private Attributes | |
IndexList | _dimensions |
the dimensions of each tensor index More... | |
IndexList | _alignPads |
the strides for each tensor index (necessary to convert coordinates to position in _data ) More... | |
IndexList | _alignMasks |
the strides for each tensor index (necessary to convert coordinates to position in _data ) More... | |
PositionType | _maxIndex |
PositionType | _maxAlignedIndex |
PosIndexPairList | _unalignedEntries |
Definition at line 27 of file AlignedIndexing.hh.
Hammer::MultiDimensional::AlignedIndexing::AlignedIndexing | ( | ) |
Definition at line 42 of file AlignedIndexing.cc.
Hammer::MultiDimensional::AlignedIndexing::AlignedIndexing | ( | IndexList | dimensions | ) |
Definition at line 46 of file AlignedIndexing.cc.
|
default |
|
default |
|
default |
PositionType Hammer::MultiDimensional::AlignedIndexing::alignedPosToPos | ( | PositionType | alignedPosition | ) | const |
convert the absolute aligned position to the absolute unaligned position that can be used with a SequentialIndexing
object
[in] | alignedPosition | the absolute aligned position |
Definition at line 235 of file AlignedIndexing.cc.
|
private |
Definition at line 204 of file AlignedIndexing.cc.
|
private |
Definition at line 197 of file AlignedIndexing.cc.
|
private |
Definition at line 183 of file AlignedIndexing.cc.
|
private |
Definition at line 219 of file AlignedIndexing.cc.
bool Hammer::MultiDimensional::AlignedIndexing::checkValidIndices | ( | const IndexList & | indices | ) | const |
check that the indices are within range for each component
[in] | indices | the element indices |
Definition at line 70 of file AlignedIndexing.cc.
bool Hammer::MultiDimensional::AlignedIndexing::checkValidIndices | ( | IndexList::const_iterator | first, |
IndexList::const_iterator | last | ||
) | const |
Definition at line 79 of file AlignedIndexing.cc.
dimension of a specific component
[in] | index | the component index |
Definition at line 54 of file AlignedIndexing.cc.
const IndexList & Hammer::MultiDimensional::AlignedIndexing::dims | ( | ) | const |
get the dimensions of all the indices at once
Definition at line 62 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::extendAlignedPosition | ( | PositionType | alignedPosition, |
IndexType | indexPosition, | ||
IndexType | indexValue | ||
) | const |
extends an aligned absolute position from a rank N-1 tensor to the corresponding aligned position for this rank N tensor given the missing index and its value.
Used in AddAt
alignedPosition | the sub-tensor aligned position |
indexPosition | the missing index coordinate |
indexValue | the missing index value |
Definition at line 257 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::extendPosition | ( | PositionType | position, |
PositionType | stride, | ||
IndexType | indexPosition, | ||
IndexType | indexValue | ||
) | const |
extends an unaligned absolute position from a rank N-1 tensor to the corresponding aligned position for this rank N tensor given the missing index and its value.
Used in AddAt
position | the sub-tensor unaligned position |
stride | the stride (in the sub-tensor) of the index preceding the missing index |
indexPosition | the missing index coordinate |
indexValue | the missing index value |
Definition at line 268 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::indicesToPos | ( | const IndexList & | indices | ) | const |
convert the indices into the (aligned) position indicizing a sparse tensor container organized as row-major
[in] | indices | the element indices |
Definition at line 88 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::indicesToPos | ( | IndexList::const_iterator | first, |
IndexList::const_iterator | last | ||
) | const |
Definition at line 92 of file AlignedIndexing.cc.
bool Hammer::MultiDimensional::AlignedIndexing::isSameShape | ( | const BasicIndexing & | other | ) | const |
Definition at line 176 of file AlignedIndexing.hh.
bool Hammer::MultiDimensional::AlignedIndexing::isSameShape | ( | const IndexList & | indices | ) | const |
Definition at line 274 of file AlignedIndexing.cc.
IndexType Hammer::MultiDimensional::AlignedIndexing::ithIndexInPos | ( | PositionType | alignedPosition, |
IndexType | indexPosition | ||
) | const |
extract the value of the i-th index from an absolute aligned position
[in] | alignedPosition | the absolute position |
[in] | indexPosition | the index coordinate i |
Definition at line 115 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::maxIndex | ( | bool | aligned = true | ) | const |
get the maximum allowed value for the absolute position
[in] | aligned | whether the maximum absolute position is aligned or not |
Definition at line 179 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::numValues | ( | ) | const |
the number of elements (product of all the dimensions)
Definition at line 66 of file AlignedIndexing.cc.
|
default |
|
default |
PositionType Hammer::MultiDimensional::AlignedIndexing::posToAlignedPos | ( | PositionType | position | ) | const |
convert the absolute unaligned position (e.g.
coming from a SequentialIndexing
object) to the absolute aligned position
[in] | position | the absolute unaligned position |
Definition at line 246 of file AlignedIndexing.cc.
void Hammer::MultiDimensional::AlignedIndexing::posToIndices | ( | PositionType | alignedPosition, |
IndexList & | result | ||
) | const |
convert the absolute aligned position (in row-major convention) into the list of indices
[in] | alignedPosition | the absolute aligned position |
[out] | result | the indices |
Definition at line 105 of file AlignedIndexing.cc.
std::tuple< IndexList, std::vector< bool >, PositionType > Hammer::MultiDimensional::AlignedIndexing::processShifts | ( | const IndexPairList & | pairs, |
IndexPairMember | which | ||
) | const |
build the input lists necessary for calling splitPosition based on which indices are being contracted and whether the tensor indexed by this class is the on left or right of Dot or it is the argument of Trace
[in] | pairs | the list of contractions (pairs od index position being contracted |
[in] | which | whether the tensor is the first or second argument of Dot or it is the argument of Trace |
Definition at line 147 of file AlignedIndexing.cc.
size_t Hammer::MultiDimensional::AlignedIndexing::rank | ( | ) | const |
rank of the tensor
Definition at line 50 of file AlignedIndexing.cc.
PositionType Hammer::MultiDimensional::AlignedIndexing::splitPosition | ( | PositionType | alignedPosition, |
const IndexList & | outerShiftsInnerPositions, | ||
const std::vector< bool > & | isOuter, | ||
IndexList & | innerList, | ||
std::vector< bool > & | innerAdded, | ||
bool | shouldCompare = false |
||
) | const |
split an absolute aligned position by separating contracted and uncontracted indices and returning the absolute position made of uncontracted indices and the coordinates of the contracted ones properly reordered.
This function is the workhorse of Dot and Trace. The method accepts an optional coordinate list for the contracted indices: if that does not match the coordinate list extracted from the position the function return 0 for the external position and an empty list for the contracted indices.
[in] | alignedPosition | the absolute aligned index |
[in] | outerShiftsInnerPositions | a list (of rank length) with a positional shift for each uncontracted index and the corresponding position for the contracted index |
[in] | isOuter | a list (of rank length) marking whether an index is not contracted |
[in] | innerList | |
[in] | innerAdded | if present, the list of values that the contracted coordinates should have |
[in] | shouldCompare | if present, the list of values that the contracted coordinates should have |
Definition at line 120 of file AlignedIndexing.cc.
|
private |
the strides for each tensor index (necessary to convert coordinates to position in _data
)
Definition at line 169 of file AlignedIndexing.hh.
|
private |
the strides for each tensor index (necessary to convert coordinates to position in _data
)
Definition at line 168 of file AlignedIndexing.hh.
|
private |
the dimensions of each tensor index
Definition at line 167 of file AlignedIndexing.hh.
|
private |
Definition at line 171 of file AlignedIndexing.hh.
|
private |
Definition at line 170 of file AlignedIndexing.hh.
|
private |
Definition at line 172 of file AlignedIndexing.hh.