TBTK
Need a break? Support the development by playing Polarity Puzzles
TBTK::HoppingAmplitudeSet Class Reference

HoppingAmplitude container. More...

#include <HoppingAmplitudeSet.h>

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

Classes

class  ConstIterator
 
class  Iterator
 

Public Member Functions

 HoppingAmplitudeSet ()
 
 HoppingAmplitudeSet (const std::vector< unsigned int > &capacity)
 
 HoppingAmplitudeSet (const std::string &serializeation, Mode mode)
 
virtual ~HoppingAmplitudeSet ()
 
void construct ()
 
bool getIsConstructed () const
 
int getFirstIndexInBlock (const Index &blockIndex) const
 
int getLastIndexInBlock (const Index &blockIndex) const
 
IndexTree getIndexTree () const
 
IndexTree getIndexTree (const Index &subspace) const
 
SparseMatrix< std::complex< double > > getSparseMatrix () const
 
Iterator begin ()
 
ConstIterator begin () const
 
ConstIterator cbegin () const
 
Iterator begin (const Index &subspace)
 
ConstIterator begin (const Index &subspace) const
 
ConstIterator cbegin (const Index &subspace) const
 
Iterator end ()
 
ConstIterator end () const
 
ConstIterator cend () const
 
Iterator end (const Index &subspace)
 
ConstIterator end (const Index &subspace) const
 
ConstIterator cend (const Index &subspace) const
 
void print ()
 
void tabulate (std::complex< double > **amplitudes, int **indices, int *numHoppingAmplitudes, int *maxIndexSize) const
 
virtual std::string serialize (Mode mode) const
 
unsigned int getSizeInBytes () const
 
void add (HoppingAmplitude ha)
 
const std::vector< HoppingAmplitude > & getHoppingAmplitudes (Index index) const
 
int getBasisIndex (const Index &index) const
 
Index getPhysicalIndex (int basisIndex) const
 
int getBasisSize () const
 
bool isProperSubspace (const Index &subspace) const
 
IndexTree getSubspaceIndices () const
 
Index getSubspaceIndex (const Index &index) const
 
std::vector< IndexgetIndexList (const Index &pattern) const
 
std::vector< IndexgetIndexListMultiplePatterns (const std::vector< Index > &patterns) 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)
 

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

HoppingAmplitude container.

A HoppingAmplitudeSet is a container for HoppingAmplitudes . The structure contains the root node for the tree structure in which the HoppingAmplitudes are stored, as well as functions for adding and accessing HoppingAmplitudes. Once all HoppingAmplitudes have been added to the HoppingAmplitudeSet, the construct method has to be called in order to construct an appropriate Hilbert space. The HoppingAmplitudeSet is most importantly used by the Model to store the Hamiltonian.

Constructor & Destructor Documentation

◆ HoppingAmplitudeSet() [1/3]

TBTK::HoppingAmplitudeSet::HoppingAmplitudeSet ( )

Constructs a HoppingAmplitudeSet.

◆ HoppingAmplitudeSet() [2/3]

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

Constructs a HoppingAmplitudeSet with a preallocated storage 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 storage structure. Internal containers for HoppingAmplitudes may still be reallocated.

Parameters
capacity'Index capacity'.

◆ HoppingAmplitudeSet() [3/3]

TBTK::HoppingAmplitudeSet::HoppingAmplitudeSet ( const std::string &  serializeation,
Mode  mode 
)

Constructor. Constructs the HoppingAmplitudeSet from a serialization string.

Parameters
serializationSerialization string from which to construct the HoppingAmplitudeSet.
modeMode with which the string has been serialized.

◆ ~HoppingAmplitudeSet()

virtual TBTK::HoppingAmplitudeSet::~HoppingAmplitudeSet ( )
virtual

Destructor.

Member Function Documentation

◆ add()

void TBTK::HoppingAmplitudeTree::add

Add a HoppingAmplitude.

Parameters
haHoppingAmplitude to add.

◆ begin() [1/4]

HoppingAmplitudeSet::ConstIterator TBTK::HoppingAmplitudeSet::begin ( )
inline

Create Iterator.

Returns
Iterator pointing to the first element in the HoppingAmplitudeSet.

◆ begin() [2/4]

ConstIterator TBTK::HoppingAmplitudeSet::begin ( ) const

Create ConstIterator.

Returns
ConstIterator pointing to the first element in the HoppingAmplitudeSet.

◆ begin() [3/4]

HoppingAmplitudeSet::Iterator TBTK::HoppingAmplitudeSet::begin ( const Index subspace)
inline

Create Iterator for a particular subspace.

Parameters
Indexfor the subspace the Iterator is to be iterating over.
Returns
Iterator pointing to the first element in the HoppingAmplitudeSet.

◆ begin() [4/4]

HoppingAmplitudeSet::ConstIterator TBTK::HoppingAmplitudeSet::begin ( const Index subspace) const
inline

Create ConstIterator for a particular subspace.

Parameters
Indexfor the subspace the ConstIterator is to be iterating over.
Returns
ConstIterator pointing to the first element in the HoppingAmplitudeSet.

◆ cbegin() [1/2]

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

Create ConstIterator.

Returns
ConstIterator pointing to the first element in the HoppingAmplitudeSet.

◆ cbegin() [2/2]

HoppingAmplitudeSet::ConstIterator TBTK::HoppingAmplitudeSet::cbegin ( const Index subspace) const
inline

Create ConstIterator for a particular subspace.

Parameters
Indexfor the subspace the ConstIterator is to be iterating over.
Returns
ConstIterator pointing to the first element in the HoppingAmplitudeSet.

◆ cend() [1/2]

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

Create ConstIterator pointing to the end.

Returns
ConstIterator pointing to the end of the HoppingAmplitudeSet.

◆ cend() [2/2]

HoppingAmplitudeSet::ConstIterator TBTK::HoppingAmplitudeSet::cend ( const Index subspace) const
inline

Create ConstIterator pointing to the end for a particular subspace.

Parameters
Indexfor the subspace the ConstIterator is to be iterating over.
Returns
ConstIterator pointing to the end of the HoppingAmplitudeSet.

◆ construct()

void TBTK::HoppingAmplitudeSet::construct ( )
inline

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

◆ end() [1/4]

HoppingAmplitudeSet::ConstIterator TBTK::HoppingAmplitudeSet::end ( )
inline

Create Iterator pointing to the end.

Returns
Iterator pointing to the end of the HoppingAmplitudeSet.

◆ end() [2/4]

ConstIterator TBTK::HoppingAmplitudeSet::end ( ) const

Create ConstIterator pointing to the end.

Returns
ConstIterator pointing to the end of the HoppingAmplitudeSet.

◆ end() [3/4]

HoppingAmplitudeSet::Iterator TBTK::HoppingAmplitudeSet::end ( const Index subspace)
inline

Create Iterator pointing to the end for a particular subspace.

Parameters
Indexfor the subspace the Iterator is to be iterating over.
Returns
Iterator pointing to the end of the HoppingAmplitudeSet.

◆ end() [4/4]

HoppingAmplitudeSet::ConstIterator TBTK::HoppingAmplitudeSet::end ( const Index subspace) const
inline

Create ConstIterator pointing to the end for a particular subspace.

Parameters
Indexfor the subspace the ConstIterator is to be iterating over.
Returns
ConstIterator pointing to the end of the HoppingAmplitudeSet.

◆ getBasisIndex()

int TBTK::HoppingAmplitudeTree::getBasisIndex

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
inline

Get basis size.

Returns
The basis size if the basis has been generated using the call to HoppingAmplitudeTree::generateBasisSize(), otherwise -1.

◆ getFirstIndexInBlock()

int TBTK::HoppingAmplitudeSet::getFirstIndexInBlock ( const Index blockIndex) const
inline

Get first index in block.

Parameters
subspaceIndexThe physical Index of the subspace.
Returns
The first Hilbert space index in the given subspace. If the subspace is emtpy, -1 is returned.

◆ getHoppingAmplitudes()

const std::vector<HoppingAmplitude>& TBTK::HoppingAmplitudeTree::getHoppingAmplitudes

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

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

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.

◆ getIndexTree() [1/2]

IndexTree TBTK::HoppingAmplitudeSet::getIndexTree ( ) const

Get an IndexTree containing all the Indices that are contained in the HoppingAmplitudeSet.

Returns
An IndexTree containing all the Indices that are contained in the HoppingAmplitudeSet.

◆ getIndexTree() [2/2]

IndexTree TBTK::HoppingAmplitudeSet::getIndexTree ( const Index subspace) const

Get an IndexTree containing all the Indices that are contained in the given subspace of the HoppingAmplitudeSet.

Parameters
subspaceThe subspaec to get the IndexTree for.
Returns
An IndexTree containing all the Indices that are contained in the given subspace of the HoppingAmplitudeSet.

◆ getIsConstructed()

bool TBTK::HoppingAmplitudeSet::getIsConstructed ( ) const
inline

Check whether the Hilbert space basis has been constructed.

Returns
True if the Hilbert space basis has been constructed.

◆ getLastIndexInBlock()

int TBTK::HoppingAmplitudeSet::getLastIndexInBlock ( const Index blockIndex) const
inline

Get last index in block.

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

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::HoppingAmplitudeSet::getSizeInBytes ( ) const
inline

Get size in bytes.

◆ getSparseMatrix()

SparseMatrix< std::complex< double > > TBTK::HoppingAmplitudeSet::getSparseMatrix ( ) const
inline

Get a sprase matrix corresponding to the HoppingAMplitudeSet. The basis of the matrix is the Hilbert space basis.

Returns
A sparse matrix representation of the HoppingAmplitudeSet.

◆ getSubspaceIndex()

Index TBTK::HoppingAmplitudeTree::getSubspaceIndex

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

Returns an IndexTree containing all proper subspace indices.

Returns
An IndexTree containing all proper subspace indices.

◆ isProperSubspace()

bool TBTK::HoppingAmplitudeTree::isProperSubspace

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::HoppingAmplitudeSet::print ( )

Print tree structure. Mainly for debuging.

◆ serialize()

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

Implements Serializable::serialize().

Reimplemented from TBTK::HoppingAmplitudeTree.

◆ tabulate()

void TBTK::HoppingAmplitudeSet::tabulate ( std::complex< double > **  amplitudes,
int **  indices,
int *  numHoppingAmplitudes,
int *  maxIndexSize 
) const

Tabulates HoppingAmplitudes to make them possible to export.

Parameters
amplitudesPointer to amplitude table pointer. Memory will be allocated and has to be freed by the user. The array will contain all the HoppingAmplitude values when the function returns.
tablePointer to index table pointer. Memory will be allocated and has to be freed by the user. The array will contain the 'to'- and 'from'-indices for the corresponding HoppingAmplitude values in amplitudes. The values are stored sequentially using the format [to0] [padding] [from0] [padding] [to1] ..., where the padding is added to align 'to'- and 'from'-indices in memory in case multiple index sizes are encounterd. The number of padding elements will be zero for indices of size maxIndexSize and the padding value is -1. The total array size is 2*numHoppingAmplitudes*maxIndexSize.
numHoppingAmplitudesPointer to int that will contain the number of HoppingAMplitudes when the function returns.
maxIndexSizePointer to int that will contain the maximum number of subindices encountered.

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