33#include <itertools/itertools.hpp>
45namespace triqs::hilbert_space {
53 using indices_t = std::vector<std::variant<long, std::string, double, std::array<long, 3>>>;
72 std::string
format_indices(
indices_t const &alpha, std::string_view sep =
",", std::string_view prefix =
"", std::string_view suffix =
"");
94 class fundamental_operator_set {
124 for (
int i = 0; i < v.size(); ++i)
125 for (
int j = 0; j < v[i]; ++j)
insert(i, j);
138 for (
auto const &alpha : A)
insert(alpha);
170 for (
auto const &[blname, blsize] :
gf_struct)
171 for (
auto i : itertools::range(blsize))
insert(blname, i);
175 explicit operator data_t()
const {
return idxs_; }
203 [[nodiscard]]
auto size()
const {
return static_cast<int>(idxs_.size()); }
211 [[nodiscard]]
bool has_indices(
indices_t const &alpha)
const {
return std::ranges::find(idxs_, alpha) != idxs_.end(); }
222 auto it = std::ranges::find(idxs_, alpha);
223 if (it == idxs_.end()) {
225 <<
") does not belong to this fundamental set!";
227 return std::distance(idxs_.begin(), it);
231 bool operator==(fundamental_operator_set
const &fops)
const {
return idxs_ == fops.idxs_; }
238 using _enum_iterator =
decltype(itertools::enumerate(std::declval<data_t>()).cbegin());
242 _cdress(_enum_iterator _it) : index(std::get<1>(*_it)), linear_index(static_cast<int>(std::get<0>(*_it))) {}
256 [[nodiscard]]
auto end() const noexcept {
return itertools::enumerate(idxs_).end(); }
259 [[nodiscard]]
auto cend() const noexcept {
return itertools::enumerate(idxs_).cend(); }
gf_struct_t gf_struct() const
Get the block structure.
Class representing a fundamental operator set.
data_t const & data() const
Get the ordered set .
friend void h5_write_attribute(h5::object obj, std::string const &name, fundamental_operator_set const &fops)
Write a triqs::hilbert_space::fundamental_operator_set to HDF5 as an attribute.
friend void h5_read_attribute(h5::object obj, std::string const &name, fundamental_operator_set &fops)
Read a triqs::hilbert_space::fundamental_operator_set from an HDF5 attribute.
std::vector< indices_t > data_t
Container type to store .
void insert(Bs const &...betas)
Insert a new index into the set.
fundamental_operator_set(std::set< IndexType > const &A)
Construct a fundamental operator set from a set of indices .
fundamental_operator_set(data_t v)
Construct a fundamental operator set from a vector of indices .
fundamental_operator_set(std::vector< int > const &v)
Construct a fundamental operator set from a vector of integers .
triqs::hilbert_space::indices_t indices_t
Index type to represent a single .
void insert_from_indices_t(indices_t const &alpha)
Insert a new index into the set.
const_iterator begin() const noexcept
Get a const iterator to the beginning of the set.
bool has_indices(indices_t const &alpha) const
Check if a given is in the set.
auto size() const
Get the number of single particle state indices in the set.
const_iterator cbegin() const noexcept
Get a const iterator to the beginning of the set.
fundamental_operator_set()=default
Default constructor leaves the set of indices empty, i.e. .
auto operator[](indices_t const &alpha) const
Subscript operator to get the position of a given index in the set.
bool operator==(fundamental_operator_set const &fops) const
Equal-to operator compares the ordered sets of indices for equality.
fundamental_operator_set(gf_struct_t const &gf_struct)
Construct a fundamental operator set from a triqs::gfs::gf_struct_t object.
auto cend() const noexcept
Get a const iterator to the end of the set.
auto end() const noexcept
Get a const iterator to the end of the set.
triqs::utility::dressed_iterator< _enum_iterator, _cdress > const_iterator
Constant iterator type.
STL-compatible iterator wrapper that dresses an underlying iterator with a user-defined view type.
TRIQS exception hierarchy and related macros.
Provides the type describing the block structure of a block Green's function.
std::vector< std::pair< std::string, long > > gf_struct_t
Type describing the structure of a block Green's function.
std::vector< std::variant< long, std::string, double, std::array< long, 3 > > > indices_t
Index type for single particle state indices .
std::string format_indices(indices_t const &alpha, std::string_view sep, std::string_view prefix, std::string_view suffix)
String representation of a single particle state index .
#define TRIQS_RUNTIME_ERROR
Throw a triqs::runtime_error with the current source location.
STL-compatible iterator that wraps an underlying iterator and dereferences to a user-supplied dressin...