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

Commit

Permalink
some details
Browse files Browse the repository at this point in the history
  • Loading branch information
videlec committed Apr 25, 2020
1 parent 1470131 commit 0d72df3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
9 changes: 5 additions & 4 deletions src/sage/combinat/sf/monomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from . import classical
import sage.libs.symmetrica.all as symmetrica
from sage.rings.integer import Integer
from sage.combinat.partition import Partition
from sage.combinat.partition import Partition, _Partitions

class SymmetricFunctionAlgebra_monomial(classical.SymmetricFunctionAlgebra_classical):
def __init__(self, Sym):
Expand Down Expand Up @@ -173,9 +173,10 @@ def from_polynomial(self, f, check=True):
assert self.base_ring() == f.base_ring()
if check and not f.is_symmetric():
raise ValueError("%s is not a symmetric polynomial"%f)
out = self.sum_of_terms((Partition(e), c)
for (e,c) in f.dict().items()
if all(e[i+1] <= e[i] for i in range(len(e) - 1)))
R = self.base_ring()
out = self._from_dict({_Partitions(e): R(c)
for (e,c) in f.dict().items()
if all(e[i+1] <= e[i] for i in range(len(e)-1))})
return out

def from_polynomial_exp(self, p):
Expand Down
15 changes: 6 additions & 9 deletions src/sage/rings/polynomial/multi_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ cdef class MPolynomial(CommutativeRingElement):
INPUT:
- ``group`` (optional) - if set, test whether the polynomial is
symmetric with respect to the given permutation group.
- ``group`` (default: symmetric group) -- if set, test whether the
polynomial is invariant with respect to the given permutation group
EXAMPLES::
Expand Down Expand Up @@ -959,7 +959,7 @@ cdef class MPolynomial(CommutativeRingElement):
sage: R.one().is_symmetric(3)
Traceback (most recent call last):
...
ValueError: wrong argument 'group'
ValueError: argument must be a permutation group
sage: R.one().is_symmetric(SymmetricGroup(4))
Traceback (most recent call last):
Expand All @@ -983,16 +983,13 @@ cdef class MPolynomial(CommutativeRingElement):
try:
gens = group.GeneratorsOfGroup()
except AttributeError:
raise ValueError("wrong argument 'group'")
raise ValueError("argument must be a permutation group")
gens = [S(g) for g in gens]

cdef dict coeffs = self.dict()
zero = self.base_ring().zero()
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
return True
return all(coeffs.get(g._act_on_etuple_on_position(e, True), zero) == coeff
for e, coeff in coeffs.items() for g in gens)

def _gap_(self, gap):
"""
Expand Down

0 comments on commit 0d72df3

Please sign in to comment.