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

Commit

Permalink
don't call exponents + force conversion to SymmetricGroup(n)
Browse files Browse the repository at this point in the history
  • Loading branch information
videlec committed Apr 24, 2020
1 parent 4e3cffe commit 1470131
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/sage/rings/polynomial/multi_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -960,13 +960,19 @@ cdef class MPolynomial(CommutativeRingElement):
Traceback (most recent call last):
...
ValueError: wrong argument 'group'
sage: R.one().is_symmetric(SymmetricGroup(4))
Traceback (most recent call last):
...
ValueError: invalid data to initialize a permutation
"""
n = self.parent().ngens()
if n <= 1:
return True

from sage.groups.perm_gps.permgroup_named import SymmetricGroup
S = SymmetricGroup(n)
if group is None:
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
S = SymmetricGroup(n)
gens = S.gens()
else:
try:
Expand All @@ -978,14 +984,11 @@ cdef class MPolynomial(CommutativeRingElement):
gens = group.GeneratorsOfGroup()
except AttributeError:
raise ValueError("wrong argument 'group'")
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
S = SymmetricGroup(n)
gens = [S(g) for g in gens]
gens = [S(g) for g in gens]

cdef dict coeffs = self.dict()
zero = self.base_ring().zero()
for e in self.exponents():
coeff = coeffs[e]
for e, coeff in coeffs.items():
for g in gens:
if coeffs.get(g._act_on_etuple_on_position(e, True), zero) != coeff:
return False
Expand Down

0 comments on commit 1470131

Please sign in to comment.