32 constexpr U1() =
default;
40 template <std::
integral T>
constexpr U1(T
value) : value_(
value) {}
44 template <std::
floating_po
int T>
explicit U1(T
value) : value_(
value) {}
69 static_cast<void>(
value);
78 static_cast<void>(
value);
86inline constexpr auto operator+(
U1 lhs,
U1 rhs) ->
U1 {
return U1{lhs.
value() + rhs.value()}; }
116namespace uni20::detail
120template <>
struct SymmetryFactorTraits<
uni20::U1>
124 static constexpr auto type_name() -> std::string_view {
return "U(1)"; }
131 auto const twice_value =
value.value().twice();
132 if (twice_value == 0)
138 auto const magnitude =
static_cast<std::uint64_t
>(twice_value);
142 if (twice_value == std::numeric_limits<half_int::value_type>::min())
144 throw std::overflow_error(
"U1 encoding cannot represent the most negative half_int value");
147 auto const magnitude =
static_cast<std::uint64_t
>(-twice_value);
154 static constexpr auto decode(std::uint64_t code) ->
uni20::U1
160 if ((code & 1U) != 0U)
170inline auto u1_factor() -> SymmetryFactor<uni20::U1>
const&
172 static SymmetryFactor<uni20::U1> factor;
173 static auto const* registered = register_symmetry_factor(&factor);
174 static_cast<void>(registered);
179inline void register_builtin_symmetry_factors() {
static_cast<void>(u1_factor()); }
183template <
typename CharT>
struct std::formatter<
uni20::U1, CharT>
185 constexpr auto parse(std::basic_format_parse_context<CharT>& ctx) {
return ctx.begin(); }
193template <>
struct std::hash<
uni20::U1>
200 return std::hash<uni20::half_int>{}(
value.value());
Value-level quantum number type representing one U(1) irrep.
Definition u1.hpp:29
constexpr auto value() const -> half_int
Return the stored U(1) charge.
Definition u1.hpp:48
constexpr U1(T value)
Construct from an integral U(1) charge.
Definition u1.hpp:40
constexpr U1()=default
Construct the scalar U(1) irrep.
constexpr auto operator<=>(U1 const &other) const =default
Compare two U(1) irreps by charge.
U1(T value)
Construct from a floating-point U(1) charge by rounding to the nearest half-integer.
Definition u1.hpp:44
constexpr U1(half_int value)
Construct from a half-integer U(1) charge.
Definition u1.hpp:36
T value_type
Underlying signed storage type.
Definition half_int.hpp:37
locale_t value
Definition data_table.cpp:49
Defines basic_half_int<T>, a signed integer type with half-integer resolution.
DiagnosticMagnitude< R > magnitude(R const &value)
Definition gmres_diagnostics.hpp:98
Definition async/async.hpp:26
auto operator<<(std::ostream &out, basic_half_int< T > value) -> std::ostream &
Stream a half-integer in integer or .5 decimal form.
Definition half_int.hpp:515
auto degree(QNum const &q) -> int
Return the integral degree of a quantum number.
Definition qnum.hpp:270
constexpr auto operator-(basic_half_int< T > lhs, basic_half_int< T > rhs) -> basic_half_int< T >
Subtract two half-integer values.
Definition half_int.hpp:345
auto qdim(QNum const &q) -> double
Return the quantum dimension of a quantum number.
Definition qnum.hpp:255
constexpr auto from_twice(T twice_value) -> basic_half_int< T >
Construct a half-integer from its doubled representation.
Definition half_int.hpp:322
auto to_string_fraction(basic_half_int< T > value) -> std::string
Format a half-integer as an integer or n/2.
Definition half_int.hpp:464
auto dual(SpaceType const &space) -> Dual< std::remove_cvref_t< SpaceType > >
Construct an explicitly dual basis without changing occurrence order.
Definition dual_space.hpp:244
auto to_string(basic_half_int< T > value) -> std::string
Format a half-integer as an integer or decimal .5.
Definition half_int.hpp:477
auto operator()(uni20::U1 const &value) const noexcept -> std::size_t
Hash a U(1) irrep by its stored half-integer charge.
Definition u1.hpp:198
Defines the internal runtime interface for concrete symmetry-factor adapters.