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

Commit

Permalink
Making CoxeterGroup.reflections return a Family and some touchups.
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Scrimshaw committed Feb 9, 2016
1 parent 90b278a commit 8c9b809
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 50 deletions.
4 changes: 3 additions & 1 deletion src/sage/combinat/subword_complex_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cpdef _flip_c(W, set positions, list extended_root_conf_indices,
3
"""
cdef int r, nr_ref, r_minus, j, k
cdef list R
r = extended_root_conf_indices[i]
nr_ref = len(W.long_element(as_word=True))
r_minus = (r + nr_ref) % (2 * nr_ref) # get the negative root -r
Expand All @@ -42,8 +43,9 @@ cpdef _flip_c(W, set positions, list extended_root_conf_indices,
break
positions.remove(i)
positions.add(j)
R = list(W.reflections())
if j != i:
t = W.reflections()[min(r, r_minus)]
t = R[min(r, r_minus)]
for k in range(min(i, j) + 1, max(i, j) + 1):
extended_root_conf_indices[k] = t.action_on_root_indices(extended_root_conf_indices[k])
return j
Expand Down
120 changes: 71 additions & 49 deletions src/sage/groups/matrix_gps/coxeter_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,53 @@ def simple_reflection(self, i):
return self.gen(self.index_set().index(i))

@cached_method
def positive_roots(self, as_reflections=False):
def _positive_roots_reflections(self):
"""
Return a family whose keys are the positive roots
and values are the reflections.
EXAMPLES::
sage: W = CoxeterGroup(['A', 2])
sage: F = W._positive_roots_reflections()
sage: F.keys()
[(1, 0), (1, 1), (0, 1)]
sage: list(F)
[
[-1 1] [ 0 -1] [ 1 0]
[ 0 1], [-1 0], [ 1 -1]
]
"""
if not self.is_finite():
raise NotImplementedError('not available for infinite groups')

word = self.long_element(as_word=True)
N = len(word)

from sage.modules.free_module import FreeModule
simple_roots = FreeModule(self.base_ring(), self.ngens()).gens()

refls = self.simple_reflections()
resu = []
d = {}
for i in range(1, N + 1):
segment = word[:i]
last = segment.pop()
ref = refls[last]
rt = simple_roots[last - 1]
while segment:
last = segment.pop()
cr = refls[last]
ref = cr * ref * cr
rt = refls[last] * rt
rt.set_immutable()
resu += [rt]
d[rt] = ref
from sage.sets.family import Family
return Family(resu, lambda rt: d[rt])

@cached_method
def positive_roots(self, as_reflections=None):
"""
Return the positive roots.
Expand All @@ -631,8 +677,6 @@ def positive_roots(self, as_reflections=False):
base of simple roots, also taken to have all the same
norm.
This can also be used to obtain the associated reflections.
.. SEEALSO::
:meth:`reflections`
Expand All @@ -641,43 +685,20 @@ def positive_roots(self, as_reflections=False):
sage: W = CoxeterGroup(['A',3], implementation='reflection')
sage: W.positive_roots()
[(1, 0, 0), (1, 1, 0), (0, 1, 0), (1, 1, 1), (0, 1, 1), (0, 0, 1)]
((1, 0, 0), (1, 1, 0), (0, 1, 0), (1, 1, 1), (0, 1, 1), (0, 0, 1))
sage: W = CoxeterGroup(['I',5], implementation='reflection')
sage: W.positive_roots()
[(1, 0),
((1, 0),
(-E(5)^2 - E(5)^3, 1),
(-E(5)^2 - E(5)^3, -E(5)^2 - E(5)^3),
(1, -E(5)^2 - E(5)^3),
(0, 1)]
(0, 1))
"""
if not self.is_finite():
raise NotImplementedError('not available for infinite groups')
if as_reflections is not None:
from sage.misc.superseded import deprecation
deprecation(20027, "as_reflections is deprecated; instead, use reflections()")
return tuple(self._positive_roots_reflections().keys())

word = self.long_element(as_word=True)
N = len(word)

if not as_reflections:
from sage.modules.free_module import FreeModule
simple_roots = FreeModule(self.base_ring(), self.ngens()).gens()

refls = self.simple_reflections()
resu = []
for i in range(1, N + 1):
segment = word[:i]
if as_reflections:
rt = refls[segment.pop()]
else:
rt = simple_roots[segment.pop() - 1]
while segment:
if as_reflections:
cr = refls[segment.pop()]
rt = cr * rt * cr
else:
rt = refls[segment.pop()] * rt
resu += [rt]
return resu

@cached_method
def reflections(self):
"""
Return the set of reflections.
Expand All @@ -687,15 +708,15 @@ def reflections(self):
EXAMPLES::
sage: W = CoxeterGroup(['A',2], implementation='reflection')
sage: W.reflections()
sage: list(W.reflections())
[
[-1 1] [ 0 -1] [ 1 0]
[ 0 1], [-1 0], [ 1 -1]
]
"""
return self.positive_roots(as_reflections=True)
return self._positive_roots_reflections()

@cached_method
@cached_method
def roots(self):
"""
Return the roots.
Expand All @@ -712,26 +733,26 @@ def roots(self):
sage: W = CoxeterGroup(['A',3], implementation='reflection')
sage: W.roots()
[(1, 0, 0),
(1, 1, 0),
(0, 1, 0),
(1, 1, 1),
(0, 1, 1),
(0, 0, 1),
(-1, 0, 0),
(-1, -1, 0),
(0, -1, 0),
(-1, -1, -1),
(0, -1, -1),
(0, 0, -1)]
((1, 0, 0),
(1, 1, 0),
(0, 1, 0),
(1, 1, 1),
(0, 1, 1),
(0, 0, 1),
(-1, 0, 0),
(-1, -1, 0),
(0, -1, 0),
(-1, -1, -1),
(0, -1, -1),
(0, 0, -1))
sage: W = CoxeterGroup(['I',5], implementation='reflection')
sage: len(W.roots())
10
"""
if not self.is_finite():
raise NotImplementedError('not available for infinite groups')
positive = self.positive_roots()
return positive + [-v for v in positive]
return positive + tuple([-v for v in positive])

def simple_root_index(self, i):
r"""
Expand Down Expand Up @@ -836,3 +857,4 @@ def action_on_root_indices(self, i):
roots = self.parent().roots()
rt = self * roots[i]
return roots.index(rt)

0 comments on commit 8c9b809

Please sign in to comment.