Skip to content

Commit a3d3dbd

Browse files
committed
use cython code for fully comm
1 parent bb59a04 commit a3d3dbd

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/sage/categories/coxeter_groups.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,26 +1577,23 @@ def is_fully_commutative(self) -> bool:
15771577
sage: len([1 for w in W if w.is_fully_commutative()])
15781578
24
15791579
"""
1580-
matrix = self.parent().coxeter_matrix()
1580+
word = self.reduced_word()
1581+
from sage.combinat.root_system.braid_orbit import is_fully_commutative as is_fully_comm
15811582

1582-
def contains_long_braid(w):
1583-
# This detects 'braid' subwords.
1584-
# TODO: optimisation
1585-
if len(w) <= 2:
1586-
return False
1587-
for i in range(len(w) - 2):
1588-
a = w[i]
1589-
b = w[i + 1]
1590-
m = matrix[a, b]
1591-
if m > 2 and i + m <= len(w):
1592-
ab = [a, b]
1593-
if all(wj == ab[j % 2]
1594-
for j, wj in enumerate(w[i:i + m])):
1595-
return True
1596-
return False
1583+
group = self.parent()
1584+
braid_rels = group.braid_relations()
1585+
I = group.index_set()
1586+
1587+
from sage.rings.integer_ring import ZZ
1588+
be_careful = any(i not in ZZ for i in I)
1589+
1590+
if be_careful:
1591+
Iinv = {i: j for j, i in enumerate(I)}
1592+
word = [Iinv[i] for i in word]
1593+
braid_rels = [[[Iinv[i] for i in l],
1594+
[Iinv[i] for i in r]] for l, r in braid_rels]
15971595

1598-
return not any(contains_long_braid(word)
1599-
for word in self.reduced_words_iter())
1596+
return is_fully_comm(word, braid_rels)
16001597

16011598
def reduced_word_reverse_iterator(self):
16021599
"""

0 commit comments

Comments
 (0)