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

Immutable coalesced tensor space represented as unique symmetry blocks. More...

#include <block_space.hpp>

Public Member Functions

auto begin () const
 Return an iterator to the first block.
 
template<std::ranges::input_range Sectors>
requires std::constructible_from<BlockSector, std::ranges::range_reference_t<Sectors>>
 BlockSpace (Symmetry sym, Sectors &&sectors, std::string label={})
 Construct a block space from an input range.
 
 BlockSpace (Symmetry sym, std::initializer_list< BlockSector > sectors, std::string label={})
 Construct a block space from initial blocks.
 
 BlockSpace (Symmetry sym, std::string label={})
 Construct an empty block space tied to one symmetry.
 
auto contains (QNum q) const -> bool
 Return whether a block with the given quantum number exists.
 
auto empty () const -> bool
 Return whether the block space contains no blocks.
 
auto end () const
 Return an iterator past the last block.
 
auto label () const -> std::string const &
 Return the semantic leg label.
 
auto operator== (BlockSpace const &other) const -> bool=default
 Compare two block spaces for exact equality.
 
auto operator[] (std::size_t index) const -> BlockSector const &
 Return indexed block access.
 
auto sectors () const -> std::span< BlockSector const >
 Return the block list as a read-only span.
 
void set_label (std::string label)
 Replace the semantic leg label without changing sector structure.
 
auto size () const -> std::size_t
 Return the number of stored blocks.
 
auto symmetry () const -> Symmetry
 Return the symmetry shared by all blocks.
 
auto total_dim () const -> std::size_t
 Return the total dimension across all blocks.
 

Detailed Description

Immutable coalesced tensor space represented as unique symmetry blocks.

Sector structure is canonicalized at construction. The semantic leg label remains mutable and participates in exact equality.

Constructor & Destructor Documentation

◆ BlockSpace() [1/3]

uni20::BlockSpace::BlockSpace ( Symmetry  sym,
std::string  label = {} 
)
inlineexplicit

Construct an empty block space tied to one symmetry.

Parameters
symSymmetry carried by every block.
labelSemantic leg label.

◆ BlockSpace() [2/3]

uni20::BlockSpace::BlockSpace ( Symmetry  sym,
std::initializer_list< BlockSector >  sectors,
std::string  label = {} 
)
inline

Construct a block space from initial blocks.

Parameters
symSymmetry carried by every block.
sectorsInitial block list.
labelSemantic leg label.

◆ BlockSpace() [3/3]

template<std::ranges::input_range Sectors>
requires std::constructible_from<BlockSector, std::ranges::range_reference_t<Sectors>>
uni20::BlockSpace::BlockSpace ( Symmetry  sym,
Sectors &&  sectors,
std::string  label = {} 
)
inline

Construct a block space from an input range.

Template Parameters
SectorsInput range whose elements construct BlockSector.
Parameters
symSymmetry carried by every block.
sectorsInitial block range.
labelSemantic leg label.

Member Function Documentation

◆ begin()

auto uni20::BlockSpace::begin ( ) const
inline

Return an iterator to the first block.

Returns
Begin iterator.

◆ contains()

auto uni20::BlockSpace::contains ( QNum  q) const -> bool
inline

Return whether a block with the given quantum number exists.

Parameters
qQuantum number to search for.
Returns
true if a matching block exists.

◆ empty()

auto uni20::BlockSpace::empty ( ) const -> bool
inline

Return whether the block space contains no blocks.

Returns
true if there are no blocks.

◆ end()

auto uni20::BlockSpace::end ( ) const
inline

Return an iterator past the last block.

Returns
End iterator.

◆ label()

auto uni20::BlockSpace::label ( ) const -> std::string const&
inline

Return the semantic leg label.

Returns
Label, which may be empty.

◆ operator==()

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

Compare two block spaces for exact equality.

Parameters
otherOther block space.
Returns
true if symmetry, canonical sectors, and label match.

◆ operator[]()

auto uni20::BlockSpace::operator[] ( std::size_t  index) const -> BlockSector const&
inline

Return indexed block access.

Parameters
indexZero-based block index.
Returns
Block at the requested position.

◆ sectors()

auto uni20::BlockSpace::sectors ( ) const -> std::span<BlockSector const>
inline

Return the block list as a read-only span.

Returns
Read-only block span.

◆ set_label()

void uni20::BlockSpace::set_label ( std::string  label)
inline

Replace the semantic leg label without changing sector structure.

Parameters
labelNew label.

◆ size()

auto uni20::BlockSpace::size ( ) const -> std::size_t
inline

Return the number of stored blocks.

Returns
Block count.

◆ symmetry()

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

Return the symmetry shared by all blocks.

Returns
Block-space symmetry.

◆ total_dim()

auto uni20::BlockSpace::total_dim ( ) const -> std::size_t
inline

Return the total dimension across all blocks.

Returns
Sum of all block dimensions.

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