glucat 0.12.0
glucat::index_set< LO, HI > Class Template Reference

Index set class based on std::bitset<> in Gnu standard C++ library. More...

#include <index_set.h>

Inheritance diagram for glucat::index_set< LO, HI >:
Collaboration diagram for glucat::index_set< LO, HI >:

Classes

class  reference
 Index set member reference. More...
 

Public Types

using index_set_t = index_set
 
using index_pair_t = std::pair<index_t, index_t>
 

Public Member Functions

 index_set ()=default
 Default constructor creates an empty set.
 
 index_set (const bitset_t bst)
 Constructor from bitset_t.
 
 index_set (const index_t idx)
 Constructor from index.
 
 index_set (const set_value_t folded_val, const index_set_t frm, const bool prechecked=false)
 Constructor from set value of an index set folded within the given frame.
 
 index_set (const index_pair_t &range, const bool prechecked=false)
 Constructor from range of indices from range.first to range.second.
 
 index_set (const std::string &str)
 Constructor from string.
 
auto operator== (const index_set_t rhs) const -> bool
 Equality.
 
auto operator!= (const index_set_t rhs) const -> bool
 Inequality.
 
auto operator~ () const -> index_set_t
 Set complement: not.
 
auto operator^= (const index_set_t rhs) -> index_set_t &
 Symmetric set difference: exclusive or.
 
auto operator&= (const index_set_t rhs) -> index_set_t &
 Set intersection: and.
 
auto operator|= (const index_set_t rhs) -> index_set_t &
 Set union: or.
 
auto operator[] (const index_t idx) const -> bool
 Subscripting: Test idx for membership: test value of bit idx.
 
auto test (const index_t idx) const -> bool
 Test idx for membership: test value of bit idx.
 
auto set () -> index_set_t &
 Include all indices except 0: set all bits except 0.
 
auto set (const index_t idx) -> index_set_t &
 Include idx: Set bit at idx if idx != 0.
 
auto set (const index_t idx, const int val) -> index_set_t &
 Set membership of idx to val if idx != 0: Set bit at idx to val if idx != 0.
 
auto reset () -> index_set_t &
 Make set empty: Set all bits to 0.
 
auto reset (const index_t idx) -> index_set_t &
 Exclude idx: Set bit at idx to 0.
 
auto flip () -> index_set_t &
 Set complement, except 0: flip all bits, except 0.
 
auto flip (const index_t idx) -> index_set_t &
 Complement membership of idx if idx != 0: flip bit at idx if idx != 0.
 
auto count () const -> index_t
 Cardinality: Number of indices included in set.
 
auto count_neg () const -> index_t
 Number of negative indices included in set.
 
auto count_pos () const -> index_t
 Number of positive indices included in set.
 
auto min () const -> index_t
 Minimum member.
 
auto max () const -> index_t
 Maximum member.
 
auto operator< (const index_set_t rhs) const -> bool
 Less than operator used for comparisons, map, etc.
 
auto is_contiguous () const -> bool
 Determine if the index set is contiguous, ie. has no gaps.
 
auto fold () const -> const index_set_t
 Fold this index set within itself as a frame.
 
auto fold (const index_set_t frm, const bool prechecked=false) const -> const index_set_t
 Fold this index set within the given frame.
 
auto unfold (const index_set_t frm, const bool prechecked=false) const -> const index_set_t
 Unfold this index set within the given frame.
 
auto value_of_fold (const index_set_t frm) const -> set_value_t
 The set value of the fold of this index set within the given frame.
 
auto sign_of_mult (const index_set_t ist) const -> int
 Sign of geometric product of two Clifford basis elements.
 
auto sign_of_square () const -> int
 Sign of geometric square of a Clifford basis element.
 
auto hash_fn () const -> size_t
 Hash function.
 
auto operator[] (index_t idx) -> reference
 Subscripting: Element access.
 

Static Public Member Functions

static auto classname () -> const std::string
 

Static Public Attributes

static const index_t v_lo = LO
 
static const index_t v_hi = HI
 

Private Types

using bitset_t = std::bitset<HI - LO>
 
using error_t = error<index_set>
 

Private Member Functions

 BOOST_STATIC_ASSERT ((LO<=0) &&(0<=HI) &&(LO< HI) &&(-LO< _GLUCAT_BITS_PER_ULONG) &&(HI< _GLUCAT_BITS_PER_ULONG) &&(HI-LO<=_GLUCAT_BITS_PER_ULONG))
 
auto lex_less_than (const index_set_t rhs) const -> bool
 Lexicographic ordering of two sets: *this < rhs.
 

Friends

class reference
 
auto operator^ (const index_set_t &lhs, const index_set_t &rhs) -> const index_set_t
 
auto operator& (const index_set_t &lhs, const index_set_t &rhs) -> const index_set_t
 
auto operator| (const index_set_t &lhs, const index_set_t &rhs) -> const index_set_t
 
auto compare (const index_set_t &lhs, const index_set_t &rhs) -> int
 

Detailed Description

template<const index_t LO, const index_t HI>
class glucat::index_set< LO, HI >

Index set class based on std::bitset<> in Gnu standard C++ library.

Definition at line 73 of file index_set.h.

Member Typedef Documentation

◆ bitset_t

template<const index_t LO, const index_t HI>
using glucat::index_set< LO, HI >::bitset_t = std::bitset<HI - LO>
private

Definition at line 81 of file index_set.h.

◆ error_t

template<const index_t LO, const index_t HI>
using glucat::index_set< LO, HI >::error_t = error<index_set>
private

Definition at line 82 of file index_set.h.

◆ index_pair_t

template<const index_t LO, const index_t HI>
using glucat::index_set< LO, HI >::index_pair_t = std::pair<index_t, index_t>

Definition at line 85 of file index_set.h.

◆ index_set_t

template<const index_t LO, const index_t HI>
using glucat::index_set< LO, HI >::index_set_t = index_set

Definition at line 84 of file index_set.h.

Constructor & Destructor Documentation

◆ index_set() [1/6]

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::index_set ( )
default

Default constructor creates an empty set.

Referenced by flip(), fold(), and fold().

◆ index_set() [2/6]

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::index_set ( const bitset_t bst)

Constructor from bitset_t.

Definition at line 61 of file index_set_imp.h.

◆ index_set() [3/6]

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::index_set ( const index_t idx)

Constructor from index.

Constructor from index value.

Definition at line 55 of file index_set_imp.h.

References set().

◆ index_set() [4/6]

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::index_set ( const set_value_t folded_val,
const index_set_t frm,
const bool prechecked = false )

Constructor from set value of an index set folded within the given frame.

Definition at line 68 of file index_set_imp.h.

References count(), fold(), min(), and unfold().

◆ index_set() [5/6]

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::index_set ( const index_pair_t & range,
const bool prechecked = false )

Constructor from range of indices from range.first to range.second.

Definition at line 82 of file index_set_imp.h.

◆ index_set() [6/6]

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::index_set ( const std::string & str)

Constructor from string.

Definition at line 102 of file index_set_imp.h.

Member Function Documentation

◆ BOOST_STATIC_ASSERT()

template<const index_t LO, const index_t HI>
glucat::index_set< LO, HI >::BOOST_STATIC_ASSERT ( (LO<=0) &&(0<=HI) &&(LO< HI) &&(-LO< _GLUCAT_BITS_PER_ULONG) &&(HI< _GLUCAT_BITS_PER_ULONG) &&(HI-LO<=_GLUCAT_BITS_PER_ULONG) )
private

◆ classname()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::classname ( ) -> const std::string
inlinestatic

Definition at line 49 of file index_set_imp.h.

◆ count()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::count ( ) const -> index_t
inline

◆ count_neg()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::count_neg ( ) const -> index_t
inline

Number of negative indices included in set.

Definition at line 364 of file index_set_imp.h.

References count().

Referenced by glucat::framed_multi< Scalar_T, LO, HI, Tune_P >::fast_matrix_multi(), and sign_of_square().

◆ count_pos()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::count_pos ( ) const -> index_t
inline

Number of positive indices included in set.

Definition at line 376 of file index_set_imp.h.

References count().

Referenced by glucat::framed_multi< Scalar_T, LO, HI, Tune_P >::fast_matrix_multi().

◆ flip() [1/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::flip ( ) -> index_set_t&
inline

Set complement, except 0: flip all bits, except 0.

Definition at line 319 of file index_set_imp.h.

References index_set().

◆ flip() [2/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::flip ( const index_t idx) -> index_set_t&
inline

Complement membership of idx if idx != 0: flip bit at idx if idx != 0.

Definition at line 330 of file index_set_imp.h.

◆ fold() [1/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::fold ( ) const -> const index_set_t
inline

Fold this index set within itself as a frame.

Definition at line 747 of file index_set_imp.h.

References fold(), and index_set().

Referenced by fold(), index_set(), and value_of_fold().

◆ fold() [2/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::fold ( const index_set_t frm,
const bool prechecked = false ) const -> const index_set_t

Fold this index set within the given frame.

Definition at line 755 of file index_set_imp.h.

References index_set(), and test().

◆ hash_fn()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::hash_fn ( ) const -> size_t
inline

Hash function.

Definition at line 950 of file index_set_imp.h.

◆ is_contiguous()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::is_contiguous ( ) const -> bool
inline

Determine if the index set is contiguous, ie. has no gaps.

Determine if the index set is contiguous, ie. has no gaps when 0 is included.

Definition at line 732 of file index_set_imp.h.

References count(), max(), and min().

Referenced by glucat::framed_multi< Scalar_T, LO, HI, Tune_P >::fold(), and glucat::framed_multi< Scalar_T, LO, HI, Tune_P >::unfold().

◆ lex_less_than()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::lex_less_than ( const index_set_t rhs) const -> bool
inlineprivate

Lexicographic ordering of two sets: *this < rhs.

Definition at line 588 of file index_set_imp.h.

Referenced by operator<().

◆ max()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::max ( ) const -> index_t

Maximum member.

Maximum member, or 0 if none.

Definition at line 550 of file index_set_imp.h.

References test().

Referenced by PyClical.index_set::__iter__(), glucat::framed_multi< Scalar_T, LO, HI, Tune_P >::framed_multi(), is_contiguous(), and unfold().

◆ min()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::min ( ) const -> index_t

Minimum member.

Minimum member, or 0 if none.

Definition at line 461 of file index_set_imp.h.

References test().

Referenced by PyClical.index_set::__iter__(), glucat::framed_multi< Scalar_T, LO, HI, Tune_P >::framed_multi(), index_set(), is_contiguous(), and unfold().

◆ operator!=()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator!= ( const index_set_t rhs) const -> bool
inline

Inequality.

Definition at line 130 of file index_set_imp.h.

◆ operator&=()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator&= ( const index_set_t rhs) -> index_set_t&
inline

Set intersection: and.

Definition at line 174 of file index_set_imp.h.

◆ operator<()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator< ( const index_set_t rhs) const -> bool
inline

Less than operator used for comparisons, map, etc.

Definition at line 596 of file index_set_imp.h.

References count(), and lex_less_than().

◆ operator==()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator== ( const index_set_t rhs) const -> bool
inline

Equality.

Definition at line 119 of file index_set_imp.h.

◆ operator[]() [1/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator[] ( const index_t idx) const -> bool
inline

Subscripting: Test idx for membership: test value of bit idx.

Definition at line 232 of file index_set_imp.h.

References test().

◆ operator[]() [2/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator[] ( index_t idx) -> reference
inline

Subscripting: Element access.

Definition at line 224 of file index_set_imp.h.

◆ operator^=()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator^= ( const index_set_t rhs) -> index_set_t&
inline

Symmetric set difference: exclusive or.

Definition at line 149 of file index_set_imp.h.

◆ operator|=()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator|= ( const index_set_t rhs) -> index_set_t&
inline

Set union: or.

Definition at line 199 of file index_set_imp.h.

◆ operator~()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::operator~ ( ) const -> index_set_t
inline

Set complement: not.

Definition at line 141 of file index_set_imp.h.

◆ reset() [1/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::reset ( ) -> index_set_t&
inline

Make set empty: Set all bits to 0.

Definition at line 294 of file index_set_imp.h.

◆ reset() [2/2]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::reset ( const index_t idx) -> index_set_t&
inline

Exclude idx: Set bit at idx to 0.

Definition at line 305 of file index_set_imp.h.

◆ set() [1/3]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::set ( ) -> index_set_t&
inline

Include all indices except 0: set all bits except 0.

Definition at line 255 of file index_set_imp.h.

Referenced by index_set().

◆ set() [2/3]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::set ( const index_t idx) -> index_set_t&
inline

Include idx: Set bit at idx if idx != 0.

Definition at line 266 of file index_set_imp.h.

◆ set() [3/3]

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::set ( const index_t idx,
const int val ) -> index_set_t&
inline

Set membership of idx to val if idx != 0: Set bit at idx to val if idx != 0.

Definition at line 280 of file index_set_imp.h.

◆ sign_of_mult()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::sign_of_mult ( const index_set_t ist) const -> int

Sign of geometric product of two Clifford basis elements.

Definition at line 880 of file index_set_imp.h.

References glucat::inverse_gray(), and glucat::inverse_reversed_gray().

◆ sign_of_square()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::sign_of_square ( ) const -> int
inline

Sign of geometric square of a Clifford basis element.

Definition at line 930 of file index_set_imp.h.

References count(), and count_neg().

◆ test()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::test ( const index_t idx) const -> bool
inline

Test idx for membership: test value of bit idx.

Definition at line 240 of file index_set_imp.h.

Referenced by fold(), max(), min(), operator[](), and unfold().

◆ unfold()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::unfold ( const index_set_t frm,
const bool prechecked = false ) const -> const index_set_t

Unfold this index set within the given frame.

Definition at line 794 of file index_set_imp.h.

References max(), min(), and test().

Referenced by index_set().

◆ value_of_fold()

template<const index_t LO, const index_t HI>
auto glucat::index_set< LO, HI >::value_of_fold ( const index_set_t frm) const -> set_value_t
inline

The set value of the fold of this index set within the given frame.

Definition at line 829 of file index_set_imp.h.

References fold().

Friends And Related Symbol Documentation

◆ compare

template<const index_t LO, const index_t HI>
auto compare ( const index_set_t & lhs,
const index_set_t & rhs ) -> int
friend

◆ operator&

template<const index_t LO, const index_t HI>
auto operator& ( const index_set_t & lhs,
const index_set_t & rhs ) -> const index_set_t
friend

◆ operator^

template<const index_t LO, const index_t HI>
auto operator^ ( const index_set_t & lhs,
const index_set_t & rhs ) -> const index_set_t
friend

◆ operator|

template<const index_t LO, const index_t HI>
auto operator| ( const index_set_t & lhs,
const index_set_t & rhs ) -> const index_set_t
friend

◆ reference

template<const index_t LO, const index_t HI>
friend class reference
friend

Definition at line 174 of file index_set.h.

Member Data Documentation

◆ v_hi

template<const index_t LO, const index_t HI>
const index_t glucat::index_set< LO, HI >::v_hi = HI
static

Definition at line 88 of file index_set.h.

◆ v_lo

template<const index_t LO, const index_t HI>
const index_t glucat::index_set< LO, HI >::v_lo = LO
static

Definition at line 87 of file index_set.h.


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