Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
faster iteration for complex non-real reflection group and new hash
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpc5 committed Jan 18, 2023
1 parent 2114066 commit 498e8db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sage/combinat/root_system/reflection_group_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
from sage.sets.family import Family
from sage.structure.unique_representation import UniqueRepresentation
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
from sage.combinat.permutation import Permutation
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.matrix.all import Matrix, identity_matrix
Expand Down Expand Up @@ -298,6 +299,8 @@ def __init__(self, W_types, index_set=None, hyperplane_index_set=None, reflectio
canonicalize=False,
category=category)

self._length_of_permutation_representation = len(Permutation(self.gens()[0]))

l_set = list(range(1, len(self.gens()) + 1))
if self._index_set is None:
self._index_set = tuple(l_set)
Expand Down Expand Up @@ -366,17 +369,20 @@ def _repr_(self):
type_str = type_str[:-3]
return 'Reducible complex reflection group of rank %s and type %s' % (self._rank, type_str)

def __iter__(self):
def iteration_tracking_words(self):
r"""
Return an iterator going through all elements in ``self``.
Return an iterator going through all elements in ``self`` which tracks the reduced expressions.
This is much slower than using the iteration as a permutation group with strong
generating set.
EXAMPLES::
sage: W = ReflectionGroup((1,1,3)) # optional - gap3
sage: for w in W: w # optional - gap3
sage: for w in W.iteration_tracking_words(): w # optional - gap3
()
(1,3)(2,5)(4,6)
(1,4)(2,3)(5,6)
(1,3)(2,5)(4,6)
(1,6,2)(3,5,4)
(1,2,6)(3,4,5)
(1,5)(2,4)(3,6)
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/root_system/reflection_group_element.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement

cdef class ComplexReflectionGroupElement(PermutationGroupElement):
cpdef test_hash(self)
cpdef action(self, vec, on_space=*)
cpdef action_on_root_indices(self, i)

Expand Down
6 changes: 6 additions & 0 deletions src/sage/combinat/root_system/reflection_group_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
"""
return hash(self._parent) | hash(tuple(self._reduced_word))

cpdef test_hash(self):
cdef int i
cdef int l = self.parent()._length_of_permutation_representation
cdef tuple perm = tuple([self.perm[i] for i in range(l)])
return hash(self._parent) | hash(perm)

def reduced_word(self):
r"""
Return a word in the simple reflections to obtain ``self``.
Expand Down

0 comments on commit 498e8db

Please sign in to comment.