glucat 0.12.0
PyClical.index_set Class Reference
Inheritance diagram for PyClical.index_set:
Collaboration diagram for PyClical.index_set:

Public Member Functions

 __cinit__ (self, other=0)
 
 __dealloc__ (self)
 
 __richcmp__ (lhs, rhs, int, op)
 
 __setitem__ (self, idx, val)
 
 __getitem__ (self, idx)
 
 __contains__ (self, idx)
 
 __iter__ (self)
 
 __invert__ (self)
 
 __xor__ (lhs, rhs)
 
 __ixor__ (self, rhs)
 
 __and__ (lhs, rhs)
 
 __iand__ (self, rhs)
 
 __or__ (lhs, rhs)
 
 __ior__ (self, rhs)
 
 count (self)
 
 count_neg (self)
 
 count_pos (self)
 
 min (self)
 
 max (self)
 
 hash_fn (self)
 
 sign_of_mult (self, rhs)
 
 sign_of_square (self)
 
 __repr__ (self)
 
 __str__ (self)
 

Public Attributes

 instance = new IndexSet((<index_set>other).unwrap())
 

Detailed Description

Return the C++ IndexSet instance wrapped by index_set(obj).
Python class index_set wraps C++ class IndexSet.

Definition at line 46 of file PyClical.pyx.

Member Function Documentation

◆ __and__()

PyClical.index_set.__and__ ( lhs,
rhs )
Set intersection: and.

>>> print(index_set({1}) & index_set({2}))
{}
>>> print(index_set({1,2}) & index_set({2}))
{2}

Definition at line 271 of file PyClical.pyx.

◆ __cinit__()

PyClical.index_set.__cinit__ ( self,
other = 0 )
Construct an object of type index_set.

>>> print(index_set(1))
{1}
>>> print(index_set({1,2}))
{1,2}
>>> print(index_set(index_set({1,2})))
{1,2}
>>> print(index_set({1,2}))
{1,2}
>>> print(index_set({1,2,1}))
{1,2}
>>> print(index_set("{1,2,1}"))
{1,2}
>>> print(index_set(""))
{}

Definition at line 74 of file PyClical.pyx.

◆ __contains__()

PyClical.index_set.__contains__ ( self,
idx )
Check that an index_set object contains the index idx: idx in self.

>>> 1 in index_set({1})
True
>>> 2 in index_set({1})
False
>>> -1 in index_set({2})
False
>>> 1 in index_set({2})
False
>>> 2 in index_set({2})
True
>>> 33 in index_set({2})
False

Definition at line 210 of file PyClical.pyx.

References instance.

◆ __dealloc__()

PyClical.index_set.__dealloc__ ( self)
Clean up by deallocating the instance of C++ class IndexSet.

Definition at line 116 of file PyClical.pyx.

References instance.

◆ __getitem__()

PyClical.index_set.__getitem__ ( self,
idx )
Get the value of an index_set object at an index.

>>> index_set({1})[1]
True
>>> index_set({1})[2]
False
>>> index_set({2})[-1]
False
>>> index_set({2})[1]
False
>>> index_set({2})[2]
True
>>> index_set({2})[33]
False

Definition at line 191 of file PyClical.pyx.

References instance.

◆ __iand__()

PyClical.index_set.__iand__ ( self,
rhs )
Set intersection: and.

>>> x = index_set({1}); x &= index_set({2}); print(x)
{}
>>> x = index_set({1,2}); x &= index_set({2}); print(x)
{2}

Definition at line 282 of file PyClical.pyx.

◆ __invert__()

PyClical.index_set.__invert__ ( self)
Set complement: not.

>>> print(~index_set({-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}))
{-32,-31,-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,-20,-19,-18,-17,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}

Definition at line 240 of file PyClical.pyx.

References instance.

◆ __ior__()

PyClical.index_set.__ior__ ( self,
rhs )
Set union: or.

>>> x = index_set({1}); x |= index_set({2}); print(x)
{1,2}
>>> x = index_set({1,2}); x |= index_set({2}); print(x)
{1,2}

Definition at line 304 of file PyClical.pyx.

◆ __iter__()

PyClical.index_set.__iter__ ( self)
Iterate over the indices of an index_set.

>>> for i in index_set({-3,4,7}):print(i, end=",")
-3,4,7,

Definition at line 229 of file PyClical.pyx.

References glucat::index_set< LO, HI >.max(), glucat::index_set< lo_ndx, hi_ndx >.max(), max(), glucat::index_set< LO, HI >.min(), glucat::index_set< lo_ndx, hi_ndx >.min(), and min().

◆ __ixor__()

PyClical.index_set.__ixor__ ( self,
rhs )
Symmetric set difference: exclusive or.

>>> x = index_set({1}); x ^= index_set({2}); print(x)
{1,2}
>>> x = index_set({1,2}); x ^= index_set({2}); print(x)
{1}

Definition at line 260 of file PyClical.pyx.

◆ __or__()

PyClical.index_set.__or__ ( lhs,
rhs )
Set union: or.

>>> print(index_set({1}) | index_set({2}))
{1,2}
>>> print(index_set({1,2}) | index_set({2}))
{1,2}

Definition at line 293 of file PyClical.pyx.

◆ __repr__()

PyClical.index_set.__repr__ ( self)
The “official” string representation of self.

>>> index_set({1,2}).__repr__()
'index_set({1,2})'
>>> repr(index_set({1,2}))
'index_set({1,2})'

Definition at line 384 of file PyClical.pyx.

References index_set_to_repr().

◆ __richcmp__()

PyClical.index_set.__richcmp__ ( lhs,
rhs,
int,
op )
Compare two objects of class index_set.

>>> index_set(1) == index_set({1})
True
>>> index_set({1}) != index_set({1})
False
>>> index_set({1}) != index_set({2})
True
>>> index_set({1}) == index_set({2})
False
>>> index_set({1}) < index_set({2})
True
>>> index_set({1}) <= index_set({2})
True
>>> index_set({1}) > index_set({2})
False
>>> index_set({1}) >= index_set({2})
False

Definition at line 122 of file PyClical.pyx.

◆ __setitem__()

PyClical.index_set.__setitem__ ( self,
idx,
val )
Set the value of an index_set object at index idx to value val.

>>> s=index_set({1}); s[2] = True; print(s)
{1,2}
>>> s=index_set({1,2}); s[1] = False; print(s)
{2}

Definition at line 179 of file PyClical.pyx.

References instance.

◆ __str__()

PyClical.index_set.__str__ ( self)
The “informal” string representation of self.

>>> index_set({1,2}).__str__()
'{1,2}'
>>> str(index_set({1,2}))
'{1,2}'

Definition at line 395 of file PyClical.pyx.

References index_set_to_str().

◆ __xor__()

PyClical.index_set.__xor__ ( lhs,
rhs )
Symmetric set difference: exclusive or.

>>> print(index_set({1}) ^ index_set({2}))
{1,2}
>>> print(index_set({1,2}) ^ index_set({2}))
{1}

Definition at line 249 of file PyClical.pyx.

◆ count()

PyClical.index_set.count ( self)
Cardinality: Number of indices included in set.

>>> index_set({-1,1,2}).count()
3

Definition at line 315 of file PyClical.pyx.

References count(), and instance.

Referenced by count().

◆ count_neg()

PyClical.index_set.count_neg ( self)
Number of negative indices included in set.

>>> index_set({-1,1,2}).count_neg()
1

Definition at line 324 of file PyClical.pyx.

References count_neg(), and instance.

Referenced by count_neg().

◆ count_pos()

PyClical.index_set.count_pos ( self)
Number of positive indices included in set.

>>> index_set({-1,1,2}).count_pos()
2

Definition at line 333 of file PyClical.pyx.

References count_pos(), and instance.

Referenced by count_pos().

◆ hash_fn()

PyClical.index_set.hash_fn ( self)
Hash function.

Definition at line 360 of file PyClical.pyx.

References hash_fn(), and instance.

Referenced by hash_fn().

◆ max()

PyClical.index_set.max ( self)
Maximum member.

>>> index_set({-1,1,2}).max()
2

Definition at line 351 of file PyClical.pyx.

References instance, and max().

Referenced by __iter__(), and max().

◆ min()

PyClical.index_set.min ( self)
Minimum member.

>>> index_set({-1,1,2}).min()
-1

Definition at line 342 of file PyClical.pyx.

References instance, and min().

Referenced by __iter__(), and min().

◆ sign_of_mult()

PyClical.index_set.sign_of_mult ( self,
rhs )
Sign of geometric product of two Clifford basis elements.

>>> s = index_set({1,2}); t=index_set({-1}); s.sign_of_mult(t)
1

Definition at line 366 of file PyClical.pyx.

References instance, and sign_of_mult().

Referenced by sign_of_mult().

◆ sign_of_square()

PyClical.index_set.sign_of_square ( self)
Sign of geometric square of a Clifford basis element.

>>> s = index_set({1,2}); s.sign_of_square()
-1

Definition at line 375 of file PyClical.pyx.

References instance, and sign_of_square().

Referenced by sign_of_square().

Member Data Documentation

◆ instance


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