TBTK
Public Member Functions | Friends | List of all members
TBTK::Index Class Reference

#include <Index.h>

Public Member Functions

 Index (std::initializer_list< int > i)
 
 Index (std::vector< int > i)
 
 Index (const Index &index)
 
 Index (const Index &head, const Index &tail)
 
bool equals (const Index &index, bool allowWildcard=false) const
 
int & at (unsigned int n)
 
const int & at (unsigned int n) const
 
unsigned int size () const
 
void push_back (int subindex)
 
int popFront ()
 
int popBack ()
 
Index getUnitRange ()
 
Index getSubIndex (int first, int last)
 
void print () const
 
std::string toString () const
 

Friends

bool operator< (const Index &i1, const Index &i2)
 
bool operator> (const Index &i1, const Index &i2)
 

Detailed Description

Flexible physical index for indexing arbitrary models. Each index can contain an arbitrary number of subindices. For example {x, y, spin}, {x, y, z, orbital, spin}, and {subsystem, x, y, z, orbital, spin}.

Constructor & Destructor Documentation

TBTK::Index::Index ( std::initializer_list< int >  i)
inline

Constructor.

TBTK::Index::Index ( std::vector< int >  i)
inline

Constructor.

TBTK::Index::Index ( const Index index)
inline

Copy constructor.

TBTK::Index::Index ( const Index head,
const Index tail 
)

Constructor. Concatenates two indices into one total index of the form {head, tail}.

Member Function Documentation

int & TBTK::Index::at ( unsigned int  n)
inline

Get subindex n.

const int & TBTK::Index::at ( unsigned int  n) const
inline

Get subindex n. Constant version.

bool TBTK::Index::equals ( const Index index,
bool  allowWildcard = false 
) const
inline

Compare this index with another index. Returns true if the indices have the same number of subindices and all subindices are equal.

Parameters
indexIndex to compare with.
allowWildcardIDX_ALL is interpreted as wildcard.
Index TBTK::Index::getSubIndex ( int  first,
int  last 
)

Returns an Index containing the subindices from position 'first' to 'last'.

Index TBTK::Index::getUnitRange ( )

Returns an index with the same number or subindices, and each subindex set to 1.

int TBTK::Index::popBack ( )
inline

Removes and returns the last subindex.

int TBTK::Index::popFront ( )
inline

Removes and returns the first subindex.

void TBTK::Index::print ( ) const
inline

Print index. Mainly for debuging.

void TBTK::Index::push_back ( int  subindex)
inline

Push subindex at the back of the index.

unsigned int TBTK::Index::size ( ) const
inline

Get size.

std::string TBTK::Index::toString ( ) const
inline

Print index. Mainly for debuging.

Friends And Related Function Documentation

bool operator< ( const Index i1,
const Index i2 
)
friend

Comparison operator. Returns false if the TreeNode structure would generate a smaller Hilbert space index for i1 than for i2.

bool operator> ( const Index i1,
const Index i2 
)
friend

Comparison operator. Returns false if the TreeNode structure would generate a larger Hilbert space index for i1 than for i2.


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