Skip to content

Commit c65bd48

Browse files
committed
polish g_cycle_type, add a test and an example
1 parent b2ef1e4 commit c65bd48

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

src/sage/rings/lazy_series.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4745,20 +4745,24 @@ def functorial_composition(self, *args):
47454745
sage: h = SymmetricFunctions(QQ).h()
47464746
sage: e = SymmetricFunctions(QQ).e()
47474747
sage: L = LazySymmetricFunctions(h)
4748-
sage: E = L(lambda n: h[n])
4749-
sage: Ep = p[1]*E.derivative_with_respect_to_p1(); Ep
4748+
sage: H = L(lambda n: h[n])
4749+
sage: Ep = p[1]*H.derivative_with_respect_to_p1(); Ep
47504750
h[1] + (h[1,1]) + (h[2,1]) + (h[3,1]) + (h[4,1]) + (h[5,1]) + O^7
47514751
sage: f = L(lambda n: h[n-n//2, n//2])
47524752
sage: f - Ep.functorial_composition(f)
47534753
O^7
47544754
4755+
The symmetric function `\sum_n h_n` is a left absorbing element::
4756+
4757+
sage: H.functorial_composition(f) - H
4758+
O^7
4759+
47554760
The functorial composition distributes over the sum::
47564761
4757-
sage: F1 = L(lambda n: h[n])
4758-
sage: F2 = L(lambda n: e[n])
4759-
sage: f1 = F1.functorial_composition(f)
4760-
sage: f2 = F2.functorial_composition(f)
4761-
sage: (F1 + F2).functorial_composition(f) - f1 - f2
4762+
sage: E = L(lambda n: e[n])
4763+
sage: f1 = H.functorial_composition(f)
4764+
sage: f2 = E.functorial_composition(f)
4765+
sage: (H + E).functorial_composition(f) - f1 - f2
47624766
O^7
47634767
47644768
TESTS:
@@ -4781,6 +4785,12 @@ def functorial_composition(self, *args):
47814785
Traceback (most recent call last):
47824786
...
47834787
ValueError: the argument is not the Frobenius character of a permutation representation
4788+
4789+
sage: g = -p[1, 1, 1]
4790+
sage: r = f.functorial_composition(g); r[3]
4791+
Traceback (most recent call last):
4792+
...
4793+
ValueError: the argument is not the Frobenius character of a permutation representation
47844794
"""
47854795
if len(args) != self.parent()._arity:
47864796
raise ValueError("arity must be equal to the number of arguments provided")
@@ -4813,21 +4823,24 @@ def g_cycle_type(s, n):
48134823
if g[0]:
48144824
return Partition([1]*ZZ(g[0].coefficient([])))
48154825
return Partition([])
4826+
4827+
g_n = g[n]
4828+
if not g_n:
4829+
return Partition([])
4830+
if any(c < 0 for c in g_n.monomial_coefficients(copy=False).values()):
4831+
raise ValueError("the argument is not the Frobenius character of a permutation representation")
48164832
res = []
4817-
# in the species case, k is at most
4818-
# factorial(n) * g[n].coefficient([1]*n)
4819-
for k in range(1, lcm(s) + 1):
4833+
# k is the length of a cycle in G[sigma], and
4834+
# n! g_n([1]*n) is the number of elements in G[n]
4835+
for k in range(1, 1 + min(lcm(s),
4836+
ZZ(factorial(n) * g_n.coefficient([1]*n)))):
48204837
e = 0
48214838
for d in divisors(k):
48224839
m = moebius(d)
48234840
if not m:
48244841
continue
48254842
u = s.power(k // d)
4826-
# it could be, that we never need to compute
4827-
# g[n], so we only do this here
4828-
g_u = g[n]
4829-
if g_u:
4830-
e += m * u.aut() * g_u.coefficient(u)
4843+
e += m * u.aut() * g_n.coefficient(u)
48314844
# e / k might not be an integer if g is not a
48324845
# group action, so it is good to check
48334846
res.extend([k] * ZZ(e / k))

0 commit comments

Comments
 (0)