Skip to content

Commit 498e8db

Browse files
committed
faster iteration for complex non-real reflection group and new hash
1 parent 2114066 commit 498e8db

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/sage/combinat/root_system/reflection_group_complex.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
from sage.sets.family import Family
206206
from sage.structure.unique_representation import UniqueRepresentation
207207
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
208+
from sage.combinat.permutation import Permutation
208209
from sage.rings.integer_ring import ZZ
209210
from sage.rings.rational_field import QQ
210211
from sage.matrix.all import Matrix, identity_matrix
@@ -298,6 +299,8 @@ def __init__(self, W_types, index_set=None, hyperplane_index_set=None, reflectio
298299
canonicalize=False,
299300
category=category)
300301

302+
self._length_of_permutation_representation = len(Permutation(self.gens()[0]))
303+
301304
l_set = list(range(1, len(self.gens()) + 1))
302305
if self._index_set is None:
303306
self._index_set = tuple(l_set)
@@ -366,17 +369,20 @@ def _repr_(self):
366369
type_str = type_str[:-3]
367370
return 'Reducible complex reflection group of rank %s and type %s' % (self._rank, type_str)
368371

369-
def __iter__(self):
372+
def iteration_tracking_words(self):
370373
r"""
371-
Return an iterator going through all elements in ``self``.
374+
Return an iterator going through all elements in ``self`` which tracks the reduced expressions.
375+
376+
This is much slower than using the iteration as a permutation group with strong
377+
generating set.
372378
373379
EXAMPLES::
374380
375381
sage: W = ReflectionGroup((1,1,3)) # optional - gap3
376-
sage: for w in W: w # optional - gap3
382+
sage: for w in W.iteration_tracking_words(): w # optional - gap3
377383
()
378-
(1,3)(2,5)(4,6)
379384
(1,4)(2,3)(5,6)
385+
(1,3)(2,5)(4,6)
380386
(1,6,2)(3,5,4)
381387
(1,2,6)(3,4,5)
382388
(1,5)(2,4)(3,6)

src/sage/combinat/root_system/reflection_group_element.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement
22

33
cdef class ComplexReflectionGroupElement(PermutationGroupElement):
4+
cpdef test_hash(self)
45
cpdef action(self, vec, on_space=*)
56
cpdef action_on_root_indices(self, i)
67

src/sage/combinat/root_system/reflection_group_element.pyx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
7474
"""
7575
return hash(self._parent) | hash(tuple(self._reduced_word))
7676

77+
cpdef test_hash(self):
78+
cdef int i
79+
cdef int l = self.parent()._length_of_permutation_representation
80+
cdef tuple perm = tuple([self.perm[i] for i in range(l)])
81+
return hash(self._parent) | hash(perm)
82+
7783
def reduced_word(self):
7884
r"""
7985
Return a word in the simple reflections to obtain ``self``.

0 commit comments

Comments
 (0)