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

Generates IndexTrees to be used as loop ranges and memory layout for Properties in the PropertyExtractors. More...

#include <IndexTreeGenerator.h>

Public Member Functions

 IndexTreeGenerator (const Model &model)
 
IndexTree generateAllIndices (const std::vector< Index > &patterns) const
 
IndexTree generateMemoryLayout (const std::vector< Index > &patterns) const
 

Detailed Description

Generates IndexTrees to be used as loop ranges and memory layout for Properties in the PropertyExtractors.

Generate a list of all compatible Index Indices

Assume a Mode with Index structure {x, y, z} and a list of patterns such as

std::vector<Index> patterns = {
{1, IDX_ALL, IDX_SUM_ALL},
{IDX_ALL, 5, IDX_SUM_ALL}
};

We can get an IndexTree that contains all Indices in the Model that are compatible with one of the patterns using

IndexTree allIndices = indexTreeGenerator.generateAllIndices(patterns);

Generate memory layout

A Property that results from summing over one or more Subindices is stored with the flag IDX_SUM_ALL in the Subindex that is summed over. It is possible to generate such an IndexTree using

IndexTree memoryLayout
= indexTreeGenerator.generateMemoryLayout(patterns);

Spin Subindex

If IDX_SPIN is present in a Subindex, it will be preserved just like IDX_SUM_ALL is preserved when generating a mameory layout.

Example

#include "TBTK/Model.h"
#include "TBTK/PropertyExtractor/IndexTreeGenerator.h"
#include "TBTK/TBTK.h"
using namespace TBTK;
using namespace PropertyExtractor;
int main(){
Model model;
for(unsigned int x = 0; x < 2; x++){
for(unsigned int y = 0; y < 2; y++){
for(unsigned int spin = 0; spin < 2; spin++){
model << HoppingAmplitude(
1,
{x, y, spin},
{x, y, spin}
);
}
}
}
model.construct();
IndexTreeGenerator indexTreeGenerator(model);
IndexTree indexTree = indexTreeGenerator.generateAllIndices(
{{1, IDX_ALL, IDX_SUM_ALL}}
);
Streams::out << indexTree << "\n";
indexTree = indexTreeGenerator.generateMemoryLayout(
{{1, IDX_ALL, IDX_SUM_ALL}}
);
Streams::out << indexTree << "\n";
indexTree = indexTreeGenerator.generateAllIndices(
{{1, IDX_SUM_ALL, IDX_SPIN}}
);
Streams::out << indexTree << "\n";
indexTree = indexTreeGenerator.generateMemoryLayout(
{{1, IDX_SUM_ALL, IDX_SPIN}}
);
Streams::out << indexTree << "\n";
indexTree = indexTreeGenerator.generateAllIndices({
{{1, IDX_ALL, IDX_SPIN}, {1, IDX_ALL, IDX_SPIN}}
});
Streams::out << indexTree << "\n";
}

Output

IndexTree
{1, 0, 0}
{1, 0, 1}
{1, 1, 0}
{1, 1, 1}
IndexTree
{1, 0, IDX_SUM_ALL}
{1, 1, IDX_SUM_ALL}
IndexTree
{1, 0, IDX_SPIN}
{1, 1, IDX_SPIN}
IndexTree
{1, IDX_SUM_ALL, IDX_SPIN}
IndexTree
{1, 0, IDX_SPIN}, {1, 0, IDX_SPIN}
{1, 0, IDX_SPIN}, {1, 1, IDX_SPIN}
{1, 1, IDX_SPIN}, {1, 0, IDX_SPIN}
{1, 1, IDX_SPIN}, {1, 1, IDX_SPIN}

Constructor & Destructor Documentation

◆ IndexTreeGenerator()

TBTK::PropertyExtractor::IndexTreeGenerator::IndexTreeGenerator ( const Model model)

Constructs a PropertyExtractor::PropertyExtractor.

Parameters
modelThe Model that the generated IndexTree is compatible with.

Member Function Documentation

◆ generateAllIndices()

IndexTree TBTK::PropertyExtractor::IndexTreeGenerator::generateAllIndices ( const std::vector< Index > &  patterns) const
inline

Generate an IndexTree that contains all the Indices in the Model that satisfies one of the given patterns.

Parameters
patternsIndex patters to match against.
Returns
An IndexTree containing all the Indices in the Model that satisfies the given patterns.

◆ generateMemoryLayout()

IndexTree TBTK::PropertyExtractor::IndexTreeGenerator::generateMemoryLayout ( const std::vector< Index > &  patterns) const
inline

Generate an IndexTree that contains all the Indices in the Model that satisfies one of the given patterns. Subindices marked with IDX_SUM_ALL will keep this flag in the coresponding position.

Parameters
patternsIndex patters to match against.
Returns
An IndexTree containing all the Indices in the Model that satisfies the given patterns.

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