TBTK
Need a break? Support the development by playing Polarity Puzzles
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
 
std::vector< IndexgetIndexListMultiplePatterns (const std::vector< Index > &patterns) 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
 
- Public Member Functions inherited from TBTK::Serializable
template<>
std::string serialize (const bool &data, Mode mode)
 
template<>
std::string serialize (const double &data, Mode mode)
 
template<>
std::string serialize (const std::complex< double > &data, Mode mode)
 
template<>
std::string serialize (const int &data, Mode mode)
 
template<>
std::string serialize (const unsigned int &data, Mode mode)
 
template<>
std::string serialize (const SpinMatrix &data, Mode mode)
 
template<>
std::string serialize (const Statistics &data, Mode mode)
 
template<>
std::string serialize (const std::vector< std::complex< double >> &data, Mode mode)
 
template<>
int deserialize (const std::string &serialization, Mode mode)
 
template<>
unsigned int deserialize (const std::string &serialization, Mode mode)
 
template<>
double deserialize (const std::string &serialization, Mode mode)
 
template<>
std::complex< double > deserialize (const std::string &serialization, Mode mode)
 
template<>
SpinMatrix deserialize (const std::string &serialization, Mode mode)
 
template<>
Statistics deserialize (const std::string &serialization, Mode mode)
 
template<>
std::vector< std::complex< double > > deserialize (const std::string &serialization, Mode mode)
 

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)
 
template<typename DataType >
static std::enable_if<!std::is_pointer< DataType >::value, std::string >::type serialize (const DataType &data, Mode mode)
 
template<typename DataType >
static std::enable_if< std::is_pointer< DataType >::value, std::string >::type serialize (const DataType &data, Mode mode)
 
template<typename DataType >
static DataType deserialize (const std::string &serialization, 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

◆ HoppingAmplitudeTree() [1/3]

TBTK::HoppingAmplitudeTree::HoppingAmplitudeTree ( )

Constructs a HoppingAmplitudeTree.

◆ HoppingAmplitudeTree() [2/3]

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'.

◆ HoppingAmplitudeTree() [3/3]

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.

◆ ~HoppingAmplitudeTree()

virtual TBTK::HoppingAmplitudeTree::~HoppingAmplitudeTree ( )
virtual

Destructor.

Member Function Documentation

◆ add()

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

Add a HoppingAmplitude.

Parameters
haHoppingAmplitude to add.

◆ begin() [1/2]

HoppingAmplitudeTree::Iterator TBTK::HoppingAmplitudeTree::begin ( )
inline

Create Iterator.

Returns
Iterator pointing to the first element in the HoppingAmplitudeTree.

◆ begin() [2/2]

HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::begin ( ) const
inline

Create ConstIterator.

Returns
ConstIterator pointing to the first element in the HoppingAmplitudeTree.

◆ cbegin()

HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::cbegin ( ) const
inline

Create ConstIterator.

Returns
ConstIterator pointing to the first element in the HoppingAmplitudeTree.

◆ cend()

HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::cend ( ) const
inline

Create ConstIterator pointing to the end.

Returns
ConstIterator pointing to the end of the HoppingAmplitudeTree.

◆ end() [1/2]

HoppingAmplitudeTree::Iterator TBTK::HoppingAmplitudeTree::end ( )
inline

Create Iterator pointing to the end.

Returns
Iterator pointing to the end of the HoppingAmplitudeTree.

◆ end() [2/2]

HoppingAmplitudeTree::ConstIterator TBTK::HoppingAmplitudeTree::end ( ) const
inline

Create ConstIterator pointing to the end.

Returns
ConstIterator pointing to the end of the HoppingAmplitudeTree.

◆ generateBasisIndices()

void TBTK::HoppingAmplitudeTree::generateBasisIndices ( )

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

◆ getBasisIndex()

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.

◆ getBasisSize()

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.

◆ getFirstIndexInSubspace()

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.

◆ getHoppingAmplitudes()

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.

◆ getIndexList()

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.

◆ getIndexListMultiplePatterns()

std::vector<Index> TBTK::HoppingAmplitudeTree::getIndexListMultiplePatterns ( const std::vector< Index > &  patterns) const

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

Parameters
patternsPatterns to match against. IDX_ALL can be used as a wildcard.
Returns
A list of physical indices that match the specified patterns.

◆ getLastIndexInSubspace()

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.

◆ getPhysicalIndex()

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.

◆ getSizeInBytes()

unsigned int TBTK::HoppingAmplitudeTree::getSizeInBytes ( ) const
inline

Get size in bytes.

Returns
Memory size required to store the Index.

◆ getSubspaceIndex()

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.

◆ getSubspaceIndices()

IndexTree TBTK::HoppingAmplitudeTree::getSubspaceIndices ( ) const

Returns an IndexTree containing all proper subspace indices.

Returns
An IndexTree containing all proper subspace indices.

◆ getSubTree() [1/2]

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.

◆ getSubTree() [2/2]

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.

◆ isProperSubspace()

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.

◆ print()

void TBTK::HoppingAmplitudeTree::print ( )

Print HoppingAmplitudes . Mainly for debuging purposes.

◆ serialize()

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.

◆ sort()

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

Sort HoppingAmplitudes in row order.


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