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

Commit

Permalink
Updating __hash__ and updating gap3 doctests to pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Jan 25, 2023
1 parent 518ecbf commit 3a1a03a
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 64 deletions.
84 changes: 42 additions & 42 deletions src/sage/categories/coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ def braid_group_as_finitely_presented_group(self):
sage: W.braid_group_as_finitely_presented_group()
Finitely presented group < S1, S2 | (S1*S2)^2*(S1^-1*S2^-1)^2 >
sage: W = ReflectionGroup(['B',3], index_set=["AA","BB",5]) # optional - gap3
sage: W.braid_group_as_finitely_presented_group() # optional - gap3
sage: W = ReflectionGroup(['B',3], index_set=["AA","BB","5"]) # optional - gap3
sage: W.braid_group_as_finitely_presented_group() # optional - gap3
Finitely presented group < SAA, SBB, S5 |
SAA*SBB*SAA*SBB^-1*SAA^-1*SBB^-1, SAA*S5*SAA^-1*S5^-1,
(SBB*S5)^2*(SBB^-1*S5^-1)^2 >
(SAA*SBB)^2*(SAA^-1*SBB^-1)^2, SAA*S5*SAA^-1*S5^-1,
SBB*S5*SBB*S5^-1*SBB^-1*S5^-1 >
"""
from sage.groups.free_group import FreeGroup
from sage.misc.misc_c import prod
Expand Down Expand Up @@ -285,25 +285,25 @@ def braid_orbit(self, word):
sage: sorted(W.braid_orbit([2,1,1,2,1]))
[[1, 2, 1, 1, 2], [2, 1, 1, 2, 1], [2, 1, 2, 1, 2], [2, 2, 1, 2, 2]]
sage: W = ReflectionGroup(['A',3], index_set=["AA","BB",5]) # optional - gap3
sage: w = W.long_element() # optional - gap3
sage: W.braid_orbit(w.reduced_word()) # optional - gap3
[['AA', 5, 'BB', 5, 'AA', 'BB'],
['AA', 'BB', 5, 'BB', 'AA', 'BB'],
[5, 'BB', 'AA', 5, 'BB', 5],
['BB', 5, 'AA', 'BB', 5, 'AA'],
[5, 'BB', 5, 'AA', 'BB', 5],
['BB', 5, 'AA', 'BB', 'AA', 5],
[5, 'AA', 'BB', 'AA', 5, 'BB'],
['BB', 'AA', 5, 'BB', 5, 'AA'],
['AA', 'BB', 'AA', 5, 'BB', 'AA'],
[5, 'BB', 'AA', 'BB', 5, 'BB'],
['BB', 'AA', 5, 'BB', 'AA', 5],
[5, 'AA', 'BB', 5, 'AA', 'BB'],
['AA', 'BB', 5, 'AA', 'BB', 'AA'],
['BB', 5, 'BB', 'AA', 'BB', 5],
['AA', 5, 'BB', 'AA', 5, 'BB'],
['BB', 'AA', 'BB', 5, 'BB', 'AA']]
sage: W = ReflectionGroup(['A',3], index_set=["AA","BB","5"]) # optional - gap3
sage: w = W.long_element() # optional - gap3
sage: W.braid_orbit(w.reduced_word()) # optional - gap3
[['BB', '5', 'AA', 'BB', '5', 'AA'],
['5', 'BB', '5', 'AA', 'BB', '5'],
['BB', 'AA', 'BB', '5', 'BB', 'AA'],
['AA', '5', 'BB', 'AA', '5', 'BB'],
['5', 'AA', 'BB', 'AA', '5', 'BB'],
['AA', 'BB', '5', 'AA', 'BB', 'AA'],
['AA', 'BB', 'AA', '5', 'BB', 'AA'],
['AA', 'BB', '5', 'BB', 'AA', 'BB'],
['BB', 'AA', '5', 'BB', 'AA', '5'],
['BB', '5', 'AA', 'BB', 'AA', '5'],
['AA', '5', 'BB', '5', 'AA', 'BB'],
['5', 'BB', 'AA', '5', 'BB', '5'],
['5', 'BB', 'AA', 'BB', '5', 'BB'],
['5', 'AA', 'BB', '5', 'AA', 'BB'],
['BB', '5', 'BB', 'AA', 'BB', '5'],
['BB', 'AA', '5', 'BB', '5', 'AA']]
.. TODO::
Expand Down Expand Up @@ -1608,25 +1608,25 @@ def reduced_words(self):
sage: sorted(w.reduced_words())
[[2, 3, 4, 2], [3, 2, 4, 2], [3, 4, 2, 4]]
sage: W = ReflectionGroup(['A',3], index_set=["AA","BB",5]) # optional - gap3
sage: w = W.long_element() # optional - gap3
sage: w.reduced_words() # optional - gap3
[['AA', 5, 'BB', 5, 'AA', 'BB'],
['AA', 'BB', 5, 'BB', 'AA', 'BB'],
[5, 'BB', 'AA', 5, 'BB', 5],
['BB', 5, 'AA', 'BB', 5, 'AA'],
[5, 'BB', 5, 'AA', 'BB', 5],
['BB', 5, 'AA', 'BB', 'AA', 5],
[5, 'AA', 'BB', 'AA', 5, 'BB'],
['BB', 'AA', 5, 'BB', 5, 'AA'],
['AA', 'BB', 'AA', 5, 'BB', 'AA'],
[5, 'BB', 'AA', 'BB', 5, 'BB'],
['BB', 'AA', 5, 'BB', 'AA', 5],
[5, 'AA', 'BB', 5, 'AA', 'BB'],
['AA', 'BB', 5, 'AA', 'BB', 'AA'],
['BB', 5, 'BB', 'AA', 'BB', 5],
['AA', 5, 'BB', 'AA', 5, 'BB'],
['BB', 'AA', 'BB', 5, 'BB', 'AA']]
sage: W = ReflectionGroup(['A',3], index_set=["AA","BB","5"]) # optional - gap3
sage: w = W.long_element() # optional - gap3
sage: w.reduced_words() # optional - gap3
[['BB', '5', 'AA', 'BB', '5', 'AA'],
['5', 'BB', '5', 'AA', 'BB', '5'],
['BB', 'AA', 'BB', '5', 'BB', 'AA'],
['AA', '5', 'BB', 'AA', '5', 'BB'],
['5', 'AA', 'BB', 'AA', '5', 'BB'],
['AA', 'BB', '5', 'AA', 'BB', 'AA'],
['AA', 'BB', 'AA', '5', 'BB', 'AA'],
['AA', 'BB', '5', 'BB', 'AA', 'BB'],
['BB', 'AA', '5', 'BB', 'AA', '5'],
['BB', '5', 'AA', 'BB', 'AA', '5'],
['AA', '5', 'BB', '5', 'AA', 'BB'],
['5', 'BB', 'AA', '5', 'BB', '5'],
['5', 'BB', 'AA', 'BB', '5', 'BB'],
['5', 'AA', 'BB', '5', 'AA', 'BB'],
['BB', '5', 'BB', 'AA', 'BB', '5'],
['BB', 'AA', '5', 'BB', '5', 'AA']]
.. TODO::
Expand Down
7 changes: 4 additions & 3 deletions src/sage/combinat/root_system/reflection_group_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,11 @@ def _repr_(self):

def iteration_tracking_words(self):
r"""
Return an iterator going through all elements in ``self`` which tracks the reduced expressions.
Return an iterator going through all elements in ``self`` that
tracks the reduced expressions.
This is much slower than using the iteration as a permutation group with strong
generating set.
This can be much slower than using the iteration as a permutation
group with strong generating set.
EXAMPLES::
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/root_system/reflection_group_element.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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
35 changes: 22 additions & 13 deletions src/sage/combinat/root_system/reflection_group_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,21 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
sage: WB_hash.intersection(WC_hash) # optional - gap3
set()
"""
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)
Check that :trac:`34912` is fixed::
sage: G4 = ReflectionGroup(4) # optional - gap3
sage: g0, g1 = G4.gens() # optional - gap3
sage: elt = g0^2 * g1 * g0^2 * g1 # optional - gap3
sage: elt # optional - gap3
(1,12)(2,24)(3,19)(4,22)(5,17)(6,20)(7,23)(8,9)(10,21)(11,13)(14,18)(15,16)
sage: y = (elt * G4.gen(1)) * G4.gen(1) * G4.gen(1) # optional - gap3
sage: elt == y # optional - gap3
True
sage: hash(elt) == hash(y) # optional - gap3
True
"""
return hash(self._parent) | super().__hash__()

def reduced_word(self):
r"""
Expand Down Expand Up @@ -142,7 +149,7 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
EXAMPLES::
sage: W = ReflectionGroup(4) # optional - gap3
sage: for w in W: # optional - gap3
sage: for w in W.iteration_tracking_words(): # optional - gap3
....: print("{} {}".format(w.reduced_word(), w.length()))
[] 0
[1] 1
Expand Down Expand Up @@ -184,9 +191,9 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
EXAMPLES::
sage: W = ReflectionGroup((3,1,2)) # optional - gap3
sage: for w in W: # optional - gap3
....: w.reduced_word() # optional - gap3
sage: W = ReflectionGroup((3,1,2)) # optional - gap3
sage: for w in W.iteration_tracking_words(): # optional - gap3
....: w.reduced_word() # optional - gap3
....: [w.to_matrix(), w.to_matrix(on_space="dual")] # optional - gap3
[]
[
Expand Down Expand Up @@ -531,7 +538,8 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
EXAMPLES::
sage: W = ReflectionGroup(4) # optional - gap3
sage: for w in W: w.reflection_eigenvalues() # optional - gap3
sage: for w in W.iteration_tracking_words(): # optional - gap3
....: w.reflection_eigenvalues()
[0, 0]
[1/3, 0]
[1/3, 0]
Expand Down Expand Up @@ -567,7 +575,8 @@ cdef class ComplexReflectionGroupElement(PermutationGroupElement):
EXAMPLES::
sage: W = ReflectionGroup(4) # optional - gap3
sage: for w in W: print(w.galois_conjugates()) # optional - gap3
sage: for w in W.iteration_tracking_words(): # optional - gap3
....: print(w.galois_conjugates())
[[1 0]
[0 1]]
[[ 1 0]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/reflection_group_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def coxeter_diagram(self):
EXAMPLES::
sage: G = ReflectionGroup(['B',3]) # optional - gap3
sage: sorted(G.coxeter_diagram().edges(labels=True)) # optional - gap3
sage: G.coxeter_diagram().edges(labels=True, sort=True) # optional - gap3
[(1, 2, 4), (2, 3, 3)]
"""
from sage.graphs.graph import Graph
Expand Down
10 changes: 6 additions & 4 deletions src/sage/combinat/subword_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
sage: Q = I + W.w0.coxeter_sorting_word(I)
sage: S = SubwordComplex(Q,W.w0)
sage: S.brick_polytope()
doctest:...: RuntimeWarning: the polytope is build with rational vertices
doctest:...: RuntimeWarning: the polytope is built with rational vertices
A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 32 vertices
AUTHORS:
Expand Down Expand Up @@ -768,7 +768,7 @@ def plot(self, list_colors=None, labels=[], thickness=3, fontsize=14,
sage: Q = c.reduced_word()*2 + W.w0.coxeter_sorting_word(c) # optional - gap3
sage: SC = SubwordComplex(Q, W.w0) # optional - gap3
sage: F = SC[15]; F.plot() # optional - gap3
Graphics object consisting of 52 graphics primitives
Graphics object consisting of 53 graphics primitives
TESTS::
Expand Down Expand Up @@ -1696,7 +1696,7 @@ def minkowski_summand(self, i):
else:
from sage.rings.cc import CC
from warnings import warn
warn("the polytope is build with rational vertices", RuntimeWarning)
warn("the polytope is built with rational vertices", RuntimeWarning)
min_sum = [[QQ(CC(v)) for v in F.extended_weight_configuration()[i]] for F in self]
return Polyhedron(min_sum)

Expand Down Expand Up @@ -1737,6 +1737,8 @@ def brick_polytope(self, coefficients=None):
sage: c = W.index_set(); Q = c + tuple(W.w0.coxeter_sorting_word(c)) # optional - gap3
sage: SC = SubwordComplex(Q,W.w0) # optional - gap3
sage: SC.brick_polytope() # optional - gap3
doctest:...:
RuntimeWarning: the polytope is built with rational vertices
A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 32 vertices
"""
BV = self.brick_vectors(coefficients=coefficients)
Expand All @@ -1747,7 +1749,7 @@ def brick_polytope(self, coefficients=None):
else:
from sage.rings.cc import CC
from warnings import warn
warn("the polytope is build with rational vertices", RuntimeWarning)
warn("the polytope is built with rational vertices", RuntimeWarning)
BV = [[QQ(CC(v).real()) for v in V] for V in BV]
return Polyhedron(BV)

Expand Down

0 comments on commit 3a1a03a

Please sign in to comment.