1 | initial version |
I've found a solution via implementing a new basis:
from sage.combinat.sf.sfa import SymmetricFunctionAlgebra_generic as SFA_generic
from sage.categories.morphism import SetMorphism
class SFA_mvar(SFA_generic):
def __init__(self, Sym, nvar):
SFA_generic.__init__(self, Sym, basis_name=
f"Monomial functions with {nvar} variables", prefix=f'm{nvar}')
self._m = Sym.m()
self.nvar = nvar
cat = HopfAlgebras(Sym.base_ring()).WithBasis()
self.register_coercion(
SetMorphism(Hom(self._m, self, cat), self._m_to_self))
self._m.register_coercion(
SetMorphism(Hom(self, self._m, cat), self._self_to_m))
def _m_to_self(self, f):
# f is a function in monomial basis and the output is in the mvar basis
#return sum(c*self(self._m[d]) for d,c in f if len(d)<=self.nvar)
return self._from_dict( {d:c for d,c in f if len(d)<=self.nvar} )
def _self_to_m(self, f):
# f is in the mvar basis and the output is in the monomial basis
return self._m.sum(c*self._m(d) for d,c in f)
class Element(SFA_generic.Element):
pass
Then
m3 = SFA_mvar(SymmetricFunctions(QQ),3)
(1+m3[1])^5
produces
m3[] + 5*m3[1] + 20*m3[1, 1] + 60*m3[1, 1, 1] + 10*m3[2] + 30*m3[2, 1] + 60*m3[2, 1, 1] + 30*m3[2, 2] + 30*m3[2, 2, 1] + 10*m3[3] + 20*m3[3, 1] + 20*m3[3, 1, 1] + 10*m3[3, 2] + 5*m3[4] + 5*m3[4, 1] + m3[5]