14#include <initializer_list>
35 this->verify_symmetry();
45 this->append_qnums(
qnums);
53 template <std::ranges::input_range QNums>
54 requires std::constructible_from<QNum, std::ranges::range_reference_t<QNums>>
57 this->append_qnums(std::forward<QNums>(
qnums));
65 this->append_qnums(
qnums);
74 auto size() const ->
std::
size_t {
return qnums_.size(); }
78 auto empty() const ->
bool {
return qnums_.empty(); }
83 auto operator[](std::size_t index)
const ->
QNum const& {
return qnums_[index]; }
91 auto begin()
const {
return qnums_.begin(); }
95 auto end()
const {
return qnums_.end(); }
99 auto label() const ->
std::
string const& {
return label_; }
112 void verify_symmetry()
const
116 throw std::invalid_argument(
"LocalSpace requires a valid symmetry");
123 template <std::ranges::input_range QNums>
void append_qnums(QNums&&
qnums)
125 for (
auto&& input :
qnums)
127 QNum q(std::forward<
decltype(input)>(input));
128 if (!q.valid() || q.symmetry() != sym_)
130 throw std::invalid_argument(
"LocalSpace state has the wrong symmetry");
132 qnums_.push_back(std::move(q));
137 std::vector<QNum> qnums_;
141static_assert(SymmetrySpace<LocalSpace>);
Ordered local-state space whose quantum numbers may repeat.
Definition local_space.hpp:28
auto operator==(LocalSpace const &other) const -> bool=default
Compare symmetry, ordered local states, and label.
auto label() const -> std::string const &
Return the semantic leg label.
Definition local_space.hpp:99
LocalSpace(Symmetry sym, QNums &&qnums, std::string label={})
Construct a local space from an input range.
Definition local_space.hpp:55
auto size() const -> std::size_t
Return the number of explicit local states.
Definition local_space.hpp:74
auto begin() const
Return an iterator to the first local state.
Definition local_space.hpp:91
LocalSpace(QNumList const &qnums, std::string label={})
Construct an immutable local space from a QNumList.
Definition local_space.hpp:63
LocalSpace(Symmetry sym, std::initializer_list< QNum > qnums, std::string label={})
Construct a local space from an initializer list.
Definition local_space.hpp:42
void set_label(std::string label)
Replace the semantic leg label without changing the space structure.
Definition local_space.hpp:103
auto symmetry() const -> Symmetry
Return the symmetry shared by every local state.
Definition local_space.hpp:70
auto operator[](std::size_t index) const -> QNum const &
Return indexed local-state access.
Definition local_space.hpp:83
auto qnums() const -> std::span< QNum const >
Return the ordered local-state quantum numbers.
Definition local_space.hpp:87
LocalSpace(Symmetry sym, std::string label={})
Construct an empty local space in an explicit symmetry.
Definition local_space.hpp:33
auto empty() const -> bool
Return whether the local space has no states.
Definition local_space.hpp:78
auto end() const
Return an iterator past the last local state.
Definition local_space.hpp:95
Explicit sparse tensor space represented as quantum numbers with one shared symmetry.
Definition qnum.hpp:102
One irrep label together with the symmetry context needed to interpret it.
Definition qnum.hpp:29
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 packed quantum numbers and same-symmetry quantum-number containers.
Defines the common tensor-space concepts.