TBTK
TreeNode.h
Go to the documentation of this file.
1 /* Copyright 2016 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_TREE_NODE
24 #define COM_DAFER45_TBTK_TREE_NODE
25 
26 #include <vector>
27 #include "HoppingAmplitude.h"
28 
29 namespace TBTK{
30 
33 class TreeNode{
34 public:
37 
39  int basisSize;
40 
44  std::vector<HoppingAmplitude> hoppingAmplitudes;
45 
48  std::vector<TreeNode> children;
49 
51  TreeNode();
52 
54  void add(HoppingAmplitude ha);
55 
57  const TreeNode* getSubTree(const Index &subspace) const;
58 
62  bool isProperSubspace(const Index &subspace);
63 
66  const std::vector<HoppingAmplitude>* getHAs(Index index) const;
67 
69  int getBasisIndex(const Index &index) const;
70 
72  Index getPhysicalIndex(int basisIndex) const;
73 
76  void generateBasisIndices();
77 
79  void sort(TreeNode *rootNode);
80 
83  void print();
84 
87  class Iterator{
88  public:
90  const TreeNode* tree;
91 
93  std::vector<int> currentIndex;
94 
98 
100  Iterator(const TreeNode *tree);
101 
103  void reset();
104 
106  void searchNextHA();
107 
109  const HoppingAmplitude* getHA() const;
110  private:
113  bool searchNext(const TreeNode *treeNode, unsigned int subindex);
114  };
115 
117  Iterator begin();
118 private:
135  bool isPotentialBlockSeparator;
136 
139  void add(HoppingAmplitude &ha, unsigned int subindex);
140 
143  const TreeNode* getSubTree(
144  const Index &subspace,
145  unsigned int subindex
146  ) const;
147 
150  bool isProperSubspace(const Index &subspace, unsigned int subindex);
151 
154  const std::vector<HoppingAmplitude>* getHAs(
155  Index index,
156  unsigned int subindex
157  ) const;
158 
161  int getBasisIndex(const Index &index, unsigned int subindex) const;
162 
165  void getPhysicalIndex(int basisIndex, std::vector<int> *indices) const;
166 
168  int getMinIndex() const;
169 
171  int getMaxIndex() const;
172 
175  int generateBasisIndices(int i);
176 
179  void print(unsigned int subindex);
180 
183  HoppingAmplitude getFirstHA() const;
184 };
185 
186 }; //End of namespace TBTK
187 
188 #endif
Index getPhysicalIndex(int basisIndex) const
Definition: TreeNode.cpp:233
int basisIndex
Definition: TreeNode.h:36
void generateBasisIndices()
Definition: TreeNode.cpp:294
void sort(TreeNode *rootNode)
Definition: TreeNode.cpp:331
Hopping amplitude from state &#39;from&#39; to &#39;to&#39;.
void reset()
Definition: TreeNode.cpp:349
int currentHoppingAmplitude
Definition: TreeNode.h:97
const HoppingAmplitude * getHA() const
Definition: TreeNode.cpp:445
bool isProperSubspace(const Index &subspace)
Definition: TreeNode.cpp:142
void add(HoppingAmplitude ha)
Definition: TreeNode.cpp:49
int basisSize
Definition: TreeNode.h:39
Definition: HoppingAmplitude.h:42
const std::vector< HoppingAmplitude > * getHAs(Index index) const
Definition: TreeNode.cpp:177
Definition: TreeNode.h:33
std::vector< TreeNode > children
Definition: TreeNode.h:48
Definition: Index.h:44
const TreeNode * tree
Definition: TreeNode.h:90
Iterator begin()
Definition: TreeNode.cpp:457
Definition: AbstractOperator.h:26
std::vector< HoppingAmplitude > hoppingAmplitudes
Definition: TreeNode.h:44
Iterator(const TreeNode *tree)
Definition: TreeNode.cpp:342
TreeNode()
Definition: TreeNode.cpp:31
int getBasisIndex(const Index &index) const
Definition: TreeNode.cpp:205
const TreeNode * getSubTree(const Index &subspace) const
Definition: TreeNode.cpp:109
void print()
Definition: TreeNode.cpp:37
Definition: TreeNode.h:87
std::vector< int > currentIndex
Definition: TreeNode.h:93
void searchNextHA()
Definition: TreeNode.cpp:356