1 #ifndef _GLUCAT_INDEX_SET_H 2 #define _GLUCAT_INDEX_SET_H 37 #include <boost/static_assert.hpp> 44 template<const index_t LO, const index_t HI>
48 template<const index_t LO, const index_t HI>
54 template<const index_t LO, const index_t HI>
60 template<const index_t LO, const index_t HI>
67 template<const index_t LO, const index_t HI>
72 template<const index_t LO, const index_t HI>
74 private std::bitset<HI-LO>
78 (-LO < _GLUCAT_BITS_PER_ULONG) && \
79 ( HI < _GLUCAT_BITS_PER_ULONG) && \
80 ( HI-LO <= _GLUCAT_BITS_PER_ULONG));
100 index_set (
const index_pair_t& range,
const bool prechecked =
false);
105 bool operator== (
const index_set_t rhs)
const;
107 bool operator!= (
const index_set_t rhs)
const;
111 index_set_t&
operator^= (
const index_set_t rhs);
113 index_set_t&
operator&= (
const index_set_t rhs);
115 index_set_t&
operator|= (
const index_set_t rhs);
123 index_set_t&
set(
const index_t idx);
125 index_set_t&
set(
const index_t idx,
const int val);
127 index_set_t&
reset();
147 bool operator< (
const index_set_t rhs)
const;
151 const index_set_t
fold ()
const;
153 const index_set_t
fold (
const index_set_t frm,
const bool prechecked =
false)
const;
155 const index_set_t
unfold (
const index_set_t frm,
const bool prechecked =
false)
const;
167 friend const index_set_t operator^<> (
const index_set_t& lhs,
const index_set_t& rhs);
168 friend const index_set_t operator&<> (
const index_set_t& lhs,
const index_set_t& rhs);
169 friend const index_set_t operator|<> (
const index_set_t& lhs,
const index_set_t& rhs);
170 friend int compare<> (
const index_set_t& lhs,
const index_set_t& rhs);
192 operator bool ()
const;
209 Default_index_set_too_big_for_value)
237 #endif // _GLUCAT_INDEX_SET_H reference & flip()
for b[i].flip();
int compare(const index_set< LO, HI > &a, const index_set< LO, HI > &b)
"lexicographic compare" eg. {3,4,5} is less than {3,7,8}
bool operator==(const index_set_t rhs) const
Equality.
index_t count_pos() const
Number of positive indices included in set.
const index_set_t fold() const
Fold this index set within itself as a frame.
static const index_t v_hi
const index_set_t unfold(const index_set_t frm, const bool prechecked=false) const
Unfold this index set within the given frame.
error< index_set > error_t
index_t max() const
Maximum member.
int sign_of_square() const
Sign of geometric square of a Clifford basis element.
const Multivector< Scalar_T, LO, HI > operator&(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Inner product.
_GLUCAT_CTAssert(std::numeric_limits< unsigned char >::radix==2, CannotDetermineBitsPerChar) const index_t BITS_PER_CHAR
If radix of unsigned char is not 2, we can't easily determine number of bits from sizeof...
set_value_t value_of_fold(const index_set_t frm) const
The set value of the fold of this index set within the given frame.
index_t count() const
Cardinality: Number of indices included in set.
bool lex_less_than(const index_set_t rhs) const
Lexicographic ordering of two sets: *this < rhs.
static const std::string classname()
index_set_t & operator^=(const index_set_t rhs)
Symmetric set difference: exclusive or.
static const index_t v_lo
reference & operator=(const bool x)
for b[i] = x;
index_t min() const
Minimum member.
const Multivector< Scalar_T, LO, HI > operator^(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Outer product.
bool is_contiguous() const
Determine if the index set is contiguous, ie. has no gaps.
index_set_t operator~() const
Set complement: not.
int sign_of_mult(const index_set_t ist) const
Sign of geometric product of two Clifford basis elements.
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))
bool operator~() const
Flips a bit.
index_t min_neg(const index_set< LO, HI > &ist)
Minimum negative index, or 0 if none.
reference()
Private default constructor is left undefined.
bool operator[](const index_t idx) const
Subscripting: Test idx for membership: test value of bit idx.
index_set_t & operator|=(const index_set_t rhs)
Set union: or.
std::pair< index_t, index_t > index_pair_t
Specific exception class.
index_set_t & flip()
Set complement, except 0: flip all bits, except 0.
bool operator!=(const index_set_t rhs) const
Inequality.
std::bitset< HI-LO > bitset_t
index_set()
Default constructor creates an empty set.
Index set class based on std::bitset<> in Gnu standard C++ library.
Index set member reference.
size_t hash_fn() const
Hash function.
const Multivector< Scalar_T, LO, HI > operator|(const Multivector< Scalar_T, LO, HI > &lhs, const RHS< Scalar_T, LO, HI > &rhs)
Transformation via twisted adjoint action.
index_t max_pos(const index_set< LO, HI > &ist)
Maximum positive index, or 0 if none.
index_set_t & reset()
Make set empty: Set all bits to 0.
int index_t
Size of index_t should be enough to represent LO, HI.
unsigned long set_value_t
Size of set_value_t should be enough to contain index_set<LO,HI>
index_set_t & operator&=(const index_set_t rhs)
Set intersection: and.
index_t count_neg() const
Number of negative indices included in set.
bool test(const index_t idx) const
Test idx for membership: test value of bit idx.