Documentation of CSL
Public Member Functions | Friends
csl::IndexStructure Class Reference

Manages a std::vector of Index, to be used by an TensorElement. More...

#include <index.h>

Public Member Functions

 IndexStructure ()
 Default constructor, empty structure.
 
 IndexStructure (int t_nIndices)
 Constructor that initializes only the size of index. More...
 
 IndexStructure (const IndexStructure &structure)
 Copy constructor. More...
 
 IndexStructure (IndexStructure &&)=default
 
IndexStructureoperator= (IndexStructure &&)=default
 
 IndexStructure (const std::initializer_list< Index > &structure)
 Constructor with one parameter: the list of indices in the structure. More...
 
 IndexStructure (const std::vector< Index > &structure)
 Constructor with one parameter: the list of indices in the structure. More...
 
 ~IndexStructure ()
 Destructor.
 
std::vector< Index > const & getIndex () const
 
const std::vector< Index > & getIndexView () const
 
std::vector< Index > & getIndex ()
 
std::vector< Index >::const_iterator find (const Index &t_index) const
 Search for a particular Index in the structure. More...
 
std::vector< Index >::iterator find (const Index &t_index)
 
IndexStructure getFreeStructure () const
 
IndexStructure getSinglePermutation (int i1, int i2) const
 
IndexStructure getPermutation (const std::vector< int > &permutation) const
 
void setIndex (const Index &newIndex, int iIndex=0)
 Sets the Index in position iIndex to newIndex. More...
 
void reset ()
 
IndexStructureoperator= (const IndexStructure &structure)=default
 operator=, Copies the IndexStructure structure. C++ default. More...
 
IndexStructureoperator+= (const Index &newIndex)
 operator+=, adds an index to the IndexStructure. More...
 
IndexStructureoperator+= (const IndexStructure &structure)
 operator+=, adds another IndexStructure at the end of the current. This function concatenates the two structures. More...
 
IndexStructure operator+ (const csl::Index &index) const
 
IndexStructure operator+ (const IndexStructure &structure) const
 operator+, concatenates the current IndexStructure with structure and returns the result. More...
 
bool hasCommonIndex (csl::IndexStructure const &other) const
 
bool exactMatch (const IndexStructure &structure) const
 Compares the IndexStructure with structure. Each index must match exactly (see Index::exactMatch()) with the Index at the same place in the second structure. More...
 
bool compareWithDummy (const IndexStructure &structure) const
 Compares *this with structure index by index (in order) using the function Index::compareWithDummy(). More...
 
bool compareWithDummy (const IndexStructure &structure, std::map< Index, Index > &constraints, bool keepAllCosntraints=false) const
 Compares *this with structure index by index (in order) using the function Index::compareWithDummy(). More...
 
bool operator== (const IndexStructure &structure) const
 operator==, compares the IndexStructure to structure in terms of free structure, independently of the dummy indices or the order of free indices. More...
 
bool operator!= (const IndexStructure &structure) const
 operator!=, returns the opposite of IndexStructure::operator==(). More...
 
bool operator|= (const IndexStructure &structure) const
 operator|=, simplicity comparator using comparators between indices, starting by comparing the first ones. More...
 
bool operator &= (const IndexStructure &structure) const
 operator&=, simplicity comparator using comparators between indices, starting by comparing the first ones. More...
 
bool operator< (const IndexStructure &structure) const
 operator<, simplicity comparator using comparators between indices, starting by comparing the first ones. More...
 
bool operator> (const IndexStructure &structure) const
 operator>, simplicity comparator using comparators between indices, starting by comparing the first ones. More...
 
bool operator<= (const IndexStructure &structure) const
 operator<=, simplicity comparator using comparators between indices, starting by comparing the first ones. More...
 
bool operator>= (const IndexStructure &structure) const
 operator>=, simplicity comparator using comparators between indices, starting by comparing the first ones. More...
 
Index operator[] (int i) const
 operator[], accessor to the Index at position i. More...
 
Indexoperator[] (int i)
 operator[], accessor to the Index at position i. More...
 

Friends

std::ostream & operator<< (std::ostream &fout, const IndexStructure &structure)
 Displays the IndexStructure in output /b fout. More...
 

Detailed Description

Manages a std::vector of Index, to be used by an TensorElement.

Constructor & Destructor Documentation

◆ IndexStructure() [1/4]

csl::IndexStructure::IndexStructure ( int  t_nIndices)
inlineexplicit

Constructor that initializes only the size of index.

Parameters
t_nIndicesNumber of indices in the IndexStructure.

◆ IndexStructure() [2/4]

csl::IndexStructure::IndexStructure ( const IndexStructure structure)
inline

Copy constructor.

Parameters
structureIndexStructure to copy in initialization.

◆ IndexStructure() [3/4]

csl::IndexStructure::IndexStructure ( const std::initializer_list< Index > &  structure)
inlineexplicit

Constructor with one parameter: the list of indices in the structure.

Parameters
structureThe list of indices initializating the IndexStructure.

◆ IndexStructure() [4/4]

csl::IndexStructure::IndexStructure ( const std::vector< Index > &  structure)
explicit

Constructor with one parameter: the list of indices in the structure.

Parameters
structureA std::vector of Index initializating the IndexStructure.

Member Function Documentation

◆ compareWithDummy() [1/2]

bool csl::IndexStructure::compareWithDummy ( const IndexStructure structure) const

Compares *this with structure index by index (in order) using the function Index::compareWithDummy().

Parameters
structureIndexStructure to compare.
Returns
True if the two structures are equal wrt Index::compareWithDummy().
False else.

◆ compareWithDummy() [2/2]

bool csl::IndexStructure::compareWithDummy ( const IndexStructure structure,
std::map< Index, Index > &  constraints,
bool  keepAllCosntraints = false 
) const

Compares *this with structure index by index (in order) using the function Index::compareWithDummy().

The map between indices contains matches between dummy indices. Dummy indices can a priori match between each other independently of their names, but one an Index has been matched with another, the pair is put into constraints. This constraints map allows then to compare properly complex expressions containing dummy indices. The map constraints is modified in the function.

Parameters
structureIndexStructure to compare.
constraintsMap of Index to Index storing constraints of correpondance between dummy indices.
Returns
True if the two structures are equal wrt Index::compareWithDummy().
False else.

◆ exactMatch()

bool csl::IndexStructure::exactMatch ( const IndexStructure structure) const

Compares the IndexStructure with structure. Each index must match exactly (see Index::exactMatch()) with the Index at the same place in the second structure.

Parameters
structureIndexStructure to compare.
Returns
True if the two structures match exactly.
False else.

◆ find()

vector< Index >::const_iterator csl::IndexStructure::find ( const Index t_index) const

Search for a particular Index in the structure.

Returns
A const_iterator corresponding to the position of t_index in the structure if it is found.
The const_iterator IndexStructure::end() if t_index is not found.

◆ getFreeStructure()

IndexStructure csl::IndexStructure::getFreeStructure ( ) const
Returns
The part of the vector index that contains free indices.

◆ getIndex() [1/2]

std::vector< Index > const & csl::IndexStructure::getIndex ( ) const
Returns
The entire index vector.

◆ getIndex() [2/2]

std::vector< Index > & csl::IndexStructure::getIndex ( )
Returns
The entire index vector.

◆ getPermutation()

IndexStructure csl::IndexStructure::getPermutation ( const std::vector< int > &  permutation) const
Parameters
permutationstd::vector of integers of the size of the IndexStructure that permutes indices.
Returns
A copy of the IndexStructure where the permutation permutation has been applied.

◆ getSinglePermutation()

IndexStructure csl::IndexStructure::getSinglePermutation ( int  i1,
int  i2 
) const
Returns
A copy of the IndexStructure where indices in places i1 and i2 have been swapped.

◆ operator &=()

bool csl::IndexStructure::operator&= ( const IndexStructure structure) const

operator&=, simplicity comparator using comparators between indices, starting by comparing the first ones.

Parameters
structureIndexStructure to compare.
Returns
True if the two indices have different simplicities.

◆ operator!=()

bool csl::IndexStructure::operator!= ( const IndexStructure structure) const

operator!=, returns the opposite of IndexStructure::operator==().

Parameters
structureIndexStructure to compares
Returns
not IndexStructure::operator==(structure).

◆ operator+()

IndexStructure csl::IndexStructure::operator+ ( const IndexStructure structure) const

operator+, concatenates the current IndexStructure with structure and returns the result.

Parameters
structureIndexStructure with which *this is concatenated.
Returns
The concatenation of *this and structure.

◆ operator+=() [1/2]

IndexStructure & csl::IndexStructure::operator+= ( const Index newIndex)

operator+=, adds an index to the IndexStructure.

Parameters
newIndexIndex to append at the end of the IndexStructure.
Returns
A reference to the modified IndexStructure.

◆ operator+=() [2/2]

IndexStructure & csl::IndexStructure::operator+= ( const IndexStructure structure)

operator+=, adds another IndexStructure at the end of the current. This function concatenates the two structures.

Parameters
structureIndexStructure to concatenate to *this.
Returns
A reference to the modified IndexStructure.

◆ operator<()

bool csl::IndexStructure::operator< ( const IndexStructure structure) const

operator<, simplicity comparator using comparators between indices, starting by comparing the first ones.

Parameters
structureIndexStructure to compare.
Returns
True if *this is simpler than structure.

◆ operator<=()

bool csl::IndexStructure::operator<= ( const IndexStructure structure) const

operator<=, simplicity comparator using comparators between indices, starting by comparing the first ones.

Parameters
structureIndexStructure to compare.
Returns
True if < or |=.

◆ operator=()

IndexStructure& csl::IndexStructure::operator= ( const IndexStructure structure)
default

operator=, Copies the IndexStructure structure. C++ default.

Parameters
structureIndexStructure to copy.
Returns
A reference to the modified IndexStructure.

◆ operator==()

bool csl::IndexStructure::operator== ( const IndexStructure structure) const

operator==, compares the IndexStructure to structure in terms of free structure, independently of the dummy indices or the order of free indices.

Parameters
structureIndexStructure to compare with *this.
Returns
True if the two structures are equivalent, i.e. are compatible as two terms of a sum wrt Einstein's convention.
False else.

◆ operator>()

bool csl::IndexStructure::operator> ( const IndexStructure structure) const

operator>, simplicity comparator using comparators between indices, starting by comparing the first ones.

Parameters
structureIndexStructure to compare.
Returns
True if structure is simpler than *this.

◆ operator>=()

bool csl::IndexStructure::operator>= ( const IndexStructure structure) const

operator>=, simplicity comparator using comparators between indices, starting by comparing the first ones.

Parameters
structureIndexStructure to compare.
Returns
True if > or |=.

◆ operator[]() [1/2]

Index csl::IndexStructure::operator[] ( int  i) const

operator[], accessor to the Index at position i.

Parameters
iPosition of the Index to get.
Returns
A copy of the Index at position i.

◆ operator[]() [2/2]

Index & csl::IndexStructure::operator[] ( int  i)

operator[], accessor to the Index at position i.

Parameters
iPosition of the Index to get.
Returns
A reference to the Index at position i (then modifiable).

◆ operator|=()

bool csl::IndexStructure::operator|= ( const IndexStructure structure) const

operator|=, simplicity comparator using comparators between indices, starting by comparing the first ones.

Parameters
structureIndexStructure to compare.
Returns
True if the two indices have the same simplicity.

◆ setIndex()

void csl::IndexStructure::setIndex ( const Index newIndex,
int  iIndex = 0 
)

Sets the Index in position iIndex to newIndex.

Parameters
newIndexNew Index to place in the IndexStructure.
iIndexPosition where to place newIndex, default 0 if not given by the user.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  fout,
const IndexStructure structure 
)
friend

Displays the IndexStructure in output /b fout.

Parameters
foutOutput flux.
structureIndexStructure to display.
Returns
A reference to the modifed flux fout.

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