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

Index object that is used for indicial objects. More...

#include <index.h>

Public Types

using ID_type = unsigned int
 

Public Member Functions

 Index ()
 Default constructor.
 
 Index (const std::string &t_name, unsigned short t_id=0)
 Constructor that initializes only the name of the Index. More...
 
 Index (char value)
 
 Index (const Index &index)=default
 Copy constructor = C++ default. More...
 
 Index (const std::string &t_name, const Space *t_space, unsigned short t_id=0)
 Constructor that initializes fully the Index. More...
 
 ~Index ()
 Destructor.
 
std::string_view getName () const
 
std::string getIndexCodeName () const
 
ID_type getID () const
 
char getValue () const
 
bool getSign () const
 
bool getFree () const
 
cslIndex::Type getType () const
 
int getMax () const
 
const SpacegetSpace () const
 
Index rename () const
 
Index getFlipped () const
 
void setName (const std::string &t_name)
 
void setID (ID_type t_id)
 
void setSpace (const Space *t_space)
 Changes the current space of the Index. More...
 
void setValue (char t_value)
 Sets the value of the Index and therefore sets its type to cslIndex::Fixed. More...
 
void setSign (bool t_sign)
 
void flipSign ()
 
void setFree (bool t_free)
 
void setType (cslIndex::Type t_type)
 
bool testContraction (const Index &t_index) const
 Tests if the Index can be contracted with t_index. Basically, returns true if the two indices are free and contractible with respect to Einstein's conventions. More...
 
void print () const
 Prints the Index in standard output.
 
std::string printLaTeX () const
 Returns the LaTeX name of the Index (for now there is no difference with the regular name).
 
void printDefinition (std::ostream &out, int indentSize) const
 
Indexoperator= (const Index &index)=default
 operator=, copy the properties of index in the current object. More...
 
Indexoperator= (int t_value)
 Sets the value of the Index. See Index::setValue(). More...
 
bool compareWithDummy (const Index &t_index) const
 Equivalent to Index::operator==() except for dummy indices for which the name does not count in the comparison. More...
 
bool compareWithoutSign (const Index &t_index) const
 Tells if two indices are equal, independently of their sign if they live in a signed Space. For now equivalent to Index::operator==(). More...
 
bool exactMatch (const Index &t_index) const
 Tells if two indices are equal, taking their sign into account, differently from the Index::compareWithoutSign() function. More...
 
Indexoperator++ ()
 
Index operator++ (int)
 
bool operator== (const Index &t_index) const
 operator==, compares two indices and tells if they are equal, independently of their sign, i.e. two indices are equals if they have the same name, space, and type. Equivalent to Index::compareWithoutSign() More...
 
bool operator== (int value) const
 operator==, compares two indices and tells if they are equal, independently of their sign, i.e. two indices are equals if they have the same name, space, and type. Equivalent to Index::compareWithoutSign() More...
 
bool operator== (size_t value) const
 operator==, compares two indices and tells if they are equal, independently of their sign, i.e. two indices are equals if they have the same name, space, and type. Equivalent to Index::compareWithoutSign() More...
 
bool operator!= (const Index &t_index) const
 operator!=, opposite of the operator!= More...
 
bool operator!= (int value) const
 
bool operator!= (size_t value) const
 
bool operator|= (const Index &index) const
 operator|=, simplicity comparator. More...
 
bool operator &= (const Index &index) const
 operator&=, simplicity comparator. More...
 
bool operator< (const Index &index) const
 operator<, simplicity comparator. More...
 
bool operator> (const Index &index) const
 operator>, simplicity comparator. More...
 
bool operator<= (const Index &index) const
 operator<=, simplicity comparator. More...
 
bool operator>= (const Index &index) const
 operator>=, simplicity comparator. More...
 

Friends

std::ostream & operator<< (std::ostream &fout, const Index &index)
 operator<<, displays the Index index in output fout. More...
 

Detailed Description

Index object that is used for indicial objects.

Constructor & Destructor Documentation

◆ Index() [1/3]

csl::Index::Index ( const std::string &  t_name,
unsigned short  t_id = 0 
)
explicit

Constructor that initializes only the name of the Index.

Parameters
t_nameName of the Index.

◆ Index() [2/3]

csl::Index::Index ( const Index index)
default

Copy constructor = C++ default.

Parameters
indexIndex to copy.

◆ Index() [3/3]

csl::Index::Index ( const std::string &  t_name,
const Space t_space,
unsigned short  t_id = 0 
)

Constructor that initializes fully the Index.

Parameters
t_nameName if the Index.
t_spaceSpace in which the Index lives.

Member Function Documentation

◆ compareWithDummy()

bool csl::Index::compareWithDummy ( const Index t_index) const

Equivalent to Index::operator==() except for dummy indices for which the name does not count in the comparison.

Parameters
t_indexIndex to compare.
Returns
True if the two indices are equal (to a renaming for dummy indices).
False else.

◆ compareWithoutSign()

bool csl::Index::compareWithoutSign ( const Index t_index) const

Tells if two indices are equal, independently of their sign if they live in a signed Space. For now equivalent to Index::operator==().

Parameters
t_indexIndex to compare.
Returns
True if the two indices are equal (independently of their sign).
False else.

◆ exactMatch()

bool csl::Index::exactMatch ( const Index t_index) const

Tells if two indices are equal, taking their sign into account, differently from the Index::compareWithoutSign() function.

Parameters
t_indexIndex to compare.
Returns
True if the two indices are strictly equal.
False else.

◆ getFlipped()

Index csl::Index::getFlipped ( ) const
Returns
A copy of the Index with a flipped sign if the Space is signed.

◆ getFree()

bool csl::Index::getFree ( ) const
inline
Returns
True if the Index is free.
False else.

◆ getMax()

int csl::Index::getMax ( ) const
Returns
The dimension of the Space in which the Index lives.

◆ getSign()

bool csl::Index::getSign ( ) const
inline
Returns
The sign of the Index.

◆ getSpace()

const Space* csl::Index::getSpace ( ) const
inline
Returns
The Space in which the Index lives.

◆ getType()

cslIndex::Type csl::Index::getType ( ) const
inline
Returns
The type of the Index.

◆ getValue()

char csl::Index::getValue ( ) const
inline
Returns
The value of the Index if it has one (value).
-1 else.

◆ operator &=()

bool csl::Index::operator&= ( const Index index) const

operator&=, simplicity comparator.

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

◆ operator!=()

bool csl::Index::operator!= ( const Index t_index) const

operator!=, opposite of the operator!=

Parameters
t_indexIndex to compare.
Returns
not (operator==(t_index)).

◆ operator<()

bool csl::Index::operator< ( const Index index) const

operator<, simplicity comparator.

Parameters
indexIndex to compare.
Returns
True if *this is simpler than index.

◆ operator<=()

bool csl::Index::operator<= ( const Index index) const

operator<=, simplicity comparator.

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

◆ operator=() [1/2]

Index& csl::Index::operator= ( const Index index)
default

operator=, copy the properties of index in the current object.

Parameters
indexIndex to copy.
Returns
A reference to the current Index.

◆ operator=() [2/2]

Index & csl::Index::operator= ( int  t_value)

Sets the value of the Index. See Index::setValue().

Parameters
t_valueNew value for the Index.
Returns
A reference to the modified Index.

◆ operator==() [1/3]

bool csl::Index::operator== ( const Index t_index) const

operator==, compares two indices and tells if they are equal, independently of their sign, i.e. two indices are equals if they have the same name, space, and type. Equivalent to Index::compareWithoutSign()

Parameters
t_indexIndex to compare.
Returns
True if the two indices are equal independantly of their sign.
False else.

◆ operator==() [2/3]

bool csl::Index::operator== ( int  value) const

operator==, compares two indices and tells if they are equal, independently of their sign, i.e. two indices are equals if they have the same name, space, and type. Equivalent to Index::compareWithoutSign()

Parameters
t_indexIndex to compare.
Returns
True if the two indices are equal independantly of their sign.
False else.

◆ operator==() [3/3]

bool csl::Index::operator== ( size_t  value) const

operator==, compares two indices and tells if they are equal, independently of their sign, i.e. two indices are equals if they have the same name, space, and type. Equivalent to Index::compareWithoutSign()

Parameters
t_indexIndex to compare.
Returns
True if the two indices are equal independantly of their sign.
False else.

◆ operator>()

bool csl::Index::operator> ( const Index index) const

operator>, simplicity comparator.

Parameters
indexIndex to compare.
Returns
True if index is simpler than *this.

◆ operator>=()

bool csl::Index::operator>= ( const Index index) const

operator>=, simplicity comparator.

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

◆ operator|=()

bool csl::Index::operator|= ( const Index index) const

operator|=, simplicity comparator.

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

◆ setFree()

void csl::Index::setFree ( bool  t_free)
Parameters
t_freeSets the free-property of the Index. Free = true, Dummy = false.

◆ setName()

void csl::Index::setName ( const std::string &  t_name)
Parameters
t_nameNew name for the Index.

◆ setSign()

void csl::Index::setSign ( bool  t_sign)
Parameters
t_signNew sign for the Index.

◆ setSpace()

void csl::Index::setSpace ( const Space t_space)

Changes the current space of the Index.

Parameters
t_spaceNew space for the Index.

◆ setType()

void csl::Index::setType ( cslIndex::Type  t_type)
Parameters
t_typeSets the type of the Index.

◆ setValue()

void csl::Index::setValue ( char  t_value)

Sets the value of the Index and therefore sets its type to cslIndex::Fixed.

Parameters
t_valueNew value for the Index.

◆ testContraction()

bool csl::Index::testContraction ( const Index t_index) const

Tests if the Index can be contracted with t_index. Basically, returns true if the two indices are free and contractible with respect to Einstein's conventions.

Parameters
t_indexIndex with which we test the contraction.
Returns

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  fout,
const Index index 
)
friend

operator<<, displays the Index index in output fout.

Parameters
foutOutput flow.
indexIndex to display.
Returns
The output flow modified.

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