Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
uni20::QNum Class Reference

One irrep label together with the symmetry context needed to interpret it. More...

#include <qnum.hpp>

Public Member Functions

auto operator== (QNum const &other) const -> bool=default
 Compare two quantum numbers for exact identity.
 
 QNum ()=default
 Construct an invalid quantum number.
 
 QNum (Symmetry sym, std::uint64_t code)
 Construct from a symmetry handle and a 63-bit inline packed code.
 
auto raw_code () const -> std::uint64_t
 Return the inline packed irrep code.
 
auto symmetry () const -> Symmetry
 Return the symmetry context of this quantum number.
 
auto valid () const -> bool
 Return whether the quantum number carries a valid symmetry context.
 

Static Public Member Functions

static auto identity (Symmetry sym) -> QNum
 Return the identity irrep of a given symmetry.
 

Friends

auto coerce (QNum const &, Symmetry) -> QNum
 Coerce a quantum number into a related symmetry by named components.
 
auto degree (QNum const &) -> int
 Return the integral degree of a quantum number.
 
auto dual (QNum const &) -> QNum
 Return the dual irrep of a quantum number.
 
auto is_identity (QNum const &) -> bool
 Return whether a quantum number is the identity irrep.
 
auto make_qnum (Symmetry, std::initializer_list< std::pair< std::string_view, U1 > >) -> QNum
 Construct a packed QNum from named U(1) component values.
 
auto operator+ (QNum const &, QNum const &) -> QNum
 Add two quantum numbers when the fusion result is uniquely defined.
 
auto qdim (QNum const &) -> double
 Return the quantum dimension of a quantum number.
 
auto to_string (QNum const &) -> std::string
 Format a quantum number as comma-separated named components.
 
auto u1_component (QNum const &, std::string_view) -> U1
 Read one named U(1) component from a quantum number.
 

Detailed Description

One irrep label together with the symmetry context needed to interpret it.

QNum is the packed runtime label used by the tensor code. See docs/symmetry/qnum.md.

Constructor & Destructor Documentation

◆ QNum() [1/2]

uni20::QNum::QNum ( )
default

Construct an invalid quantum number.

◆ QNum() [2/2]

uni20::QNum::QNum ( Symmetry  sym,
std::uint64_t  code 
)
inlineexplicit

Construct from a symmetry handle and a 63-bit inline packed code.

Parameters
symSymmetry context.
codeInline packed irrep code. Bit 63 is reserved for an out-of-line representation.

Member Function Documentation

◆ identity()

static auto uni20::QNum::identity ( Symmetry  sym) -> QNum
inlinestatic

Return the identity irrep of a given symmetry.

Parameters
symSymmetry context.
Returns
Identity quantum number.

◆ operator==()

auto uni20::QNum::operator== ( QNum const &  other) const -> bool=default
default

Compare two quantum numbers for exact identity.

Parameters
otherOther quantum number.
Returns
true if both symmetry context and packed code match.

◆ raw_code()

auto uni20::QNum::raw_code ( ) const -> std::uint64_t
inline

Return the inline packed irrep code.

Returns
Canonical code in the low 63 bits.

◆ symmetry()

auto uni20::QNum::symmetry ( ) const -> Symmetry
inline

Return the symmetry context of this quantum number.

Returns
Symmetry handle corresponding to this quantum number.

◆ valid()

auto uni20::QNum::valid ( ) const -> bool
inline

Return whether the quantum number carries a valid symmetry context.

Returns
true if this quantum number is initialized.

Friends And Related Symbol Documentation

◆ coerce

auto coerce ( QNum const &  q,
Symmetry  target 
) -> QNum
friend

Coerce a quantum number into a related symmetry by named components.

Parameters
qSource quantum number.
targetTarget symmetry.
Returns
Coerced quantum number in the target symmetry.

◆ degree

auto degree ( QNum const &  q) -> int
friend

Return the integral degree of a quantum number.

Parameters
qQuantum number to inspect.
Returns
Product of factor degrees.

◆ dual

auto dual ( QNum const &  q) -> QNum
friend

Return the dual irrep of a quantum number.

Parameters
qQuantum number to dualize.
Returns
Dual quantum number in the same symmetry.

◆ is_identity

auto is_identity ( QNum const &  q) -> bool
friend

Return whether a quantum number is the identity irrep.

Parameters
qQuantum number to test.
Returns
true if every factor is the identity.

◆ make_qnum

auto make_qnum ( Symmetry  sym,
std::initializer_list< std::pair< std::string_view, U1 > >  values 
) -> QNum
friend

Construct a packed QNum from named U(1) component values.

Parameters
symTarget symmetry.
valuesNamed component assignments. Missing components default to the identity.
Returns
Packed quantum number in the requested symmetry.

◆ operator+

auto operator+ ( QNum const &  lhs,
QNum const &  rhs 
) -> QNum
friend

Add two quantum numbers when the fusion result is uniquely defined.

Parameters
lhsLeft operand.
rhsRight operand.
Returns
Sum in the shared symmetry context.

◆ qdim

auto qdim ( QNum const &  q) -> double
friend

Return the quantum dimension of a quantum number.

Parameters
qQuantum number to inspect.
Returns
Product of factor quantum dimensions.

◆ to_string

auto to_string ( QNum const &  q) -> std::string
friend

Format a quantum number as comma-separated named components.

Parameters
qQuantum number to format.
Returns
Human-readable string form.

◆ u1_component

auto u1_component ( QNum const &  q,
std::string_view  name 
) -> U1
friend

Read one named U(1) component from a quantum number.

Parameters
qQuantum number to decode.
nameName of the requested symmetry component.
Returns
U(1) charge for that component.

The documentation for this class was generated from the following file: