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

Commit

Permalink
Merge branch 'u/mantepse/parent_of_plethysm' of https://github.com/sa…
Browse files Browse the repository at this point in the history
…gemath/sagetrac-mirror into u/tscrim/parent_plethysm-27652
  • Loading branch information
tscrim committed Sep 22, 2022
2 parents d95f9ba + 9280ad9 commit 5b8a696
Showing 1 changed file with 44 additions and 35 deletions.
79 changes: 44 additions & 35 deletions src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3043,21 +3043,21 @@ def plethysm(self, x, include=None, exclude=None):
sage: Sym = SymmetricFunctions(QQ)
sage: s = Sym.s()
sage: h = Sym.h()
sage: s ( h([3])( h([2]) ) )
sage: s(h[3](h[2]))
s[2, 2, 2] + s[4, 2] + s[6]
sage: p = Sym.p()
sage: p([3])( s([2,1]) )
sage: p(p[3](s[2,1]))
1/3*p[3, 3, 3] - 1/3*p[9]
sage: e = Sym.e()
sage: e([3])( e([2]) )
sage: e[3](e[2])
e[3, 3] + e[4, 1, 1] - 2*e[4, 2] - e[5, 1] + e[6]
::
sage: R.<t> = QQ[]
sage: s = SymmetricFunctions(R).s()
sage: a = s([3])
sage: f = t*s([2])
sage: f = t * s([2])
sage: a(f)
t^3*s[2, 2, 2] + t^3*s[4, 2] + t^3*s[6]
sage: f(a)
Expand Down Expand Up @@ -3142,39 +3142,40 @@ def plethysm(self, x, include=None, exclude=None):
Check that we can compute the plethysm with a constant::
sage: p[2,2,1](2)
8*p[]
8
sage: p[2,2,1](int(2))
8*p[]
8
sage: p[2,2,1](a1)
a1^5*p[]
a1^5
sage: X = algebras.Shuffle(QQ, 'ab')
sage: Y = algebras.Shuffle(QQ, 'bc')
sage: T = tensor([X,Y])
sage: T = tensor([X, Y])
sage: s = SymmetricFunctions(T).s()
sage: s(2*T.one())
(2*B[]#B[])*s[]
sage: s[2](5)
15*B[] # B[]
.. TODO::
The implementation of plethysm in
:class:`sage.data_structures.stream.Stream_plethysm` seems
to be faster. This should be investigated.
"""
parent = self.parent()
from sage.structure.element import parent as get_parent
Px = get_parent(x)
if not self:
return self
return Px(0)

parent = self.parent()
R = parent.base_ring()
tHA = HopfAlgebrasWithBasis(R).TensorProducts()
from sage.structure.element import parent as get_parent
Px = get_parent(x)
tensorflag = Px in tHA
if not is_SymmetricFunction(x):
if Px is R: # Handle stuff that is directly in the base ring
x = parent(x)
if R.has_coerce_map_from(Px) or x in R:
x = R(x)
Px = R
elif (not tensorflag or any(not isinstance(factor, SymmetricFunctionAlgebra_generic)
for factor in Px._sets)):
from sage.rings.lazy_series import LazySymmetricFunction
Expand All @@ -3198,13 +3199,15 @@ def plethysm(self, x, include=None, exclude=None):

if tensorflag:
tparents = Px._sets
s = sum(d * prod(sum(_raise_variables(c, r, degree_one)
* tensor([p[r].plethysm(base(la))
for base, la in zip(tparents, trm)])
for trm, c in x)
for r in mu)
for mu, d in p(self))
return tensor([parent]*len(tparents))(s)
lincomb = Px.linear_combination
elt = lincomb((prod(lincomb((tensor([p[r].plethysm(base(la))
for base, la in zip(tparents, trm)]),
_raise_variables(c, r, degree_one))
for trm, c in x)
for r in mu),
d)
for mu, d in p(self))
return Px(elt)

# Takes a symmetric function f, and an n and returns the
# symmetric function with all of its basis partitions scaled
Expand All @@ -3218,7 +3221,11 @@ def pn_pleth(f, n):
def f(part):
return p.prod(pn_pleth(p_x.map_coefficients(lambda c: _raise_variables(c, i, degree_one)), i)
for i in part)
return parent(p._apply_module_morphism(p(self), f, codomain=p))
ret = p._apply_module_morphism(p(self), f, codomain=p)
if Px is R:
# special case for things in the base ring
return next(iter(ret._monomial_coefficients.values()))
return Px(ret)

__call__ = plethysm

Expand Down Expand Up @@ -6202,21 +6209,20 @@ def _nonnegative_coefficients(x):
return x >= 0

def _variables_recursive(R, include=None, exclude=None):
"""
r"""
Return all variables appearing in the ring ``R``.
INPUT:
- ``R`` -- a :class:`Ring`
- ``include``, ``exclude`` (optional, default ``None``) --
iterables of variables in ``R``
- ``include``, ``exclude`` -- (optional) iterables of variables in ``R``
OUTPUT:
- If ``include`` is specified, only these variables are returned
as elements of ``R``. Otherwise, all variables in ``R``
(recursively) with the exception of those in ``exclude`` are
returned.
If ``include`` is specified, only these variables are returned
as elements of ``R``. Otherwise, all variables in ``R``
(recursively) with the exception of those in ``exclude`` are
returned.
EXAMPLES::
Expand Down Expand Up @@ -6251,15 +6257,15 @@ def _variables_recursive(R, include=None, exclude=None):
except AttributeError:
try:
degree_one = R.gens()
except NotImplementedError:
except (NotImplementedError, AttributeError):
degree_one = []
if exclude is not None:
degree_one = [g for g in degree_one if g not in exclude]

return [g for g in degree_one if g != R.one()]

def _raise_variables(c, n, variables):
"""
r"""
Replace the given variables in the ring element ``c`` with their
``n``-th power.
Expand All @@ -6276,6 +6282,9 @@ def _raise_variables(c, n, variables):
sage: S.<t> = R[]
sage: _raise_variables(2*a + 3*b*t, 2, [a, t])
3*b*t^2 + 2*a^2
"""
return c.subs(**{str(g): g ** n for g in variables})
try:
return c.subs(**{str(g): g ** n for g in variables})
except AttributeError:
return c

0 comments on commit 5b8a696

Please sign in to comment.