15#include <initializer_list>
37 this->verify_symmetry();
55 template <std::ranges::input_range Sectors>
56 requires std::constructible_from<BlockSector, std::ranges::range_reference_t<Sectors>>
59 this->append_sectors(std::forward<Sectors>(
sectors));
68 auto size() const ->
std::
size_t {
return sectors_.size(); }
72 auto empty() const ->
bool {
return sectors_.empty(); }
78 return std::accumulate(sectors_.begin(), sectors_.end(), std::size_t{0},
79 [](std::size_t total,
BlockSector const& sector) { return total + sector.dim; });
87 this->verify_symmetry(q);
88 return std::ranges::find(sectors_, q, &
BlockSector::q) != sectors_.end();
102 auto begin()
const {
return sectors_.begin(); }
106 auto end()
const {
return sectors_.end(); }
110 auto label() const ->
std::
string const& {
return label_; }
123 void verify_symmetry()
const
127 throw std::invalid_argument(
"IrregularSpace requires a valid symmetry");
133 void verify_symmetry(
QNum const& q)
const
137 throw std::invalid_argument(
"IrregularSpace block has the wrong symmetry");
144 template <std::ranges::input_range Sectors>
void append_sectors(Sectors&&
sectors)
148 BlockSector sector(std::forward<
decltype(input)>(input));
149 this->verify_symmetry(sector.q);
152 throw std::invalid_argument(
"IrregularSpace blocks must have positive dimension");
154 sectors_.push_back(std::move(sector));
159 std::vector<BlockSector> sectors_;
163static_assert(SymmetrySpace<IrregularSpace>);
Defines one quantum-number sector and its degeneracy dimension.
Ordered block space whose quantum-number sectors may repeat.
Definition irregular_space.hpp:30
auto symmetry() const -> Symmetry
Return the symmetry shared by all blocks.
Definition irregular_space.hpp:64
auto label() const -> std::string const &
Return the semantic leg label.
Definition irregular_space.hpp:110
IrregularSpace(Symmetry sym, Sectors &§ors, std::string label={})
Construct an irregular space from an input range.
Definition irregular_space.hpp:57
auto begin() const
Return an iterator to the first block.
Definition irregular_space.hpp:102
auto end() const
Return an iterator past the last block.
Definition irregular_space.hpp:106
auto total_dim() const -> std::size_t
Return the total dimension across all blocks.
Definition irregular_space.hpp:76
auto sectors() const -> std::span< BlockSector const >
Return the ordered block list.
Definition irregular_space.hpp:98
auto size() const -> std::size_t
Return the number of stored blocks.
Definition irregular_space.hpp:68
auto contains(QNum q) const -> bool
Return whether any block carries the requested quantum number.
Definition irregular_space.hpp:85
auto empty() const -> bool
Return whether the space contains no blocks.
Definition irregular_space.hpp:72
IrregularSpace(Symmetry sym, std::string label={})
Construct an empty irregular space tied to one symmetry.
Definition irregular_space.hpp:35
auto operator[](std::size_t index) const -> BlockSector const &
Return indexed block access.
Definition irregular_space.hpp:94
auto operator==(IrregularSpace const &other) const -> bool=default
Compare symmetry, ordered segmented blocks, and label.
void set_label(std::string label)
Replace the semantic leg label without changing block structure.
Definition irregular_space.hpp:114
IrregularSpace(Symmetry sym, std::initializer_list< BlockSector > sectors, std::string label={})
Construct an irregular space from an ordered block list.
Definition irregular_space.hpp:44
One irrep label together with the symmetry context needed to interpret it.
Definition qnum.hpp:29
auto symmetry() const -> Symmetry
Return the symmetry context of this quantum number.
Definition qnum.hpp:51
auto valid() const -> bool
Return whether the quantum number carries a valid symmetry context.
Definition qnum.hpp:47
Public handle to a canonicalized direct-product symmetry specification.
Definition symmetry.hpp:24
auto valid() const -> bool
Return whether this handle refers to a valid symmetry.
Definition symmetry.hpp:44
Definition async/async.hpp:26
std::size_t span
Definition presentation.cpp:2017
Defines the common tensor-space concepts.
One symmetry sector inside a block-structured space.
Definition block_sector.hpp:18
QNum q
Quantum number carried by the block.
Definition block_sector.hpp:20