7#include <unordered_map>
8#include <unordered_set>
10#include "tabulate/table.hpp"
13#include "yas/serialize.hpp"
14#include "yas/std_types.hpp"
37template <
typename Symmetry, std::
size_t depth = 1,
typename AllocationPolicy = HeapPolicy>
40 template <
typename Symmetry_, std::
size_t depth_,
typename AllocationPolicy_>
43 typedef typename Symmetry::qType qType;
46 std::vector<std::tuple<qType, size_t, Basis>,
typename AllocationPolicy::template Allocator<std::tuple<qType, std::size_t, Basis>>>;
47 template <std::
size_t tree_depth>
48 using TreeVector = std::vector<FusionTree<tree_depth, Symmetry>,
typename AllocationPolicy::template Allocator<FusionTree<tree_depth, Symmetry>>>;
49 using TreeType = std::unordered_map<
54 typename AllocationPolicy::template Allocator<
55 std::pair<
const qType,
56 std::vector<FusionTree<depth, Symmetry>,
typename AllocationPolicy::template Allocator<FusionTree<depth, Symmetry>>>>>>;
65 template <
typename Container>
75 inline std::size_t
dim()
const
78 for(
const auto& [qVal, num, plain] : data_) { out += plain.dim(); }
89 for(
const auto& [qVal, num, plain] : data_) { out += plain.dim() * Symmetry::degeneracy(qVal); }
97 inline std::size_t
Nq()
const {
return data_.size(); }
103 qType
getQ(
const size_t& num)
const;
106 inline std::vector<qType>
qs()
const
108 std::vector<qType> out;
109 out.reserve(data_.size());
110 for(
auto triple : data_) { out.push_back(std::get<0>(triple)); }
115 std::unordered_set<qType> out;
116 for(
auto triple : data_) { out.insert(std::get<0>(triple)); }
122 inline std::vector<std::size_t>
dims()
const
124 std::vector<std::size_t> out;
125 out.reserve(data_.size());
126 for(
auto triple : data_) { out.push_back(std::get<2>(triple).
dim()); }
133 bool IS_PRESENT(
const qType& q)
const {
return cfind(q) != data_.end(); }
142 size_t inner_dim(
const size_t& num_in)
const;
150 size_t index(
const qType& q)
const;
156 assert(
index < data_.size());
157 return std::get<0>(data_[
index]);
160 void remove(
const qType& q);
164 auto qs = this->
qs();
165 return *std::max_element(
qs.begin(),
qs.end());
169 auto qs = this->
qs();
170 return *std::min_element(
qs.begin(),
qs.end());
175 void truncate(
const std::unordered_set<qType>&
qs,
const std::size_t& M);
185 void setRandom(
const std::size_t& fullSize,
const std::size_t& max_sectorSize = 5ul);
214 std::string
print()
const;
217 std::string
info()
const;
224 inline auto begin() {
return data_.begin(); }
225 inline auto end() {
return data_.end(); }
227 inline auto cbegin()
const {
return data_.cbegin(); }
228 inline auto cend()
const {
return data_.cend(); }
233 std::vector<std::size_t>
sort();
240 inline const auto&
tree(
const qType& q)
const
242 auto it = trees.find(q);
243 assert(it != trees.end());
249 template <
typename Ar>
252 ar& YAS_OBJECT_NVP(
"Qbasis", (
"data", data_), (
"curr_dim", curr_dim), (
"trees", trees), (
"IS_SORTED", IS_SORTED_), (
"CONJ", CONJ));
256 typename ContainerType::const_iterator cfind(
const qType& q)
const;
258 typename ContainerType::iterator find(
const qType& q);
262 ContainerType data_{};
263 std::size_t curr_dim = 0;
266 bool IS_SORTED_ =
false;
270template <
typename Symmetry, std::
size_t depth,
typename AllocationPolicy>
279#ifndef XPED_COMPILED_LIB
Definition: Qbasis.hpp:39
void serialize(Ar &ar)
Definition: Qbasis.hpp:250
std::size_t fullDim() const
Definition: Qbasis.hpp:86
static Qbasis< Symmetry, 1, AllocationPolicy > TrivialBasis()
Definition: Qbasis.cpp:24
std::vector< std::size_t > sort()
Definition: Qbasis.cpp:304
size_t outer_num(const qType &q) const
Definition: Qbasis.cpp:165
std::string print() const
Definition: Qbasis.cpp:506
qType getQ(const size_t &num) const
Definition: Qbasis.cpp:132
auto cbegin() const
Definition: Qbasis.hpp:227
TreeType & allTrees()
Definition: Qbasis.hpp:247
size_t index(const qType &q) const
Definition: Qbasis.cpp:187
void push_back(const qType &q, const size_t &inner_dim)
Definition: Qbasis.cpp:32
Qbasis< Symmetry, 1, AllocationPolicy > forgetHistory() const
Definition: Qbasis.cpp:408
std::size_t Nq() const
Definition: Qbasis.hpp:97
qType qn(std::size_t index) const
Definition: Qbasis.hpp:154
Qbasis< Symmetry, depth, AllocationPolicy > conj() const
Definition: Qbasis.cpp:416
Qbasis< Symmetry, depth, AllocationPolicy > add(const Qbasis< Symmetry, depth, AllocationPolicy > &other) const
Definition: Qbasis.cpp:351
std::string printTrees() const
Definition: Qbasis.cpp:543
void setRandom(const std::size_t &fullSize, const std::size_t &max_sectorSize=5ul)
Definition: Qbasis.cpp:91
std::string info() const
Definition: Qbasis.cpp:495
std::unordered_set< qType > unordered_qs() const
Definition: Qbasis.hpp:113
size_t full_outer_num(const qType &q) const
Definition: Qbasis.cpp:173
std::pair< std::vector< std::size_t >, Qbasis< Symmetry, depth, AllocationPolicy > > shift(qType qshift) const
Definition: Qbasis.cpp:375
bool IS_SORTED() const
Definition: Qbasis.hpp:235
auto begin()
Definition: Qbasis.hpp:224
size_t leftOffset(const FusionTree< depth, Symmetry > &tree, const std::array< size_t, depth > &plain=std::array< std::size_t, depth >()) const
Definition: Qbasis.cpp:206
std::size_t largestSector() const
Definition: Qbasis.cpp:103
qType maxQ() const
Definition: Qbasis.hpp:162
bool IS_CONJ() const
Definition: Qbasis.hpp:236
Qbasis(const Container &qins, const size_t &dim)
Definition: Qbasis.hpp:66
bool NOT_PRESENT(const qType &q) const
Definition: Qbasis.hpp:135
const auto & tree(const qType &q) const
Definition: Qbasis.hpp:240
size_t inner_num(const size_t &outer_num) const
Definition: Qbasis.cpp:143
void SET_CONJ()
Definition: Qbasis.hpp:238
auto cend() const
Definition: Qbasis.hpp:228
size_t inner_dim(const size_t &num_in) const
Definition: Qbasis.cpp:195
Qbasis< Symmetry, depth+1, AllocationPolicy > combine(const Qbasis< Symmetry, 1, AllocationPolicy > &other, bool CONJ=false) const
Definition: Qbasis.cpp:439
void clear()
Definition: Qbasis.hpp:188
size_t rightOffset(const FusionTree< depth, Symmetry > &tree, const std::array< size_t, depth > &plain=std::array< std::size_t, depth >()) const
Definition: Qbasis.cpp:225
bool operator==(const Qbasis< Symmetry, depth, AllocationPolicy > &other) const
Definition: Qbasis.cpp:331
void remove(const qType &q)
Definition: Qbasis.cpp:247
void truncate(const std::unordered_set< qType > &qs, const std::size_t &M)
Definition: Qbasis.cpp:275
Qbasis< Symmetry, depth, AllocationPolicy > intersection(const Qbasis< Symmetry, depth, AllocationPolicy > &other) const
Definition: Qbasis.cpp:395
qType minQ() const
Definition: Qbasis.hpp:167
std::size_t dim() const
Definition: Qbasis.hpp:75
auto end()
Definition: Qbasis.hpp:225
std::vector< std::size_t > dims() const
Definition: Qbasis.hpp:122
bool IS_PRESENT(const qType &q) const
Definition: Qbasis.hpp:133
std::vector< qType > qs() const
Definition: Qbasis.hpp:106
std::ostream & operator<<(std::ostream &os, const FusionTree< depth, Symmetry > &tree)
Definition: FusionTree.hpp:93
Definition: FusionTree.hpp:24