Xped
Loading...
Searching...
No Matches
Pattern.hpp
Go to the documentation of this file.
1#ifndef XPED_PATTERN_H_
2#define XPED_PATTERN_H_
3
4#include <map>
5#include <string>
6#include <vector>
7
8#include "yas/serialize.hpp"
9#include "yas/std_types.hpp"
10
11#include "tabulate/table.hpp"
12
13namespace Xped {
14
15struct UnitCell;
16
17struct Pattern
18{
19 friend struct UnitCell;
20
21 // Pattern(const std::vector<std::vector<std::string>>& pat = {{"a"}})
22 // : data(pat)
23 // {
24 // init();
25 // }
26
27 explicit Pattern(const std::vector<std::vector<std::size_t>>& pat = {{0ul}}, bool TRANSPOSE = false)
28 : data(pat)
29 {
30 // data.resize(TRANSPOSE ? pat[0].size() : pat.size());
31 // for(auto y = 0ul; y < pat.size(); ++y) {
32 // data[y].resize(TRANSPOSE ? pat.size() : pat[y].size());
33 // for(auto x = 0ul; x < pat[y].size(); ++x) { data[y][x] = std::to_string(TRANSPOSE ? pat[x][y] : pat[y][x]); }
34 // }
35 init();
36 }
37
38 void init();
39
40 Pattern row(int x) const;
41 Pattern col(int y) const;
42
43 inline std::size_t uniqueSize() const { return label2index.size(); }
44 inline std::size_t size() const { return Lx * Ly; }
45 std::size_t index(const int x, const int y) const;
46 std::size_t uniqueIndex(const int x, const int y) const;
47 std::size_t uniqueIndex(const std::size_t index) const;
48 std::pair<int, int> coords(const std::size_t index) const;
49 bool isUnique(const int x, const int y) const;
50
51 tabulate::Table print() const;
52
53 template <typename Ar>
54 void serialize(Ar& ar) const
55 {
56 ar& YAS_OBJECT_NVP("Pattern", ("data", data));
57 }
58
59 template <typename Ar>
60 void serialize(Ar& ar)
61 {
62 ar& YAS_OBJECT_NVP("Pattern", ("data", data));
63 init();
64 }
65
66 bool operator==(const Pattern& other) const { return data == other.data; }
67
68 std::map<std::size_t, std::size_t> label2index;
69 std::map<std::size_t, std::size_t> index2unique;
70 std::vector<std::vector<std::size_t>> data;
71 std::map<std::size_t, std::vector<std::size_t>> sites_of_label;
72 std::size_t Lx = 1, Ly = 1;
73};
74
75std::ostream& operator<<(std::ostream& os, const Pattern& pat);
76
77} // namespace Xped
78
79#ifndef XPED_COMPILED_LIB
80# include "PEPS/Pattern.cpp"
81#endif
82
83#endif
Definition: bench.cpp:62
std::ostream & operator<<(std::ostream &os, const FusionTree< depth, Symmetry > &tree)
Definition: FusionTree.hpp:93
Definition: Pattern.hpp:18
std::size_t index(const int x, const int y) const
Definition: Pattern.cpp:53
tabulate::Table print() const
Definition: Pattern.cpp:76
std::vector< std::vector< std::size_t > > data
Definition: Pattern.hpp:70
void init()
Definition: Pattern.cpp:7
std::size_t Ly
Definition: Pattern.hpp:72
Pattern row(int x) const
Definition: Pattern.cpp:46
std::size_t Lx
Definition: Pattern.hpp:72
std::map< std::size_t, std::size_t > label2index
Definition: Pattern.hpp:68
std::size_t uniqueSize() const
Definition: Pattern.hpp:43
Pattern(const std::vector< std::vector< std::size_t > > &pat={{0ul}}, bool TRANSPOSE=false)
Definition: Pattern.hpp:27
Pattern col(int y) const
Definition: Pattern.cpp:39
bool operator==(const Pattern &other) const
Definition: Pattern.hpp:66
std::map< std::size_t, std::vector< std::size_t > > sites_of_label
Definition: Pattern.hpp:71
std::size_t size() const
Definition: Pattern.hpp:44
std::size_t uniqueIndex(const int x, const int y) const
Definition: Pattern.cpp:66
bool isUnique(const int x, const int y) const
Definition: Pattern.cpp:74
void serialize(Ar &ar) const
Definition: Pattern.hpp:54
void serialize(Ar &ar)
Definition: Pattern.hpp:60
std::map< std::size_t, std::size_t > index2unique
Definition: Pattern.hpp:69
std::pair< int, int > coords(const std::size_t index) const
Definition: Pattern.cpp:70
Definition: UnitCell.hpp:15