Skip to content

Commit

Permalink
provide a construction functor
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Feb 1, 2024
1 parent 3dd953c commit 5536cd8
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/sage/combinat/sf/elementary.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, Sym):
sage: TestSuite(e).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])
sage: TestSuite(e).run(elements = [e[1,1]+e[2], e[1]+2*e[1,1]])
"""
self._descriptor = (("elementary",),)
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, "elementary", 'e')

def _dual_basis_default(self):
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/sf/homogeneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, Sym):
sage: TestSuite(h).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])
sage: TestSuite(h).run(elements = [h[1,1]+h[2], h[1]+2*h[1,1]])
"""
self._descriptor = (("homogeneous",),)
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, "homogeneous", 'h')

def _dual_basis_default(self):
Expand Down
5 changes: 5 additions & 0 deletions src/sage/combinat/sf/macdonald.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ def __init__(self, macdonald):
sage: TestSuite(Q).run(elements = [Q.t*Q[1,1]+Q.q*Q[2], Q[1]+(Q.q+Q.t)*Q[1,1]]) # long time (depends on previous)
"""
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._descriptor = (("macdonald", {"q": self.q, "t": self.t}), ("Q",))

self._J = macdonald.J()
self._P = macdonald.P()
Expand Down Expand Up @@ -1118,6 +1119,7 @@ def __init__(self, macdonald):
self._self_to_s_cache = _j_to_s_cache
self._s_to_self_cache = _s_to_j_cache
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._descriptor = (("macdonald", {"q": self.q, "t": self.t}), ("J",))

def _s_cache(self, n):
r"""
Expand Down Expand Up @@ -1218,6 +1220,7 @@ def __init__(self, macdonald):
"""
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._descriptor = (("macdonald", {"q": self.q, "t": self.t}), ("H",))
self._m = self._sym.m()
self._Lmunu = macdonald.Ht()._Lmunu
if not self.t:
Expand Down Expand Up @@ -1440,6 +1443,7 @@ def __init__(self, macdonald):
"""
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._descriptor = (("macdonald", {"q": self.q, "t": self.t}), ("Ht",))
self._self_to_m_cache = _ht_to_m_cache
self._m = self._sym.m()
category = ModulesWithBasis(self.base_ring())
Expand Down Expand Up @@ -1735,6 +1739,7 @@ def __init__(self, macdonald):
"""
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._descriptor = (("macdonald", {"q": self.q, "t": self.t}), ("S",))
self._s = macdonald._s
self._self_to_s_cache = _S_to_s_cache
self._s_to_self_cache = _s_to_S_cache
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/sf/monomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, Sym):
sage: TestSuite(m).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])
sage: TestSuite(m).run(elements = [m[1,1]+m[2], m[1]+2*m[1,1]])
"""
self._descriptor = (("monomial",),)
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, "monomial", 'm')

def _dual_basis_default(self):
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/sf/powersum.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, Sym):
sage: TestSuite(p).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])
sage: TestSuite(p).run(elements = [p[1,1]+p[2], p[1]+2*p[1,1]])
"""
self._descriptor = (("powersum",),)
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, "powersum", 'p')

def coproduct_on_generators(self, i):
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/sf/schur.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, Sym):
sage: TestSuite(s).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])
sage: TestSuite(s).run(elements = [s[1,1]+s[2], s[1]+2*s[1,1]])
"""
self._descriptor = (("schur",),)
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, "Schur", 's')

def _dual_basis_default(self):
Expand Down
1 change: 0 additions & 1 deletion src/sage/combinat/sf/sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ class function on the symmetric group where the elements
- Devise a mechanism so that pickling bases of symmetric
functions pickles the coercions which have a cache.
"""

def __init__(self, R):
r"""
Initialization of ``self``.
Expand Down
78 changes: 76 additions & 2 deletions src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,6 @@ class SymmetricFunctionAlgebra_generic(CombinatorialFreeModule):
sage: s(m([2,1]))
-2*s[1, 1, 1] + s[2, 1]
"""

def __init__(self, Sym, basis_name=None, prefix=None, graded=True):
r"""
Initializes the symmetric function algebra.
Expand Down Expand Up @@ -3013,6 +3012,21 @@ def coproduct_by_coercion(self, elt):
return self.tensor_square().sum(coeff * tensor([self(s[x]), self(s[y])])
for ((x,y), coeff) in s(elt).coproduct())

def construction(self):
"""
Return a pair ``(F, R)``, where ``F`` is a
:class:`SymmetricFunctionsFunctor` and `R` is a ring, such
that ``F(R)`` returns ``self``.
EXAMPLES::
sage: s = SymmetricFunctions(ZZ).s()
sage: F, R = s.construction()
sage: F(QQ)
Symmetric Functions over Rational Field in the Schur basis
"""
return SymmetricFunctionsFunctor(self._descriptor), self.base_ring()


class SymmetricFunctionAlgebra_generic_Element(CombinatorialFreeModule.Element):
r"""
Expand All @@ -3033,7 +3047,6 @@ class SymmetricFunctionAlgebra_generic_Element(CombinatorialFreeModule.Element):
m[1, 1, 1] + m[2, 1] + m[3]
sage: m.set_print_style('lex')
"""

def factor(self):
"""
Return the factorization of this symmetric function.
Expand Down Expand Up @@ -6375,6 +6388,67 @@ def exponential_specialization(self, t=None, q=1):

SymmetricFunctionAlgebra_generic.Element = SymmetricFunctionAlgebra_generic_Element

from sage.categories.pushout import ConstructionFunctor
from sage.categories.commutative_rings import CommutativeRings
from sage.categories.functor import Functor

class SymmetricFunctionsFunctor(ConstructionFunctor):
rank = 9

def __init__(self, descriptor):
self._descriptor = descriptor
Functor.__init__(self, CommutativeRings(), CommutativeRings())

def _apply_functor(self, R):
"""
Apply the functor to an object of ``self``'s domain.
EXAMPLES::
sage: s = SymmetricFunctions(ZZ).s()
sage: F, R = s.construction()
sage: F(QQ)
Symmetric Functions over Rational Field in the Schur basis
"""
from sage.combinat.sf.sf import SymmetricFunctions
S = SymmetricFunctions(R)
for method, *params in self._descriptor:
if params:
assert len(params) == 1
S = S.__getattribute__(method)(**params[0])
else:
S = S.__getattribute__(method)()
return S

def _apply_functor_to_morphism(self, f):
"""
Apply the functor ``self`` to the ring morphism `f`.
"""
dom = self(f.domain())
codom = self(f.codomain())

def action(x):
return codom._from_dict({a: f(b)
for a, b in x.monomial_coefficients().items()})
return dom.module_morphism(function=action, codomain=codom)

def __eq__(self, other):
if not isinstance(other, SymmetricFunctionsFunctor):
return False
return self.vars == other.vars

def _repr_(self):
"""
TESTS::
sage: R.<q,t> = ZZ[]
sage: H = SymmetricFunctions(R).macdonald().H()
sage: F, R = H.construction()
sage: F
(('macdonald', {'q': q, 't': t}), ('H',))
"""
return repr(self._descriptor)

###################
def _lmax(x):
Expand Down

0 comments on commit 5536cd8

Please sign in to comment.