TBTK
TBTK::HoppingAmplitudeTree Class Reference

Node in tree used by HoppingAmplitudeSet to store HoppingAmplitudes . More...

#include <HoppingAmplitudeTree.h>

Inheritance diagram for TBTK::HoppingAmplitudeTree:
TBTK::Serializable TBTK::HoppingAmplitudeSet

Classes

class  ConstIterator
 
class  Iterator
 

Public Member Functions

 HoppingAmplitudeTree ()
 
 HoppingAmplitudeTree (const std::vector< unsigned int > &capacity)
 
 HoppingAmplitudeTree (const std::string &serialization, Mode mode)
 
virtual ~HoppingAmplitudeTree ()
 
void add (HoppingAmplitude ha)
 
int getBasisSize () const
 
HoppingAmplitudeTreegetSubTree (const Index &subspace)
 
const HoppingAmplitudeTreegetSubTree (const Index &subspace) const
 
bool isProperSubspace (const Index &subspace) const
 
IndexTree getSubspaceIndices () const
 
Index getSubspaceIndex (const Index &index) const
 
int getFirstIndexInSubspace (const Index &subspaceIndex) const
 
int getLastIndexInSubspace (const Index &subspaceIndex) const
 
const std::vector< HoppingAmplitude > & getHoppingAmplitudes (Index index) const
 
int getBasisIndex (const Index &index) const
 
Index getPhysicalIndex (int basisIndex) const
 
void generateBasisIndices ()
 
std::vector< IndexgetIndexList (const Index &pattern) const
 
void sort (HoppingAmplitudeTree *rootNode)
 
void print ()
 
Iterator begin ()
 
ConstIterator begin () const
 
ConstIterator cbegin () const
 
Iterator end ()
 
ConstIterator end () const
 
ConstIterator cend () const
 
virtual std::string serialize (Mode mode) const
 
unsigned int getSizeInBytes () const
 

Additional Inherited Members

- Public Types inherited from TBTK::Serializable
enum  Mode { Debug, Binary, XML, JSON }
 
- Static Public Member Functions inherited from TBTK::Serializable
static bool hasID (const std::string &serialization, Mode mode)
 
static std::string getID (const std::string &serialization, Mode mode)
 
static std::string extractComponent (const std::string &serialization, const std::string &containerID, const std::string &componentID, const std::string &componentName, Mode mode)
 
- Static Protected Member Functions inherited from TBTK::Serializable
static bool validate (const std::string &serialization, const std::string &id, Mode mode)
 
static std::string getContent (const std::string &serialization, Mode mode)
 
static std::vector< std::string > split (const std::string &content, Mode mode)
 
static std::string serialize (bool b, Mode mode)
 
static void deserialize (const std::string &serialization, bool *b, Mode mode)
 
static std::string serialize (int i, Mode mode)
 
static void deserialize (const std::string &serialization, int *i, Mode mode)
 
static std::string serialize (unsigned int u, Mode mode)
 
static void deserialize (const std::string &serialization, unsigned int *u, Mode mode)
 
static std::string serialize (double d, Mode mode)
 
static void deserialize (const std::string &serialization, double *d, Mode mode)
 
static std::string serialize (std::complex< double > c, Mode mode)
 
static void deserialize (const std::string &serialization, std::complex< double > *c, Mode mode)
 
static std::string serialize (Statistics s, Mode mode)
 
static void deserialize (const std::string &serialization, Statistics *s, Mode mode)
 
static std::string extract (const std::string &serialization, Mode mode, std::string component)
 

Detailed Description

Node in tree used by HoppingAmplitudeSet to store HoppingAmplitudes .

HoppingAmplitudeTree is a tree structure used to build a tree for stroing HoppingAmplitudes . Used by AmplitudeSet.

Constructor & Destructor Documentation

TBTK::HoppingAmplitudeTree::HoppingAmplitudeTree ( )

Constructs a HoppingAmplitudeTree.

TBTK::HoppingAmplitudeTree::HoppingAmplitudeTree ( const std::vector< unsigned int > &  capacity)

Constructs a HoppingAmplitudeTree with a preallocated tree structure such that the addition of HoppingAmplitudes with indices that have the same subindex structure as 'capacity', but with smaller subindices will not cause reallocation for the main tree stucture. Internal containers for HoppingAmplitudes may still be reallocated.

Parameters
capacityThe 'Index capacity'.
TBTK::HoppingAmplitudeTree::HoppingAmplitudeTree ( const std::string &  serialization,
Mode  mode 
)

Constructor. Constructs the HoppingAmplitudeTree from a serialization string.

Parameters
serializationSerialization string from which to construct the Index.
modeMode with which the string has been serialized.
virtual TBTK::HoppingAmplitudeTree::~HoppingAmplitudeTree ( )
virtual

Destructor.

Member Function Documentation

void TBTK::HoppingAmplitudeTree::add ( HoppingAmplitude  ha)

Add a HoppingAmplitude.

Parameters
haHoppingAmplitude to add.
HoppingAmplitudeTree::Iterator TBTK::HoppingAmplitudeTree::begin ( )
inline

Create Iterator.

Returns
Iterator pointing to the first element in the HoppingAmplitudeTree.
HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::begin ( ) const
inline

Create ConstIterator.

Returns
ConstIterator pointing to the first element in the HoppingAmplitudeTree.
HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::cbegin ( ) const
inline

Create ConstIterator.

Returns
ConstIterator pointing to the first element in the HoppingAmplitudeTree.
HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::cend ( ) const
inline

Create ConstIterator pointing to the end.

Returns
ConstIterator pointing to the end of the HoppingAmplitudeTree.
HoppingAmplitudeTree::Iterator TBTK::HoppingAmplitudeTree::end ( )
inline

Create Iterator pointing to the end.

Returns
Iterator pointing to the end of the HoppingAmplitudeTree.
HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::end ( ) const
inline

Create ConstIterator pointing to the end.

Returns
ConstIterator pointing to the end of the HoppingAmplitudeTree.
void TBTK::HoppingAmplitudeTree::generateBasisIndices ( )

Generate Hilbert space indices. No more HoppingAmplitudes should be added after this call.

int TBTK::HoppingAmplitudeTree::getBasisIndex ( const Index index) const

Get Hilbert space basis index for given physical index.

Parameters
indexPhysical Index for which to obtain the Hilbert space index.
Returns
The Hilbert space index corresponding to the given Physical Index. Returns -1 if HoppingAmplitudeTree::generateBasisIndices() has not been called.
int TBTK::HoppingAmplitudeTree::getBasisSize ( ) const
inline

Get basis size.

Returns
The basis size if the basis has been generated using the call to HoppingAmplitudeTree::generateBasisSize(), otherwise -1.
int TBTK::HoppingAmplitudeTree::getFirstIndexInSubspace ( const Index subspaceIndex) const
inline

Get first index in subspace.

Parameters
subspaceIndexThe physical Index of the subspace.
Returns
The first Hilbert space index in the given subspace. If the subspace is empty, -1 is returned.
const std::vector<HoppingAmplitude>& TBTK::HoppingAmplitudeTree::getHoppingAmplitudes ( Index  index) const

Get all HoppingAmplitudes with given 'from'-index.

Parameters
indexFrom-Index.
Returns
All HoppingAmplitudes with the given from-Index.
std::vector<Index> TBTK::HoppingAmplitudeTree::getIndexList ( const Index pattern) const

Generate a list containing the indices in the HoppingAmplitudeTree that satisfies the specified pattern. The indices are ordered in terms of rising Hilbert space indices.

Parameters
patternPattern to match against. IDX_ALL can be used as a wildcard.
Returns
A list of physical indices that match the specified pattern.
int TBTK::HoppingAmplitudeTree::getLastIndexInSubspace ( const Index subspaceIndex) const
inline

Get last index in subspace.

Parameters
subspaceIndexThe physical Index of the subspace.
Returns
The last Hilbert space index in the given subspace. If the subspace is empty, -1 is returned.
Index TBTK::HoppingAmplitudeTree::getPhysicalIndex ( int  basisIndex) const

Get physical Index for given Hilbert space basis index.

Parameters
basisIndexHilbert space index for which to obtain the physical Index.
Returns
The physical Index corresponding to the given Hilbert space index.
unsigned int TBTK::HoppingAmplitudeTree::getSizeInBytes ( ) const
inline

Get size in bytes.

Returns
Memory size required to store the Index.
Index TBTK::HoppingAmplitudeTree::getSubspaceIndex ( const Index index) const

Returns the subspace part of an Index.

Parameters
indexAn Index.
Returns
A new Index containing only the subspace Index of index.
IndexTree TBTK::HoppingAmplitudeTree::getSubspaceIndices ( ) const

Returns an IndexTree containing all proper subspace indices.

Returns
An IndexTree containing all proper subspace indices.
HoppingAmplitudeTree* TBTK::HoppingAmplitudeTree::getSubTree ( const Index subspace)

Get HoppingAmplitudeTree containing the HoppingAmplitudes of the specified subspace. If the original HoppingAMplitudeTree has an Index structure with {subspace, intra subspace indices}, then the new HoppingAmplitudeTree has the Index-structure {intra subspace indices}. This function does not guarantee to return a closed subspace and can contain HoppingAmplitudes to components with other subspace indices if the specified subspace is not a proper subspace. If in doubt, use HoppingAmplitudeTree::isProperSubspace() to check whether a given subspace is a proper subspace before calling this function. Empty subspaces for which no HoppingAmplitudes have been added return empty subspaces.

Parameters
subspaceA number of subindices that when used as leftmost subindices in an Index specifies a subspace.
Returns
A (possibly improper) subspace of the HoppingAmplitudeTree.
const HoppingAmplitudeTree* TBTK::HoppingAmplitudeTree::getSubTree ( const Index subspace) const

Get HoppingAmplitudeTree containing the HoppingAmplitudes of the specified subspace. If the original HoppingAMplitudeTree has an Index structure with {subspace, intra subspace indices}, then the new HoppingAmplitudeTree has the Index-structure {intra subspace indices}. This function does not guarantee to return a closed subspace and can contain HoppingAmplitudes to components with other subspace indices if the specified subspace is not a proper subspace. If in doubt, use HoppingAmplitudeTree::isProperSubspace() to check whether a given subspace is a proper subspace before calling this function. Empty subspaces for which no HoppingAmplitudes have been added return empty subspaces.

Parameters
subspaceA number of subindices that when used as leftmost subindices in an Index specifies a subspace.
Returns
A (possibly improper) subspace of the HoppingAmplitudeTree.
bool TBTK::HoppingAmplitudeTree::isProperSubspace ( const Index subspace) const

Returns true if the subspace is a proper subspace. That is, if the corresponding subtree only contains HoppingAmplitudes that connects states within the subtree (see exception below). Empty subspaces for which no HoppingAmplitudes have been added are considered proper subspaces.

Exception: For a subspace to be considered a proper subspace, each of it subindices needs to completely split the problem into independent parts. For example, for the set of HoppingAmplitudes below, {0, 0, 0} is a proper subspace in the sense that it contains no HoppingAmplitudes to other subspaces. However, the second subindex does not split the problem completely since {0, 0, 1} and {0, 0, 2} belong to the same subspace. In this case {0, 0} therefore is the most specific proper subspace.
HoppingAmplitude(1, {0, 0, 0}, {0, 0, 0});
HoppingAmplitude(1, {0, 0, 1}, {0, 0, 2});
HoppingAmplitude(1, {0, 0, 2}, {0, 0, 1});

Parameters
subspaceA number of subindices that when used as leftmost subindices in an Index specifies a subspace.
Returns
True if the subspace is a proper subspace according to the definition above, otherwise false.
void TBTK::HoppingAmplitudeTree::print ( )

Print HoppingAmplitudes . Mainly for debuging purposes.

virtual std::string TBTK::HoppingAmplitudeTree::serialize ( Mode  mode) const
virtual

Implements Serializable::serialize.

Parameters
modeSerialization mode to use.
Returns
Serialized string represenation of the Index.

Implements TBTK::Serializable.

Reimplemented in TBTK::HoppingAmplitudeSet.

void TBTK::HoppingAmplitudeTree::sort ( HoppingAmplitudeTree rootNode)

Sort HoppingAmplitudes in row order.


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