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::SequentialIndexing Class Reference

#include <SequentialIndexing.hh>

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

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
 
SequentialIndexingoperator= (const SequentialIndexing &)=default
 
SequentialIndexingoperator= (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 IndexListdims () 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 PositionListstrides () 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
 

Detailed Description

Definition at line 23 of file SequentialIndexing.hh.

Member Typedef Documentation

using Hammer::MultiDimensional::SequentialIndexing::StrideMap = std::vector<std::tuple<PositionType, long, bool>>

Definition at line 37 of file SequentialIndexing.hh.

Constructor & Destructor Documentation

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.

Hammer::MultiDimensional::SequentialIndexing::SequentialIndexing ( const SequentialIndexing )
default
Hammer::MultiDimensional::SequentialIndexing::SequentialIndexing ( SequentialIndexing &&  )
default
Hammer::MultiDimensional::SequentialIndexing::~SequentialIndexing ( )
defaultnoexcept

Member Function Documentation

PositionType Hammer::MultiDimensional::SequentialIndexing::build2ndPosition ( PositionType  reducedPosition,
PositionType  innerPosition,
const PositionPairList conversion 
) const

Definition at line 132 of file SequentialIndexing.cc.

SequentialIndexing::StrideMap Hammer::MultiDimensional::SequentialIndexing::buildStrideMap ( const std::map< IndexType, long >  innerMap) const
protected

Definition at line 187 of file SequentialIndexing.cc.

void Hammer::MultiDimensional::SequentialIndexing::calcPadding ( )
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

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

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.

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

dimension of a specific component

Parameters
[in]indexthe component index
Returns
the dimension

Definition at line 39 of file SequentialIndexing.cc.

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

get the dimensions of all the indices at once

Returns
the list of dimensions

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

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.

Parameters
positions
secondStrides
flipSecond
Returns

Definition at line 173 of file SequentialIndexing.cc.

PositionPairList Hammer::MultiDimensional::SequentialIndexing::getOuterStrides2nd ( const IndexPairList positions) const

Get the Outer Strides2nd object.

Parameters
positions
Returns

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

Parameters
[in]indicesthe element indices
Returns
the absolute position

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.

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

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

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.

SequentialIndexing& Hammer::MultiDimensional::SequentialIndexing::operator= ( const SequentialIndexing )
default
SequentialIndexing& Hammer::MultiDimensional::SequentialIndexing::operator= ( SequentialIndexing &&  )
default
void Hammer::MultiDimensional::SequentialIndexing::posToIndices ( PositionType  position,
IndexList result 
) const

convert the absolute position (in row-major convention) into the list of indices

Parameters
[in]positionthe absolute position
[out]resultthe indices

Definition at line 93 of file SequentialIndexing.cc.

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

rank of the tensor

Returns
the number of components

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.

Parameters
[in]indexthe component index
Returns
the stride

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.

Returns
the strides

Definition at line 254 of file SequentialIndexing.cc.

Member Data Documentation

IndexList Hammer::MultiDimensional::SequentialIndexing::_dimensions
private

the dimensions of each tensor index

Definition at line 139 of file SequentialIndexing.hh.

PositionType Hammer::MultiDimensional::SequentialIndexing::_maxIndex
private

Definition at line 141 of file SequentialIndexing.hh.

PositionList Hammer::MultiDimensional::SequentialIndexing::_strides
private

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

Definition at line 140 of file SequentialIndexing.hh.


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