Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Hammer::MultiDimensional::AlignedIndexing Class Reference

#include <AlignedIndexing.hh>

+ Inheritance diagram for Hammer::MultiDimensional::AlignedIndexing:
+ Collaboration diagram for Hammer::MultiDimensional::AlignedIndexing:

Public Member Functions

 AlignedIndexing ()
 
 AlignedIndexing (IndexList dimensions)
 
 AlignedIndexing (const AlignedIndexing &)=default
 
 AlignedIndexing (AlignedIndexing &&)=default
 
AlignedIndexingoperator= (const AlignedIndexing &)=default
 
AlignedIndexingoperator= (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 IndexListdims () 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
 

Detailed Description

Definition at line 27 of file AlignedIndexing.hh.

Constructor & Destructor Documentation

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.

Hammer::MultiDimensional::AlignedIndexing::AlignedIndexing ( const AlignedIndexing )
default
Hammer::MultiDimensional::AlignedIndexing::AlignedIndexing ( AlignedIndexing &&  )
default
Hammer::MultiDimensional::AlignedIndexing::~AlignedIndexing ( )
default

Member Function Documentation

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

Parameters
[in]alignedPositionthe absolute aligned position
Returns
the absolute unaligned position

Definition at line 235 of file AlignedIndexing.cc.

void Hammer::MultiDimensional::AlignedIndexing::calc ( )
private

Definition at line 204 of file AlignedIndexing.cc.

void Hammer::MultiDimensional::AlignedIndexing::calcMasks ( const IndexList dimensions,
IndexList masks 
) const
private

Definition at line 197 of file AlignedIndexing.cc.

PositionType Hammer::MultiDimensional::AlignedIndexing::calcPadding ( const IndexList dimensions,
IndexList pads 
) const
private

Definition at line 183 of file AlignedIndexing.cc.

void Hammer::MultiDimensional::AlignedIndexing::calcUnaligned ( const IndexList dimensions,
const IndexList pads,
PosIndexPairList unaligned 
) const
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

Parameters
[in]indicesthe element indices
Returns
true if all indices are OK

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.

IndexType Hammer::MultiDimensional::AlignedIndexing::dim ( IndexType  index) const

dimension of a specific component

Parameters
[in]indexthe component index
Returns
the dimension

Definition at line 54 of file AlignedIndexing.cc.

const IndexList & Hammer::MultiDimensional::AlignedIndexing::dims ( ) const

get the dimensions of all the indices at once

Returns
the list of dimensions

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
Parameters
alignedPositionthe sub-tensor aligned position
indexPositionthe missing index coordinate
indexValuethe missing index value
Returns
the corresponding absolute aligned position

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
Parameters
positionthe sub-tensor unaligned position
stridethe stride (in the sub-tensor) of the index preceding the missing index
indexPositionthe missing index coordinate
indexValuethe missing index value
Returns
the corresponding absolute aligned position

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

Parameters
[in]indicesthe element indices
Returns
the absolute (aligned) position

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.

template<typename BasicIndexing >
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

Parameters
[in]alignedPositionthe absolute position
[in]indexPositionthe index coordinate i
Returns
the index value

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

Parameters
[in]alignedwhether the maximum absolute position is aligned or not
Returns
the maximum allowed absolute position

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.

AlignedIndexing& Hammer::MultiDimensional::AlignedIndexing::operator= ( const AlignedIndexing )
default
AlignedIndexing& Hammer::MultiDimensional::AlignedIndexing::operator= ( AlignedIndexing &&  )
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

Parameters
[in]positionthe absolute unaligned position
Returns
the absolute aligned 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

Parameters
[in]alignedPositionthe absolute aligned position
[out]resultthe 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

Parameters
[in]pairsthe list of contractions (pairs od index position being contracted
[in]whichwhether the tensor is the first or second argument of Dot or it is the argument of Trace
Returns
the lists to be fed to splitPosition (outerShiftsInnerPositions and isOuter) and the maximum aligned index of the uncontracted indices

Definition at line 147 of file AlignedIndexing.cc.

size_t Hammer::MultiDimensional::AlignedIndexing::rank ( ) const

rank of the tensor

Returns
the number of components

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.

Parameters
[in]alignedPositionthe absolute aligned index
[in]outerShiftsInnerPositionsa list (of rank length) with a positional shift for each uncontracted index and the corresponding position for the contracted index
[in]isOutera list (of rank length) marking whether an index is not contracted
[in]innerList
[in]innerAddedif present, the list of values that the contracted coordinates should have
[in]shouldCompareif present, the list of values that the contracted coordinates should have
Returns
a pair (absolute aligned position made of the uncontracted indices, reduced index list for the contracted indices reordered according to the shifts)

Definition at line 120 of file AlignedIndexing.cc.

Member Data Documentation

IndexList Hammer::MultiDimensional::AlignedIndexing::_alignMasks
private

the strides for each tensor index (necessary to convert coordinates to position in _data)

Definition at line 169 of file AlignedIndexing.hh.

IndexList Hammer::MultiDimensional::AlignedIndexing::_alignPads
private

the strides for each tensor index (necessary to convert coordinates to position in _data)

Definition at line 168 of file AlignedIndexing.hh.

IndexList Hammer::MultiDimensional::AlignedIndexing::_dimensions
private

the dimensions of each tensor index

Definition at line 167 of file AlignedIndexing.hh.

PositionType Hammer::MultiDimensional::AlignedIndexing::_maxAlignedIndex
private

Definition at line 171 of file AlignedIndexing.hh.

PositionType Hammer::MultiDimensional::AlignedIndexing::_maxIndex
private

Definition at line 170 of file AlignedIndexing.hh.

PosIndexPairList Hammer::MultiDimensional::AlignedIndexing::_unalignedEntries
private

Definition at line 172 of file AlignedIndexing.hh.


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