code stringlengths 17 6.64M |
|---|
class HallLittlewood_qp(HallLittlewood_generic):
class Element(HallLittlewood_generic.Element):
pass
def __init__(self, hall_littlewood):
"\n The Hall-Littlewood `Qp` basis is calculated through the symmetrica\n library (see the function :meth:`HallLittlewood_qp._to_s`).\n\n INPUT:\n\n - ``self`` -- an instance of the Hall-Littlewood `P` basis\n - ``hall_littlewood`` -- a class for the family of Hall-Littlewood bases\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: Qp = Sym.hall_littlewood().Q()\n sage: TestSuite(Qp).run(skip=['_test_passociativity', '_test_distributivity', '_test_prod']) # products are too expensive, long time (3s on sage.math, 2012)\n sage: TestSuite(Qp).run(elements = [Qp.t*Qp[1,1]+Qp[2], Qp[1]+(1+Qp.t)*Qp[1,1]]) # long time (depends on previous)\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HLP = Sym.hall_littlewood().P()\n sage: HLQ = Sym.hall_littlewood().Q()\n sage: HLQp = Sym.hall_littlewood().Qp()\n sage: s = Sym.schur(); p = Sym.power()\n sage: HLQp(HLP([2])) # indirect doctest\n -t*HLQp[1, 1] + (t^2+1)*HLQp[2]\n sage: HLQp(s(HLQ([2]))) # work around bug reported in issue #12969\n (t^2-t)*HLQp[1, 1] + (-t^3+t^2-t+1)*HLQp[2]\n sage: HLQp(s([2]))\n HLQp[2]\n sage: HLQp(p([2]))\n -HLQp[1, 1] + (t+1)*HLQp[2]\n sage: s = HLQp.symmetric_function_ring().s()\n sage: HLQp.transition_matrix(s,3)\n [ 1 0 0]\n [ t 1 0]\n [ t^3 t^2 + t 1]\n sage: s.transition_matrix(HLP,3)\n [ 1 t t^3]\n [ 0 1 t^2 + t]\n [ 0 0 1]\n "
HallLittlewood_generic.__init__(self, hall_littlewood)
self._self_to_s_cache = qp_to_s_cache
self._s_to_self_cache = s_to_qp_cache
def _to_s(self, part):
"\n Returns a function which gives the coefficient of a partition\n in the Schur expansion of ``self(part)``.\n\n INPUT:\n\n - ``self`` -- an instance of the Hall-Littlewood `P` basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a function which accepts a second partition ``part2``\n and returns the coefficient of the expansion of the `Qp`\n in the Schur basis. This is the `t`-Kostka-Foulkes polynomial\n `K_{part2,part}(t)`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HLQp = Sym.hall_littlewood().Qp()\n sage: f21 = HLQp._to_s(Partition([2,1]))\n sage: [f21(p) for p in Partitions(3)]\n [t, 1, 0]\n "
t = QQt.gen()
if (not part):
return (lambda part2: QQt.one())
res = hall_littlewood(part)
f = (lambda part2: res.coefficient(part2).subs(x=t))
return f
def _s_cache(self, n):
"\n Computes the change of basis between the `Q^\\prime` polynomials and the\n Schur functions for partitions of size ``n``.\n\n Uses the fact that the transformation matrix is lower-triangular in\n order to obtain the inverse transformation.\n\n INPUT:\n\n - ``self`` -- an instance of the Hall-Littlewood `P` basis\n - ``n`` -- a positive integer\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HLQp = Sym.hall_littlewood().Qp()\n sage: HLQp._s_cache(2)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(HLQp._s_to_self_cache[2])\n [([1, 1], [([1, 1], 1), ([2], -t)]), ([2], [([2], 1)])]\n sage: l(HLQp._self_to_s_cache[2])\n [([1, 1], [([1, 1], 1), ([2], t)]), ([2], [([2], 1)])]\n "
self._invert_morphism(n, QQt, self._self_to_s_cache, self._s_to_self_cache, to_other_function=self._to_s, lower_triangular=True, ones_on_diagonal=True)
|
class HeckeCharacter(SymmetricFunctionAlgebra_multiplicative):
"\n Basis of the symmetric functions that gives the characters of the\n Hecke algebra in analogy to the Frobenius formula for the\n symmetric group.\n\n Consider the Hecke algebra `H_n(q)` with quadratic relations\n\n .. MATH::\n\n T_i^2 = (q - 1) T_i + q.\n\n Let `\\mu` be a partition of `n` with length `\\ell`. The character\n `\\chi` of a `H_n(q)`-representation is completely determined by\n the elements `T_{\\gamma_{\\mu}}`, where\n\n .. MATH::\n\n \\gamma_{\\mu} = (\\mu_1, \\ldots, 1) (\\mu_2 + \\mu_1, \\ldots, 1 + \\mu_1)\n \\cdots (n, \\ldots, 1 + \\sum_{i < \\ell} \\mu_i),\n\n (written in cycle notation). We define a basis of the symmetric\n functions by\n\n .. MATH::\n\n \\bar{q}_{\\mu} = \\sum_{\\lambda \\vdash n}\n \\chi^{\\lambda}(T_{\\gamma_{\\mu}}) s_{\\lambda}.\n\n INPUT:\n\n - ``sym`` -- the ring of symmetric functions\n - ``q`` -- (default: ``'q'``) the parameter `q`\n\n EXAMPLES::\n\n sage: q = ZZ['q'].fraction_field().gen()\n sage: Sym = SymmetricFunctions(q.parent())\n sage: qbar = Sym.hecke_character(q)\n sage: qbar[2] * qbar[3] * qbar[3,1]\n qbar[3, 3, 2, 1]\n\n sage: s = Sym.s()\n sage: s(qbar([2]))\n -s[1, 1] + q*s[2]\n sage: s(qbar([4]))\n -s[1, 1, 1, 1] + q*s[2, 1, 1] - q^2*s[3, 1] + q^3*s[4]\n sage: qbar(s[2])\n (1/(q+1))*qbar[1, 1] + (1/(q+1))*qbar[2]\n sage: qbar(s[1,1])\n (q/(q+1))*qbar[1, 1] - (1/(q+1))*qbar[2]\n\n sage: s(qbar[2,1])\n -s[1, 1, 1] + (q-1)*s[2, 1] + q*s[3]\n sage: qbar(s[2,1])\n (q/(q^2+q+1))*qbar[1, 1, 1] + ((q-1)/(q^2+q+1))*qbar[2, 1]\n - (1/(q^2+q+1))*qbar[3]\n\n We compute character tables for Hecke algebras, which correspond\n to the transition matrix from the `\\bar{q}` basis to the Schur\n basis::\n\n sage: qbar.transition_matrix(s, 1)\n [1]\n sage: qbar.transition_matrix(s, 2)\n [ q -1]\n [ 1 1]\n sage: qbar.transition_matrix(s, 3)\n [ q^2 -q 1]\n [ q q - 1 -1]\n [ 1 2 1]\n sage: qbar.transition_matrix(s, 4)\n [ q^3 -q^2 0 q -1]\n [ q^2 q^2 - q -q -q + 1 1]\n [ q^2 q^2 - 2*q q^2 + 1 -2*q + 1 1]\n [ q 2*q - 1 q - 1 q - 2 -1]\n [ 1 3 2 3 1]\n\n We can do computations with a specialized `q` to a generic element\n of the base ring. We compute some examples with `q = 2`::\n\n sage: qbar = Sym.qbar(q=2)\n sage: s = Sym.schur()\n sage: qbar(s[2,1])\n 2/7*qbar[1, 1, 1] + 1/7*qbar[2, 1] - 1/7*qbar[3]\n sage: s(qbar[2,1])\n -s[1, 1, 1] + s[2, 1] + 2*s[3]\n\n REFERENCES:\n\n - [Ram1991]_\n - [RR1997]_\n "
def __init__(self, sym, q='q'):
"\n Initialize ``self``.\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(ZZ['q']))\n sage: qbar = Sym.qbar()\n sage: TestSuite(qbar).run()\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: qbar = Sym.qbar(q=2)\n sage: TestSuite(qbar).run()\n\n Check that the conversion `q \\to p \\to s` agrees with\n the definition of `q \\to s` from [Ram1991]_::\n\n sage: Sym = SymmetricFunctions(FractionField(ZZ['q']))\n sage: qbar = Sym.qbar()\n sage: s = Sym.s()\n sage: q = qbar.q()\n sage: def to_schur(mu):\n ....: if not mu:\n ....: return s.one()\n ....: mone = -qbar.base_ring().one()\n ....: return s.prod(sum(mone**(r-m) * q**(m-1)\n ....: * s[Partition([m] + [1]*(r-m))]\n ....: for m in range(1, r+1))\n ....: for r in mu)\n sage: phi = qbar.module_morphism(to_schur, codomain=s)\n sage: all(phi(qbar[mu]) == s(qbar[mu]) for n in range(6)\n ....: for mu in Partitions(n))\n True\n "
self.q = sym.base_ring()(q)
SymmetricFunctionAlgebra_multiplicative.__init__(self, sym, basis_name='Hecke character with q={}'.format(self.q), prefix='qbar')
self._p = sym.power()
self.register_coercion(self._p._module_morphism(self._p_to_qbar_on_basis, codomain=self))
self._p.register_coercion(self._module_morphism(self._qbar_to_p_on_basis, codomain=self._p))
def _p_to_qbar_on_generator(self, n):
"\n Convert `p_n` to ``self``\n\n INPUT:\n\n - ``n`` -- a non-negative integer\n\n EXAMPLES::\n\n sage: qbar = SymmetricFunctions(QQ['q'].fraction_field()).qbar('q')\n sage: qbar._p_to_qbar_on_generator(3)\n ((q^2-2*q+1)/(q^2+q+1))*qbar[1, 1, 1]\n + ((-3*q+3)/(q^2+q+1))*qbar[2, 1]\n + (3/(q^2+q+1))*qbar[3]\n sage: qbar = SymmetricFunctions(QQ).qbar(-1)\n sage: qbar._p_to_qbar_on_generator(3)\n 2*qbar[2, 1] + 3*qbar[3]\n "
if (n == 1):
return self([1])
q = self.q
if ((q ** n) == self.base_ring().one()):
raise ValueError(('the parameter q=%s must not be a %s root of unity' % (q, n)))
out = ((n * self([n])) - sum((((((q ** i) - 1) * self._p_to_qbar_on_generator(i)) * self([(n - i)])) for i in range(1, n) if ((q ** i) != 1))))
return ((out * (q - 1)) / ((q ** n) - 1))
def _p_to_qbar_on_basis(self, mu):
"\n Convert the power sum basis element indexed by ``mu`` to ``self``.\n\n INPUT:\n\n - ``mu`` -- a partition or a list of non-negative integers\n\n EXAMPLES::\n\n sage: qbar = SymmetricFunctions(QQ['q'].fraction_field()).qbar('q')\n sage: qbar._p_to_qbar_on_basis([3,1])\n ((q^2-2*q+1)/(q^2+q+1))*qbar[1, 1, 1, 1]\n + ((-3*q+3)/(q^2+q+1))*qbar[2, 1, 1]\n + (3/(q^2+q+1))*qbar[3, 1]\n sage: qbar = SymmetricFunctions(QQ).qbar(2)\n sage: qbar._p_to_qbar_on_basis([3,1])\n 1/7*qbar[1, 1, 1, 1] - 3/7*qbar[2, 1, 1] + 3/7*qbar[3, 1]\n "
return self.prod((self._p_to_qbar_on_generator(p) for p in mu))
def _qbar_to_p_on_generator(self, n):
"\n Convert a generator of the basis indexed by ``n`` to the\n power sum basis.\n\n INPUT:\n\n - ``n`` -- a non-negative integer\n\n EXAMPLES::\n\n sage: qbar = SymmetricFunctions(QQ['q'].fraction_field()).qbar('q')\n sage: qbar._qbar_to_p_on_generator(3)\n (1/6*q^2-1/3*q+1/6)*p[1, 1, 1]\n + (1/2*q^2-1/2)*p[2, 1]\n + (1/3*q^2+1/3*q+1/3)*p[3]\n sage: qbar = SymmetricFunctions(QQ).qbar(-1)\n sage: qbar._qbar_to_p_on_generator(3)\n 2/3*p[1, 1, 1] + 1/3*p[3]\n "
if (n == 1):
return self._p([1])
q = self.q
BR = self.base_ring()
return ((q ** (n - 1)) * self._p.sum(((((sum(((q ** (- i)) for i in range(mu[0]))) * BR.prod(((1 - (q ** (- p))) for p in mu[1:]))) * self._p(mu)) / mu.centralizer_size()) for mu in Partitions(n) if (not any((((q ** p) == 1) for p in mu[1:]))))))
def _qbar_to_p_on_basis(self, mu):
"\n Convert a basis element indexed by the partition ``mu``\n to the power basis.\n\n INPUT:\n\n - ``mu`` -- a partition or a list of non-negative integers\n\n EXAMPLES::\n\n sage: qbar = SymmetricFunctions(QQ['q'].fraction_field()).qbar('q')\n sage: qbar._qbar_to_p_on_basis([3,1])\n (1/6*q^2-1/3*q+1/6)*p[1, 1, 1, 1]\n + (1/2*q^2-1/2)*p[2, 1, 1]\n + (1/3*q^2+1/3*q+1/3)*p[3, 1]\n sage: qbar = SymmetricFunctions(QQ).qbar(-1)\n sage: qbar._qbar_to_p_on_basis([3,1])\n 2/3*p[1, 1, 1, 1] + 1/3*p[3, 1]\n "
return self._p.prod((self._qbar_to_p_on_generator(p) for p in mu))
def coproduct_on_generators(self, r):
"\n Return the coproduct on the generator `\\bar{q}_r` of ``self``.\n\n Define the coproduct on `\\bar{q}_r` by\n\n .. MATH::\n\n \\Delta(\\bar{q}_r) = \\bar{q}_0 \\otimes \\bar{q}_r\n + (q - 1) \\sum_{j=1}^{r-1} \\bar{q}_j \\otimes \\bar{q}_{r-j}\n + \\bar{q}_r \\otimes \\bar{q}_0.\n\n EXAMPLES::\n\n sage: q = ZZ['q'].fraction_field().gen()\n sage: Sym = SymmetricFunctions(q.parent())\n sage: qbar = Sym.hecke_character()\n sage: s = Sym.s()\n sage: qbar[2].coproduct()\n qbar[] # qbar[2] + (q-1)*qbar[1] # qbar[1] + qbar[2] # qbar[]\n "
def P(i):
return (_Partitions([i]) if i else _Partitions([]))
T = self.tensor_square()
one = self.base_ring().one()
q = self.q
return T.sum_of_terms((((P(j), P((r - j))), (one if (j in [0, r]) else (q - one))) for j in range((r + 1))))
|
class SymmetricFunctionAlgebra_homogeneous(multiplicative.SymmetricFunctionAlgebra_multiplicative):
def __init__(self, Sym):
"\n A class of methods specific to the homogeneous basis of\n symmetric functions.\n\n INPUT:\n\n - ``self`` -- a homogeneous basis of symmetric functions\n - ``Sym`` -- an instance of the ring of symmetric functions\n\n TESTS::\n\n sage: h = SymmetricFunctions(QQ).e()\n sage: h == loads(dumps(h))\n True\n sage: TestSuite(h).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])\n sage: TestSuite(h).run(elements = [h[1,1]+h[2], h[1]+2*h[1,1]])\n "
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, 'homogeneous', 'h')
def _dual_basis_default(self):
'\n Return the dual basis to ``self``.\n\n INPUT:\n\n - ``self`` -- a homogeneous basis of symmetric functions\n - ``scalar`` -- optional input which specifies a function ``zee``\n on partitions. The function ``zee`` determines the scalar\n product on the power sum basis with normalization\n `\\langle p_\\mu, p_\\mu \\rangle = \\mathrm{zee}(mu)`.\n (default: uses standard ``zee`` function)\n - ``scalar_name`` -- specifies the name of the scalar function\n (optional)\n - ``prefix`` -- optional input, specifies the prefix to be\n used to display the basis.\n\n OUTPUT:\n\n The dual basis of the homogeneous basis with respect to the\n standard scalar product (the monomial basis). If a function\n ``zee`` is specified, the dual basis is with respect to the\n modified scalar product.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: h = SymmetricFunctions(QQ).h()\n sage: h.dual_basis() == m\n True\n\n sage: zee = lambda x : 2\n sage: hh = h.dual_basis(zee); hh\n Dual basis to Symmetric Functions over Rational Field in the homogeneous basis\n sage: hh[2,1].scalar(h[2,1])\n 1\n sage: hh[2,2].scalar(h[2,2])\n 4\n\n TESTS::\n\n sage: h._dual_basis_default() is h.dual_basis()\n True\n '
return self.realization_of().m()
def coproduct_on_generators(self, i):
'\n Return the coproduct on `h_i`.\n\n INPUT:\n\n - ``self`` -- a homogeneous basis of symmetric functions\n - ``i`` -- a nonnegative integer\n\n OUTPUT:\n\n - the sum `\\sum_{r=0}^i h_r \\otimes h_{i-r}`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: h = Sym.homogeneous()\n sage: h.coproduct_on_generators(2)\n h[] # h[2] + h[1] # h[1] + h[2] # h[]\n sage: h.coproduct_on_generators(0)\n h[] # h[]\n '
def P(i):
return (Partition([i]) if i else Partition([]))
T = self.tensor_square()
return T.sum_of_monomials(((P(j), P((i - j))) for j in range((i + 1))))
class Element(classical.SymmetricFunctionAlgebra_classical.Element):
def omega(self):
'\n Return the image of ``self`` under the omega automorphism.\n\n The *omega automorphism* is defined to be the unique algebra\n endomorphism `\\omega` of the ring of symmetric functions that\n satisfies `\\omega(e_k) = h_k` for all positive integers `k`\n (where `e_k` stands for the `k`-th elementary symmetric\n function, and `h_k` stands for the `k`-th complete homogeneous\n symmetric function). It furthermore is a Hopf algebra\n endomorphism and an involution, and it is also known as the\n *omega involution*. It sends the power-sum symmetric function\n `p_k` to `(-1)^{k-1} p_k` for every positive integer `k`.\n\n The images of some bases under the omega automorphism are given by\n\n .. MATH::\n\n \\omega(e_{\\lambda}) = h_{\\lambda}, \\qquad\n \\omega(h_{\\lambda}) = e_{\\lambda}, \\qquad\n \\omega(p_{\\lambda}) = (-1)^{|\\lambda| - \\ell(\\lambda)}\n p_{\\lambda}, \\qquad\n \\omega(s_{\\lambda}) = s_{\\lambda^{\\prime}},\n\n where `\\lambda` is any partition, where `\\ell(\\lambda)` denotes\n the length (:meth:`~sage.combinat.partition.Partition.length`)\n of the partition `\\lambda`, where `\\lambda^{\\prime}` denotes the\n conjugate partition\n (:meth:`~sage.combinat.partition.Partition.conjugate`) of\n `\\lambda`, and where the usual notations for bases are used\n (`e` = elementary, `h` = complete homogeneous, `p` = powersum,\n `s` = Schur).\n\n :meth:`omega_involution()` is a synonym for the :meth:`omega()`\n method.\n\n OUTPUT:\n\n - the image of ``self`` under the omega automorphism\n\n EXAMPLES::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: a = h([2,1]); a\n h[2, 1]\n sage: a.omega()\n h[1, 1, 1] - h[2, 1]\n sage: e = SymmetricFunctions(QQ).e()\n sage: e(h([2,1]).omega())\n e[2, 1]\n '
e = self.parent().realization_of().e()
return self.parent()(e._from_element(self))
omega_involution = omega
def expand(self, n, alphabet='x'):
"\n Expand the symmetric function ``self`` as a symmetric polynomial\n in ``n`` variables.\n\n INPUT:\n\n - ``n`` -- a nonnegative integer\n\n - ``alphabet`` -- (default: ``'x'``) a variable for the expansion\n\n OUTPUT:\n\n A monomial expansion of ``self`` in the `n` variables\n labelled by ``alphabet``.\n\n EXAMPLES::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: h([3]).expand(2)\n x0^3 + x0^2*x1 + x0*x1^2 + x1^3\n sage: h([1,1,1]).expand(2)\n x0^3 + 3*x0^2*x1 + 3*x0*x1^2 + x1^3\n sage: h([2,1]).expand(3)\n x0^3 + 2*x0^2*x1 + 2*x0*x1^2 + x1^3 + 2*x0^2*x2 + 3*x0*x1*x2 + 2*x1^2*x2 + 2*x0*x2^2 + 2*x1*x2^2 + x2^3\n sage: h([3]).expand(2,alphabet='y')\n y0^3 + y0^2*y1 + y0*y1^2 + y1^3\n sage: h([3]).expand(2,alphabet='x,y')\n x^3 + x^2*y + x*y^2 + y^3\n sage: h([3]).expand(3,alphabet='x,y,z')\n x^3 + x^2*y + x*y^2 + y^3 + x^2*z + x*y*z + y^2*z + x*z^2 + y*z^2 + z^3\n sage: (h([]) + 2*h([1])).expand(3)\n 2*x0 + 2*x1 + 2*x2 + 1\n sage: h([1]).expand(0)\n 0\n sage: (3*h([])).expand(0)\n 3\n "
if (n == 0):
return self.counit()
condition = (lambda part: False)
return self._expand(condition, n, alphabet)
def principal_specialization(self, n=infinity, q=None):
'\n Return the principal specialization of a symmetric function.\n\n The *principal specialization* of order `n` at `q`\n is the ring homomorphism `ps_{n,q}` from the ring of\n symmetric functions to another commutative ring `R`\n given by `x_i \\mapsto q^{i-1}` for `i \\in \\{1,\\dots,n\\}`\n and `x_i \\mapsto 0` for `i > n`.\n Here, `q` is a given element of `R`, and we assume that\n the variables of our symmetric functions are\n `x_1, x_2, x_3, \\ldots`.\n (To be more precise, `ps_{n,q}` is a `K`-algebra\n homomorphism, where `K` is the base ring.)\n See Section 7.8 of [EnumComb2]_.\n\n The *stable principal specialization* at `q` is the ring\n homomorphism `ps_q` from the ring of symmetric functions\n to another commutative ring `R` given by\n `x_i \\mapsto q^{i-1}` for all `i`.\n This is well-defined only if the resulting infinite sums\n converge; thus, in particular, setting `q = 1` in the\n stable principal specialization is an invalid operation.\n\n INPUT:\n\n - ``n`` (default: ``infinity``) -- a nonnegative integer or\n ``infinity``, specifying whether to compute the principal\n specialization of order ``n`` or the stable principal\n specialization.\n\n - ``q`` (default: ``None``) -- the value to use for `q`; the\n default is to create a ring of polynomials in ``q``\n (or a field of rational functions in ``q``) over the\n given coefficient ring.\n\n We use the formulas from Proposition 7.8.3 of [EnumComb2]_\n (using Gaussian binomial coefficients `\\binom{u}{v}_q`):\n\n .. MATH::\n\n ps_{n,q}(h_\\lambda) = \\prod_i \\binom{n+\\lambda_i-1}{\\lambda_i}_q,\n\n ps_{n,1}(h_\\lambda) = \\prod_i \\binom{n+\\lambda_i-1}{\\lambda_i},\n\n ps_q(h_\\lambda) = 1 / \\prod_i \\prod_{j=1}^{\\lambda_i} (1-q^j).\n\n EXAMPLES::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: x = h[2,1]\n sage: x.principal_specialization(3)\n q^6 + 2*q^5 + 4*q^4 + 4*q^3 + 4*q^2 + 2*q + 1\n sage: x = 3*h[2] + 2*h[1] + 1\n sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic\n 2*(q^3 - 1)/(q - 1) + 3*(q^4 - 1)*(q^3 - 1)/((q^2 - 1)*(q - 1)) + 1\n\n TESTS::\n\n sage: x = h.zero()\n sage: s = x.principal_specialization(3); s\n 0\n\n '
from sage.combinat.q_analogues import q_binomial
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q is None):
q = get_variable(self.base_ring(), 'q')
if (q == 1):
if (n == infinity):
raise ValueError('the stable principal specialization at q=1 is not defined')
f = (lambda partition: prod((binomial(((n + part) - 1), part) for part in partition)))
elif (n == infinity):
f = (lambda partition: prod(((1 / prod(((1 - (q ** i)) for i in range(1, (part + 1))))) for part in partition)))
else:
f = (lambda partition: prod((q_binomial(((n + part) - 1), part, q=q) for part in partition)))
return self.parent()._apply_module_morphism(self, f, q.parent())
def exponential_specialization(self, t=None, q=1):
'\n Return the exponential specialization of a\n symmetric function (when `q = 1`), or the\n `q`-exponential specialization (when `q \\neq 1`).\n\n The *exponential specialization* `ex` at `t` is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R`.\n It is defined whenever the base ring `K` is a\n `\\QQ`-algebra and `t` is an element of `R`.\n The easiest way to define it is by specifying its\n values on the powersum symmetric functions to be\n `p_1 = t` and `p_n = 0` for `n > 1`.\n Equivalently, on the homogeneous functions it is\n given by `ex(h_n) = t^n / n!`; see Proposition 7.8.4 of\n [EnumComb2]_.\n\n By analogy, the `q`-exponential specialization is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R` that\n depends on two elements `t` and `q` of `R` for which\n the elements `1 - q^i` for all positive integers `i`\n are invertible.\n It can be defined by specifying its values on the\n complete homogeneous symmetric functions to be\n\n .. MATH::\n\n ex_q(h_n) = t^n / [n]_q!,\n\n where `[n]_q!` is the `q`-factorial. Equivalently, for\n `q \\neq 1` and a homogeneous symmetric function `f` of\n degree `n`, we have\n\n .. MATH::\n\n ex_q(f) = (1-q)^n t^n ps_q(f),\n\n where `ps_q(f)` is the stable principal specialization of `f`\n (see :meth:`principal_specialization`).\n (See (7.29) in [EnumComb2]_.)\n\n The limit of `ex_q` as `q \\to 1` is `ex`.\n\n INPUT:\n\n - ``t`` (default: ``None``) -- the value to use for `t`;\n the default is to create a ring of polynomials in ``t``.\n\n - ``q`` (default: `1`) -- the value to use for `q`. If\n ``q`` is ``None``, then a ring (or fraction field) of\n polynomials in ``q`` is created.\n\n EXAMPLES::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: x = h[5,3]\n sage: x.exponential_specialization()\n 1/720*t^8\n sage: factorial(5)*factorial(3)\n 720\n\n sage: x = 5*h[1,1,1] + 3*h[2,1] + 1\n sage: x.exponential_specialization()\n 13/2*t^3 + 1\n\n We also support the `q`-exponential_specialization::\n\n sage: factor(h[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic\n t^3/((q^2 + q + 1)*(q + 1))\n\n TESTS::\n\n sage: x = h.zero()\n sage: s = x.exponential_specialization(); s\n 0\n\n '
from sage.combinat.q_analogues import q_factorial
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q == 1):
if (t is None):
t = get_variable(self.base_ring(), 't')
def f(partition):
n = 0
m = 1
for part in partition:
n += part
m *= factorial(part)
return ((t ** n) / m)
return self.parent()._apply_module_morphism(self, f, t.parent())
if ((q is None) and (t is None)):
q = get_variable(self.base_ring(), 'q')
t = get_variable(q.parent(), 't')
elif (q is None):
q = get_variable(t.parent(), 'q')
elif (t is None):
t = get_variable(q.parent(), 't')
def f(partition):
n = 0
m = 1
for part in partition:
n += part
m *= q_factorial(part, q=q)
return ((t ** n) / m)
return self.parent()._apply_module_morphism(self, f, t.parent())
|
class Jack(UniqueRepresentation):
def __init__(self, Sym, t='t'):
"\n The family of Jack symmetric functions including the `P`, `Q`, `J`, `Qp`\n bases. The default parameter is ``t``.\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n - ``Sym`` -- a ring of symmetric functions\n - ``t`` -- an optional parameter (default : 't')\n\n EXAMPLES::\n\n sage: SymmetricFunctions(FractionField(QQ['t'])).jack()\n Jack polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n sage: SymmetricFunctions(QQ).jack(1)\n Jack polynomials with t=1 over Rational Field\n "
self._sym = Sym
self.t = Sym.base_ring()(t)
self._name_suffix = ''
if (str(t) != 't'):
self._name_suffix += (' with t=%s' % t)
self._name = ((('Jack polynomials' + self._name_suffix) + ' over ') + repr(Sym.base_ring()))
def __repr__(self):
'\n The string representation for the family of Jack symmetric function bases\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT:\n\n - returns the name of the family of bases\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).jack(1)\n Jack polynomials with t=1 over Rational Field\n '
return self._name
def base_ring(self):
'\n Returns the base ring of the symmetric functions in which the\n Jack symmetric functions live\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT:\n\n - the base ring of the symmetric functions ring of ``self``\n\n EXAMPLES::\n\n sage: J2 = SymmetricFunctions(QQ).jack(t=2)\n sage: J2.base_ring()\n Rational Field\n '
return self._sym.base_ring()
def symmetric_function_ring(self):
"\n Returns the base ring of the symmetric functions of the Jack symmetric\n function bases\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT:\n\n - the symmetric functions ring of ``self``\n\n EXAMPLES::\n\n sage: Jacks = SymmetricFunctions(FractionField(QQ['t'])).jack()\n sage: Jacks.symmetric_function_ring()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
return self._sym
def P(self):
"\n Returns the algebra of Jack polynomials in the `P` basis.\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT:\n\n - the `P` basis of the Jack symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JP = Sym.jack().P(); JP\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack P basis\n sage: Sym.jack(t=-1).P()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack P with t=-1 basis\n\n At `t = 1`, the Jack polynomials in the `P` basis are the Schur\n symmetric functions.\n\n ::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JP = Sym.jack(t=1).P()\n sage: s = Sym.schur()\n sage: s(JP([2,2,1]))\n s[2, 2, 1]\n sage: JP(s([2,2,1]))\n JackP[2, 2, 1]\n sage: JP([2,1])^2\n JackP[2, 2, 1, 1] + JackP[2, 2, 2] + JackP[3, 1, 1, 1] + 2*JackP[3, 2, 1] + JackP[3, 3] + JackP[4, 1, 1] + JackP[4, 2]\n\n At `t = 2`, the Jack polynomials in the `P` basis are the zonal\n polynomials.\n\n ::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JP = Sym.jack(t=2).P()\n sage: Z = Sym.zonal()\n sage: Z(JP([2,2,1]))\n Z[2, 2, 1]\n sage: JP(Z[2, 2, 1])\n JackP[2, 2, 1]\n sage: JP([2])^2\n 64/45*JackP[2, 2] + 16/21*JackP[3, 1] + JackP[4]\n sage: Z([2])^2\n 64/45*Z[2, 2] + 16/21*Z[3, 1] + Z[4]\n\n ::\n\n sage: Sym = SymmetricFunctions(QQ['a','b'].fraction_field())\n sage: (a,b) = Sym.base_ring().gens()\n sage: Jacka = Sym.jack(t=a)\n sage: Jackb = Sym.jack(t=b)\n sage: m = Sym.monomial()\n sage: JPa = Jacka.P()\n sage: JPb = Jackb.P()\n sage: m(JPa[2,1])\n (6/(a+2))*m[1, 1, 1] + m[2, 1]\n sage: m(JPb[2,1])\n (6/(b+2))*m[1, 1, 1] + m[2, 1]\n sage: m(a*JPb([2,1]) + b*JPa([2,1]))\n ((6*a^2+6*b^2+12*a+12*b)/(a*b+2*a+2*b+4))*m[1, 1, 1] + (a+b)*m[2, 1]\n sage: JPa(JPb([2,1]))\n ((6*a-6*b)/(a*b+2*a+2*b+4))*JackP[1, 1, 1] + JackP[2, 1]\n\n ::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JQ = Sym.jack().Q()\n sage: JP = Sym.jack().P()\n sage: JJ = Sym.jack().J()\n\n ::\n\n sage: JP(JQ([2,1]))\n ((1/2*t+1)/(t^3+1/2*t^2))*JackP[2, 1]\n sage: JP(JQ([3]))\n ((1/3*t^2+1/2*t+1/6)/t^3)*JackP[3]\n sage: JP(JQ([1,1,1]))\n (6/(t^3+3*t^2+2*t))*JackP[1, 1, 1]\n\n ::\n\n sage: JP(JJ([3]))\n (2*t^2+3*t+1)*JackP[3]\n sage: JP(JJ([2,1]))\n (t+2)*JackP[2, 1]\n sage: JP(JJ([1,1,1]))\n 6*JackP[1, 1, 1]\n\n ::\n\n sage: s = Sym.schur()\n sage: JP(s([2,1]))\n ((2*t-2)/(t+2))*JackP[1, 1, 1] + JackP[2, 1]\n sage: s(_)\n s[2, 1]\n "
return JackPolynomials_p(self)
def Q(self):
"\n Returns the algebra of Jack polynomials in the `Q` basis.\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT:\n\n - the `Q` basis of the Jack symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JQ = Sym.jack().Q(); JQ\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack Q basis\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym.jack(t=-1).Q()\n Symmetric Functions over Rational Field in the Jack Q with t=-1 basis\n\n ::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JQ = Sym.jack().Q()\n sage: JP = Sym.jack().P()\n sage: JQ(sum(JP(p) for p in Partitions(3)))\n (1/6*t^3+1/2*t^2+1/3*t)*JackQ[1, 1, 1] + ((2*t^3+t^2)/(t+2))*JackQ[2, 1] + (3*t^3/(t^2+3/2*t+1/2))*JackQ[3]\n\n ::\n\n sage: s = Sym.schur()\n sage: JQ(s([3])) # indirect doctest\n (1/6*t^3-1/2*t^2+1/3*t)*JackQ[1, 1, 1] + ((2*t^3-2*t^2)/(t+2))*JackQ[2, 1] + (3*t^3/(t^2+3/2*t+1/2))*JackQ[3]\n sage: JQ(s([2,1]))\n (1/3*t^3-1/3*t)*JackQ[1, 1, 1] + ((2*t^3+t^2)/(t+2))*JackQ[2, 1]\n sage: JQ(s([1,1,1]))\n (1/6*t^3+1/2*t^2+1/3*t)*JackQ[1, 1, 1]\n "
return JackPolynomials_q(self)
def J(self):
"\n Returns the algebra of Jack polynomials in the `J` basis.\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT: the `J` basis of the Jack symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JJ = Sym.jack().J(); JJ\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack J basis\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym.jack(t=-1).J()\n Symmetric Functions over Rational Field in the Jack J with t=-1 basis\n\n At `t = 1`, the Jack polynomials in the `J` basis are scalar multiples\n of the Schur functions with the scalar given by a Partition's\n :meth:`~sage.combinat.partition.Partition.hook_product` method at 1::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JJ = Sym.jack(t=1).J()\n sage: s = Sym.schur()\n sage: p = Partition([3,2,1,1])\n sage: s(JJ(p)) == p.hook_product(1)*s(p) # long time (4s on sage.math, 2012)\n True\n\n At `t = 2`, the Jack polynomials in the `J` basis are scalar multiples\n of the zonal polynomials with the scalar given by a Partition's\n :meth:`~sage.combinat.partition.Partition.hook_product` method at 2.\n\n ::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JJ = Sym.jack(t=2).J()\n sage: Z = Sym.zonal()\n sage: p = Partition([2,2,1])\n sage: Z(JJ(p)) == p.hook_product(2)*Z(p)\n True\n\n ::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JJ = Sym.jack().J()\n sage: JP = Sym.jack().P()\n sage: JJ(sum(JP(p) for p in Partitions(3)))\n 1/6*JackJ[1, 1, 1] + (1/(t+2))*JackJ[2, 1] + (1/2/(t^2+3/2*t+1/2))*JackJ[3]\n\n ::\n\n sage: s = Sym.schur()\n sage: JJ(s([3])) # indirect doctest\n ((1/6*t^2-1/2*t+1/3)/(t^2+3*t+2))*JackJ[1, 1, 1] + ((t-1)/(t^2+5/2*t+1))*JackJ[2, 1] + (1/2/(t^2+3/2*t+1/2))*JackJ[3]\n sage: JJ(s([2,1]))\n ((1/3*t-1/3)/(t+2))*JackJ[1, 1, 1] + (1/(t+2))*JackJ[2, 1]\n sage: JJ(s([1,1,1]))\n 1/6*JackJ[1, 1, 1]\n "
return JackPolynomials_j(self)
def Qp(self):
"\n Returns the algebra of Jack polynomials in the `Qp`, which is dual to\n the `P` basis with respect to the standard scalar product.\n\n INPUT:\n\n - ``self`` -- the family of Jack symmetric function bases\n\n OUTPUT:\n\n - the `Q'` basis of the Jack symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JP = Sym.jack().P()\n sage: JQp = Sym.jack().Qp(); JQp\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack Qp basis\n sage: a = JQp([2])\n sage: a.scalar(JP([2]))\n 1\n sage: a.scalar(JP([1,1]))\n 0\n sage: JP(JQp([2])) # todo: missing auto normalization\n ((t-1)/(t+1))*JackP[1, 1] + JackP[2]\n sage: JP._normalize(JP(JQp([2])))\n ((t-1)/(t+1))*JackP[1, 1] + JackP[2]\n "
return JackPolynomials_qp(self)
|
def c1(part, t):
"\n Returns the `t`-Jack scalar product between ``J(part)`` and ``P(part)``.\n\n INPUT:\n\n - ``part`` -- a partition\n - ``t`` -- an optional parameter (default: uses the parameter `t` from the\n Jack basis)\n\n OUTPUT:\n\n - a polynomial in the parameter ``t`` which is equal to the scalar\n product of ``J(part)`` and ``P(part)``\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.jack import c1\n sage: t = QQ['t'].gen()\n sage: [c1(p,t) for p in Partitions(3)]\n [2*t^2 + 3*t + 1, t + 2, 6]\n "
return prod([((1 + (t * part.arm_lengths(flat=True)[i])) + part.leg_lengths(flat=True)[i]) for i in range(sum(part))], t.parent().one())
|
def c2(part, t):
"\n Returns the t-Jack scalar product between ``J(part)`` and ``Q(part)``.\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``part`` -- a partition\n - ``t`` -- an optional parameter (default: uses the parameter `t` from the\n Jack basis)\n\n OUTPUT:\n\n - a polynomial in the parameter ``t`` which is equal to the scalar\n product of ``J(part)`` and ``Q(part)``\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.jack import c2\n sage: t = QQ['t'].gen()\n sage: [c2(p,t) for p in Partitions(3)]\n [6*t^3, 2*t^3 + t^2, t^3 + 3*t^2 + 2*t]\n "
return prod([((t + (t * part.arm_lengths(flat=True)[i])) + part.leg_lengths(flat=True)[i]) for i in range(sum(part))], t.parent().one())
|
def normalize_coefficients(self, c):
"\n If our coefficient ring is the field of fractions over a univariate\n polynomial ring over the rationals, then we should clear both the\n numerator and denominator of the denominators of their\n coefficients.\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``c`` -- a coefficient in the base ring of ``self``\n\n OUTPUT:\n\n - divide numerator and denominator by the greatest common divisor\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: t = JP.base_ring().gen()\n sage: a = 2/(1/2*t+1/2)\n sage: JP._normalize_coefficients(a)\n 4/(t + 1)\n sage: a = 1/(1/3+1/6*t)\n sage: JP._normalize_coefficients(a)\n 6/(t + 2)\n sage: a = 24/(4*t^2 + 12*t + 8)\n sage: JP._normalize_coefficients(a)\n 6/(t^2 + 3*t + 2)\n "
BR = self.base_ring()
if (is_FractionField(BR) and (BR.base_ring() == QQ)):
denom = c.denominator()
numer = c.numerator()
a = lcm([i.denominator() for i in denom.coefficients(sparse=False)])
b = lcm([i.denominator() for i in numer.coefficients(sparse=False)])
l = Integer(a).lcm(Integer(b))
denom *= l
numer *= l
a = gcd([i.numerator() for i in denom.coefficients(sparse=False)])
b = gcd([i.numerator() for i in numer.coefficients(sparse=False)])
l = Integer(a).gcd(Integer(b))
denom = (denom // l)
numer = (numer // l)
return c.parent()(numer, denom)
else:
return c
|
class JackPolynomials_generic(sfa.SymmetricFunctionAlgebra_generic):
def __init__(self, jack):
"\n A class of methods which are common to all Jack bases of the symmetric functions\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``jack`` -- a family of Jack symmetric function bases\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JP = Sym.jack().P(); JP.base_ring()\n Fraction Field of Univariate Polynomial Ring in t over Rational Field\n sage: Sym = SymmetricFunctions(QQ)\n sage: JP = Sym.jack(t=2).P(); JP.base_ring()\n Rational Field\n "
s = self.__class__.__name__[16:].capitalize()
sfa.SymmetricFunctionAlgebra_generic.__init__(self, jack._sym, basis_name=(('Jack ' + s) + jack._name_suffix), prefix=('Jack' + s))
self.t = jack.t
self._sym = jack._sym
self._jack = jack
if hasattr(self, '_m_cache'):
category = sage.categories.all.ModulesWithBasis(self._sym.base_ring())
self._m = self._sym.monomial()
self.register_coercion(SetMorphism(Hom(self._m, self, category), self._m_to_self))
self._m.register_coercion(SetMorphism(Hom(self, self._m, category), self._self_to_m))
if hasattr(self, '_h_cache'):
category = sage.categories.all.ModulesWithBasis(self._sym.base_ring())
self._h = self._sym.homogeneous()
self.register_coercion(SetMorphism(Hom(self._h, self, category), self._h_to_self))
self._h.register_coercion(SetMorphism(Hom(self, self._h, category), self._self_to_h))
def _m_to_self(self, x):
'\n Isomorphism from the monomial basis into ``self``\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``x`` -- element of the monomial basis\n\n OUTPUT:\n\n - an element of ``self`` equivalent to ``x``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JP = Sym.jack(t=2).P()\n sage: m = Sym.monomial()\n sage: JP._m_to_self(m[2,1])\n -3/2*JackP[1, 1, 1] + JackP[2, 1]\n\n This is for internal use only. Please use instead::\n\n sage: JP(m[2,1])\n -3/2*JackP[1, 1, 1] + JackP[2, 1]\n '
return self._from_cache(x, self._m_cache, self._m_to_self_cache, t=self.t)
def _self_to_m(self, x):
'\n Isomorphism from self to the monomial basis\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``x`` -- an element of ``self``\n\n OUTPUT:\n\n - an element of the monomial basis equivalent to ``x``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JP = Sym.jack(t=2).P()\n sage: m = Sym.monomial()\n sage: JP._self_to_m(JP[2,1])\n 3/2*m[1, 1, 1] + m[2, 1]\n\n This is for internal use only. Please use instead::\n\n sage: m(JP[2,1])\n 3/2*m[1, 1, 1] + m[2, 1]\n '
return self._m._from_cache(x, self._m_cache, self._self_to_m_cache, t=self.t)
def c1(self, part):
"\n Returns the `t`-Jack scalar product between ``J(part)`` and ``P(part)``.\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``part`` -- a partition\n - ``t`` -- an optional parameter (default: uses the parameter `t` from the\n Jack basis)\n\n OUTPUT:\n\n - a polynomial in the parameter ``t`` which is equal to the scalar\n product of ``J(part)`` and ``P(part)``\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: JP.c1(Partition([2,1]))\n t + 2\n "
return c1(part, self.t)
def c2(self, part):
"\n Returns the `t`-Jack scalar product between ``J(part)`` and ``Q(part)``.\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``part`` -- a partition\n - ``t`` -- an optional parameter (default: uses the parameter `t` from the\n Jack basis)\n\n OUTPUT:\n\n - a polynomial in the parameter ``t`` which is equal to the scalar\n product of ``J(part)`` and ``Q(part)``\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: JP.c2(Partition([2,1]))\n 2*t^3 + t^2\n "
return c2(part, self.t)
_normalize_coefficients = normalize_coefficients
def _normalize(self, x):
"\n Normalize the coefficients of ``x``\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``x`` -- an element of ``self``\n\n OUTPUT:\n\n - returns ``x`` with _normalize_coefficient applied to each of the coefficients\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: t = JP.base_ring().gen()\n sage: a = 2/(1/2*t+1/2)\n sage: b = 1/(1/3+1/6*t)\n sage: c = 24/(4*t^2 + 12*t + 8)\n sage: JP._normalize( a*JP[1] + b*JP[2] + c*JP[2,1] )\n (4/(t+1))*JackP[1] + (6/(t+2))*JackP[2] + (6/(t^2+3*t+2))*JackP[2, 1]\n\n .. TODO:: this should be a method on the elements (what's the standard name for such methods?)\n "
return x.map_coefficients(self._normalize_coefficients)
def _normalize_morphism(self, category):
"\n Returns the normalize morphism\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``category`` -- a category\n\n OUTPUT:\n\n - the normalized morphism\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: normal = JP._normalize_morphism(AlgebrasWithBasis(JP.base_ring()))\n sage: normal.parent()\n Set of Homomorphisms from Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack P basis to Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack P basis\n sage: normal.category_for()\n Category of algebras with basis over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n\n sage: t = JP.t\n sage: a = 2/(1/2*t+1/2)\n sage: b = 1/(1/3+1/6*t)\n sage: c = 24/(4*t^2 + 12*t + 8)\n sage: normal( a*JP[1] + b*JP[2] + c*JP[2,1] )\n (4/(t+1))*JackP[1] + (6/(t+2))*JackP[2] + (6/(t^2+3*t+2))*JackP[2, 1]\n\n .. TODO::\n\n This method should not be needed once short idioms to\n construct morphisms are available\n "
return SetMorphism(End(self, category), self._normalize)
def product(self, left, right):
"\n The product of two Jack symmetric functions is done by multiplying the\n elements in the `P` basis and then expressing the elements\n in the basis ``self``.\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``left``, ``right`` -- symmetric function elements\n\n OUTPUT:\n\n the product of ``left`` and ``right`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: JJ = SymmetricFunctions(FractionField(QQ['t'])).jack().J()\n sage: JJ([1])^2 # indirect doctest\n (t/(t+1))*JackJ[1, 1] + (1/(t+1))*JackJ[2]\n sage: JJ([2])^2\n (t^2/(t^2+3/2*t+1/2))*JackJ[2, 2] + (4/3*t/(t^2+4/3*t+1/3))*JackJ[3, 1] + ((1/6*t+1/6)/(t^2+5/6*t+1/6))*JackJ[4]\n sage: JQ = SymmetricFunctions(FractionField(QQ['t'])).jack().Q()\n sage: JQ([1])^2 # indirect doctest\n JackQ[1, 1] + (2/(t+1))*JackQ[2]\n sage: JQ([2])^2\n JackQ[2, 2] + (2/(t+1))*JackQ[3, 1] + ((t+1)/(t^2+5/6*t+1/6))*JackQ[4]\n "
return self((self._P(left) * self._P(right)))
def jack_family(self):
'\n Returns the family of Jack bases associated to the basis ``self``\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n\n OUTPUT:\n\n - the family of Jack symmetric functions associated to ``self``\n\n EXAMPLES::\n\n sage: JackP = SymmetricFunctions(QQ).jack(t=2).P()\n sage: JackP.jack_family()\n Jack polynomials with t=2 over Rational Field\n '
return self._jack
def coproduct_by_coercion(self, elt):
"\n Returns the coproduct of the element ``elt`` by coercion to the Schur basis.\n\n INPUT:\n\n - ``self`` -- a Jack symmetric function basis\n - ``elt`` -- an instance of this basis\n\n OUTPUT:\n\n - The coproduct acting on ``elt``, the result is an element of the\n tensor squared of the Jack symmetric function basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: Sym.jack().P()[2,2].coproduct() #indirect doctest\n JackP[] # JackP[2, 2] + (2/(t+1))*JackP[1] # JackP[2, 1] + ((8*t+4)/(t^3+4*t^2+5*t+2))*JackP[1, 1] # JackP[1, 1] + JackP[2] # JackP[2] + (2/(t+1))*JackP[2, 1] # JackP[1] + JackP[2, 2] # JackP[]\n "
from sage.categories.tensor import tensor
s = self.realization_of().schur()
g = self.tensor_square().sum(((coeff * tensor([self(s[x]), self(s[y])])) for ((x, y), coeff) in s(elt).coproduct()))
normalize = self._normalize_coefficients
return self.tensor_square().sum(((normalize(coeff) * tensor([self(x), self(y)])) for ((x, y), coeff) in g))
class Element(sfa.SymmetricFunctionAlgebra_generic.Element):
def scalar_jack(self, x, t=None):
"\n A scalar product where the power sums are orthogonal and\n `\\langle p_\\mu, p_\\mu \\rangle = z_\\mu t^{length(\\mu)}`\n\n INPUT:\n\n - ``self`` -- an element of a Jack basis of the symmetric functions\n - ``x`` -- an element of the symmetric functions\n - ``t`` -- an optional parameter (default : None uses the parameter from\n the basis)\n\n OUTPUT:\n\n - returns the Jack scalar product between ``x`` and ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JP = Sym.jack().P()\n sage: JQ = Sym.jack().Q()\n sage: p = Partitions(3).list()\n sage: matrix([[JP(a).scalar_jack(JQ(b)) for a in p] for b in p])\n [1 0 0]\n [0 1 0]\n [0 0 1]\n "
parent = self.parent()
p = parent.realization_of().power()
res = p(self).scalar_jack(p(x), t)
return parent._normalize_coefficients(res)
|
def part_scalar_jack(part1, part2, t):
'\n Returns the Jack scalar product between ``p(part1)`` and ``p(part2)`` where\n `p` is the power-sum basis.\n\n INPUT:\n\n - ``part1``, ``part2`` -- two partitions\n - ``t`` -- a parameter\n\n OUTPUT:\n\n - returns the scalar product between the power sum indexed by ``part1`` and ``part2``\n\n EXAMPLES::\n\n sage: Q.<t> = QQ[]\n sage: from sage.combinat.sf.jack import part_scalar_jack\n sage: matrix([[part_scalar_jack(p1,p2,t) for p1 in Partitions(4)] for p2 in Partitions(4)])\n [ 4*t 0 0 0 0]\n [ 0 3*t^2 0 0 0]\n [ 0 0 8*t^2 0 0]\n [ 0 0 0 4*t^3 0]\n [ 0 0 0 0 24*t^4]\n '
if (part1 != part2):
return 0
else:
return (part1.centralizer_size() * (t ** len(part1)))
|
class JackPolynomials_p(JackPolynomials_generic):
def __init__(self, jack):
"\n The `P` basis is uni-triangularly related to the monomial basis and\n orthogonal with respect to the Jack scalar product.\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `P` basis of the symmetric functions\n - ``jack`` -- a family of Jack symmetric function bases\n\n EXAMPLES::\n\n sage: P = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: TestSuite(P).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive\n sage: TestSuite(P).run(elements = [P.t*P[1,1]+P[2], P[1]+(1+P.t)*P[1,1]])\n "
self._name = 'Jack polynomials in the P basis'
self._prefix = 'JackP'
self._m_to_self_cache = m_to_p_cache
self._self_to_m_cache = p_to_m_cache
JackPolynomials_generic.__init__(self, jack)
def _m_cache(self, n):
"\n Computes the change of basis between the Jack polynomials in the `P`\n basis and the monomial symmetric functions. This uses Gram-Schmidt\n to go to the monomials, and then that matrix is simply inverted.\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `P` basis of the symmetric functions\n - ``n`` -- a positive integer indicating the degree\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: JP._m_cache(2)\n sage: l(JP._self_to_m_cache[2])\n [([1, 1], [([1, 1], 1)]), ([2], [([1, 1], 2/(t + 1)), ([2], 1)])]\n sage: l(JP._m_to_self_cache[2])\n [([1, 1], [([1, 1], 1)]), ([2], [([1, 1], -2/(t + 1)), ([2], 1)])]\n sage: JP._m_cache(3)\n sage: l(JP._m_to_self_cache[3])\n [([1, 1, 1], [([1, 1, 1], 1)]),\n ([2, 1], [([1, 1, 1], -6/(t + 2)), ([2, 1], 1)]),\n ([3], [([1, 1, 1], 6/(t^2 + 3*t + 2)), ([2, 1], -3/2/(t + 1/2)), ([3], 1)])]\n sage: l(JP._self_to_m_cache[3])\n [([1, 1, 1], [([1, 1, 1], 1)]),\n ([2, 1], [([1, 1, 1], 6/(t + 2)), ([2, 1], 1)]),\n ([3],\n [([1, 1, 1], 3/(t^2 + 3/2*t + 1/2)), ([2, 1], 3/2/(t + 1/2)), ([3], 1)])]\n "
if (n in self._self_to_m_cache):
return
self._self_to_m_cache[n] = {}
t = QQt.gen()
monomial = sage.combinat.sf.sf.SymmetricFunctions(QQt).monomial()
JP = sage.combinat.sf.sf.SymmetricFunctions(QQt).jack().P()
JP._gram_schmidt(n, monomial, (lambda p: part_scalar_jack(p, p, t)), self._self_to_m_cache[n], upper_triangular=True)
JP._invert_morphism(n, QQt, self._self_to_m_cache, self._m_to_self_cache, to_other_function=self._to_m)
def _to_m(self, part):
"\n Return a function that takes in a partition lambda that returns the\n coefficient of lambda in the expansion of self(part) in the\n monomial basis.\n\n This assumes that the cache from the Jack polynomials in the `P`\n basis to the monomial symmetric functions has already been\n computed.\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `P` basis of the symmetric functions\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a function that accepts a partition and returns the coefficients\n of the expansion of the element of ``P(part)`` in the monomial basis\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: JP._m_cache(3)\n sage: f = JP._to_m(Partition([2,1]))\n sage: [f(part) for part in Partitions(3)]\n [0, 1, 6/(t + 2)]\n sage: JP.symmetric_function_ring().m()(JP[2,1])\n (6/(t+2))*m[1, 1, 1] + m[2, 1]\n "
f = (lambda part2: self._self_to_m_cache[sum(part)][part].get(part2, 0))
return f
def product(self, left, right):
"\n The product of two Jack symmetric functions is done by multiplying the\n elements in the monomial basis and then expressing the elements\n the basis ``self``.\n\n INPUT:\n\n - ``self`` -- a Jack basis of the symmetric functions\n - ``left``, ``right`` -- symmetric function elements\n\n OUTPUT:\n\n the product of ``left`` and ``right`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: m = JP.symmetric_function_ring().m()\n sage: JP([1])^2 # indirect doctest\n (2*t/(t+1))*JackP[1, 1] + JackP[2]\n sage: m(_)\n 2*m[1, 1] + m[2]\n sage: JP = SymmetricFunctions(QQ).jack(t=2).P()\n sage: JP([2,1])^2\n 125/63*JackP[2, 2, 1, 1] + 25/12*JackP[2, 2, 2] + 25/18*JackP[3, 1, 1, 1] + 12/5*JackP[3, 2, 1] + 4/3*JackP[3, 3] + 4/3*JackP[4, 1, 1] + JackP[4, 2]\n sage: m(_)\n 45*m[1, 1, 1, 1, 1, 1] + 51/2*m[2, 1, 1, 1, 1] + 29/2*m[2, 2, 1, 1] + 33/4*m[2, 2, 2] + 9*m[3, 1, 1, 1] + 5*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2]\n "
return self((self._m(left) * self._m(right)))
def scalar_jack_basis(self, part1, part2=None):
"\n Returns the scalar product of `P(part1)` and `P(part2)`.\n\n This is equation (10.16) of [Mc1995]_ on page 380.\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `P` basis of the symmetric functions\n - ``part1`` -- a partition\n - ``part2`` -- an optional partition (default : None)\n\n OUTPUT:\n\n - the scalar product between `P(part1)` and `P(part2)` (or itself if `part2` is None)\n\n REFERENCES:\n\n .. [Mc1995] \\I. G. Macdonald, Symmetric functions and Hall\n polynomials, second ed., The Clarendon Press, Oxford\n University Press, New York, 1995, With contributions by\n A. Zelevinsky, Oxford Science Publications.\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: JJ = SymmetricFunctions(FractionField(QQ['t'])).jack().J()\n sage: JP.scalar_jack_basis(Partition([2,1]), Partition([1,1,1]))\n 0\n sage: JP._normalize_coefficients(JP.scalar_jack_basis(Partition([3,2,1]), Partition([3,2,1])))\n (6*t^6 + 10*t^5 + 11/2*t^4 + t^3)/(t^3 + 11/2*t^2 + 10*t + 6)\n sage: JJ(JP[3,2,1]).scalar_jack(JP[3,2,1])\n (6*t^6 + 10*t^5 + 11/2*t^4 + t^3)/(t^3 + 11/2*t^2 + 10*t + 6)\n\n With a single argument, takes `part2 = part1`::\n\n sage: JP.scalar_jack_basis(Partition([2,1]), Partition([2,1]))\n (2*t^3 + t^2)/(t + 2)\n sage: JJ(JP[2,1]).scalar_jack(JP[2,1])\n (2*t^3 + t^2)/(t + 2)\n "
if ((part2 is not None) and (part1 != part2)):
return self.base_ring().zero()
return (self.c2(part1) / self.c1(part1))
class Element(JackPolynomials_generic.Element):
def scalar_jack(self, x, t=None):
"\n The scalar product on the symmetric functions where the power sums\n are orthogonal and `\\langle p_\\mu, p_\\mu \\rangle = z_\\mu t^{length(mu)}`\n where the t parameter from the Jack symmetric function family.\n\n INPUT:\n\n - ``self`` -- an element of the Jack `P` basis\n - ``x`` -- an element of the `P` basis\n\n EXAMPLES::\n\n sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()\n sage: l = [JP(p) for p in Partitions(3)]\n sage: matrix([[a.scalar_jack(b) for a in l] for b in l])\n [3*t^3/(t^2 + 3/2*t + 1/2) 0 0]\n [ 0 (2*t^3 + t^2)/(t + 2) 0]\n [ 0 0 1/6*t^3 + 1/2*t^2 + 1/3*t]\n "
if (isinstance(x, JackPolynomials_p) and (t is None)):
P = self.parent()
return P._apply_multi_module_morphism(self, x, P.scalar_jack_basis, orthogonal=True)
else:
return JackPolynomials_generic.Element.scalar_jack(self, x, t)
|
class JackPolynomials_j(JackPolynomials_generic):
def __init__(self, jack):
"\n The `J` basis is a defined as a normalized form of the `P` basis\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `P` basis of the symmetric functions\n - ``jack`` -- a family of Jack symmetric function bases\n\n EXAMPLES::\n\n sage: J = SymmetricFunctions(FractionField(QQ['t'])).jack().J()\n sage: TestSuite(J).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive\n sage: TestSuite(J).run(elements = [J.t*J[1,1]+J[2], J[1]+(1+J.t)*J[1,1]]) # long time (3s on sage.math, 2012)\n "
self._name = 'Jack polynomials in the J basis'
self._prefix = 'JackJ'
JackPolynomials_generic.__init__(self, jack)
self._P = self._jack.P()
category = sage.categories.all.ModulesWithBasis(self.base_ring())
phi = self.module_morphism(diagonal=self.c1, codomain=self._P, category=category)
self._P.register_coercion((self._P._normalize_morphism(category) * phi))
self.register_coercion((self._normalize_morphism(category) * (~ phi)))
class Element(JackPolynomials_generic.Element):
pass
|
class JackPolynomials_q(JackPolynomials_generic):
def __init__(self, jack):
"\n The `Q` basis is defined as a normalized form of the `P` basis\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `Q` basis of the symmetric functions\n - ``jack`` -- a family of Jack symmetric function bases\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(FractionField(QQ['t'])).jack().Q()\n sage: TestSuite(Q).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive\n sage: TestSuite(Q).run(elements = [Q.t*Q[1,1]+Q[2], Q[1]+(1+Q.t)*Q[1,1]]) # long time (3s on sage.math, 2012)\n "
self._name = 'Jack polynomials in the Q basis'
self._prefix = 'JackQ'
JackPolynomials_generic.__init__(self, jack)
self._P = self._jack.P()
category = sage.categories.all.ModulesWithBasis(self.base_ring())
phi = self._P.module_morphism(diagonal=self._P.scalar_jack_basis, codomain=self, category=category)
self.register_coercion((self._normalize_morphism(category) * phi))
self._P.register_coercion((self._P._normalize_morphism(category) * (~ phi)))
class Element(JackPolynomials_generic.Element):
pass
|
class JackPolynomials_qp(JackPolynomials_generic):
def __init__(self, jack):
"\n The `Qp` basis is the dual basis to the `P` basis with respect to the\n standard scalar product\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `Qp` basis of the symmetric functions\n - ``jack`` -- a family of Jack symmetric function bases\n\n EXAMPLES::\n\n sage: Qp = SymmetricFunctions(FractionField(QQ['t'])).jack().Qp()\n sage: TestSuite(Qp).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive\n sage: TestSuite(Qp).run(elements = [Qp.t*Qp[1,1]+Qp[2], Qp[1]+(1+Qp.t)*Qp[1,1]]) # long time (3s on sage.math, 2012)\n "
self._name = 'Jack polynomials in the Qp basis'
self._prefix = 'JackQp'
JackPolynomials_generic.__init__(self, jack)
self._P = self._jack.P()
self._self_to_h_cache = qp_to_h_cache
self._h_to_self_cache = h_to_qp_cache
def product(self, left, right):
"\n The product of two Jack symmetric functions is done by multiplying the\n elements in the monomial basis and then expressing the elements\n the basis ``self``.\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `Qp` basis of the symmetric functions\n - ``left``, ``right`` -- symmetric function elements\n\n OUTPUT:\n\n the product of ``left`` and ``right`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: JQp = SymmetricFunctions(FractionField(QQ['t'])).jack().Qp()\n sage: h = JQp.symmetric_function_ring().h()\n sage: JQp([1])^2 # indirect doctest\n JackQp[1, 1] + (2/(t+1))*JackQp[2]\n sage: h(_)\n h[1, 1]\n sage: JQp = SymmetricFunctions(QQ).jack(t=2).Qp()\n sage: h = SymmetricFunctions(QQ).h()\n sage: JQp([2,1])^2\n JackQp[2, 2, 1, 1] + 2/3*JackQp[2, 2, 2] + 2/3*JackQp[3, 1, 1, 1] + 48/35*JackQp[3, 2, 1] + 28/75*JackQp[3, 3] + 128/225*JackQp[4, 1, 1] + 28/75*JackQp[4, 2]\n sage: h(_)\n h[2, 2, 1, 1] - 6/5*h[3, 2, 1] + 9/25*h[3, 3]\n "
return self((self._h(left) * self._h(right)))
def _h_cache(self, n):
"\n Computes the change of basis between the Jack polynomials in the `Qp`\n basis and the homogeneous symmetric functions. This uses the coefficients\n in the change of basis between the Jack `P` basis and the monomial basis.\n\n INPUT:\n\n - ``self`` -- an instance of the Jack `Qp` basis of the symmetric functions\n - ``n`` -- a positive integer indicating the degree\n\n EXAMPLES::\n\n sage: JQp = SymmetricFunctions(FractionField(QQ['t'])).jack().Qp()\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: JQp._h_cache(2)\n sage: l(JQp._self_to_h_cache[2])\n [([1, 1], [([1, 1], 1), ([2], -2/(t + 1))]), ([2], [([2], 1)])]\n sage: l(JQp._h_to_self_cache[2])\n [([1, 1], [([1, 1], 1), ([2], 2/(t + 1))]), ([2], [([2], 1)])]\n sage: JQp._h_cache(3)\n sage: l(JQp._h_to_self_cache[3])\n [([1, 1, 1],\n [([1, 1, 1], 1), ([2, 1], 6/(t + 2)), ([3], 3/(t^2 + 3/2*t + 1/2))]),\n ([2, 1], [([2, 1], 1), ([3], 3/2/(t + 1/2))]),\n ([3], [([3], 1)])]\n sage: l(JQp._self_to_h_cache[3])\n [([1, 1, 1], [([1, 1, 1], 1), ([2, 1], -6/(t + 2)), ([3], 6/(t^2 + 3*t + 2))]),\n ([2, 1], [([2, 1], 1), ([3], -3/2/(t + 1/2))]),\n ([3], [([3], 1)])]\n "
if (n in self._self_to_h_cache):
return
else:
self._self_to_h_cache[n] = {}
self._h_to_self_cache[n] = {}
self._P._m_cache(n)
from_cache_1 = self._P._self_to_m_cache[n]
to_cache_1 = self._self_to_h_cache[n]
from_cache_2 = self._P._m_to_self_cache[n]
to_cache_2 = self._h_to_self_cache[n]
for mu in from_cache_1:
for la in from_cache_1[mu]:
if (la not in to_cache_1):
to_cache_1[la] = {}
to_cache_2[la] = {}
to_cache_2[la][mu] = from_cache_1[mu][la]
to_cache_1[la][mu] = from_cache_2[mu][la]
def _self_to_h(self, x):
'\n Isomorphism from self to the homogeneous basis\n\n INPUT:\n\n - ``self`` -- a Jack `Qp` basis of the symmetric functions\n - ``x`` -- an element of the Jack `Qp` basis\n\n OUTPUT:\n\n - an element of the homogeneous basis equivalent to ``x``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JQp = Sym.jack(t=2).Qp()\n sage: h = Sym.homogeneous()\n sage: JQp._self_to_h(JQp[2,1])\n h[2, 1] - 3/5*h[3]\n\n This is for internal use only. Please use instead::\n\n sage: h(JQp[2,1])\n h[2, 1] - 3/5*h[3]\n '
return self._h._from_cache(x, self._h_cache, self._self_to_h_cache, t=self.t)
def _h_to_self(self, x):
'\n Isomorphism from the homogeneous basis into ``self``\n\n INPUT:\n\n - ``self`` -- a Jack `Qp` basis of the symmetric functions\n - ``x`` -- element of the homogeneous basis\n\n OUTPUT:\n\n - an element of the Jack `Qp` basis equivalent to ``x``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: JQp = Sym.jack(t=2).Qp()\n sage: h = Sym.homogeneous()\n sage: JQp._h_to_self(h[2,1])\n JackQp[2, 1] + 3/5*JackQp[3]\n\n This is for internal use only. Please use instead::\n\n sage: JQp(h[2,1])\n JackQp[2, 1] + 3/5*JackQp[3]\n '
return self._from_cache(x, self._h_cache, self._h_to_self_cache, t=self.t)
def coproduct_by_coercion(self, elt):
"\n Returns the coproduct of the element ``elt`` by coercion to the Schur basis.\n\n INPUT:\n\n - ``elt`` -- an instance of the ``Qp`` basis\n\n OUTPUT:\n\n - The coproduct acting on ``elt``, the result is an element of the\n tensor squared of the ``Qp`` symmetric function basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: JQp = Sym.jack().Qp()\n sage: JQp[2,2].coproduct() #indirect doctest\n JackQp[] # JackQp[2, 2] + (2*t/(t+1))*JackQp[1] # JackQp[2, 1] + JackQp[1, 1] # JackQp[1, 1] + ((2*t^3+4*t^2)/(t^3+5/2*t^2+2*t+1/2))*JackQp[2] # JackQp[2] + (2*t/(t+1))*JackQp[2, 1] # JackQp[1] + JackQp[2, 2] # JackQp[]\n "
h = elt.parent().realization_of().h()
parent = elt.parent()
from sage.categories.tensor import tensor
cfunc = (lambda x, y: tensor([parent(x), parent(y)]))
cprod = h(elt).coproduct().apply_multilinear_morphism(cfunc)
normalize = (lambda c: normalize_coefficients(parent, c))
return cprod.parent().sum(((normalize(coeff) * tensor([parent(x), parent(y)])) for ((x, y), coeff) in cprod))
class Element(JackPolynomials_generic.Element):
pass
|
class SymmetricFunctionAlgebra_zonal(sfa.SymmetricFunctionAlgebra_generic):
def __init__(self, Sym):
"\n Returns the algebra of zonal polynomials.\n\n INPUT:\n\n - ``self`` -- a zonal basis of the symmetric functions\n - ``Sym`` -- a ring of the symmetric functions\n\n EXAMPLES::\n\n sage: Z = SymmetricFunctions(QQ).zonal()\n sage: Z([2])^2\n 64/45*Z[2, 2] + 16/21*Z[3, 1] + Z[4]\n sage: Z = SymmetricFunctions(QQ).zonal()\n sage: TestSuite(Z).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive\n sage: TestSuite(Z).run(elements = [Z[1,1]+Z[2], Z[1]+2*Z[1,1]])\n "
self._sym = Sym
self._jack = self._sym.jack(t=2)
self._P = self._jack.P()
sfa.SymmetricFunctionAlgebra_generic.__init__(self, self._sym, prefix='Z', basis_name='zonal')
category = sage.categories.all.ModulesWithBasis(self._sym.base_ring())
self.register_coercion(SetMorphism(Hom(self._P, self, category), self.sum_of_terms))
self._P.register_coercion(SetMorphism(Hom(self, self._P, category), self._P.sum_of_terms))
def product(self, left, right):
'\n The product of two zonal symmetric functions is done by multiplying the\n elements in the monomial basis and then expressing the elements\n in the basis ``self``.\n\n INPUT:\n\n - ``self`` -- a zonal basis of the symmetric functions\n - ``left``, ``right`` -- symmetric function elements\n\n OUTPUT:\n\n the product of ``left`` and ``right`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Z = Sym.zonal()\n sage: JP = Sym.jack(t=1).P()\n sage: Z([2])*Z([3]) # indirect doctest\n 192/175*Z[3, 2] + 32/45*Z[4, 1] + Z[5]\n sage: Z([2])*JP([2])\n 10/27*Z[2, 1, 1] + 64/45*Z[2, 2] + 23/21*Z[3, 1] + Z[4]\n sage: JP = Sym.jack(t=2).P()\n sage: Z([2])*JP([2])\n 64/45*Z[2, 2] + 16/21*Z[3, 1] + Z[4]\n '
return self((self._P(left) * self._P(right)))
class Element(sfa.SymmetricFunctionAlgebra_generic.Element):
def scalar_zonal(self, x):
'\n The zonal scalar product has the power sum basis and the zonal\n symmetric functions are orthogonal. In particular,\n `\\langle p_\\mu, p_\\mu \\rangle = z_\\mu 2^{length(\\mu)}`.\n\n INPUT:\n\n - ``self`` -- an element of the zonal basis\n - ``x`` -- an element of the symmetric function\n\n OUTPUT:\n\n - the scalar product between ``self`` and ``x``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Z = Sym.zonal()\n sage: parts = Partitions(3).list()\n sage: matrix([[Z(a).scalar_zonal(Z(b)) for a in parts] for b in parts])\n [16/5 0 0]\n [ 0 5 0]\n [ 0 0 4]\n sage: p = Z.symmetric_function_ring().power()\n sage: matrix([[Z(p(a)).scalar_zonal(p(b)) for a in parts] for b in parts])\n [ 6 0 0]\n [ 0 8 0]\n [ 0 0 48]\n '
P = self.parent()._P
return P(self).scalar_jack(P(x), 2)
|
class KBoundedQuotient(UniqueRepresentation, Parent):
def __init__(self, Sym, k, t='t'):
"\n Initialization of the ring of Symmetric functions modulo the ideal of monomial\n symmetric functions which are indexed by partitions whose first part is greater\n than `k`.\n\n INPUT:\n\n - ``Sym`` -- an element of class :class:`sage.combinat.sf.sf.SymmetricFunctions`\n\n - ``k`` -- a positive integer\n\n - ``R`` -- a ring\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Q = Sym.kBoundedQuotient(3,t=1)\n sage: Q\n 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1\n sage: km = Q.km()\n sage: km\n 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded monomial basis\n sage: F = Q.affineSchur()\n sage: F(km(F[3,1,1])) == F[3,1,1]\n True\n sage: km(F(km([3,2]))) == km[3,2]\n True\n sage: F[3,2].lift()\n m[1, 1, 1, 1, 1] + m[2, 1, 1, 1] + m[2, 2, 1] + m[3, 1, 1] + m[3, 2]\n sage: F[2,1]*F[2,1]\n 2*F3[1, 1, 1, 1, 1, 1] + 4*F3[2, 1, 1, 1, 1] + 4*F3[2, 2, 1, 1] + 4*F3[2, 2, 2] + 2*F3[3, 1, 1, 1] + 4*F3[3, 2, 1] + 2*F3[3, 3]\n sage: F[1,2]\n Traceback (most recent call last):\n ...\n ValueError: [1, 2] is not an element of 3-Bounded Partitions\n sage: F[4,2]\n Traceback (most recent call last):\n ...\n ValueError: [4, 2] is not an element of 3-Bounded Partitions\n sage: km[2,1]*km[2,1]\n 4*m3[2, 2, 1, 1] + 6*m3[2, 2, 2] + 2*m3[3, 2, 1] + 2*m3[3, 3]\n sage: HLPk = Q.kHallLittlewoodP()\n sage: HLPk[2,1]*HLPk[2,1]\n 4*HLP3[2, 2, 1, 1] + 6*HLP3[2, 2, 2] + 2*HLP3[3, 2, 1] + 2*HLP3[3, 3]\n sage: dks = Q.dual_k_Schur()\n sage: dks[2,1]*dks[2,1]\n 2*dks3[1, 1, 1, 1, 1, 1] + 4*dks3[2, 1, 1, 1, 1] + 4*dks3[2, 2, 1, 1] + 4*dks3[2, 2, 2] + 2*dks3[3, 1, 1, 1] + 4*dks3[3, 2, 1] + 2*dks3[3, 3]\n\n ::\n\n sage: Q = Sym.kBoundedQuotient(3)\n Traceback (most recent call last):\n ...\n TypeError: unable to convert 't' to a rational\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: Q = Sym.kBoundedQuotient(3)\n sage: km = Q.km()\n sage: F = Q.affineSchur()\n sage: F(km(F[3,1,1])) == F[3,1,1]\n True\n sage: km(F(km([3,2]))) == km[3,2]\n True\n sage: dks = Q.dual_k_Schur()\n sage: HLPk = Q.kHallLittlewoodP()\n sage: dks(HLPk(dks[3,1,1])) == dks[3,1,1]\n True\n sage: km(dks(km([3,2]))) == km[3,2]\n True\n sage: dks[2,1]*dks[2,1]\n (t^3+t^2)*dks3[1, 1, 1, 1, 1, 1] + (2*t^2+2*t)*dks3[2, 1, 1, 1, 1] + (t^2+2*t+1)*dks3[2, 2, 1, 1] + (t^2+2*t+1)*dks3[2, 2, 2] + (t+1)*dks3[3, 1, 1, 1] + (2*t+2)*dks3[3, 2, 1] + (t+1)*dks3[3, 3]\n\n TESTS::\n\n sage: TestSuite(Q).run()\n\n "
R = Sym.base_ring()
self.k = k
self.t = R(t)
self._base = R
self._sym = Sym
if (t == 1):
self._quotient_basis = Sym.m()
else:
self._quotient_basis = Sym.hall_littlewood(t=self.t).P()
Parent.__init__(self, category=GradedHopfAlgebras(R).Quotients().WithRealizations())
self.indices = ConstantFunction(Partitions_all_bounded(k))
def ambient(self):
'\n\n Returns the Symmetric Functions over the same ring as ``self``. This is needed to\n realize our ring as a quotient.\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Q = Sym.kBoundedQuotient(3,t=1)\n sage: Q.ambient()\n Symmetric Functions over Rational Field\n\n '
return self._sym
def a_realization(self):
'\n Returns a particular realization of ``self`` (the basis of `k`-bounded monomials\n if `t=1` and the basis of `k`-bounded Hall-Littlewood functions otherwise).\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Q = Sym.kBoundedQuotient(3,t=1)\n sage: Q.a_realization()\n 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded monomial basis\n sage: Q = Sym.kBoundedQuotient(3,t=2)\n sage: Q.a_realization()\n 3-Bounded Quotient of Symmetric Functions over Rational Field with t=2 in the 3-bounded Hall-Littlewood P basis\n '
if (self.t == 1):
return self.kmonomial()
else:
return self.kHallLittlewoodP()
def _repr_(self):
'\n Representation of ``self``.\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(RR) # indirect doctest\n sage: Sym.kBoundedQuotient(4,t=1)\n 4-Bounded Quotient of Symmetric Functions over Real Field with 53 bits of precision with t=1.00000000000000\n '
ending = ''
if (str(self.t) != 't'):
ending = (' with t=%s' % self.t)
return (('%s-Bounded Quotient of Symmetric Functions over %s' % (self.k, self.base_ring())) + ending)
def kmonomial(self):
'\n The monomial basis of the `k`-bounded quotient of symmetric functions, indexed by\n `k`-bounded partitions.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).kBoundedQuotient(2,t=1).kmonomial()\n 2-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 2-bounded monomial basis\n '
return kMonomial(self)
km = kmonomial
def kHallLittlewoodP(self):
"\n The Hall-Littlewood P basis of the `k`-bounded quotient of symmetric functions,\n indexed by `k`-bounded partitions. At `t=1` this basis is equal to the\n `k`-bounded monomial basis and calculations will be faster using elements in the\n `k`-bounded monomial basis (see :meth:`kmonomial`).\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(2).kHallLittlewoodP()\n 2-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 2-bounded Hall-Littlewood P basis\n "
return kbounded_HallLittlewoodP(self)
kHLP = kHallLittlewoodP
def dual_k_Schur(self):
"\n The dual `k`-Schur basis of the `k`-bounded quotient of symmetric functions,\n indexed by `k`-bounded partitions. At `t=1` this is also equal to the affine\n Schur basis and calculations will be faster using elements in the :meth:`affineSchur`\n basis.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(2).dual_k_Schur()\n 2-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the dual 2-Schur basis\n "
return DualkSchurFunctions(self)
dks = dual_k_Schur
def affineSchur(self):
'\n The affine Schur basis of the `k`-bounded quotient of symmetric functions,\n indexed by `k`-bounded partitions. This is also equal to the affine Stanley\n symmetric functions (see :meth:`WeylGroups.ElementMethods.stanley_symmetric_function`)\n indexed by an affine Grassmannian permutation.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).kBoundedQuotient(2,t=1).affineSchur()\n 2-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 2-bounded affine Schur basis\n '
return AffineSchurFunctions(self)
F = affineSchur
@cached_method
def _G_to_km_on_basis_single_level(self, w, m):
"\n Returns the `m^{th}` level of the affine Grothendieck polynomial indexed by the\n affine Permutation ``w``. This code could be significantly sped up if it didn't\n depend on the Iwahori Hecke algebra code.\n\n INPUT:\n\n - ``w`` -- An affine permutation (an element of the affine type `A` Weyl group).\n\n - ``m`` -- An integer.\n\n OUTPUT:\n\n - An element of the `k`-bounded quotient.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: W = WeylGroup(['A',3,1])\n sage: Q._G_to_km_on_basis_single_level(W.an_element(), 3)\n 0\n sage: Q._G_to_km_on_basis_single_level(W.an_element(), 4)\n m3[1, 1, 1, 1]\n sage: Q._G_to_km_on_basis_single_level(W.an_element(), 5)\n -4*m3[1, 1, 1, 1, 1]\n\n "
kB = self._sym.kBoundedSubspace(self.k, t=1)
g = kB.K_kschur()
mon = self.km()
if (m < w.length()):
return 0
ans = self.zero()
for la in Partitions(m, max_part=self.k):
ans += (g.homogeneous_basis_noncommutative_variables_zero_Hecke(la).coefficient(w) * mon(la))
return ans
def _AffineGrothendieck(self, w, m):
"\n Returns the affine Grothendieck polynomial indexed by the affine permutation\n ``w``. Because this belongs to the completion of the algebra, and hence is an\n infinite sum, it computes only up to those symmetric functions of degree at most\n ``m``.\n\n INPUT:\n\n - ``w`` -- An affine permutation (an element of the affine type `A` Weyl group).\n\n - ``m`` -- An integer.\n\n OUTPUT:\n\n - An element of the `k`-bounded quotient.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: W = WeylGroup(['A',3,1])\n sage: Q._AffineGrothendieck(W.an_element(), 5)\n m3[1, 1, 1, 1] - 4*m3[1, 1, 1, 1, 1]\n "
return sum((self._G_to_km_on_basis_single_level(w, j) for j in range(w.length(), (m + 1))))
@cached_method
def _AffineGrothendieckPolynomial(self, la, m):
'\n Returns the affine Grothendieck polynomial indexed by the partition ``la``.\n Because this belongs to the completion of the algebra, and hence is an infinite\n sum, it computes only up to those symmetric functions of degree at most ``m``.\n This method is here to cache the polynomials.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n - ``m`` -- An integer\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q._AffineGrothendieckPolynomial(Partition([2,1]),4)\n 2*m3[1, 1, 1] - 8*m3[1, 1, 1, 1] + m3[2, 1] - 3*m3[2, 1, 1] - m3[2, 2]\n '
return self._AffineGrothendieck(la.to_core(self.k).to_grassmannian(), m)
def AffineGrothendieckPolynomial(self, la, m):
'\n Returns the affine Grothendieck polynomial indexed by the partition ``la``.\n Because this belongs to the completion of the algebra, and hence is an infinite\n sum, it computes only up to those symmetric functions of degree at most ``m``.\n See :meth:`_AffineGrothendieckPolynomial` for the code.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n - ``m`` -- An integer\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q.AffineGrothendieckPolynomial([2,1],4)\n 2*m3[1, 1, 1] - 8*m3[1, 1, 1, 1] + m3[2, 1] - 3*m3[2, 1, 1] - m3[2, 2]\n '
if (la == []):
return self.a_realization().one()
return self._AffineGrothendieckPolynomial(Partition(la), m)
def an_element(self):
'\n Returns an element of the quotient ring of `k`-bounded symmetric functions. This\n method is here to make the TestSuite run properly.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q.an_element()\n 2*m3[] + 2*m3[1] + 3*m3[2]\n '
return self.a_realization().an_element()
def one(self):
'\n Returns the unit of the quotient ring of `k`-bounded symmetric functions. This\n method is here to make the TestSuite run properly.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q.one()\n m3[]\n '
return self.a_realization().one()
def retract(self, la):
'\n Gives the retract map from the symmetric functions to the quotient ring of\n `k`-bounded symmetric functions. This method is here to make the TestSuite run\n properly.\n\n INPUT:\n\n - ``la`` -- A partition\n\n OUTPUT:\n\n - The monomial element of the `k`-bounded quotient indexed by ``la``.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q.retract([2,1])\n m3[2, 1]\n '
km = self.a_realization()
return km.retract(la)
def lift(self, la):
"\n Gives the lift map from the quotient ring of `k`-bounded symmetric functions to\n the symmetric functions. This method is here to make the TestSuite run properly.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n OUTPUT:\n\n - The monomial element or a Hall-Littlewood P element of the symmetric functions\n indexed by the partition ``la``.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q.lift([2,1])\n m[2, 1]\n sage: Q = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3)\n sage: Q.lift([2,1])\n HLP[2, 1]\n "
km = self.a_realization()
return km.lift(la)
def realizations(self):
"\n A list of realizations of the `k`-bounded quotient.\n\n EXAMPLES::\n\n sage: kQ = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3)\n sage: kQ.realizations()\n [3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-bounded monomial basis, 3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-bounded Hall-Littlewood P basis, 3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-bounded affine Schur basis, 3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the dual 3-Schur basis]\n sage: HLP = kQ.ambient().hall_littlewood().P()\n sage: all( rzn(HLP[3,2,1]).lift() == HLP[3,2,1] for rzn in kQ.realizations())\n True\n sage: kQ = SymmetricFunctions(QQ).kBoundedQuotient(3,1)\n sage: kQ.realizations()\n [3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded monomial basis, 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded Hall-Littlewood P basis, 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded affine Schur basis, 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the dual 3-Schur basis]\n sage: m = kQ.ambient().m()\n sage: all( rzn(m[3,2,1]).lift() == m[3,2,1] for rzn in kQ.realizations())\n True\n "
return [self.km(), self.kHLP(), self.affineSchur(), self.dual_k_Schur()]
|
class KBoundedQuotientBases(Category_realization_of_parent):
'\n The category of bases for the `k`-bounded subspace of symmetric functions.\n '
def __init__(self, base):
"\n Initialization of the bases of the `k`-bounded subspace.\n\n INPUT:\n\n - ``base`` -- a basis in the `k`-bounded subspace\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: from sage.combinat.sf.k_dual import KBoundedQuotientBases\n sage: Q = Sym.kBoundedQuotient(3,t=1)\n sage: KQB = KBoundedQuotientBases(Q); KQB\n Category of k bounded quotient bases of 3-Bounded Quotient of Symmetric Functions over Univariate Polynomial Ring in t over Rational Field with t=1\n "
Category_realization_of_parent.__init__(self, base)
def super_categories(self):
"\n The super categories of ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: from sage.combinat.sf.k_dual import KBoundedQuotientBases\n sage: Q = Sym.kBoundedQuotient(3,t=1)\n sage: KQB = KBoundedQuotientBases(Q)\n sage: KQB.super_categories()\n [Category of realizations of 3-Bounded Quotient of Symmetric Functions over Univariate Polynomial Ring in t over Rational Field with t=1,\n Join of Category of graded Hopf algebras with basis over Univariate Polynomial Ring in t over Rational Field\n and Category of quotients of algebras over Univariate Polynomial Ring in t over Rational Field\n and Category of quotients of graded modules with basis over Univariate Polynomial Ring in t over Rational Field]\n "
R = self.base().base_ring()
category = GradedHopfAlgebrasWithBasis(R)
return [Realizations(self.base()), category.Quotients()]
class ParentMethods():
def retract(self, la):
'\n Gives the retract map from the symmetric functions to the quotient ring of\n `k`-bounded symmetric functions. This method is here to make the TestSuite run\n properly.\n\n INPUT:\n\n - ``la`` -- A partition\n\n OUTPUT:\n\n - The monomial element of the `k`-bounded quotient indexed by ``la``.\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: Q.retract([2,1])\n m3[2, 1]\n '
kmhlp = self.realization_of().a_realization()
return kmhlp.retract(la)
def _element_constructor_(self, x):
'\n Needed to rewrite the element constructor because of a bug in free_module.py.\n Ideally :meth:`_element_constructor_` would be inherited from free_module.py,\n but it allows for bad inputs.\n\n INPUT:\n\n - ``x`` -- a `k`-bounded partition\n\n OUTPUT:\n\n - an element of the `k`-bounded basis\n\n EXAMPLES::\n\n sage: Q = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: F = Q.affineSchur()\n sage: F([2,1])\n F3[2, 1]\n sage: F(Partition([4,1]))\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded affine Schur basis)\n '
R = self.base_ring()
if isinstance(x, int):
x = Integer(x)
if (x in R):
if (x == 0):
return self.zero()
else:
raise TypeError(('do not know how to make x (= %s) an element of %s' % (x, self)))
elif (x in self._indices):
return self.monomial(self._indices(x))
raise TypeError(('do not know how to make x (= %s) an element of self (=%s)' % (x, self)))
def ambient(self):
'\n Returns the symmetric functions.\n\n EXAMPLES::\n\n sage: km = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).km()\n sage: km.ambient()\n Symmetric Functions over Rational Field\n '
return self.realization_of()._sym
def __getitem__(self, c):
'\n Implements shorthand for accessing basis elements.\n\n For a basis `X` indexed by partitions, this method allows for\n `X[[3,2]]` and `X[3,2]` to be equivalent to `X[Partition([3,2])]`.\n\n Due to limitations in Python syntax, one must use `X[[]]` and not\n `X[]` for the basis element indexed by the empty partition.\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F[3,2]\n F3[3, 2]\n sage: F[[]]\n F3[]\n '
if (c in ZZ):
c = self._kbounded_partitions([c])
else:
c = self._kbounded_partitions(c)
return self.monomial(c)
def _repr_term(self, c):
'\n Display elements with single brackets.\n\n The default implementation of CombinatorialFreeModule gives double\n brackets for basis elements indexed by partitions, i.e.,\n `X[[3,2]]`.\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F[3,2] # indirect doctest\n F3[3, 2]\n '
return (self.prefix() + str(c))
@cached_method
def one_basis(self):
'\n Return the basis element indexing ``1``.\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F.one() # indirect doctest\n F3[]\n '
return self._kbounded_partitions([])
def degree_on_basis(self, b):
'\n Return the degree of the basis element indexed by ``b``.\n\n INPUT:\n\n - ``b`` -- a partition\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F.degree_on_basis(Partition([3,2]))\n 5\n '
return sum(b)
def indices(self):
'\n The set of `k`-bounded partitions of all non-negative integers.\n\n EXAMPLES::\n\n sage: km = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).km()\n sage: km.indices()\n 3-Bounded Partitions\n '
return self._kbounded_partitions
def lift(self, la):
"\n Implements the lift map from the basis ``self`` to the monomial basis of\n symmetric functions.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A symmetric function in the monomial basis.\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F.lift([3,1])\n m[1, 1, 1, 1] + m[2, 1, 1] + m[2, 2] + m[3, 1]\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: dks = Sym.kBoundedQuotient(3).dual_k_Schur()\n sage: dks.lift([3,1])\n t^5*HLP[1, 1, 1, 1] + t^2*HLP[2, 1, 1] + t*HLP[2, 2] + HLP[3, 1]\n sage: dks = Sym.kBoundedQuotient(3,t=1).dual_k_Schur()\n sage: dks.lift([3,1])\n m[1, 1, 1, 1] + m[2, 1, 1] + m[2, 2] + m[3, 1]\n "
kmhlp = self.realization_of().a_realization()
return kmhlp(self(la)).lift()
def product(self, x, y):
"\n Returns the product of two elements ``x`` and ``y``.\n\n INPUT:\n\n - ``x``, ``y`` -- Elements of the `k`-bounded quotient of symmetric functions.\n\n OUTPUT:\n\n - A `k`-bounded symmetric function in the dual `k`-Schur function basis\n\n EXAMPLES::\n\n sage: dks3 = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).dual_k_Schur()\n sage: dks3.product(dks3[2,1],dks3[1,1])\n 2*dks3[1, 1, 1, 1, 1] + 2*dks3[2, 1, 1, 1] + 2*dks3[2, 2, 1] + dks3[3, 1, 1] + dks3[3, 2]\n sage: dks3.product(dks3[2,1]+dks3[1], dks3[1,1])\n dks3[1, 1, 1] + 2*dks3[1, 1, 1, 1, 1] + dks3[2, 1] + 2*dks3[2, 1, 1, 1] + 2*dks3[2, 2, 1] + dks3[3, 1, 1] + dks3[3, 2]\n sage: dks3.product(dks3[2,1]+dks3[1], dks3([]))\n dks3[1] + dks3[2, 1]\n sage: dks3.product(dks3([]), dks3([]))\n dks3[]\n sage: dks3.product(dks3([]), dks3([4,1]))\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the dual 3-Schur basis)\n\n ::\n\n sage: dks3 = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3).dual_k_Schur()\n sage: dks3.product(dks3[2,1],dks3[1,1])\n (t^2+t)*dks3[1, 1, 1, 1, 1] + (t+1)*dks3[2, 1, 1, 1] + (t+1)*dks3[2, 2, 1] + dks3[3, 1, 1] + dks3[3, 2]\n sage: dks3.product(dks3[2,1]+dks3[1], dks3[1,1])\n dks3[1, 1, 1] + (t^2+t)*dks3[1, 1, 1, 1, 1] + dks3[2, 1] + (t+1)*dks3[2, 1, 1, 1] + (t+1)*dks3[2, 2, 1] + dks3[3, 1, 1] + dks3[3, 2]\n sage: dks3.product(dks3[2,1]+dks3[1], dks3([]))\n dks3[1] + dks3[2, 1]\n sage: dks3.product(dks3([]), dks3([]))\n dks3[]\n\n ::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F.product(F[2,1],F[1,1])\n 2*F3[1, 1, 1, 1, 1] + 2*F3[2, 1, 1, 1] + 2*F3[2, 2, 1] + F3[3, 1, 1] + F3[3, 2]\n sage: F.product(F[2,1]+F[1], F[1,1])\n F3[1, 1, 1] + 2*F3[1, 1, 1, 1, 1] + F3[2, 1] + 2*F3[2, 1, 1, 1] + 2*F3[2, 2, 1] + F3[3, 1, 1] + F3[3, 2]\n sage: F.product(F[2,1]+F[1], F([]))\n F3[1] + F3[2, 1]\n sage: F.product(F([]), F([]))\n F3[]\n sage: F.product(F([]), F([4,1]))\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded affine Schur basis)\n\n ::\n\n sage: F = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3).affineSchur()\n sage: F.product(F[2,1],F[1,1])\n 2*F3[1, 1, 1, 1, 1] + 2*F3[2, 1, 1, 1] + 2*F3[2, 2, 1] + F3[3, 1, 1] + F3[3, 2]\n sage: F.product(F[2,1],F[2])\n (t^4+t^3-2*t^2+1)*F3[1, 1, 1, 1, 1] + (-t^2+t+1)*F3[2, 1, 1, 1] + (-t^2+t+2)*F3[2, 2, 1] + (t+1)*F3[3, 1, 1] + (t+1)*F3[3, 2]\n sage: F.product(F[2,1]+F[1], F[1,1])\n F3[1, 1, 1] + 2*F3[1, 1, 1, 1, 1] + F3[2, 1] + 2*F3[2, 1, 1, 1] + 2*F3[2, 2, 1] + F3[3, 1, 1] + F3[3, 2]\n sage: F.product(F[2,1]+F[1], F([]))\n F3[1] + F3[2, 1]\n sage: F.product(F([]), F([]))\n F3[]\n\n ::\n\n sage: km = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).km()\n sage: km.product(km[2,1],km[2,1])\n 4*m3[2, 2, 1, 1] + 6*m3[2, 2, 2] + 2*m3[3, 2, 1] + 2*m3[3, 3]\n sage: Q3 = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3)\n sage: km = Q3.km()\n sage: km.product(km[2,1],km[2,1])\n (t^5+7*t^4-8*t^3-28*t^2+47*t-19)*m3[1, 1, 1, 1, 1, 1] + (t^4-3*t^3-9*t^2+23*t-12)*m3[2, 1, 1, 1, 1] + (-t^3-3*t^2+11*t-3)*m3[2, 2, 1, 1] + (-t^2+5*t+2)*m3[2, 2, 2] + (6*t-6)*m3[3, 1, 1, 1] + (3*t-1)*m3[3, 2, 1] + (t+1)*m3[3, 3]\n sage: dks = Q3.dual_k_Schur()\n sage: km.product(dks[2,1],dks[1,1])\n 20*m3[1, 1, 1, 1, 1] + 9*m3[2, 1, 1, 1] + 4*m3[2, 2, 1] + 2*m3[3, 1, 1] + m3[3, 2]\n "
return self((x.lift() * y.lift()))
def antipode(self, element):
"\n Return the antipode of ``element`` via lifting to the symmetric\n functions and then retracting into the `k`-bounded quotient basis.\n\n INPUT:\n\n - ``element`` -- an element in a basis of the ring of symmetric\n functions\n\n EXAMPLES::\n\n sage: dks3 = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).dual_k_Schur()\n sage: dks3[3,2].antipode()\n -dks3[1, 1, 1, 1, 1]\n sage: km = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).km()\n sage: km[3,2].antipode()\n m3[3, 2]\n sage: km.antipode(km[3,2])\n m3[3, 2]\n sage: m = SymmetricFunctions(QQ).m()\n sage: m[3,2].antipode()\n m[3, 2] + 2*m[5]\n\n ::\n\n sage: km = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3).km()\n sage: km[1,1,1,1].antipode()\n (t^3-3*t^2+3*t)*m3[1, 1, 1, 1] + (-t^2+2*t)*m3[2, 1, 1] + t*m3[2, 2] + t*m3[3, 1]\n sage: kHP = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3).kHLP()\n sage: kHP[2,2].antipode()\n (t^9-t^6-t^5+t^2)*HLP3[1, 1, 1, 1] + (t^6-t^3-t^2+t)*HLP3[2, 1, 1] + (t^5-t^2+1)*HLP3[2, 2] + (t^4-t)*HLP3[3, 1]\n sage: dks = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3).dks()\n sage: dks[2,2].antipode()\n dks3[2, 2]\n sage: dks[3,2].antipode()\n -t^2*dks3[1, 1, 1, 1, 1] + (t^2-1)*dks3[2, 2, 1] + (-t^5+t)*dks3[3, 2]\n "
return self(element.lift().antipode())
def coproduct(self, element):
"\n Return the coproduct of ``element`` via lifting to the symmetric\n functions and then returning to the `k`-bounded quotient basis.\n This method is implemented for all `t` but is (weakly) conjectured\n to not be the correct operation for arbitrary `t` because the\n coproduct on dual-`k`-Schur functions does not have a positive\n expansion.\n\n INPUT:\n\n - ``element`` -- an element in a basis of the ring of symmetric\n functions\n\n EXAMPLES::\n\n sage: Q3 = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1)\n sage: km = Q3.km()\n sage: km[3,2].coproduct()\n m3[] # m3[3, 2] + m3[2] # m3[3] + m3[3] # m3[2] + m3[3, 2] # m3[]\n sage: dks3 = Q3.dual_k_Schur()\n sage: dks3[2,2].coproduct()\n dks3[] # dks3[2, 2] + dks3[1] # dks3[2, 1] + dks3[1, 1] # dks3[1, 1] + dks3[2] # dks3[2] + dks3[2, 1] # dks3[1] + dks3[2, 2] # dks3[]\n\n ::\n\n sage: Q3t = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3)\n sage: km = Q3t.km()\n sage: km[3,2].coproduct()\n m3[] # m3[3, 2] + m3[2] # m3[3] + m3[3] # m3[2] + m3[3, 2] # m3[]\n sage: dks = Q3t.dks()\n sage: dks[2,1,1].coproduct()\n dks3[] # dks3[2, 1, 1] + (-t+1)*dks3[1] # dks3[1, 1, 1] + dks3[1] # dks3[2, 1] + (-t+1)*dks3[1, 1] # dks3[1, 1] + dks3[1, 1] # dks3[2] + (-t+1)*dks3[1, 1, 1] # dks3[1] + dks3[2] # dks3[1, 1] + dks3[2, 1] # dks3[1] + dks3[2, 1, 1] # dks3[]\n sage: kHLP = Q3t.kHLP()\n sage: kHLP[2,1].coproduct()\n HLP3[] # HLP3[2, 1] + (-t^2+1)*HLP3[1] # HLP3[1, 1] + HLP3[1] # HLP3[2] + (-t^2+1)*HLP3[1, 1] # HLP3[1] + HLP3[2] # HLP3[1] + HLP3[2, 1] # HLP3[]\n sage: km.coproduct(km[3,2])\n m3[] # m3[3, 2] + m3[2] # m3[3] + m3[3] # m3[2] + m3[3, 2] # m3[]\n "
from sage.categories.tensor import tensor
base = element.lift().parent()
return self.tensor_square().sum(((coeff * tensor([self(base[x]), self(base[y])])) for ((x, y), coeff) in element.lift().coproduct()))
def counit(self, element):
"\n Return the counit of ``element``.\n\n The counit is the constant term of ``element``.\n\n INPUT:\n\n - ``element`` -- an element in a basis\n\n EXAMPLES::\n\n sage: km = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3).km()\n sage: f = 2*km[2,1] - 3*km([])\n sage: f.counit()\n -3\n sage: km.counit(f)\n -3\n "
return element.coefficient([])
class ElementMethods():
pass
|
class KBoundedQuotientBasis(CombinatorialFreeModule):
'\n Abstract base class for the bases of the `k`-bounded quotient.\n '
def __init__(self, kBoundedRing, prefix):
"\n Initializes ``self``.\n\n INPUT:\n\n - ``kBoundedRing`` -- an element which is of class :class:`KBoundedQuotient`\n - ``prefix`` -- a string used to distinguish this basis, and used in printing.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.k_dual import kMonomial\n sage: km = kMonomial(SymmetricFunctions(QQ).kBoundedQuotient(4,t=1))\n sage: km.prefix() # indirect doctest\n 'm4'\n sage: isinstance(km, sage.combinat.sf.k_dual.KBoundedQuotientBasis)\n True\n\n "
CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category=KBoundedQuotientBases(kBoundedRing), prefix=('%s%d' % (prefix, kBoundedRing.k)))
self._kBoundedRing = kBoundedRing
self.k = kBoundedRing.k
self.t = kBoundedRing.t
self._kbounded_partitions = Partitions_all_bounded(kBoundedRing.k)
__getitem__ = raw_getattr(KBoundedQuotientBases.ParentMethods, '__getitem__')
_repr_term = raw_getattr(KBoundedQuotientBases.ParentMethods, '_repr_term')
_element_constructor_ = raw_getattr(KBoundedQuotientBases.ParentMethods, '_element_constructor_')
|
class kMonomial(KBoundedQuotientBasis):
'\n The basis of monomial symmetric functions indexed by partitions with first\n part less than or equal to `k`.\n '
def __init__(self, kBoundedRing):
'\n Initializes the ring which is the `k`-Bounded monomial quotient basis.\n\n INPUT:\n\n - ``kBoundedRing`` -- an element which is of class :class:`KBoundedQuotient`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.k_dual import kMonomial\n sage: km = kMonomial(SymmetricFunctions(QQ).kBoundedQuotient(4,t=1))\n sage: km\n 4-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 4-bounded monomial basis\n sage: TestSuite(km).run()\n '
KBoundedQuotientBasis.__init__(self, kBoundedRing, 'm')
Sym = kBoundedRing.ambient()
Sym.m().module_morphism(self.retract, codomain=self).register_as_coercion()
def _repr_(self):
"\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: km = Sym.kBoundedQuotient(3,t=1).km()\n sage: km._repr_()\n '3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded monomial basis'\n "
return (self.realization_of()._repr_() + (' in the %s-bounded monomial basis' % self.k))
def retract(self, la):
"\n Implements the retract function on the monomial basis. Given a partition ``la``,\n the retract will return the corresponding `k`-bounded monomial basis element if\n ``la`` is `k`-bounded; zero otherwise.\n\n INPUT:\n\n - ``la`` -- A partition\n\n OUTPUT:\n\n - A `k`-bounded monomial symmetric function in the `k`-quotient of symmetric\n functions.\n\n EXAMPLES::\n\n sage: km = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).km()\n sage: km.retract(Partition([3,1]))\n m3[3, 1]\n sage: km.retract(Partition([4,1]))\n 0\n sage: km.retract([])\n m3[]\n sage: m = SymmetricFunctions(QQ).m()\n sage: km(m[3, 1])\n m3[3, 1]\n sage: km(m[4, 1])\n 0\n\n ::\n\n sage: km = SymmetricFunctions(FractionField(QQ['t'])).kBoundedQuotient(3).km()\n sage: km.retract(Partition([3,1]))\n m3[3, 1]\n sage: km.retract(Partition([4,1]))\n (t^4+t^3-9*t^2+11*t-4)*m3[1, 1, 1, 1, 1] + (-3*t^2+6*t-3)*m3[2, 1, 1, 1] + (-t^2+3*t-2)*m3[2, 2, 1] + (2*t-2)*m3[3, 1, 1] + (t-1)*m3[3, 2]\n sage: m = SymmetricFunctions(FractionField(QQ['t'])).m()\n sage: km(m[3, 1])\n m3[3, 1]\n sage: km(m[4, 1])\n (t^4+t^3-9*t^2+11*t-4)*m3[1, 1, 1, 1, 1] + (-3*t^2+6*t-3)*m3[2, 1, 1, 1] + (-t^2+3*t-2)*m3[2, 2, 1] + (2*t-2)*m3[3, 1, 1] + (t-1)*m3[3, 2]\n "
if (la == []):
return self([])
if (la[0] <= self.k):
return self(la)
if (self.t == 1):
return self.zero()
else:
kHLP = self._kBoundedRing.kHallLittlewoodP()
return self(kHLP._m_to_kHLP_on_basis(la))
def lift(self, la):
'\n Implements the lift function on the monomial basis. Given a `k`-bounded partition\n ``la``, the lift will return the corresponding monomial basis element.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n OUTPUT:\n\n - A monomial symmetric function.\n\n EXAMPLES::\n\n sage: km = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).km()\n sage: km.lift(Partition([3,1]))\n m[3, 1]\n sage: km.lift([])\n m[]\n sage: km.lift(Partition([4,1]))\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded monomial basis)\n '
m = self._kBoundedRing.ambient().m()
return m._from_dict(dict(self(la)))
|
class kbounded_HallLittlewoodP(KBoundedQuotientBasis):
'\n The basis of P Hall-Littlewood symmetric functions indexed by partitions with first\n part less than or equal to `k`.\n '
def __init__(self, kBoundedRing):
"\n Initializes the ring which is the `k`-Bounded Hall-Littlewood P quotient basis.\n\n INPUT:\n\n - ``kBoundedRing`` -- an element which is of class :class:`KBoundedQuotient`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.k_dual import kbounded_HallLittlewoodP\n sage: kP = kbounded_HallLittlewoodP(SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(4))\n sage: kP\n 4-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 4-bounded Hall-Littlewood P basis\n sage: TestSuite(kP).run()\n "
KBoundedQuotientBasis.__init__(self, kBoundedRing, 'HLP')
Sym = kBoundedRing.ambient()
Sym.hall_littlewood(kBoundedRing.t).P().module_morphism(self.retract, codomain=self).register_as_coercion()
km = kBoundedRing.km()
self.module_morphism(self._HLP_to_mk_on_basis, codomain=km, triangular='lower', unitriangular=True).register_as_coercion()
km.module_morphism(self._m_to_kHLP_on_basis, codomain=self, triangular='lower', unitriangular=True).register_as_coercion()
def _repr_(self):
"\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: kHLP = Sym.kBoundedQuotient(3).kHallLittlewoodP()\n sage: kHLP._repr_()\n '3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-bounded Hall-Littlewood P basis'\n "
return (self.realization_of()._repr_() + (' in the %s-bounded Hall-Littlewood P basis' % self.k))
def _m_to_kHLP_on_basis(self, la):
"\n Converts from the monomial basis to the `k`-bounded Hall-Littlewood\n P basis. If ``la`` is not `k`-bounded then it returns the projection of\n the monomial by the ideal generated by the Hall-Littlewood P basis indexed\n by partitions whose first part is greater than `k`.\n\n INPUT:\n\n - ``la`` - a partition\n\n OUTPUT:\n\n - an element of the `k`-bounded Hall-Littlewood P basis.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: kHLP = Sym.kBoundedQuotient(3).kHallLittlewoodP()\n sage: kHLP._m_to_kHLP_on_basis([3,1])\n (t^5-2*t^2-t+2)*HLP3[1, 1, 1, 1] + (t^2-1)*HLP3[2, 1, 1] + (t-1)*HLP3[2, 2] + HLP3[3, 1]\n sage: kHLP._m_to_kHLP_on_basis([4])\n (t^6-t^5-t^4+t^2+t-1)*HLP3[1, 1, 1, 1] + (t^3-t^2-t+1)*HLP3[2, 1, 1] + (t^2-t)*HLP3[2, 2] + (t-1)*HLP3[3, 1]\n sage: mk = kHLP.realization_of().km()\n sage: kHLP(mk([1,1])^2)\n (t^4+t^3+2*t^2+t+1)*HLP3[1, 1, 1, 1] + (t+1)*HLP3[2, 1, 1] + HLP3[2, 2]\n sage: kHLP._m_to_kHLP_on_basis([])\n HLP3[]\n sage: kHLP = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).kHallLittlewoodP()\n sage: kHLP._m_to_kHLP_on_basis([3,1])\n HLP3[3, 1]\n sage: kHLP._m_to_kHLP_on_basis([4])\n 0\n sage: mk = kHLP.realization_of().km()\n sage: kHLP(mk([1,1])^2)\n 6*HLP3[1, 1, 1, 1] + 2*HLP3[2, 1, 1] + HLP3[2, 2]\n sage: kHLP(mk([2,1])^2)\n 4*HLP3[2, 2, 1, 1] + 6*HLP3[2, 2, 2] + 2*HLP3[3, 2, 1] + 2*HLP3[3, 3]\n "
if (self.t == 1):
if (la in self._kbounded_partitions):
return self(la)
else:
return self.zero()
else:
HLP = self._kBoundedRing._quotient_basis
m = self._kBoundedRing._sym.m()
elt = dict((x for x in dict(HLP(m(la))).items() if (x[0] in self._kbounded_partitions)))
return self._from_dict(elt)
def _HLP_to_mk_on_basis(self, la):
"\n Converts from the Hall-Littlewood P basis to the `k`-bounded monomial basis and\n projects into the `k`-bounded quotient if ``la`` is not a bounded partition.\n\n INPUT:\n\n - ``la`` - a partition\n\n OUTPUT:\n\n - an element of the `k`-bounded monomial basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: kHLP = Sym.kBoundedQuotient(3).kHallLittlewoodP()\n sage: kHLP._HLP_to_mk_on_basis([3,1])\n (t^3+t^2-5*t+3)*m3[1, 1, 1, 1] + (-2*t+2)*m3[2, 1, 1] + (-t+1)*m3[2, 2] + m3[3, 1]\n sage: kHLP._HLP_to_mk_on_basis([4,1])\n 0\n sage: kHLP._HLP_to_mk_on_basis([])\n m3[]\n sage: kHLP = Sym.kBoundedQuotient(3,t=1).kHallLittlewoodP()\n sage: kHLP._HLP_to_mk_on_basis([3,1])\n m3[3, 1]\n sage: kHLP._HLP_to_mk_on_basis([4,1])\n 0\n sage: kHLP._HLP_to_mk_on_basis([])\n m3[]\n "
mk = self._kBoundedRing.km()
if (la not in self._kbounded_partitions):
return mk.zero()
if (self.t == 1):
return mk(la)
else:
HLP = self._kBoundedRing._quotient_basis
return mk(HLP(la))
def retract(self, la):
"\n Implements the retract function on the Hall-Littlewood P basis. Given a partition\n ``la``, the retract will return the corresponding `k`-bounded Hall-Littlewood P\n basis element if ``la`` is `k`-bounded; zero otherwise.\n\n INPUT:\n\n - ``la`` -- A partition\n\n OUTPUT:\n\n - A `k`-bounded Hall-Littlewood P symmetric function in the `k`-quotient of\n symmetric functions.\n\n EXAMPLES::\n\n sage: kHLP = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3).kHallLittlewoodP()\n sage: kHLP.retract(Partition([3,1]))\n HLP3[3, 1]\n sage: kHLP.retract(Partition([4,1]))\n 0\n sage: kHLP.retract([])\n HLP3[]\n sage: m = kHLP.realization_of().ambient().m()\n sage: kHLP(m[2,2])\n (t^4-t^3-t+1)*HLP3[1, 1, 1, 1] + (t-1)*HLP3[2, 1, 1] + HLP3[2, 2]\n "
if (la == []):
return self([])
if (la[0] > self.k):
return self.zero()
hlp = self._kBoundedRing.ambient().hall_littlewood(self.t).P()
f = hlp(la)
return sum(((self(x) * f.coefficient(x)) for x in f.support() if (x in self._kbounded_partitions)))
def lift(self, la):
"\n Implements the lift function on the Hall-Littlewood P basis. Given a `k`-bounded\n partition ``la``, the lift will return the corresponding Hall-Littlewood P basis\n element.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n OUTPUT:\n\n - A Hall-Littlewood symmetric function.\n\n EXAMPLES::\n\n sage: kHLP = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3).kHallLittlewoodP()\n sage: kHLP.lift(Partition([3,1]))\n HLP[3, 1]\n sage: kHLP.lift([])\n HLP[]\n sage: kHLP.lift(Partition([4,1]))\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-bounded Hall-Littlewood P basis)\n "
HLP = self._kBoundedRing.ambient().hall_littlewood(t=self.t).P()
return HLP._from_dict(dict(self(la)))
|
class DualkSchurFunctions(KBoundedQuotientBasis):
'\n This basis is dual to the `k`-Schur functions. The expansion is given\n in Section 4.12 of [LLMSSZ]_. When `t=1` this basis is equal to the\n :class:`AffineSchurFunctions` and that basis is more efficient in this case.\n\n REFERENCES:\n\n .. [LLMSSZ] \\T. Lam, L. Lapointe, J. Morse, A. Schilling, M. Shimozono, M. Zabrocki,\n k-Schur functions and affine Schubert calculus.\n '
def __init__(self, kBoundedRing):
"\n Initializes the ring which is the dual `k`-Schur function basis.\n\n INPUT:\n\n - ``kBoundedRing`` -- an element which is of class :class:`KBoundedQuotient`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.k_dual import DualkSchurFunctions\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: dks4 = DualkSchurFunctions(Sym.kBoundedQuotient(4))\n sage: dks4\n 4-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the dual 4-Schur basis\n sage: TestSuite(dks4).run() # long time (7s on sage.math, 2013)\n sage: dks4 = DualkSchurFunctions(Sym.kBoundedQuotient(4,t=1))\n sage: TestSuite(dks4).run() # long time (7s on sage.math, 2013)\n "
KBoundedQuotientBasis.__init__(self, kBoundedRing, 'dks')
kHLP = kBoundedRing.kHallLittlewoodP()
self.module_morphism(self._dks_to_khlp_on_basis, codomain=kHLP).register_as_coercion()
kHLP.module_morphism(self._khlp_to_dks_on_basis, codomain=self).register_as_coercion()
def _repr_(self):
"\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: dks3 = Sym.kBoundedQuotient(3).dual_k_Schur()\n sage: dks3._repr_()\n '3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the dual 3-Schur basis'\n "
return (self.realization_of()._repr_() + (' in the dual %s-Schur basis' % self.k))
def _dks_to_khlp_on_basis(self, la):
'\n Gives the expansion of the dual `k`-Schur basis element indexed by ``la`` into\n the Hall-Littlewood P basis.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A symmetric function in the Hall-Littlewood P basis\n\n EXAMPLES::\n\n sage: dks3 = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).dual_k_Schur()\n sage: dks3._dks_to_khlp_on_basis(Partition([2,1]))\n 2*HLP3[1, 1, 1] + HLP3[2, 1]\n sage: dks3._dks_to_khlp_on_basis(Partition([]))\n HLP3[]\n sage: dks3._dks_to_khlp_on_basis(Partition([4,1]))\n Traceback (most recent call last):\n ...\n AssertionError: [4, 1] should be an element of 3-Bounded Partitions\n '
Sym = self._kBoundedRing.ambient()
kB = Sym.kBoundedSubspace(self.k, t=self.t)
Qp = Sym.hall_littlewood(t=self.t).Qp()
ks = kB.kschur()
kHLP = self._kBoundedRing.kHallLittlewoodP()
return sum(((ks(Qp(x)).coefficient(la) * kHLP(x)) for x in PartitionsGreatestLE(sum(la), self.k)))
def _khlp_to_dks_on_basis(self, la):
"\n Gives the expansion of the `k`-bounded Hall-Littlewood P basis element indexed by\n ``la`` into the dual `k`-Schur basis.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A `k`-bounded quotient symmetric function in the dual `k`-Schur basis\n\n EXAMPLES::\n\n sage: dks3 = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).dual_k_Schur()\n sage: dks3._khlp_to_dks_on_basis(Partition([2,1]))\n -2*dks3[1, 1, 1] + dks3[2, 1]\n sage: dks3._khlp_to_dks_on_basis([2,1])\n -2*dks3[1, 1, 1] + dks3[2, 1]\n sage: dks3._khlp_to_dks_on_basis(Partition([]))\n dks3[]\n sage: dks3._khlp_to_dks_on_basis(Partition([4,1]))\n 0\n\n ::\n\n sage: dks3 = SymmetricFunctions(QQ['t'].fraction_field()).kBoundedQuotient(3).dual_k_Schur()\n sage: dks3._khlp_to_dks_on_basis(Partition([2,1]))\n (-t^2-t)*dks3[1, 1, 1] + dks3[2, 1]\n sage: dks3._khlp_to_dks_on_basis(Partition([2,2]))\n (t^3-t^2)*dks3[1, 1, 1, 1] - t*dks3[2, 1, 1] + dks3[2, 2]\n sage: dks3._khlp_to_dks_on_basis(Partition([]))\n dks3[]\n sage: dks3._khlp_to_dks_on_basis(Partition([4,1]))\n 0\n "
Sym = self._kBoundedRing.ambient()
kB = Sym.kBoundedSubspace(self.k, t=self.t)
Qp = Sym.hall_littlewood(t=self.t).Qp()
ks = kB.kschur()
return sum(((Qp(ks(x)).coefficient(la) * self(x)) for x in PartitionsGreatestLE(sum(la), self.k)))
|
class AffineSchurFunctions(KBoundedQuotientBasis):
'\n This basis is dual to the `k`-Schur functions at `t=1`. This realization\n follows the monomial expansion given by Lam [Lam2006]_.\n\n REFERENCES:\n\n .. [Lam2006] \\T. Lam, Schubert polynomials for the affine Grassmannian, J. Amer.\n Math. Soc., 21 (2008), 259-281.\n '
def __init__(self, kBoundedRing):
"\n Initializes the ring which is the `k`-Bounded affine Schur quotient basis.\n\n INPUT:\n\n - ``kBoundedRing`` -- an element which is of class :class:`KBoundedQuotient`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.k_dual import AffineSchurFunctions\n sage: F = AffineSchurFunctions(SymmetricFunctions(QQ['t']).kBoundedQuotient(4,t=1))\n sage: F\n 4-Bounded Quotient of Symmetric Functions over Univariate Polynomial Ring in t over Rational Field with t=1 in the 4-bounded affine Schur basis\n sage: TestSuite(F).run() # long time (5s on sage.math, 2013)\n "
KBoundedQuotientBasis.__init__(self, kBoundedRing, 'F')
from sage.combinat.root_system.weyl_group import WeylGroup
self._weyl = WeylGroup(['A', kBoundedRing.k, 1])
km = kBoundedRing.km()
self.module_morphism(self._F_to_m_on_basis, codomain=km).register_as_coercion()
km.module_morphism(self._m_to_F_on_basis, codomain=self).register_as_coercion()
def _repr_(self):
"\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: F = Sym.kBoundedQuotient(3,t=1).affineSchur()\n sage: F._repr_()\n '3-Bounded Quotient of Symmetric Functions over Rational Field with t=1 in the 3-bounded affine Schur basis'\n "
return (self.realization_of()._repr_() + (' in the %s-bounded affine Schur basis' % self.k))
def _F_to_m_on_basis(self, la):
'\n Gives the expansion of the affine Schur basis element indexed by ``la`` into\n the monomial basis.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A symmetric function in the monomial basis\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F._F_to_m_on_basis(Partition([2,1]))\n 2*m[1, 1, 1] + m[2, 1]\n sage: F._F_to_m_on_basis(Partition([]))\n m[]\n sage: km = F.realization_of().km()\n sage: km( F[2,2] )\n 2*m3[1, 1, 1, 1] + m3[2, 1, 1] + m3[2, 2]\n sage: F._F_to_m_on_basis(Partition([4,1]))\n Traceback (most recent call last):\n ...\n ValueError: the partition must be 3-bounded\n '
return self._weyl.from_reduced_word(Partition(la).from_kbounded_to_reduced_word(self.k)).stanley_symmetric_function()
def _m_to_F_on_basis(self, la):
'\n Gives the expansion of the `k`-monomial basis element indexed by ``la`` into\n the affine Schur basis.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A `k`-bounded quotient symmetric function in the affine Schur basis\n\n EXAMPLES::\n\n sage: F = SymmetricFunctions(QQ).kBoundedQuotient(3,t=1).affineSchur()\n sage: F._m_to_F_on_basis(Partition([2,1]))\n -2*F3[1, 1, 1] + F3[2, 1]\n sage: F._m_to_F_on_basis([2,1])\n -2*F3[1, 1, 1] + F3[2, 1]\n sage: F._m_to_F_on_basis(Partition([]))\n F3[]\n sage: F._m_to_F_on_basis(Partition([4,1]))\n Traceback (most recent call last):\n ...\n AssertionError: [4, 1] should be an element of 3-Bounded Partitions\n '
Sym = self._kBoundedRing.ambient()
kB = Sym.kBoundedSubspace(self.k, t=1)
h = kB.khomogeneous()
ks = kB.kschur()
return sum(((h(ks(x)).coefficient(la) * self(x)) for x in PartitionsGreatestLE(sum(la), self.k)))
|
def KostkaFoulkesPolynomial(mu, nu, t=None):
"\n Returns the Kostka-Foulkes polynomial `K_{\\mu, \\nu}(t)`.\n\n INPUT:\n\n - ``mu``, ``nu`` -- partitions\n - ``t`` -- an optional parameter (default: ``None``)\n\n OUTPUT:\n\n - the Koskta-Foulkes polynomial indexed by partitions ``mu`` and ``nu`` and\n evaluated at the parameter ``t``. If ``t`` is ``None`` the resulting\n polynomial is in the polynomial ring `\\ZZ['t']`.\n\n EXAMPLES::\n\n sage: KostkaFoulkesPolynomial([2,2],[2,2])\n 1\n sage: KostkaFoulkesPolynomial([2,2],[4])\n 0\n sage: KostkaFoulkesPolynomial([2,2],[1,1,1,1])\n t^4 + t^2\n sage: KostkaFoulkesPolynomial([2,2],[2,1,1])\n t\n sage: q = PolynomialRing(QQ,'q').gen()\n sage: KostkaFoulkesPolynomial([2,2],[2,1,1],q)\n q\n\n TESTS::\n\n sage: KostkaFoulkesPolynomial([2,4],[2,2])\n Traceback (most recent call last):\n ...\n ValueError: mu must be a partition\n sage: KostkaFoulkesPolynomial([2,2],[2,4])\n Traceback (most recent call last):\n ...\n ValueError: nu must be a partition\n sage: KostkaFoulkesPolynomial([3,2],[2,1])\n Traceback (most recent call last):\n ...\n ValueError: mu and nu must be partitions of the same size\n "
if (mu not in _Partitions):
raise ValueError('mu must be a partition')
if (nu not in _Partitions):
raise ValueError('nu must be a partition')
if (sum(mu) != sum(nu)):
raise ValueError('mu and nu must be partitions of the same size')
return kfpoly(mu, nu, t)
|
def kfpoly(mu, nu, t=None):
"\n Return the Kostka-Foulkes polynomial `K_{\\mu, \\nu}(t)`\n by generating all rigging sequences for the shape `\\mu`, and then\n selecting those of content `\\nu`.\n\n INPUT:\n\n - ``mu``, ``nu`` -- partitions\n - ``t`` -- an optional parameter (default: ``None``)\n\n OUTPUT:\n\n - the Koskta-Foulkes polynomial indexed by partitions ``mu`` and ``nu`` and\n evaluated at the parameter ``t``. If ``t`` is ``None`` the resulting polynomial\n is in the polynomial ring `\\ZZ['t']`.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.kfpoly import kfpoly\n sage: kfpoly([2,2], [2,1,1])\n t\n sage: kfpoly([4], [2,1,1])\n t^3\n sage: kfpoly([4], [2,2])\n t^2\n sage: kfpoly([1,1,1,1], [2,2])\n 0\n\n TESTS::\n\n sage: kfpoly([], [])\n 1\n "
if (mu == nu):
return 1
if (t is None):
t = polygen(ZZ, 't')
nuc = _Partitions(nu).conjugate()
f = (lambda x: (weight(x, t) if (x[0] == nuc) else 0))
return sum((f(rg) for rg in riggings(mu)))
|
def schur_to_hl(mu, t=None):
"\n Return a dictionary corresponding to `s_\\mu` in Hall-Littlewood `P` basis.\n\n INPUT:\n\n - ``mu`` -- a partition\n - ``t`` -- an optional parameter (default: the generator from `\\ZZ['t']` )\n\n OUTPUT:\n\n - a dictionary with the coefficients `K_{\\mu\\nu}(t)` for `\\nu` smaller\n in dominance order than `\\mu`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.kfpoly import *\n sage: schur_to_hl([1,1,1])\n {[1, 1, 1]: 1}\n sage: a = schur_to_hl([2,1])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1], t^2 + t)\n ([2, 1], 1)\n sage: a = schur_to_hl([3])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1], t^3)\n ([2, 1], t)\n ([3], 1)\n sage: a = schur_to_hl([4])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1, 1], t^6)\n ([2, 1, 1], t^3)\n ([2, 2], t^2)\n ([3, 1], t)\n ([4], 1)\n sage: a = schur_to_hl([3,1])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1, 1], t^5 + t^4 + t^3)\n ([2, 1, 1], t^2 + t)\n ([2, 2], t)\n ([3, 1], 1)\n sage: a = schur_to_hl([2,2])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1, 1], t^4 + t^2)\n ([2, 1, 1], t)\n ([2, 2], 1)\n sage: a = schur_to_hl([2,1,1])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1, 1], t^3 + t^2 + t)\n ([2, 1, 1], 1)\n sage: a = schur_to_hl([1,1,1,1])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1, 1], 1)\n sage: a = schur_to_hl([2,2,2])\n sage: for mc in sorted(a.items()): print(mc)\n ([1, 1, 1, 1, 1, 1], t^9 + t^7 + t^6 + t^5 + t^3)\n ([2, 1, 1, 1, 1], t^4 + t^2)\n ([2, 2, 1, 1], t)\n ([2, 2, 2], 1)\n "
if (mu == []):
return {mu: 1}
if (t is None):
t = polygen(ZZ, 't')
res = {}
for rg in riggings(mu):
res[rg[0]] = (res.get(rg[0], 0) + weight(rg, t))
d = {}
for key in res:
d[key.conjugate()] = res[key]
return d
|
def riggings(part):
'\n Generate all possible rigging sequences for a fixed partition ``part``.\n\n INPUT:\n\n - ``part`` -- a partition\n\n OUTPUT:\n\n - a list of riggings associated to the partition ``part``\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.kfpoly import *\n sage: riggings([3])\n [[[1, 1, 1]], [[2, 1]], [[3]]]\n sage: riggings([2,1])\n [[[2, 1], [1]], [[3], [1]]]\n sage: riggings([1,1,1])\n [[[3], [2], [1]]]\n sage: riggings([2,2])\n [[[2, 2], [1, 1]], [[3, 1], [1, 1]], [[4], [1, 1]], [[4], [2]]]\n sage: riggings([2,2,2])\n [[[3, 3], [2, 2], [1, 1]],\n [[4, 2], [2, 2], [1, 1]],\n [[5, 1], [2, 2], [1, 1]],\n [[6], [2, 2], [1, 1]],\n [[5, 1], [3, 1], [1, 1]],\n [[6], [3, 1], [1, 1]],\n [[6], [4], [2]]]\n '
l = len(part)
res = [[[], []]]
sa = 0
for i in sorted(part):
sa += i
res = [([new] + nu) for nu in res for new in compat(sa, nu[0], nu[1])]
return [x[:l] for x in res]
|
def compat(n, mu, nu):
'\n Generate all possible partitions of `n` that can precede `\\mu, \\nu`\n in a rigging sequence.\n\n INPUT:\n\n - ``n`` -- a positive integer\n - ``mu``, ``nu`` -- partitions\n\n OUTPUT:\n\n - a list of partitions\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.kfpoly import *\n sage: compat(4, [1], [2,1])\n [[1, 1, 1, 1], [2, 1, 1], [2, 2], [3, 1], [4]]\n sage: compat(3, [1], [2,1])\n [[1, 1, 1], [2, 1], [3]]\n sage: compat(2, [1], [])\n [[2]]\n sage: compat(3, [1], [])\n [[2, 1], [3]]\n sage: compat(3, [2], [1])\n [[3]]\n sage: compat(4, [1,1], [])\n [[2, 2], [3, 1], [4]]\n sage: compat(4, [2], [])\n [[4]]\n '
l = max(len(mu), len(nu))
mmu = (list(mu) + ([0] * (l - len(mu))))
nnu = (list(nu) + ([0] * (l - len(nu))))
bd = []
sa = 0
for i in range(l):
sa += ((2 * mmu[i]) - nnu[i])
bd.append(sa)
for la in ZS1_iterator(n):
if dom(la, bd):
return [x.conjugate() for x in _Partitions(la).dominated_partitions()]
return []
|
def dom(mup, snu):
'\n Return ``True`` if ``sum(mu[:i+1]) >= snu[i]`` for all\n ``0 <= i < len(snu)``; otherwise, it returns ``False``.\n\n INPUT:\n\n - ``mup`` -- a partition conjugate to ``mu``\n - ``snu`` -- a sequence of positive integers\n\n OUTPUT:\n\n - a boolean value\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.kfpoly import *\n sage: dom([3,2,1],[2,4,5])\n True\n sage: dom([3,2,1],[2,4,7])\n False\n sage: dom([3,2,1],[2,6,5])\n False\n sage: dom([3,2,1],[4,4,4])\n False\n\n TESTS::\n\n sage: dom([],[])\n True\n '
if (not mup):
return (not snu)
l = len(snu)
lmup = len(mup)
if any(((((k + 1) * lmup) < snu[k]) for k in range(min(mup[(- 1)], l)))):
return False
pos = mup[(- 1)]
sa = (mup[(- 1)] * lmup)
for i in range((lmup - 1), 0, (- 1)):
for k in range((mup[(i - 1)] - mup[i])):
if (pos >= l):
return True
sa += i
if (sa < snu[pos]):
return False
pos += 1
return all(((sa >= snu[j]) for j in range(pos, l)))
|
def weight(rg, t=None):
"\n Return the weight of a rigging.\n\n INPUT:\n\n - ``rg`` -- a rigging, a list of partitions\n - ``t`` -- an optional parameter, (default: the generator from `\\ZZ['t']`)\n\n OUTPUT:\n\n - a polynomial in the parameter ``t``\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.kfpoly import weight\n sage: weight([[2,1], [1]])\n 1\n sage: weight([[3], [1]])\n t^2 + t\n sage: weight([[2,1], [3]])\n t^4\n sage: weight([[2, 2], [1, 1]])\n 1\n sage: weight([[3, 1], [1, 1]])\n t\n sage: weight([[4], [1, 1]], 2)\n 16\n sage: weight([[4], [2]], t=2)\n 4\n "
from sage.combinat.q_analogues import q_binomial
if (t is None):
t = polygen(ZZ, 't')
nu = (rg + [[]])
l = (1 + max(map(len, nu)))
nu = [(list(mu) + ([0] * l)) for mu in nu]
res = (t ** int(sum((((i * (i - 1)) // 2) for i in rg[(- 1)]))))
for k in range(1, (len(nu) - 1)):
sa = 0
mid = nu[k]
for i in range(max(len(rg[k]), len(rg[(k - 1)]))):
sa += ((nu[(k - 1)][i] - (2 * mid[i])) + nu[(k + 1)][i])
if (((mid[i] - mid[(i + 1)]) + sa) >= 0):
res *= q_binomial(((mid[i] - mid[(i + 1)]) + sa), sa, t)
mu = (nu[(k - 1)][i] - mid[i])
res *= (t ** int(((mu * (mu - 1)) // 2)))
return res
|
class LLT_class(UniqueRepresentation):
"\n A class for working with LLT symmetric functions.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: L3 = Sym.llt(3); L3\n level 3 LLT polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n sage: L3.cospin([3,2,1])\n (t+1)*m[1, 1] + m[2]\n sage: HC3 = L3.hcospin(); HC3\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT cospin basis\n sage: m = Sym.monomial()\n sage: m( HC3[1,1] )\n (t+1)*m[1, 1] + m[2]\n\n We require that the parameter `t` must be in the base ring::\n\n sage: Symxt = SymmetricFunctions(QQ['x','t'].fraction_field())\n sage: (x,t) = Symxt.base_ring().gens()\n sage: LLT3x = Symxt.llt(3,t=x)\n sage: LLT3 = Symxt.llt(3)\n sage: HS3x = LLT3x.hspin()\n sage: HS3t = LLT3.hspin()\n sage: s = Symxt.schur()\n sage: s(HS3x[2,1])\n s[2, 1] + x*s[3]\n sage: s(HS3t[2,1])\n s[2, 1] + t*s[3]\n sage: HS3x(HS3t[2,1])\n HSp3[2, 1] + (-x+t)*HSp3[3]\n sage: s(HS3x(HS3t[2,1]))\n s[2, 1] + t*s[3]\n sage: LLT3t2 = Symxt.llt(3,t=2)\n sage: HC3t2 = LLT3t2.hcospin()\n sage: HS3x(HC3t2[3,1])\n 2*HSp3[3, 1] + (-2*x+1)*HSp3[4]\n "
def __init__(self, Sym, k, t='t'):
'\n Class of LLT symmetric function bases\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric function bases\n - ``k`` -- a positive integer (the level)\n - ``t`` -- a parameter (default: `t`)\n\n EXAMPLES::\n\n sage: L3 = SymmetricFunctions(FractionField(QQ[\'t\'])).llt(3)\n sage: L3 == loads(dumps(L3))\n True\n sage: TestSuite(L3).run(skip=["_test_associativity","_test_distributivity","_test_prod"])\n\n TESTS::\n\n sage: L3 != SymmetricFunctions(FractionField(QQ[\'t\'])).llt(2)\n True\n sage: L3p = SymmetricFunctions(FractionField(QQ[\'t\'])).llt(3,t=1)\n sage: L3 != L3p\n True\n sage: L3p != SymmetricFunctions(QQ).llt(3,t=1)\n True\n\n sage: Sym = SymmetricFunctions(QQ[\'t\'])\n sage: ks3 = Sym.kschur(3)\n sage: llt3 = Sym.llt(3)\n sage: f = llt3.cospin([[1],[2,1],[1,1]]).omega()\n sage: ks3(f)\n ks3[2, 2, 1, 1] + ks3[2, 2, 2] + t*ks3[3, 1, 1, 1] + t^2*ks3[3, 2, 1]\n '
self._k = k
self._sym = Sym
self._name = ('level %s LLT polynomials' % self._k)
self.t = Sym.base_ring()(t)
self._name_suffix = ''
if (str(t) != 't'):
self._name_suffix += (' with t=%s' % self.t)
self._name += (self._name_suffix + (' over %s' % self._sym.base_ring()))
self._m = Sym.monomial()
def __repr__(self):
"\n Representation of the LLT symmetric functions\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric function bases\n\n OUTPUT:\n\n - returns a string representing the LLT symmetric functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(FractionField(QQ['t'])).llt(3)\n level 3 LLT polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n sage: SymmetricFunctions(QQ).llt(3,t=2)\n level 3 LLT polynomials with t=2 over Rational Field\n "
return self._name
def symmetric_function_ring(self):
"\n The symmetric function algebra associated to the family of LLT\n symmetric function bases\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n\n OUTPUT:\n\n - returns the symmetric function ring associated to ``self``.\n\n EXAMPLES::\n\n sage: L3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3)\n sage: L3.symmetric_function_ring()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
return self._sym
def base_ring(self):
"\n Returns the base ring of ``self``.\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n\n OUTPUT:\n\n - returns the base ring of the symmetric function ring associated to ``self``\n\n EXAMPLES::\n\n sage: SymmetricFunctions(FractionField(QQ['t'])).llt(3).base_ring()\n Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
return self._sym.base_ring()
def level(self):
"\n Returns the level of ``self``.\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n\n OUTPUT:\n\n - the level is the parameter of `k` in the basis\n\n EXAMPLES::\n\n sage: SymmetricFunctions(FractionField(QQ['t'])).llt(3).level()\n 3\n "
return self._k
def _llt_generic(self, skp, stat):
"\n Takes in partition, list of partitions, or a list of skew\n partitions as well as a function which takes in two partitions and\n a level and returns a coefficient.\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n - ``skp`` -- a partition or a list of partitions or a list of skew partitions\n - ``stat`` -- a function which accepts two partitions and a value\n for the level and returns a coefficient which is a polynomial\n in a parameter `t`. The first partition is the index of the\n LLT function, the second partition is the index of the monomial\n basis element.\n\n OUTPUT:\n\n - returns the monomial expansion of the LLT symmetric function\n indexed by ``skp``\n\n EXAMPLES::\n\n sage: L3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3)\n sage: f = lambda skp,mu,level: QQ(1)\n sage: L3._llt_generic([3,2,1],f)\n m[1, 1] + m[2]\n sage: L3._llt_generic([[2,1],[1],[2]],f)\n m[1, 1, 1, 1, 1, 1] + m[2, 1, 1, 1, 1] + m[2, 2, 1, 1] + m[2, 2, 2] + m[3, 1, 1, 1] + m[3, 2, 1] + m[3, 3] + m[4, 1, 1] + m[4, 2] + m[5, 1] + m[6]\n sage: L3._llt_generic([[[2,2],[1]],[[2,1],[]]],f)\n m[1, 1, 1, 1] + m[2, 1, 1] + m[2, 2] + m[3, 1] + m[4]\n "
if (skp in _Partitions):
m = (sum(skp) / self.level()).floor()
if (m == 0):
raise ValueError(('level (%s=) must divide %s ' % (sum(skp), self.level())))
mu = Partitions(ZZ((sum(skp) / self.level())))
elif (isinstance(skp, list) and (skp[0] in sage.combinat.skew_partition.SkewPartitions())):
skp2 = [Partition(core=[], quotient=[skp[i][0] for i in range(len(skp))])]
skp2 += [Partition(core=[], quotient=[skp[i][1] for i in range(len(skp))])]
mu = Partitions(ZZ(((skp2[0].size() - skp2[1].size()) / self.level())))
skp = skp2
elif (isinstance(skp, list) and (skp[0] in _Partitions)):
skp = Partition(core=[], quotient=skp)
mu = Partitions(ZZ((sum(skp) / self.level())))
else:
raise ValueError(('LLT polynomials not defined for %s' % skp))
BR = self.base_ring()
return sum([(BR(stat(skp, nu, self.level()).subs(t=self.t)) * self._m(nu)) for nu in mu])
def spin_square(self, skp):
"\n Calculate a single instance of a spin squared LLT symmetric function\n associated with a partition, list of partitions, or a list of skew partitions.\n\n This family of symmetric functions is defined in [LT2000]_ equation (43).\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n - ``skp`` -- a partition of a list of partitions or a list of skew\n partitions\n\n OUTPUT:\n\n the monomial expansion of the LLT symmetric function spin-square\n functions indexed by ``skp``\n\n EXAMPLES::\n\n sage: L3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3)\n sage: L3.spin_square([2,1])\n t*m[1]\n sage: L3.spin_square([3,2,1])\n (t^3+t)*m[1, 1] + t^3*m[2]\n sage: L3.spin_square([[1],[1],[1]])\n (t^6+2*t^4+2*t^2+1)*m[1, 1, 1] + (t^6+t^4+t^2)*m[2, 1] + t^6*m[3]\n sage: L3.spin_square([[[2,2],[1]],[[2,1],[]]])\n (2*t^4+3*t^2+1)*m[1, 1, 1, 1] + (t^4+t^2)*m[2, 1, 1] + t^4*m[2, 2]\n "
return self._llt_generic(skp, ribbon_tableau.spin_polynomial_square)
def cospin(self, skp):
"\n Calculate a single instance of the cospin symmetric functions.\n\n These are the functions defined in [LLT1997]_ equation (26).\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n - ``skp`` -- a partition or a list of partitions or a list of skew\n partitions\n\n OUTPUT:\n\n the monomial expansion of the LLT symmetric function cospin\n functions indexed by ``skp``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: L3 = Sym.llt(3)\n sage: L3.cospin([2,1])\n m[1]\n sage: L3.cospin([3,2,1])\n (t+1)*m[1, 1] + m[2]\n sage: s = Sym.schur()\n sage: s(L3.cospin([[2],[1],[2]]))\n t^4*s[2, 2, 1] + t^3*s[3, 1, 1] + (t^3+t^2)*s[3, 2] + (t^2+t)*s[4, 1] + s[5]\n "
return self._llt_generic(skp, ribbon_tableau.cospin_polynomial)
def hcospin(self):
"\n Returns the HCospin basis.\n This basis is defined [LLT1997]_ equation (27).\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n\n OUTPUT:\n\n - returns the h-cospin basis of the LLT symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HCosp3 = Sym.llt(3).hcospin(); HCosp3\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT cospin basis\n sage: HCosp3([1])^2\n 1/t*HCosp3[1, 1] + ((t-1)/t)*HCosp3[2]\n\n sage: s = Sym.schur()\n sage: HCosp3(s([2]))\n HCosp3[2]\n sage: HCosp3(s([1,1]))\n 1/t*HCosp3[1, 1] - 1/t*HCosp3[2]\n sage: s(HCosp3([2,1]))\n t*s[2, 1] + s[3]\n "
return LLT_cospin(self)
def hspin(self):
"\n Returns the HSpin basis.\n This basis is defined [LLT1997]_ equation (28).\n\n INPUT:\n\n - ``self`` -- a family of LLT symmetric functions bases\n\n OUTPUT:\n\n - returns the h-spin basis of the LLT symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HSp3 = Sym.llt(3).hspin(); HSp3\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT spin basis\n sage: HSp3([1])^2\n HSp3[1, 1] + (-t+1)*HSp3[2]\n\n sage: s = Sym.schur()\n sage: HSp3(s([2]))\n HSp3[2]\n sage: HSp3(s([1,1]))\n HSp3[1, 1] - t*HSp3[2]\n sage: s(HSp3([2,1]))\n s[2, 1] + t*s[3]\n "
return LLT_spin(self)
|
class LLT_generic(sfa.SymmetricFunctionAlgebra_generic):
def __init__(self, llt, prefix):
"\n A class of methods which are common to both the hspin and hcospin\n of the LLT symmetric functions.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin or hcospin basis\n - ``llt`` -- a family of LLT symmetric functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT spin basis\n sage: SymmetricFunctions(QQ).llt(3,t=2).hspin()\n Symmetric Functions over Rational Field in the level 3 LLT spin with t=2 basis\n sage: QQz = FractionField(QQ['z']); z = QQz.gen()\n sage: SymmetricFunctions(QQz).llt(3,t=z).hspin()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in z over Rational Field in the level 3 LLT spin with t=z basis\n "
s = self.__class__.__name__[4:]
sfa.SymmetricFunctionAlgebra_generic.__init__(self, llt._sym, basis_name=((('level %s LLT ' % llt.level()) + s) + llt._name_suffix), prefix=prefix)
self.t = llt.t
self._sym = llt._sym
self._llt = llt
self._k = llt._k
sfa.SymmetricFunctionAlgebra_generic.__init__(self, self._sym)
category = sage.categories.all.ModulesWithBasis(self._sym.base_ring())
self._m = llt._sym.m()
self.register_coercion(SetMorphism(Hom(self._m, self, category), self._m_to_self))
self._m.register_coercion(SetMorphism(Hom(self, self._m, category), self._self_to_m))
def _m_to_self(self, x):
"\n Isomorphism from the monomial basis into ``self``\n\n INPUT:\n\n - ``self`` - an instance of the LLT hspin or hcospin basis\n - ``x`` - an element of the monomial basis\n\n OUTPUT:\n\n - returns ``x`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HSp3 = Sym.llt(3).hspin()\n sage: m = Sym.monomial()\n sage: HSp3._m_to_self(m[2,1])\n -2*HSp3[1, 1, 1] + (2*t^2+2*t+1)*HSp3[2, 1] + (-2*t^2-t)*HSp3[3]\n\n This is for internal use only. Please use instead::\n\n sage: HSp3(m[2,1])\n -2*HSp3[1, 1, 1] + (2*t^2+2*t+1)*HSp3[2, 1] + (-2*t^2-t)*HSp3[3]\n "
return self._from_cache(x, self._m_cache, self._m_to_self_cache, t=self.t)
def _self_to_m(self, x):
"\n Isomorphism from self to the monomial basis\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin or hcospin basis\n - ``x`` -- an element of ``self``\n\n OUTPUT:\n\n - returns ``x`` expanded in the monomial basis.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HSp3 = Sym.llt(3).hspin()\n sage: m = Sym.monomial()\n sage: HSp3._self_to_m(HSp3[2,1])\n (t+2)*m[1, 1, 1] + (t+1)*m[2, 1] + t*m[3]\n\n This is for internal use only. Please use instead::\n\n sage: m(HSp3[2,1])\n (t+2)*m[1, 1, 1] + (t+1)*m[2, 1] + t*m[3]\n "
return self._m._from_cache(x, self._m_cache, self._self_to_m_cache, t=self.t)
def level(self):
"\n Returns the level of ``self``.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin or hcospin basis\n\n OUTPUT:\n\n - returns the level associated to the basis ``self``.\n\n EXAMPLES::\n\n sage: HSp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin()\n sage: HSp3.level()\n 3\n "
return self._k
def llt_family(self):
"\n The family of the llt bases of the symmetric functions.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin or hcospin basis\n\n OUTPUT:\n\n - returns an instance of the family of LLT bases associated to ``self``.\n\n EXAMPLES::\n\n sage: HSp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin()\n sage: HSp3.llt_family()\n level 3 LLT polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
return self._llt
def product(self, left, right):
"\n Convert to the monomial basis, do the multiplication there, and\n convert back to the basis ``self``.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin or hcospin basis\n - ``left``, ``right`` -- elements of the symmetric functions\n\n OUTPUT:\n\n the product of ``left`` and ``right`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: HSp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin()\n sage: HSp3.product(HSp3([1]), HSp3([2]))\n HSp3[2, 1] + (-t+1)*HSp3[3]\n sage: HCosp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hcospin()\n sage: HCosp3.product(HCosp3([1]), HSp3([2]))\n 1/t*HCosp3[2, 1] + ((t-1)/t)*HCosp3[3]\n "
return self((self._m(left) * self._m(right)))
def _m_cache(self, n):
"\n Compute the change of basis from the monomial symmetric functions\n to ``self``.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin or hcospin basis\n - ``n`` -- a positive integer representing the degree\n\n EXAMPLES::\n\n sage: HSp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin()\n sage: HSp3._m_cache(2)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l( HSp3._self_to_m_cache[2] )\n [([1, 1], [([1, 1], t + 1), ([2], t)]), ([2], [([1, 1], 1), ([2], 1)])]\n sage: l( HSp3._m_to_self_cache[2] )\n [([1, 1], [([1, 1], 1), ([2], -t)]), ([2], [([1, 1], -1), ([2], t + 1)])]\n sage: HCosp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hcospin()\n sage: HCosp3._m_cache(2)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l( HCosp3._self_to_m_cache[2] )\n [([1, 1], [([1, 1], t + 1), ([2], 1)]), ([2], [([1, 1], 1), ([2], 1)])]\n sage: l( HCosp3._m_to_self_cache[2] )\n [([1, 1], [([1, 1], 1/t), ([2], -1/t)]),\n ([2], [([1, 1], -1/t), ([2], (t + 1)/t)])]\n "
self._invert_morphism(n, QQt, self._self_to_m_cache, self._m_to_self_cache, to_other_function=self._to_m)
class Element(sfa.SymmetricFunctionAlgebra_generic.Element):
pass
|
class LLT_spin(LLT_generic):
def __init__(self, llt):
'\n A class of methods for the h-spin LLT basis of the symmetric functions.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hcospin basis\n - ``llt`` -- a family of LLT symmetric function bases\n\n TESTS::\n\n sage: HSp3 = SymmetricFunctions(FractionField(QQ[\'t\'])).llt(3).hspin()\n sage: TestSuite(HSp3).run(skip = ["_test_associativity", "_test_distributivity", "_test_prod"]) # products are too expensive, long time (10s on sage.math, 2012)\n sage: TestSuite(HSp3).run(elements = [HSp3.t*HSp3[1,1]+HSp3.t*HSp3[2], HSp3[1]+(1+HSp3.t)*HSp3[1,1]]) # long time (depends on previous)\n\n ::\n\n sage: HS3t2 = SymmetricFunctions(QQ).llt(3,t=2).hspin()\n sage: TestSuite(HS3t2).run() # products are too expensive, long time (7s on sage.math, 2012)\n\n ::\n\n sage: HS3x = SymmetricFunctions(FractionField(QQ[\'x\'])).llt(3,t=x).hspin()\n sage: TestSuite(HS3x).run(skip = ["_test_associativity", "_test_distributivity", "_test_prod"]) # products are too expensive, long time (4s on sage.math, 2012)\n sage: TestSuite(HS3x).run(elements = [HS3x.t*HS3x[1,1]+HS3x.t*HS3x[2], HS3x[1]+(1+HS3x.t)*HS3x[1,1]]) # long time (depends on previous)\n '
level = llt._k
if (level not in hsp_to_m_cache):
hsp_to_m_cache[level] = {}
m_to_hsp_cache[level] = {}
self._self_to_m_cache = hsp_to_m_cache[level]
self._m_to_self_cache = m_to_hsp_cache[level]
LLT_generic.__init__(self, llt, prefix=('HSp%s' % level))
def _to_m(self, part):
"\n Returns a function which gives the coefficient of a partition\n in the monomial expansion of self(part).\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hspin basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a function which accepts a partition and returns the coefficient\n in the expansion of the monomial basis\n\n EXAMPLES::\n\n sage: HSp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin()\n sage: f21 = HSp3._to_m(Partition([2,1]))\n sage: [f21(p) for p in Partitions(3)]\n [t, t + 1, t + 2]\n sage: HSp3.symmetric_function_ring().m()( HSp3[2,1] )\n (t+2)*m[1, 1, 1] + (t+1)*m[2, 1] + t*m[3]\n "
level = self.level()
f = (lambda part2: QQt(ribbon_tableau.spin_polynomial([(level * i) for i in part], part2, level)))
return f
class Element(LLT_generic.Element):
pass
|
class LLT_cospin(LLT_generic):
def __init__(self, llt):
'\n A class of methods for the h-cospin LLT basis of the symmetric functions.\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hcospin basis\n - ``llt`` -- a family of LLT symmetric function bases\n\n TESTS::\n\n sage: HCosp3 = SymmetricFunctions(FractionField(QQ[\'t\'])).llt(3).hcospin()\n sage: TestSuite(HCosp3).run(skip = ["_test_associativity", "_test_distributivity", "_test_prod"]) # products are too expensive, long time (11s on sage.math, 2012)\n sage: TestSuite(HCosp3).run(elements = [HCosp3.t*HCosp3[1,1]+HCosp3.t*HCosp3[2], HCosp3[1]+(1+HCosp3.t)*HCosp3[1,1]]) # long time (depends on previous)\n\n ::\n\n sage: HC3t2 = SymmetricFunctions(QQ).llt(3,t=2).hcospin()\n sage: TestSuite(HC3t2).run() # products are too expensive, long time (6s on sage.math, 2012)\n\n ::\n\n sage: HC3x = SymmetricFunctions(FractionField(QQ[\'x\'])).llt(3,t=x).hcospin()\n sage: TestSuite(HC3x).run(skip = ["_test_associativity", "_test_distributivity", "_test_prod"]) # products are too expensive, long time (5s on sage.math, 2012)\n sage: TestSuite(HC3x).run(elements = [HC3x.t*HC3x[1,1]+HC3x.t*HC3x[2], HC3x[1]+(1+HC3x.t)*HC3x[1,1]]) # long time (depends on previous)\n '
level = llt._k
if (level not in hcosp_to_m_cache):
hcosp_to_m_cache[level] = {}
m_to_hcosp_cache[level] = {}
self._self_to_m_cache = hcosp_to_m_cache[level]
self._m_to_self_cache = m_to_hcosp_cache[level]
LLT_generic.__init__(self, llt, prefix=('HCosp%s' % level))
def _to_m(self, part):
"\n Returns a function which gives the coefficient of part2 in the\n monomial expansion of self(part).\n\n INPUT:\n\n - ``self`` -- an instance of the LLT hcospin basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a function which accepts a partition and returns the coefficient\n in the expansion of the monomial basis\n\n EXAMPLES::\n\n sage: HCosp3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3).hcospin()\n sage: f21 = HCosp3._to_m(Partition([2,1]))\n sage: [f21(p) for p in Partitions(3)]\n [1, t + 1, 2*t + 1]\n sage: HCosp3.symmetric_function_ring().m()( HCosp3[2,1] )\n (2*t+1)*m[1, 1, 1] + (t+1)*m[2, 1] + m[3]\n "
level = self.level()
f = (lambda part2: QQt(ribbon_tableau.cospin_polynomial([(level * i) for i in part], part2, level)))
return f
class Element(LLT_generic.Element):
pass
|
class Macdonald(UniqueRepresentation):
def __repr__(self):
"\n The family of Macdonald symmetric function bases\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - a string representing the Macdonald symmetric function family\n\n EXAMPLES::\n\n sage: t = QQ['t'].gen(); SymmetricFunctions(QQ['t'].fraction_field()).macdonald(q=t,t=1)\n Macdonald polynomials with q=t and t=1 over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
return self._name
def __init__(self, Sym, q='q', t='t'):
"\n Macdonald Symmetric functions including `P`, `Q`, `J`, `H`, `Ht` bases\n also including the S basis which is the plethystic transformation\n of the Schur basis (that which is dual to the Schur basis\n with respect to the Macdonald `q,t`-scalar product)\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n EXAMPLES::\n\n sage: t = QQ['t'].gen(); SymmetricFunctions(QQ['t'].fraction_field()).macdonald(q=t,t=1)\n Macdonald polynomials with q=t and t=1 over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n sage: Sym = SymmetricFunctions(FractionField(QQ['t'])).macdonald()\n Traceback (most recent call last):\n ...\n TypeError: unable to evaluate 'q' in Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
self._sym = Sym
self._s = Sym.s()
self.q = Sym.base_ring()(q)
self.t = Sym.base_ring()(t)
self._name_suffix = ''
if (str(q) != 'q'):
self._name_suffix += (' with q=%s' % q)
if (str(t) != 't'):
self._name_suffix += ' and '
if (str(t) != 't'):
if (str(q) == 'q'):
self._name_suffix += ' with '
self._name_suffix += ('t=%s' % t)
self._name = ((('Macdonald polynomials' + self._name_suffix) + ' over ') + repr(Sym.base_ring()))
def base_ring(self):
"\n Returns the base ring of the symmetric functions where the\n Macdonald symmetric functions live\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - the base ring associated to the corresponding symmetric function ring\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['q'].fraction_field())\n sage: Mac = Sym.macdonald(t=0)\n sage: Mac.base_ring()\n Fraction Field of Univariate Polynomial Ring in q over Rational Field\n "
return self._sym.base_ring()
def symmetric_function_ring(self):
"\n Returns the base ring of the symmetric functions where the\n Macdonald symmetric functions live\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - the symmetric function ring associated to the Macdonald bases\n\n EXAMPLES::\n\n sage: Mac = SymmetricFunctions(QQ['q'].fraction_field()).macdonald(t=0)\n sage: Mac.symmetric_function_ring()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in q over Rational Field\n "
return self._sym
def P(self):
"\n Returns Macdonald polynomials in `P` basis.\n The `P` basis is defined here as a normalized form of the `J` basis.\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - returns the `P` Macdonald basis of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P(); P\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald P basis\n sage: P[2]\n McdP[2]\n\n The `P` Macdonald basis is upper triangularly related to the monomial symmetric functions and are\n orthogonal with respect to the `qt`-Hall scalar product::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P(); P\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald P basis\n sage: m = Sym.monomial()\n sage: P.transition_matrix(m,2)\n [ 1 (q*t - q + t - 1)/(q*t - 1)]\n [ 0 1]\n sage: P([1,1]).scalar_qt(P([2]))\n 0\n sage: P([2]).scalar_qt(P([2]))\n (-q^3 + q^2 + q - 1)/(-q*t^2 + q*t + t - 1)\n sage: P([1,1]).scalar_qt(P([1,1]))\n (-q^2*t + q*t + q - 1)/(-t^3 + t^2 + t - 1)\n\n When `q = 0`, the Macdonald polynomials on the `P` basis are the same\n as the Hall-Littlewood polynomials on the `P` basis.\n\n ::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: P = Sym.macdonald(q=0).P(); P\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Macdonald P with q=0 basis\n sage: P([2])^2\n (t+1)*McdP[2, 2] + (-t+1)*McdP[3, 1] + McdP[4]\n sage: HLP = Sym.hall_littlewood().P()\n sage: HLP([2])^2\n (t+1)*HLP[2, 2] + (-t+1)*HLP[3, 1] + HLP[4]\n\n Coercions from the `Q` and `J` basis (proportional) are\n implemented::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: Q = Sym.macdonald().Q()\n sage: J = Sym.macdonald().J()\n sage: s = Sym.schur()\n\n ::\n\n sage: P(Q([2]))\n ((q*t^2-q*t-t+1)/(q^3-q^2-q+1))*McdP[2]\n sage: P(Q([2,1]))\n ((-q*t^4+2*q*t^3-q*t^2+t^2-2*t+1)/(-q^4*t+2*q^3*t-q^2*t+q^2-2*q+1))*McdP[2, 1]\n\n ::\n\n sage: P(J([2]))\n (q*t^2-q*t-t+1)*McdP[2]\n sage: P(J([2,1]))\n (-q*t^4+2*q*t^3-q*t^2+t^2-2*t+1)*McdP[2, 1]\n\n By transitivity, one get coercions from the classical bases::\n\n sage: P(s([2]))\n ((q-t)/(q*t-1))*McdP[1, 1] + McdP[2]\n sage: P(s([2,1]))\n ((q*t-t^2+q-t)/(q*t^2-1))*McdP[1, 1, 1] + McdP[2, 1]\n\n ::\n\n sage: Sym = SymmetricFunctions(QQ['x','y','z'].fraction_field())\n sage: (x,y,z) = Sym.base_ring().gens()\n sage: Macxy = Sym.macdonald(q=x,t=y)\n sage: Macyz = Sym.macdonald(q=y,t=z)\n sage: Maczx = Sym.macdonald(q=z,t=x)\n sage: P1 = Macxy.P()\n sage: P2 = Macyz.P()\n sage: P3 = Maczx.P()\n sage: m(P1[2,1])\n ((-2*x*y^2+x*y-y^2+x-y+2)/(-x*y^2+1))*m[1, 1, 1] + m[2, 1]\n sage: m(P2[2,1])\n ((-2*y*z^2+y*z-z^2+y-z+2)/(-y*z^2+1))*m[1, 1, 1] + m[2, 1]\n sage: m(P1(P2(P3[2,1])))\n ((-2*x^2*z-x^2+x*z-x+z+2)/(-x^2*z+1))*m[1, 1, 1] + m[2, 1]\n sage: P1(P2[2])\n ((-x*y^2+2*x*y*z-y^2*z-x+2*y-z)/(x*y^2*z-x*y-y*z+1))*McdP[1, 1] + McdP[2]\n sage: m(z*P1[2]+x*P2[2])\n ((x^2*y^2*z+x*y^2*z^2-x^2*y^2+x^2*y*z-x*y*z^2+y^2*z^2-x^2*y-2*x*y*z-y*z^2+x*y-y*z+x+z)/(x*y^2*z-x*y-y*z+1))*m[1, 1] + (x+z)*m[2]\n "
return MacdonaldPolynomials_p(self)
def Q(self):
"\n Returns the Macdonald polynomials on the `Q` basis. These are dual to\n the Macdonald polynomials on the P basis with respect to the\n `qt`-Hall scalar product.\n The `Q` basis is defined to be a normalized form of the `J` basis.\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - returns the `Q` Macdonald basis of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: Q = Sym.macdonald().Q(); Q\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald Q basis\n sage: P = Sym.macdonald().P()\n sage: Q([2]).scalar_qt(P([2]))\n 1\n sage: Q([2]).scalar_qt(P([1,1]))\n 0\n sage: Q([1,1]).scalar_qt(P([2]))\n 0\n sage: Q([1,1]).scalar_qt(P([1,1]))\n 1\n sage: Q(P([2]))\n ((q^3-q^2-q+1)/(q*t^2-q*t-t+1))*McdQ[2]\n sage: Q(P([1,1]))\n ((q^2*t-q*t-q+1)/(t^3-t^2-t+1))*McdQ[1, 1]\n\n\n Coercions from the `P` and `J` basis (proportional) are implemented::\n\n sage: P = Sym.macdonald().P()\n sage: Q = Sym.macdonald().Q()\n sage: J = Sym.macdonald().J()\n sage: s = Sym.schur()\n\n ::\n\n sage: Q(J([2]))\n (q^3-q^2-q+1)*McdQ[2]\n\n ::\n\n sage: Q(P([2]))\n ((q^3-q^2-q+1)/(q*t^2-q*t-t+1))*McdQ[2]\n sage: P(Q(P([2])))\n McdP[2]\n sage: Q(P(Q([2])))\n McdQ[2]\n\n By transitivity, one gets coercions from the classical bases::\n\n sage: Q(s([2]))\n ((q^2-q*t-q+t)/(t^3-t^2-t+1))*McdQ[1, 1] + ((q^3-q^2-q+1)/(q*t^2-q*t-t+1))*McdQ[2]\n "
return MacdonaldPolynomials_q(self)
def J(self):
"\n Returns the Macdonald polynomials on the `J` basis also known as the\n integral form of the Macdonald polynomials. These are scalar\n multiples of both the `P` and `Q` bases. When expressed in the `P` or `Q`\n basis, the scaling coefficients are polynomials in `q` and `t` rather\n than rational functions.\n\n The `J` basis is calculated using determinantal formulas of\n Lapointe-Lascoux-Morse giving the action on the S-basis [LLM1998]_.\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - returns the `J` Macdonald basis of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: J = Sym.macdonald().J(); J\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald J basis\n sage: P = Sym.macdonald().P()\n sage: Q = Sym.macdonald().Q()\n sage: P(J([2]))\n (q*t^2-q*t-t+1)*McdP[2]\n sage: P(J([1,1]))\n (t^3-t^2-t+1)*McdP[1, 1]\n sage: Q(J([2]))\n (q^3-q^2-q+1)*McdQ[2]\n sage: Q(J([1,1]))\n (q^2*t-q*t-q+1)*McdQ[1, 1]\n\n Coercions from the `Q` and `J` basis (proportional) and to/from\n the Schur basis are implemented::\n\n sage: P = Sym.macdonald().P()\n sage: Q = Sym.macdonald().Q()\n sage: J = Sym.macdonald().J()\n sage: s = Sym.schur()\n\n ::\n\n sage: J(P([2]))\n (1/(q*t^2-q*t-t+1))*McdJ[2]\n\n ::\n\n sage: J(Q([2]))\n (1/(q^3-q^2-q+1))*McdJ[2]\n\n ::\n\n sage: s(J([2]))\n (-q*t+t^2+q-t)*s[1, 1] + (q*t^2-q*t-t+1)*s[2]\n sage: J(s([2]))\n ((q-t)/(q*t^4-q*t^3-q*t^2-t^3+q*t+t^2+t-1))*McdJ[1, 1] + (1/(q*t^2-q*t-t+1))*McdJ[2]\n "
return MacdonaldPolynomials_j(self)
def H(self):
"\n Returns the Macdonald polynomials on the H basis. When the `H` basis\n is expanded on the Schur basis, the coefficients are the `qt`-Kostka\n numbers.\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - returns the `H` Macdonald basis of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: H = Sym.macdonald().H(); H\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald H basis\n sage: s = Sym.schur()\n sage: s(H([2]))\n q*s[1, 1] + s[2]\n sage: s(H([1,1]))\n s[1, 1] + t*s[2]\n\n Coercions to/from the Schur basis are implemented::\n\n sage: H = Sym.macdonald().H()\n sage: s = Sym.schur()\n sage: H(s([2]))\n (q/(q*t-1))*McdH[1, 1] - (1/(q*t-1))*McdH[2]\n "
return MacdonaldPolynomials_h(self)
def Ht(self):
"\n Returns the Macdonald polynomials on the `Ht` basis. The elements of\n the `Ht` basis are eigenvectors of the `nabla` operator. When expanded\n on the Schur basis, the coefficients are the modified `qt`-Kostka\n numbers.\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - returns the `Ht` Macdonald basis of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: Ht = Sym.macdonald().Ht(); Ht\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald Ht basis\n sage: [Ht(p).nabla() for p in Partitions(3)]\n [q^3*McdHt[3], q*t*McdHt[2, 1], t^3*McdHt[1, 1, 1]]\n\n ::\n\n sage: s = Sym.schur()\n sage: from sage.combinat.sf.macdonald import qt_kostka\n sage: q,t = Ht.base_ring().gens()\n sage: s(Ht([2,1]))\n q*t*s[1, 1, 1] + (q+t)*s[2, 1] + s[3]\n sage: qt_kostka([1,1,1],[2,1]).subs(t=1/t)*t^Partition([2,1]).weighted_size()\n q*t\n sage: qt_kostka([2,1],[2,1]).subs(t=1/t)*t^Partition([2,1]).weighted_size()\n q + t\n sage: qt_kostka([3],[2,1]).subs(t=1/t)*t^Partition([2,1]).weighted_size()\n 1\n\n Coercions to/from the Schur basis are implemented::\n\n sage: Ht = Sym.macdonald().Ht()\n sage: s = Sym.schur()\n sage: Ht(s([2,1]))\n (q/(q*t^2-t^3-q^2+q*t))*McdHt[1, 1, 1] + ((-q^2-q*t-t^2)/(q^2*t^2-q^3-t^3+q*t))*McdHt[2, 1] + (t/(-q^3+q^2*t+q*t-t^2))*McdHt[3]\n sage: Ht(s([2]))\n ((-q)/(-q+t))*McdHt[1, 1] + (t/(-q+t))*McdHt[2]\n "
return MacdonaldPolynomials_ht(self)
def S(self):
"\n Returns the modified Schur functions defined by the plethystic\n substitution `S_{\\mu} = s_{\\mu}[X(1-t)/(1-q)]`. When the\n Macdonald polynomials in the J basis are expressed in terms of the\n modified Schur functions at `q=0`, the coefficients are `qt`-Kostka numbers.\n\n INPUT:\n\n - ``self`` -- a family of Macdonald symmetric function bases\n\n OUTPUT:\n\n - returns the `S` Macdonald basis of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S(); S\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald S basis\n sage: p = Sym.power()\n sage: p(S[2,1])\n ((1/3*t^3-t^2+t-1/3)/(q^3-3*q^2+3*q-1))*p[1, 1, 1] + ((-1/3*t^3+1/3)/(q^3-1))*p[3]\n sage: J = Sym.macdonald().J()\n sage: S(J([2]))\n (q^3-q^2-q+1)*McdS[2]\n sage: S(J([1,1]))\n (q^2*t-q*t-q+1)*McdS[1, 1] + (q^2-q*t-q+t)*McdS[2]\n sage: S = Sym.macdonald(q=0).S()\n sage: S(J[1,1])\n McdS[1, 1] + t*McdS[2]\n sage: S(J[2])\n q*McdS[1, 1] + McdS[2]\n sage: p(S[2,1])\n (-1/3*t^3+t^2-t+1/3)*p[1, 1, 1] + (1/3*t^3-1/3)*p[3]\n\n sage: from sage.combinat.sf.macdonald import qt_kostka\n sage: qt_kostka([2],[1,1])\n t\n sage: qt_kostka([1,1],[2])\n q\n\n Coercions to/from the Schur basis are implemented::\n\n sage: S = Sym.macdonald().S()\n sage: s = Sym.schur()\n sage: S(s([2]))\n ((q^2-q*t-q+t)/(t^3-t^2-t+1))*McdS[1, 1] + ((-q^2*t+q*t+q-1)/(-t^3+t^2+t-1))*McdS[2]\n sage: s(S([1,1]))\n ((-q*t^2+q*t+t-1)/(-q^3+q^2+q-1))*s[1, 1] + ((q*t-t^2-q+t)/(-q^3+q^2+q-1))*s[2]\n "
return MacdonaldPolynomials_s(self)
|
def c1(part, q, t):
"\n This function returns the qt-Hall scalar product between ``J(part)``\n and ``P(part)``.\n\n This coefficient is `c_\\lambda` in equation (8.1') p. 352 of\n Macdonald's book [Mac1995]_.\n\n INPUT:\n\n - ``part`` -- a partition\n - ``q``, ``t`` -- parameters\n\n OUTPUT:\n\n - returns a polynomial of the scalar product between the `J` and `P` bases\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.macdonald import c1\n sage: R.<q,t> = QQ[]\n sage: c1(Partition([2,1]),q,t)\n -q^4*t + 2*q^3*t - q^2*t + q^2 - 2*q + 1\n sage: c1(Partition([1,1]),q,t)\n q^2*t - q*t - q + 1\n "
R = q.parent()
arms = part.arm_lengths(flat=True)
legs = part.leg_lengths(flat=True)
return R.prod(((1 - ((q ** (a + 1)) * (t ** l))) for (a, l) in zip(arms, legs)))
|
def c2(part, q, t):
"\n This function returns the qt-Hall scalar product between J(part)\n and Q(part).\n\n This coefficient is `c_\\lambda` in equation (8.1) p. 352 of\n Macdonald's book [Mac1995]_.\n\n INPUT:\n\n - ``part`` -- a partition\n - ``q``, ``t`` -- parameters\n\n OUTPUT:\n\n - returns a polynomial of the scalar product between the `J` and `P` bases\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.macdonald import c2\n sage: R.<q,t> = QQ[]\n sage: c2(Partition([1,1]),q,t)\n t^3 - t^2 - t + 1\n sage: c2(Partition([2,1]),q,t)\n -q*t^4 + 2*q*t^3 - q*t^2 + t^2 - 2*t + 1\n "
R = q.parent()
arms = part.arm_lengths(flat=True)
legs = part.leg_lengths(flat=True)
return R.prod(((1 - ((q ** a) * (t ** (l + 1)))) for (a, l) in zip(arms, legs)))
|
@cached_function
def cmunu1(mu, nu):
"\n Return the coefficient of `{\\tilde H}_\\nu` in `h_1^\\perp {\\tilde H}_\\mu`.\n\n INPUT:\n\n - ``mu``, ``nu`` -- partitions with ``nu`` precedes ``mu``\n\n OUTPUT:\n\n - an element of the fraction field of polynomials in `q` and `t`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.macdonald import cmunu1\n sage: cmunu1(Partition([2,1]),Partition([2]))\n (-t^2 + q)/(q - t)\n sage: cmunu1(Partition([2,1]),Partition([1,1]))\n (-q^2 + t)/(-q + t)\n sage: Sym = SymmetricFunctions(QQ['q','t'].fraction_field())\n sage: h = Sym.h()\n sage: Ht = Sym.macdonald().Ht()\n sage: all(Ht[3,2,1].skew_by(h[1]).coefficient(nu)\n ....: == cmunu1(Partition([3,2,1]),nu)\n ....: for nu in Partition([3,2,1]).down_list())\n True\n "
(q, t) = QQqt.gens()
for (i, val) in enumerate(nu._list):
if (val < mu._list[i]):
A = prod(((((t ** mu.leg_length(i, s)) - (q ** (mu.arm_length(i, s) + 1))) / ((t ** nu.leg_length(i, s)) - (q ** (nu.arm_length(i, s) + 1)))) for s in range(val)))
B = prod(((((q ** mu.arm_length(*s)) - (t ** (mu.leg_length(*s) + 1))) / ((q ** nu.arm_length(*s)) - (t ** (nu.leg_length(*s) + 1)))) for s in nu.cells() if (s[1] == val)))
return QQqt((A * B))
return QQqt(prod(((((q ** mu.arm_length(s, 0)) - (t ** (mu.leg_length(s, 0) + 1))) / ((q ** nu.arm_length(s, 0)) - (t ** (nu.leg_length(s, 0) + 1)))) for s in range(len(nu._list)))))
|
@cached_function
def cmunu(mu, nu):
"\n Return the coefficient of `{\\tilde H}_\\nu` in `h_r^\\perp {\\tilde H}_\\mu`.\n\n Proposition 5 of F. Bergeron and M. Haiman [BH2013]_ states\n\n .. MATH::\n\n c_{\\mu\\nu} = \\sum_{\\alpha \\leftarrow \\nu} c_{\\mu\\alpha}\n c_{\\alpha\\nu} B_{\\alpha/\\nu}/B_{\\mu/\\nu}\n\n where `c_{\\mu\\nu}` is the coefficient of `{\\tilde H}_\\nu` in\n `h_r^\\perp {\\tilde H}_\\mu` and `B_{\\mu/\\nu}` is the bi-exponent generator\n implemented in the function :func:`sage.combinat.sf.macdonald.Bmu`.\n\n INPUT:\n\n - ``mu``, ``nu`` -- partitions with ``nu`` contained in ``mu``\n\n OUTPUT:\n\n - an element of the fraction field of polynomials in `q` and `t`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.macdonald import cmunu\n sage: cmunu(Partition([2,1]),Partition([1]))\n q + t + 1\n sage: cmunu(Partition([2,2]),Partition([1,1]))\n (-q^3 - q^2 + q*t + t)/(-q + t)\n sage: Sym = SymmetricFunctions(QQ['q','t'].fraction_field())\n sage: h = Sym.h()\n sage: Ht = Sym.macdonald().Ht()\n sage: all(Ht[2,2].skew_by(h[r]).coefficient(nu)\n ....: == cmunu(Partition([2,2]),nu)\n ....: for r in range(1,5) for nu in Partitions(4-r))\n True\n "
if (not nu):
return QQqt.one()
if (not mu.contains(nu)):
return QQqt.zero()
if (mu.size() == (nu.size() + 1)):
return cmunu1(mu, nu)
def Bmu_skew(outer, inner):
inner = list(inner)
inner += ([0] * (len(outer) - len(inner)))
(q, t) = QQqt.gens()
res = QQqt.zero()
for (i, val) in enumerate(outer):
for j in range(inner[i], val):
res += ((t ** i) * (q ** j))
return res
nulist = nu._list
return (sum((((cmunu(mu, al) * cmunu1(al, nu)) * Bmu_skew(al, nulist)) for al in nu.up())) / Bmu_skew(mu, nulist))
|
class MacdonaldPolynomials_generic(sfa.SymmetricFunctionAlgebra_generic):
def __init__(self, macdonald):
'\n A class for methods for one of the Macdonald bases of the symmetric functions\n\n INPUT:\n\n - ``self`` -- a Macdonald basis\n - ``macdonald`` -- a family of Macdonald symmetric function bases\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q,t\'])); Sym.rename("Sym"); Sym\n Sym\n sage: Sym.macdonald().P()\n Sym in the Macdonald P basis\n sage: Sym.macdonald(t=2).P()\n Sym in the Macdonald P with t=2 basis\n sage: Sym.rename()\n\n TESTS::\n\n sage: Sym.macdonald().P()._prefix\n \'McdP\'\n sage: Sym.macdonald().Ht()._prefix\n \'McdHt\'\n '
s = self.__class__.__name__[21:].capitalize()
sfa.SymmetricFunctionAlgebra_generic.__init__(self, macdonald._sym, basis_name=(('Macdonald ' + s) + macdonald._name_suffix), prefix=('Mcd' + s))
self.q = macdonald.q
self.t = macdonald.t
self._macdonald = macdonald
self._s = self._macdonald._s
if hasattr(self, '_s_cache'):
category = ModulesWithBasis(self.base_ring())
self.register_coercion(SetMorphism(Hom(self._s, self, category), self._s_to_self))
self._s.register_coercion(SetMorphism(Hom(self, self._s, category), self._self_to_s))
def _s_to_self(self, x):
"\n Isomorphism from the Schur basis into self\n\n INPUT:\n\n - ``self`` -- a Macdonald basis\n - ``x`` -- an element of the Schur basis\n\n OUTPUT:\n\n - returns the basis element ``x`` in the basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q']))\n sage: J = Sym.macdonald(t=2).J()\n sage: s = Sym.schur()\n sage: J._s_to_self(s[2,1])\n ((-1/28*q+1/14)/(q-1/4))*McdJ[1, 1, 1] - (1/4/(q-1/4))*McdJ[2, 1]\n\n This is for internal use only. Please use instead::\n\n sage: J(s[2,1])\n ((-1/28*q+1/14)/(q-1/4))*McdJ[1, 1, 1] - (1/4/(q-1/4))*McdJ[2, 1]\n "
return self._from_cache(x, self._s_cache, self._s_to_self_cache, q=self.q, t=self.t)
def _self_to_s(self, x):
"\n Isomorphism from self to the Schur basis\n\n INPUT:\n\n - ``self`` -- a Macdonald basis\n - ``x`` -- an element of a Macdonald basis\n\n OUTPUT:\n\n - returns the basis element ``x`` in the Schur functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q']))\n sage: J = Sym.macdonald(t=2).J()\n sage: s = Sym.schur()\n sage: J._self_to_s(J[2,1])\n (3*q-6)*s[1, 1, 1] + (-4*q+1)*s[2, 1]\n\n This is for internal use only. Please use instead::\n\n sage: s(J[2,1])\n (3*q-6)*s[1, 1, 1] + (-4*q+1)*s[2, 1]\n "
return self._s._from_cache(x, self._s_cache, self._self_to_s_cache, q=self.q, t=self.t)
def c1(self, part):
"\n Returns the qt-Hall scalar product between ``J(part)`` and ``P(part)``.\n\n INPUT:\n\n - ``self`` -- a Macdonald basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns the `qt`-Hall scalar product between ``J(part)`` and ``P(part)``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: P.c1(Partition([2,1]))\n -q^4*t + 2*q^3*t - q^2*t + q^2 - 2*q + 1\n "
return c1(part, self.q, self.t)
def c2(self, part):
"\n Returns the `qt`-Hall scalar product between ``J(part)`` and ``Q(part)``.\n\n INPUT:\n\n - ``self`` -- a Macdonald basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns the `qt`-Hall scalar product between ``J(part)`` and ``Q(part)``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: P.c2(Partition([2,1]))\n -q*t^4 + 2*q*t^3 - q*t^2 + t^2 - 2*t + 1\n "
return c2(part, self.q, self.t)
def product(self, left, right):
"\n Multiply an element of the Macdonald symmetric function\n basis ``self`` and another symmetric function\n\n Convert to the Schur basis, do the multiplication there, and\n convert back to ``self`` basis.\n\n INPUT:\n\n - ``self`` -- a Macdonald symmetric function basis\n - ``left`` -- an element of the basis ``self``\n - ``right`` -- another symmetric function\n\n OUTPUT:\n\n the product of ``left`` and ``right`` expanded in the basis ``self``\n\n EXAMPLES::\n\n sage: Mac = SymmetricFunctions(FractionField(QQ['q','t'])).macdonald()\n sage: H = Mac.H()\n sage: J = Mac.J()\n sage: P = Mac.P()\n sage: Q = Mac.Q()\n sage: Ht = Mac.Ht()\n sage: J([1])^2 #indirect doctest\n ((q-1)/(q*t-1))*McdJ[1, 1] + ((t-1)/(q*t-1))*McdJ[2]\n sage: J.product( J[1], J[2] )\n ((-q^2+1)/(-q^2*t+1))*McdJ[2, 1] + ((-t+1)/(-q^2*t+1))*McdJ[3]\n sage: H.product( H[1], H[2] )\n ((q^2-1)/(q^2*t-1))*McdH[2, 1] + ((-t+1)/(-q^2*t+1))*McdH[3]\n sage: P.product( P[1], P[2] )\n ((-q^3*t^2+q*t^2+q^2-1)/(-q^3*t^2+q^2*t+q*t-1))*McdP[2, 1] + McdP[3]\n sage: Q.product(Q[1],Q[2])\n McdQ[2, 1] + ((q^2*t-q^2+q*t-q+t-1)/(q^2*t-1))*McdQ[3]\n sage: Ht.product(Ht[1],Ht[2])\n ((q^2-1)/(q^2-t))*McdHt[2, 1] + ((t-1)/(-q^2+t))*McdHt[3]\n "
return self((self._s(left) * self._s(right)))
def macdonald_family(self):
"\n Returns the family of Macdonald bases associated to the basis ``self``\n\n INPUT:\n\n - ``self`` -- a Macdonald basis\n\n OUTPUT:\n\n - the family of Macdonald symmetric functions associated to ``self``\n\n EXAMPLES::\n\n sage: MacP = SymmetricFunctions(QQ['q'].fraction_field()).macdonald(t=0).P()\n sage: MacP.macdonald_family()\n Macdonald polynomials with t=0 over Fraction Field of Univariate Polynomial Ring in q over Rational Field\n "
return self._macdonald
class Element(sfa.SymmetricFunctionAlgebra_generic.Element):
def nabla(self, q=None, t=None, power=1):
"\n Return the value of the nabla operator applied to ``self``.\n\n The eigenvectors of the nabla operator are the Macdonald\n polynomials in the `Ht` basis. For more information\n see: [BGHT1999]_.\n\n The operator nabla acts on symmetric functions and has the\n Macdonald `Ht` basis as eigenfunctions and the eigenvalues\n are `q^{n(\\mu')} t^{n(\\mu)}` where\n `n(\\mu) = \\sum_{i} (i-1) \\mu_i` and `\\mu'` is the conjugate\n shape of `\\mu`.\n\n If the parameter ``power`` is an integer then it calculates\n nabla to that integer. The default value of ``power`` is 1.\n\n INPUT:\n\n - ``self`` -- an element of a Macdonald basis\n - ``q``, ``t`` -- optional parameters to specialize\n - ``power`` -- an integer (default: 1)\n\n OUTPUT:\n\n - returns the symmetric function of `\\nabla` acting on ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: P([1,1]).nabla()\n ((q^2*t+q*t^2-2*t)/(q*t-1))*McdP[1, 1] + McdP[2]\n sage: P([1,1]).nabla(t=1)\n ((q^2*t+q*t-t-1)/(q*t-1))*McdP[1, 1] + McdP[2]\n sage: H = Sym.macdonald().H()\n sage: H([1,1]).nabla()\n t*McdH[1, 1] + (-t^2+1)*McdH[2]\n sage: H([1,1]).nabla(q=1)\n ((t^2+q-t-1)/(q*t-1))*McdH[1, 1] + ((-t^3+t^2+t-1)/(q*t-1))*McdH[2]\n sage: H(0).nabla()\n 0\n sage: H([2,2,1]).nabla(t=1/H.t)\n ((-q^2)/(-t^4))*McdH[2, 2, 1]\n sage: H([2,2,1]).nabla(t=1/H.t,power=-1)\n ((-t^4)/(-q^2))*McdH[2, 2, 1]\n "
parent = self.parent()
if ((q is None) and (t is None)):
Ht = parent._macdonald.Ht()
else:
if (q is None):
q = parent.q
if (t is None):
t = parent.t
Ht = parent.realization_of().macdonald(q=q, t=t).Ht()
return parent(Ht(self).nabla(power=power))
|
class MacdonaldPolynomials_p(MacdonaldPolynomials_generic):
def __init__(self, macdonald):
'\n The `P` basis is defined here as the `J` basis times a\n normalizing coefficient `c2`.\n\n INPUT:\n\n - ``self`` -- a Macdonald `P` basis\n - ``macdonald`` -- a family of Macdonald bases\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: P = Sym.macdonald().P()\n sage: TestSuite(P).run(skip=["_test_associativity","_test_distributivity","_test_prod"]) # long time (20s on sage.math, 2012)\n sage: TestSuite(P).run(elements = [P.t*P[1,1]+P.q*P[2], P[1]+(P.q+P.t)*P[1,1]]) # long time (depends on previous)\n '
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._J = macdonald.J()
category = ModulesWithBasis(self.base_ring())
phi = self._J.module_morphism(diagonal=self.c2, codomain=self, category=category)
self.register_coercion(phi)
self._J.register_coercion((~ phi))
def scalar_qt_basis(self, part1, part2=None):
"\n Returns the scalar product of `P(part1)` and `P(part2)`\n This scalar product formula is given in equation (4.11) p.323\n and (6.19) p.339 of Macdonald's book [Mac1995]_.\n\n INPUT:\n\n - ``self`` -- a Macdonald `P` basis\n - ``part1``, ``part2`` -- partitions\n\n OUTPUT:\n\n - returns the scalar product of ``P(part1)`` and ``P(part2)``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: P.scalar_qt_basis(Partition([2,1]), Partition([1,1,1]))\n 0\n sage: f = P.scalar_qt_basis(Partition([3,2,1]), Partition([3,2,1]))\n sage: factor(f.numerator())\n (q - 1)^3 * (q^2*t - 1)^2 * (q^3*t^2 - 1)\n sage: factor(f.denominator())\n (t - 1)^3 * (q*t^2 - 1)^2 * (q^2*t^3 - 1)\n\n With a single argument, takes `part2 = part1`::\n\n sage: P.scalar_qt_basis(Partition([2,1]), Partition([2,1]))\n (-q^4*t + 2*q^3*t - q^2*t + q^2 - 2*q + 1)/(-q*t^4 + 2*q*t^3 - q*t^2 + t^2 - 2*t + 1)\n\n "
if ((part2 is not None) and (part1 != part2)):
return self.base_ring().zero()
return (self.c1(part1) / self.c2(part1))
class Element(MacdonaldPolynomials_generic.Element):
pass
|
class MacdonaldPolynomials_q(MacdonaldPolynomials_generic):
def __init__(self, macdonald):
'\n The `Q` basis is defined here as the `J` basis times a\n normalizing coefficient.\n\n INPUT:\n\n - ``self`` -- a Macdonald `Q` basis\n - ``macdonald`` -- a family of Macdonald bases\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: Q = Sym.macdonald().Q()\n sage: TestSuite(Q).run(skip=["_test_associativity","_test_distributivity","_test_prod"]) # long time (29s on sage.math, 2012)\n 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)\n '
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._J = macdonald.J()
self._P = macdonald.P()
category = ModulesWithBasis(self.base_ring())
phi = self._P.module_morphism(diagonal=self._P.scalar_qt_basis, codomain=self, category=category)
self.register_coercion(phi)
self._P.register_coercion((~ phi))
class Element(MacdonaldPolynomials_generic.Element):
pass
|
class MacdonaldPolynomials_j(MacdonaldPolynomials_generic):
def __init__(self, macdonald):
'\n The `J` basis is calculated using determinantal formulas of\n Lapointe-Lascoux-Morse giving the action on the `S`-basis.\n\n INPUT:\n\n - ``self`` -- a Macdonald `J` basis\n - ``macdonald`` -- a family of Macdonald bases\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: J = Sym.macdonald().J()\n sage: TestSuite(J).run(skip=["_test_associativity","_test_distributivity","_test_prod"]) # long time (19s on sage.math, 2012)\n sage: TestSuite(J).run(elements = [J.t*J[1,1]+J.q*J[2], J[1]+(J.q+J.t)*J[1,1]]) # long time (depends on previous)\n '
self._self_to_s_cache = _j_to_s_cache
self._s_to_self_cache = _s_to_j_cache
MacdonaldPolynomials_generic.__init__(self, macdonald)
def _s_cache(self, n):
"\n Compute the change of basis and its inverse between the Macdonald\n polynomials on the `J` basis and the Schur functions\n these computations are completed with coefficients in fraction\n field of polynomials in `q` and `t`\n\n INPUT:\n\n - ``self`` -- a Macdonald `J` basis\n - ``n`` -- a non-negative integer\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: J = Sym.macdonald().J()\n sage: J._s_cache(2)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l( J._s_to_self_cache[2] )\n [([1, 1], [([1, 1], 1/(t^3 - t^2 - t + 1))]),\n ([2],\n [([1, 1], (q - t)/(q*t^4 - q*t^3 - q*t^2 - t^3 + q*t + t^2 + t - 1)),\n ([2], 1/(q*t^2 - q*t - t + 1))])]\n sage: l( J._self_to_s_cache[2] )\n [([1, 1], [([1, 1], t^3 - t^2 - t + 1)]),\n ([2], [([1, 1], -q*t + t^2 + q - t), ([2], q*t^2 - q*t - t + 1)])]\n "
self._invert_morphism(n, QQqt, self._self_to_s_cache, self._s_to_self_cache, to_other_function=self._to_s, upper_triangular=False)
def _to_s(self, part):
"\n Returns a function which gives the coefficient of a partition in\n the Schur expansion of self(part).\n\n These computations are completed with coefficients in fraction\n field of polynomials in `q` and `t`\n\n INPUT:\n\n - ``self`` -- a Macdonald `J` basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a function which returns the coefficients of the expansion of `J`\n in the Schur basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: J = Sym.macdonald().J()\n sage: f21 = J._to_s(Partition([2,1]))\n sage: [f21(part) for part in Partitions(3)]\n [0,\n -q*t^4 + 2*q*t^3 - q*t^2 + t^2 - 2*t + 1,\n q*t^3 - t^4 - q*t^2 + t^3 - q*t + t^2 + q - t]\n sage: Sym.schur()( J[2,1] )\n (q*t^3-t^4-q*t^2+t^3-q*t+t^2+q-t)*s[1, 1, 1] + (-q*t^4+2*q*t^3-q*t^2+t^2-2*t+1)*s[2, 1]\n "
(q, t) = QQqt.gens()
S = self._macdonald.S()
res = S(1)
for k in reversed(part):
res = res.creation(k)
res = res._omega_qt_in_schurs()
res = res.map_coefficients((lambda c: c(t, q)))
f = res.coefficient
return f
class Element(MacdonaldPolynomials_generic.Element):
pass
|
class MacdonaldPolynomials_h(MacdonaldPolynomials_generic):
def __init__(self, macdonald):
'\n The `H` basis is defined as `H_\\mu = \\sum_{\\lambda} K_{\\lambda\\mu}(q,t) s_\\lambda`\n where `K_{\\lambda\\mu}(q,t)` are the Macdonald Kostka coefficients.\n\n In this implementation, it is calculated by using the Macdonald `Ht` basis and\n substituting `t \\rightarrow 1/t` and multiplying by `t^{n(\\mu)}`.\n\n INPUT:\n\n - ``self`` -- a Macdonald `H` basis\n - ``macdonald`` -- a family of Macdonald bases\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: H = Sym.macdonald().H()\n sage: TestSuite(H).run(skip=["_test_associativity","_test_distributivity","_test_prod"])\n sage: TestSuite(H).run(elements = [H.t*H[1,1]+H.q*H[2], H[1]+(H.q+H.t)*H[1,1]]) # long time (26s on sage.math, 2012)\n\n '
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._m = self._sym.m()
self._Lmunu = macdonald.Ht()._Lmunu
if (not self.t):
self._Qp = self._sym.hall_littlewood(t=self.q).Qp()
category = ModulesWithBasis(self.base_ring())
self._s.register_coercion(SetMorphism(Hom(self, self._s, category), self._self_to_s))
self.register_coercion(SetMorphism(Hom(self._s, self, category), self._s_to_self))
self._m.register_coercion(SetMorphism(Hom(self, self._m, category), self._self_to_m))
self.register_coercion(SetMorphism(Hom(self._m, self, category), self._m_to_self))
def _self_to_s(self, x):
"\n Return an element ``x`` of ``self`` expanded in the Schur basis.\n\n If `t=0` then the expression for `H_\\mu[X;q,0]` is equal to\n `\\omega Q'_{\\mu'}[X;q]` where `Q'` is the Hall-Littlewood basis.\n\n If `t \\neq 0` then the conversion uses the monomial basis.\n\n INPUT:\n\n - ``x`` -- an element of ``H`` basis\n\n OUTPUT:\n\n - an element of the Schur basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: H = Sym.macdonald().H()\n sage: s = Sym.s()\n sage: s(H[2,1])\n q*s[1, 1, 1] + (q*t+1)*s[2, 1] + t*s[3]\n sage: H2 = Sym.macdonald(t=0).H()\n sage: s(H2[2,1])\n q*s[1, 1, 1] + s[2, 1]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['x']))\n sage: x = Sym.base_ring().gen()\n sage: H = Sym.macdonald(q=x,t=1/x).H()\n sage: s = Sym.s()\n sage: s(H[2,1])\n x*s[1, 1, 1] + 2*s[2, 1] + 1/x*s[3]\n "
if self.t:
return self._s(self._self_to_m(x))
else:
return sum(((cmu * self._s(self._Qp(mu.conjugate()))) for (mu, cmu) in x)).omega()
def _s_to_self(self, x):
"\n Return an element of the Schur basis ``x`` expanded in the ``H`` basis.\n\n If `t=0` then the expression for `H_\\mu[X;q,0]` is equal to\n `\\omega Q'_{\\mu'}[X;q]` where `Q'` is the Hall-Littlewood basis.\n\n If `t \\neq 0` then the conversion uses the monomial basis.\n\n INPUT:\n\n - ``x`` -- an element of the Schur basis\n\n OUTPUT:\n\n - an element of the ``H`` basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: H = Sym.macdonald().H()\n sage: s = Sym.s()\n sage: H(s[1,1])\n -(1/(q*t-1))*McdH[1, 1] + (t/(q*t-1))*McdH[2]\n sage: (q,t) = Sym.base_ring().gens()\n sage: H(q*s[1, 1, 1] + (q*t+1)*s[2, 1] + t*s[3])\n McdH[2, 1]\n sage: H2 = Sym.macdonald(t=0).H()\n sage: H2(q*s[1, 1, 1] + (q*t+1)*s[2, 1] + t*s[3])\n (-q^2*t+1)*McdH[2, 1] + t*McdH[3]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['x']))\n sage: x = Sym.base_ring().gen()\n sage: H = Sym.macdonald(q=x,t=1/x).H()\n sage: s = Sym.s()\n sage: H(x*s[1, 1, 1] + 2*s[2, 1] + 1/x*s[3])\n McdH[2, 1]\n "
if self.t:
return self._m_to_self(self._m(x))
else:
return self._from_dict({mu.conjugate(): cmu for (mu, cmu) in self._Qp(x.omega())})
def _self_to_m(self, x):
"\n Return an element ``x`` of ``self`` expanded in the monomial basis.\n\n INPUT:\n\n - ``x`` -- an element of ``H`` basis\n\n OUTPUT:\n\n - an element of the monomial basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: H = Sym.macdonald().H()\n sage: m = Sym.m()\n sage: m(H[2,1])\n (2*q*t+q+t+2)*m[1, 1, 1] + (q*t+t+1)*m[2, 1] + t*m[3]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['x']))\n sage: x = Sym.base_ring().gen()\n sage: H = Sym.macdonald(q=x,t=1/x).H()\n sage: m = Sym.m()\n sage: m(H[2,1])\n ((x^2+4*x+1)/x)*m[1, 1, 1] + ((2*x+1)/x)*m[2, 1] + 1/x*m[3]\n sage: H2 = Sym.macdonald(q=x,t=1).H()\n sage: H2((3*x+3)*m[1, 1, 1] + (x+2)*m[2, 1] + m[3])\n McdH[2, 1]\n sage: H3 = Sym.macdonald(q=x,t=0).H()\n sage: H3((3*x+3)*m[1, 1, 1] + (x+2)*m[2, 1] + m[3])\n (-x^2+1)*McdH[2, 1] + McdH[3]\n "
if self.t:
tinv = (~ self.t)
part_coeff = (lambda x, d: sorted(((mu, c) for (mu, c) in x if (sum(mu) == d))))
return self._m._from_dict({part2: self._base(sum((((c * (self.t ** mu.weighted_size())) * self._Lmunu(part2, mu).subs(q=self.q, t=tinv)) for (mu, c) in part_coeff(x, d)))) for d in range((x.degree() + 1)) for part2 in Partitions_n(d)})
else:
return self._m(self._self_to_s(x))
def _m_to_self(self, f):
"\n Convert an element ``f`` from the monomial basis to the ``H`` basis.\n\n This calculation is performed by using the fact that `H_\\mu[X(1-t)]`\n is `c_\\mu m_\\mu` plus terms which are smaller in dominance order.\n The leading coefficient of the expansion of ``f`` in the `H_\\mu`\n basis is equal to the leading coefficient of `c_\\mu^{-1} f[X(1-t)]`.\n\n If `t=1`, we must appeal to another triangularity since ``Ht``\n is (usually) still a basis, however `H_\\mu[X(1-t)]=0`. In this\n case we assume that it is a basis and `H_\\mu[X(q-1)]` is\n `c_\\mu m_{\\mu'}` plus terms which are lower in dominance order.\n\n INPUT:\n\n - ``f`` -- an element of the monomial basis\n\n OUTPUT:\n\n - an element of the ``H`` basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: H = Sym.macdonald().H()\n sage: m = Sym.m()\n sage: H(m[1,1])\n -(1/(q*t-1))*McdH[1, 1] + (t/(q*t-1))*McdH[2]\n sage: (q,t) = Sym.base_ring().gens()\n sage: H((2*q*t+q+t+2)*m[1, 1, 1] + (q*t+t+1)*m[2, 1] + t*m[3])\n McdH[2, 1]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['x']))\n sage: x = Sym.base_ring().gen()\n sage: H = Sym.macdonald(q=x,t=1).H()\n sage: m = Sym.m()\n sage: H((3*x+3)*m[1, 1, 1] + (x+2)*m[2, 1] + m[3])\n McdH[2, 1]\n "
if (self.t == 1):
g = f.omega_qt(q=self.q, t=0)
fl = (lambda x: x.conjugate())
mu_to_H = (lambda mu: self._self_to_m(self(mu.conjugate())).omega_qt(q=self.q, t=0))
else:
g = f.theta_qt(q=self.t, t=0)
fl = (lambda x: x)
mu_to_H = (lambda mu: self._self_to_m(self(mu)).theta_qt(q=self.t, t=0))
out = {}
while (not g.is_zero()):
sprt = sorted(g.support())
Hmu = mu_to_H(sprt[(- 1)])
fl_sprt = fl(sprt[(- 1)])
out[fl_sprt] = self._base((g.coefficient(sprt[(- 1)]) / Hmu.coefficient(sprt[(- 1)])))
g -= (out[fl_sprt] * Hmu)
return self._from_dict(out)
class Element(MacdonaldPolynomials_generic.Element):
pass
|
class MacdonaldPolynomials_ht(MacdonaldPolynomials_generic):
def __init__(self, macdonald):
'\n The `Ht` basis is defined as `{\\tilde H}_\\mu = t^{n(\\mu)} \\sum_{\\lambda}\n K_{\\lambda\\mu}(q,t^{-1}) s_\\lambda` where `K_{\\lambda\\mu}(q,t)` are the\n Macdonald `(q,t)`-Kostka coefficients and `n(\\mu) = \\sum_{i} (i-1) \\mu_i`.\n\n It is implemented here by using a Pieri formula due to F. Bergeron\n and M. Haiman [BH2013]_.\n\n INPUT:\n\n - ``self`` -- a Macdonald `Ht` basis\n - ``macdonald`` -- a family of Macdonald bases\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: Ht = Sym.macdonald().Ht()\n sage: TestSuite(Ht).run(skip=["_test_associativity","_test_distributivity","_test_prod"]) # long time (26s on sage.math, 2012)\n sage: TestSuite(Ht).run(elements = [Ht.t*Ht[1,1]+Ht.q*Ht[2], Ht[1]+(Ht.q+Ht.t)*Ht[1,1]]) # long time (depends on previous)\n\n '
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._self_to_m_cache = _ht_to_m_cache
self._m = self._sym.m()
category = ModulesWithBasis(self.base_ring())
self._s.register_coercion(SetMorphism(Hom(self, self._s, category), self._self_to_s))
self.register_coercion(SetMorphism(Hom(self._s, self, category), self._s_to_self))
self._m.register_coercion(SetMorphism(Hom(self, self._m, category), self._self_to_m))
self.register_coercion(SetMorphism(Hom(self._m, self, category), self._m_to_self))
def _self_to_s(self, x):
"\n Convert an element of the ``Ht`` basis to the Schur basis\n\n This function is here to force the coercion path to the Schur basis\n because these bases are computed using their monomial expansion.\n\n INPUT:\n\n - ``x`` - an element of ``self``\n\n OUTPUT:\n\n - an element of the Schur basis\n\n EXAMPLES::\n\n sage: Ht = SymmetricFunctions(FractionField(QQ['q','t'])).macdonald().Ht()\n sage: s = Ht.symmetric_function_ring().s()\n sage: Ht._self_to_s(Ht[2,1])\n q*t*s[1, 1, 1] + (q+t)*s[2, 1] + s[3]\n "
return self._s(self._self_to_m(x))
def _s_to_self(self, x):
"\n Convert an element of either the Schur basis to the ``Ht`` basis\n\n This function is here to force the coercion path from the Schur basis\n because these bases are computed using the monomial expansion.\n\n INPUT:\n\n - ``x`` - an element of ``s`` basis\n\n OUTPUT:\n\n - an element of the basis ``self``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(FractionField(QQ['q','t'])).s()\n sage: Ht = s.symmetric_function_ring().macdonald().Ht()\n sage: Ht._s_to_self(s[2])\n ((-q)/(-q+t))*McdHt[1, 1] + (t/(-q+t))*McdHt[2]\n "
return self._m_to_self(self._m(x))
def _Lmunu(self, nu, mu):
"\n Return the coefficient of `m_\\nu` in `{\\tilde H}_\\mu`.\n\n The coefficient is a `(q,t)`-analogue of `n` choose `\\nu`. Let\n `c_{\\mu\\gamma}` be the coefficient of `{\\tilde H}_\\gamma` in\n `h_r^\\perp {\\tilde H}_\\mu`. The coefficient of `m_\\nu` in\n `{\\tilde H}_\\mu` is\n\n .. MATH::\n\n L_{\\mu\\nu} = \\sum_{\\gamma} c_{\\mu\\gamma} L_{\\gamma\\overline{\\nu}},\n\n where the sum is over partitions `\\gamma \\subseteq \\mu` with\n `\\gamma \\vdash |(\\nu_1, \\ldots, \\nu_{\\ell(\\nu)-1})|`. There is a\n recursive formula for `c_{\\mu\\gamma}` which is due to F. Bergeron\n and M. Haiman [BH2013]_ and this is implemented in\n :func:`sage.combinat.sf.macdonald.cmunu`.\n\n INPUT:\n\n - ``nu``, ``mu`` -- partitions of the same size\n\n OUTPUT:\n\n - a polynomial in `q` and `t`\n\n EXAMPLES::\n\n sage: Lmunu = SymmetricFunctions(FractionField(QQ['q','t'])).macdonald().Ht()._Lmunu\n sage: Lmunu(Partition([3,1]),Partition([3,1]))\n q^2 + q + t + 1\n sage: Lmunu(Partition([3,1]),Partition([2,2]))\n q*t + q + t + 1\n sage: Lmunu(Partition([3,1]),Partition([2,1,1]))\n t^2 + q + t + 1\n sage: Lmunu(Partition([2,2]),Partition([2,1,1]))\n q*t + 2*t^2 + q + t + 1\n\n "
if (not mu):
if (not nu):
return QQqt.one()
else:
return QQqt.zero()
if ((mu, nu) in self._self_to_m_cache):
return self._self_to_m_cache[(mu, nu)]
if (len(nu) == 1):
return QQqt.one()
short_nu = _Partitions(nu[:(- 1)])
if (nu[(- 1)] == 1):
self._self_to_m_cache[(mu, nu)] = QQqt(sum(((cmunu1(mu, ga) * self._Lmunu(short_nu, ga)) for ga in mu.down())))
else:
self._self_to_m_cache[(mu, nu)] = QQqt(sum(((cmunu(mu, ga) * self._Lmunu(short_nu, ga)) for ga in Partitions_n(short_nu.size()) if mu.contains(ga))))
return self._self_to_m_cache[(mu, nu)]
def _self_to_m(self, x):
"\n Takes an element of the ``Ht`` basis and returns the expansion in the\n monomial basis.\n\n INPUT:\n\n - ``x`` -- an element of ``Ht`` basis\n\n OUTPUT:\n\n - an element of the monomial basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: Ht = Sym.macdonald().Ht()\n sage: m = Sym.m()\n sage: m(Ht[2,1])\n (q*t+2*q+2*t+1)*m[1, 1, 1] + (q+t+1)*m[2, 1] + m[3]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['x']))\n sage: x = Sym.base_ring().gen()\n sage: Ht = Sym.macdonald(q=x,t=1/x).Ht()\n sage: m = Sym.m()\n sage: m(Ht[2,1])\n ((2*x^2+2*x+2)/x)*m[1, 1, 1] + ((x^2+x+1)/x)*m[2, 1] + m[3]\n\n "
part_coeff = (lambda x, d: sorted(((mu, c) for (mu, c) in x if (sum(mu) == d))))
return self._m._from_dict({part2: self._base(sum(((c * self._Lmunu(part2, mu).subs(q=self.q, t=self.t)) for (mu, c) in part_coeff(x, d)))) for d in range((x.degree() + 1)) for part2 in Partitions_n(d)})
def _m_to_self(self, f):
"\n Convert an element ``f`` from the monomial basis to the ``Ht`` basis.\n\n This calculation is performed by using the fact that\n `{\\tilde H}_\\mu[X(t-1)]` is `c_\\mu m_\\mu` plus terms which are\n smaller in dominance order. The leading coefficient of the\n expansion of ``f`` in the `{\\tilde H}_\\mu` basis is equal to\n the leading coefficient of `c_\\mu^{-1} f[X(t-1)]`.\n\n If `t=1`, we must appeal to another triangularity since ``Ht``\n is (usually) still a basis, however `{\\tilde H}_\\mu[X(t-1)]=0`.\n In this case we assume that it is a basis and `{\\tilde H}_\\mu[X(q-1)]`\n is `c_\\mu m_{\\mu'}` plus terms which are lower in dominance order.\n\n INPUT:\n\n - ``f`` -- an element of the monomial basis\n\n OUTPUT:\n\n - an element of the ``Ht`` basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: Ht = Sym.macdonald().Ht()\n sage: m = Sym.m()\n sage: Ht(m[1,1])\n (1/(-q+t))*McdHt[1, 1] - (1/(-q+t))*McdHt[2]\n sage: (q,t) = Sym.base_ring().gens()\n sage: Ht((q*t+2*q+2*t+1)*m[1, 1, 1] + (q+t+1)*m[2, 1] + m[3])\n McdHt[2, 1]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['x']))\n sage: x = Sym.base_ring().gen()\n sage: Ht = Sym.macdonald(q=x,t=1).Ht()\n sage: m = Sym.m()\n sage: Ht((3*x+3)*m[1, 1, 1] + (x+2)*m[2, 1] + m[3])\n McdHt[2, 1]\n\n "
if (self.t == 1):
subsval = self.q
fl = (lambda x: x.conjugate())
else:
subsval = self.t
fl = (lambda x: x)
g = f.omega_qt(q=subsval, t=0)
out = {}
while (not g.is_zero()):
sprt = sorted(g.support())
Htmu = self._self_to_m(self(fl(sprt[(- 1)]))).omega_qt(q=subsval, t=0)
out[fl(sprt[(- 1)])] = self._base((g.coefficient(sprt[(- 1)]) / Htmu.coefficient(sprt[(- 1)])))
g -= (out[fl(sprt[(- 1)])] * Htmu)
return self._from_dict(out)
class Element(MacdonaldPolynomials_generic.Element):
def nabla(self, q=None, t=None, power=1):
"\n Returns the value of the nabla operator applied to ``self``. The\n eigenvectors of the `nabla` operator are the Macdonald polynomials in\n the `Ht` basis. For more information see: [BGHT1999]_.\n\n The operator `nabla` acts on symmetric functions and has the\n Macdonald `Ht` basis as eigenfunctions and the eigenvalues\n are `q^{n(\\mu')} t^{n(\\mu)}` where `n(\\mu) = \\sum_{i} (i-1) \\mu_i`.\n\n If the parameter ``power`` is an integer then it calculates\n nabla to that integer. The default value of ``power`` is 1.\n\n INPUT:\n\n - ``self`` -- an element of the Macdonald `Ht` basis\n - ``q``, ``t`` -- optional parameters to specialize\n - ``power`` -- an integer (default: 1)\n\n OUTPUT:\n\n - returns the symmetric function of `\\nabla` acting on ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: Ht = Sym.macdonald().Ht()\n sage: t = Ht.t; q = Ht.q\n sage: s = Sym.schur()\n sage: a = sum(Ht(p) for p in Partitions(3))\n sage: Ht(0).nabla()\n 0\n sage: a.nabla() == t^3*Ht([1,1,1])+q*t*Ht([2,1]) + q^3*Ht([3])\n True\n sage: a.nabla(t=3) == 27*Ht([1,1,1])+3*q*Ht([2,1]) + q^3*Ht([3])\n True\n sage: a.nabla(q=3) == t^3*Ht([1,1,1])+3*t*Ht([2,1]) + 27*Ht([3])\n True\n sage: Ht[2,1].nabla(power=-1)\n 1/(q*t)*McdHt[2, 1]\n sage: Ht[2,1].nabla(power=4)\n q^4*t^4*McdHt[2, 1]\n sage: s(a.nabla(q=3))\n (t^6+27*q^3+3*q*t^2)*s[1, 1, 1] + (t^5+t^4+27*q^2+3*q*t+3*t^2+27*q)*s[2, 1] + (t^3+3*t+27)*s[3]\n sage: Ht = Sym.macdonald(q=3).Ht()\n sage: a = sum(Ht(p) for p in Partitions(3))\n sage: s(a.nabla())\n (t^6+9*t^2+729)*s[1, 1, 1] + (t^5+t^4+3*t^2+9*t+324)*s[2, 1] + (t^3+3*t+27)*s[3]\n\n "
P = self.parent()
Ht = P._macdonald.Ht()
selfHt = Ht(self)
if (self == Ht.zero()):
return Ht.zero()
if (q is None):
q = Ht.q
if (t is None):
t = Ht.t
f = (lambda part: (((t ** (part.weighted_size() * power)) * (q ** (part.conjugate().weighted_size() * power))) * Ht(part)))
return P(Ht._apply_module_morphism(selfHt, f))
|
class MacdonaldPolynomials_s(MacdonaldPolynomials_generic):
def __init__(self, macdonald):
'\n An implementation of the basis `s_\\lambda[(1-t)X/(1-q)]`\n\n This is perhaps misnamed as a \'Macdonald\' basis for\n the symmetric functions but is used in the calculation\n of the Macdonald `J` basis (see method \'creation\' below)\n but does use both of the two parameters and can be\n specialized to `s_\\lambda[(1-t)X]` and `s_\\lambda[X/(1-t)]`.\n\n INPUT:\n\n - ``self`` -- a Macdonald `S` basis\n - ``macdonald`` -- a family of Macdonald bases\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: S = Sym.macdonald().S()\n sage: TestSuite(S).run(skip=["_test_associativity","_test_distributivity","_test_prod"])\n sage: TestSuite(S).run(elements = [S.t*S[1,1]+S.q*S[2], S[1]+(S.q+S.t)*S[1,1]])\n\n '
MacdonaldPolynomials_generic.__init__(self, macdonald)
self._s = macdonald._s
self._self_to_s_cache = _S_to_s_cache
self._s_to_self_cache = _s_to_S_cache
def product(self, left, right):
"\n The multiplication of the modified Schur functions behaves the same\n as the multiplication of the Schur functions.\n\n INPUT:\n\n - ``self`` -- a Macdonald `S` basis\n - ``left``, ``right`` -- a symmetric functions\n\n OUTPUT:\n\n the product of ``left`` and ``right``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: S([2])^2 #indirect doctest\n McdS[2, 2] + McdS[3, 1] + McdS[4]\n "
s_left = self._s._from_element(left)
s_right = self._s._from_element(right)
product = (s_left * s_right)
return self._from_element(product)
def _to_s(self, part):
"\n Returns a function which gives the coefficient of a partition in\n the Schur expansion of ``self(part)``.\n these computations are completed with coefficients in fraction\n field of polynomials in `q` and `t`\n\n INPUT:\n\n - ``self`` -- a Macdonald `S` basis\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a function which accepts a partition ``part2`` and\n this function returns the coefficient of the Schur function\n indexed by ``part2`` in ``S(part)``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: S2 = S._to_s(Partition([2]))\n sage: S2(Partition([2]))\n (-q*t^2 + q*t + t - 1)/(-q^3 + q^2 + q - 1)\n sage: S2(Partition([1,1]))\n (q*t - t^2 - q + t)/(-q^3 + q^2 + q - 1)\n "
(q, t) = QQqt.gens()
p = self._sym.p()
s = self._s
p_x = p(s(part))
f = (lambda m, c: (m, (c * prod([((1 - (t ** k)) / (1 - (q ** k))) for k in m]))))
res = s(p_x.map_item(f))
f = res.coefficient
return f
def _s_cache(self, n):
"\n Compute the change of basis and its inverse between the Macdonald\n polynomials on the S basis and the Schur functions.\n\n These computations are completed with coefficients in fraction\n field of polynomials in `q` and `t`.\n\n INPUT:\n\n - ``self`` -- a Macdonald `S` basis\n - ``n`` -- a positive integer\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: S._s_cache(2)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l( S._s_to_self_cache[2] )\n [([1, 1], [([1, 1], (q^2*t - q*t - q + 1)/(t^3 - t^2 - t + 1)), ([2], (q^2 - q*t - q + t)/(t^3 - t^2 - t + 1))]), ([2], [([1, 1], (q^2 - q*t - q + t)/(t^3 - t^2 - t + 1)), ([2], (-q^2*t + q*t + q - 1)/(-t^3 + t^2 + t - 1))])]\n sage: l( S._self_to_s_cache[2] )\n [([1, 1], [([1, 1], (-q*t^2 + q*t + t - 1)/(-q^3 + q^2 + q - 1)), ([2], (q*t - t^2 - q + t)/(-q^3 + q^2 + q - 1))]), ([2], [([1, 1], (q*t - t^2 - q + t)/(-q^3 + q^2 + q - 1)), ([2], (-q*t^2 + q*t + t - 1)/(-q^3 + q^2 + q - 1))])]\n "
self._invert_morphism(n, QQqt, self._self_to_s_cache, self._s_to_self_cache, to_other_function=self._to_s)
class Element(MacdonaldPolynomials_generic.Element):
def _creation_by_determinant_helper(self, k, part):
"\n Formula from [LLM1998]_ Corollary 4.3 p. 970\n\n This is part of a formula for a column adding creation operator\n for the `J` basis and its action on the `S` basis.\n\n INPUT:\n\n - ``self`` -- an element of the Macdonald `S` basis\n - ``k`` -- a positive integer at least as big as the\n length of ``part``\n - ``part`` -- a partition\n\n OUTPUT:\n\n - returns a symmetric function which is the action of a\n column adding operator on the `J` basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: a = S([2,1])\n sage: a._creation_by_determinant_helper(2,[1])\n (q^3*t-q^2*t-q+1)*McdS[2, 1] + (q^3-q^2*t-q+t)*McdS[3]\n "
(q, t) = QQqt.gens()
from sage.combinat.sf.sf import SymmetricFunctions
S = SymmetricFunctions(QQqt).macdonald().S()
part += ([0] * (k - len(part)))
if (len(part) > k):
raise ValueError('the column to add is too small')
h = S._sym.homogeneous()
MS = MatrixSpace(h, k, k)
m = []
for i in range(k):
row = ([0] * max(0, (((i + 1) - 2) - part[i])))
for j in range(max(0, (((i + 1) - 2) - part[i])), k):
value = (((part[i] + j) - i) + 1)
p = ([value] if (value > 0) else [])
row.append(((1 - ((q ** (((part[i] + j) - i) + 1)) * (t ** (k - (j + 1))))) * h(p)))
m.append(row)
M = MS(m)
res = M.det()
res = S._s(res)
return S._from_element(res)
def _creation_by_determinant(self, k):
"\n This function is a creation operator for the `J`-basis\n for which the action is known on the Macdonald `S`-basis\n by formula from [LLM1998]_.\n\n INPUT:\n\n - ``self`` -- an element of the Macdonald `S` basis\n - ``k`` -- a positive integer\n\n OUTPUT:\n\n - returns the column adding operator on the `J` basis on ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: a = S(1)\n sage: a = a._creation_by_determinant(1); a\n (-q+1)*McdS[1]\n sage: a = a._creation_by_determinant(3)\n sage: Sym.macdonald().J()(a)\n McdJ[2, 1, 1]\n "
S = self.parent()
f = functools.partial(self._creation_by_determinant_helper, k)
return S._apply_module_morphism(self, f)
def creation(self, k):
"\n This function is a creation operator for the J-basis\n for which the action is known on the 'Macdonald' S-basis\n by formula from [LLM1998]_.\n\n INPUT:\n\n - ``self`` -- an element of the Macdonald `S` basis\n - ``k`` -- a positive integer\n\n OUTPUT:\n\n - returns the column adding operator on the `J` basis on ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: a = S(1)\n sage: a.creation(1)\n (-q+1)*McdS[1]\n sage: a.creation(2)\n (q^2*t-q*t-q+1)*McdS[1, 1] + (q^2-q*t-q+t)*McdS[2]\n "
return self._creation_by_determinant(k)
def _omega_qt_in_schurs(self):
"\n Returns the image of self under the omega_qt automorphism in the\n Schur basis.\n\n INPUT:\n\n - ``self`` -- an element of the Macdonald `S` basis\n\n OUTPUT:\n\n - the action of the `\\omega_{qt}` operator changes the\n Macdonald `S` basis indexed by the partition `\\mu` to\n the Schur indexed by the conjugate of `\\mu`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: a = S([2,1]) + S([1,1,1])\n sage: a._omega_qt_in_schurs()\n s[2, 1] + s[3]\n "
S = self.parent()
f = (lambda part: S._s(part.conjugate()))
return S._s._apply_module_morphism(self, f)
|
def qt_kostka(lam, mu):
'\n Returns the `K_{\\lambda\\mu}(q,t)` by computing the change\n of basis from the Macdonald H basis to the Schurs.\n\n INPUT:\n\n - ``lam``, ``mu`` -- partitions of the same size\n\n OUTPUT:\n\n - returns the `q,t`-Kostka polynomial indexed by the\n partitions ``lam`` and ``mu``\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.macdonald import qt_kostka\n sage: qt_kostka([2,1,1],[1,1,1,1])\n t^3 + t^2 + t\n sage: qt_kostka([1,1,1,1],[2,1,1])\n q\n sage: qt_kostka([1,1,1,1],[3,1])\n q^3\n sage: qt_kostka([1,1,1,1],[1,1,1,1])\n 1\n sage: qt_kostka([2,1,1],[2,2])\n q^2*t + q*t + q\n sage: qt_kostka([2,2],[2,2])\n q^2*t^2 + 1\n sage: qt_kostka([4],[3,1])\n t\n sage: qt_kostka([2,2],[3,1])\n q^2*t + q\n sage: qt_kostka([3,1],[2,1,1])\n q*t^3 + t^2 + t\n sage: qt_kostka([2,1,1],[2,1,1])\n q*t^2 + q*t + 1\n sage: qt_kostka([2,1],[1,1,1,1])\n 0\n '
lam = _Partitions(lam)
mu = _Partitions(mu)
if (lam.size() != mu.size()):
return QQqt.zero()
if ((lam, mu) in _qt_kostka_cache):
return _qt_kostka_cache[(lam, mu)]
from sage.combinat.sf.sf import SymmetricFunctions
Sym = SymmetricFunctions(QQqt)
H = Sym.macdonald().H()
s = Sym.schur()
parts = Partitions_n(mu.size())
for p2 in parts:
res = s(H(p2))
for p1 in parts:
_qt_kostka_cache[(p1, p2)] = QQqt(res.coefficient(p1).numerator())
return _qt_kostka_cache[(lam, mu)]
|
class SymmetricFunctionAlgebra_monomial(classical.SymmetricFunctionAlgebra_classical):
def __init__(self, Sym):
"\n A class for methods related to monomial symmetric functions\n\n INPUT:\n\n - ``self`` -- a monomial symmetric function basis\n - ``Sym`` -- an instance of the ring of the symmetric functions\n\n TESTS::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: m == loads(dumps(m))\n True\n sage: TestSuite(m).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])\n sage: TestSuite(m).run(elements = [m[1,1]+m[2], m[1]+2*m[1,1]])\n "
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, 'monomial', 'm')
def _dual_basis_default(self):
'\n Return the default dual basis to ``self`` when no scalar product is specified\n\n This method returns the dual basis of the monomial basis with\n respect to the standard scalar product, which is the\n homogeneous basis.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: h = SymmetricFunctions(QQ).h()\n sage: m.dual_basis() == h\n True\n\n TESTS::\n\n sage: m._dual_basis_default() is m.dual_basis()\n True\n sage: zee = lambda x : x.centralizer_size()\n sage: dm = m.dual_basis(zee)\n sage: dm[3,1].scalar(m[2,1,1])\n 0\n sage: m[2,1,1].scalar(dm[3,1])\n 0\n '
return self.realization_of().h()
def product(self, left, right):
"\n Return the product of ``left`` and ``right``.\n\n - ``left``, ``right`` -- symmetric functions written in the\n monomial basis ``self``.\n\n OUTPUT:\n\n - the product of ``left`` and ``right``, expanded in the\n monomial basis, as a dictionary whose keys are partitions and\n whose values are the coefficients of these partitions (more\n precisely, their respective monomial symmetric functions) in the\n product.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: a = m([2,1])\n sage: a^2\n 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2]\n\n ::\n\n sage: QQx.<x> = QQ['x']\n sage: m = SymmetricFunctions(QQx).m()\n sage: a = m([2,1])+x\n sage: 2*a # indirect doctest\n 2*x*m[] + 2*m[2, 1]\n sage: a^2\n x^2*m[] + 2*x*m[2, 1] + 4*m[2, 2, 1, 1] + 6*m[2, 2, 2] + 2*m[3, 2, 1] + 2*m[3, 3] + 2*m[4, 1, 1] + m[4, 2]\n "
z_elt = {}
for (left_m, left_c) in left._monomial_coefficients.items():
for (right_m, right_c) in right._monomial_coefficients.items():
if ((not left_m) and (not right_m)):
z_elt[left_m] = (left_c * right_c)
continue
d = symmetrica.mult_monomial_monomial({left_m: Integer(1)}, {right_m: Integer(1)}).monomial_coefficients()
for m in d:
if (m in z_elt):
z_elt[m] += ((left_c * right_c) * d[m])
else:
z_elt[m] = ((left_c * right_c) * d[m])
return self._from_dict(z_elt)
def from_polynomial(self, f, check=True):
"\n Return the symmetric function in the monomial basis corresponding to the polynomial ``f``.\n\n INPUT:\n\n - ``self`` -- a monomial symmetric function basis\n - ``f`` -- a polynomial in finitely many variables over the same base ring as ``self``.\n It is assumed that this polynomial is symmetric.\n - ``check`` -- boolean (default: ``True``), checks whether the polynomial is indeed symmetric\n\n OUTPUT:\n\n - This function converts a symmetric polynomial `f` in a polynomial ring in finitely\n many variables to a symmetric function in the monomial\n basis of the ring of symmetric functions over the same base ring.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: P = PolynomialRing(QQ, 'x', 3)\n sage: x = P.gens()\n sage: f = x[0] + x[1] + x[2]\n sage: m.from_polynomial(f)\n m[1]\n sage: f = x[0]**2+x[1]**2+x[2]**2\n sage: m.from_polynomial(f)\n m[2]\n sage: f = x[0]^2+x[1]\n sage: m.from_polynomial(f)\n Traceback (most recent call last):\n ...\n ValueError: x0^2 + x1 is not a symmetric polynomial\n sage: f = (m[2,1]+m[1,1]).expand(3)\n sage: m.from_polynomial(f)\n m[1, 1] + m[2, 1]\n sage: f = (2*m[2,1]+m[1,1]+3*m[3]).expand(3)\n sage: m.from_polynomial(f)\n m[1, 1] + 2*m[2, 1] + 3*m[3]\n "
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._from_dict({_Partitions.element_class(_Partitions, list(e)): c for (e, c) in f.dict().items() if all(((e[(i + 1)] <= e[i]) for i in range((len(e) - 1))))}, remove_zeros=False)
return out
def from_polynomial_exp(self, p):
"\n Conversion from polynomial in exponential notation\n\n INPUT:\n\n - ``self`` -- a monomial symmetric function basis\n - ``p`` -- a polynomial over the same base ring as ``self``\n\n OUTPUT:\n\n - This returns a symmetric function by mapping each monomial of\n `p` with exponents ``exp`` into `m_\\lambda` where `\\lambda` is\n the partition with exponential notation ``exp``.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: P = PolynomialRing(QQ,'x',5)\n sage: x = P.gens()\n\n The exponential notation of the partition `(5,5,5,3,1,1)` is::\n\n sage: Partition([5,5,5,3,1,1]).to_exp()\n [2, 0, 1, 0, 3]\n\n Therefore, the monomial::\n\n sage: f = x[0]^2 * x[2] * x[4]^3\n\n is mapped to::\n\n sage: m.from_polynomial_exp(f)\n m[5, 5, 5, 3, 1, 1]\n\n Furthermore, this function is linear::\n\n sage: f = 3 * x[3] + 2 * x[0]^2 * x[2] * x[4]^3\n sage: m.from_polynomial_exp(f)\n 3*m[4] + 2*m[5, 5, 5, 3, 1, 1]\n\n .. SEEALSO::\n\n :func:`Partition`, :meth:`Partition.to_exp`\n "
assert (self.base_ring() == p.parent().base_ring())
from sage.combinat.sf.sfa import _from_polynomial
return _from_polynomial(p, self)
def antipode_by_coercion(self, element):
'\n The antipode of ``element`` via coercion to and from the power-sum\n basis or the Schur basis (depending on whether the power sums really\n form a basis over the given ground ring).\n\n INPUT:\n\n - ``element`` -- element in a basis of the ring of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.monomial()\n sage: m[3,2].antipode()\n m[3, 2] + 2*m[5]\n sage: m.antipode_by_coercion(m[3,2])\n m[3, 2] + 2*m[5]\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: m = Sym.monomial()\n sage: m[3,2].antipode()\n m[3, 2] + 2*m[5]\n sage: m.antipode_by_coercion(m[3,2])\n m[3, 2] + 2*m[5]\n\n .. TODO::\n\n Is there a not too difficult way to get the power-sum computations\n to work over any ring, not just one with coercion from `\\QQ`?\n '
from sage.rings.rational_field import RationalField
if self.has_coerce_map_from(RationalField()):
p = self.realization_of().powersum()
return self(p.antipode(p(element)))
s = self.realization_of().schur()
return self(s.antipode(s(element)))
class Element(classical.SymmetricFunctionAlgebra_classical.Element):
def expand(self, n, alphabet='x'):
"\n Expand the symmetric function ``self`` as a symmetric polynomial\n in ``n`` variables.\n\n INPUT:\n\n - ``n`` -- a nonnegative integer\n\n - ``alphabet`` -- (default: ``'x'``) a variable for the expansion\n\n OUTPUT:\n\n A monomial expansion of ``self`` in the `n` variables\n labelled by ``alphabet``.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: m([2,1]).expand(3)\n x0^2*x1 + x0*x1^2 + x0^2*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2\n sage: m([1,1,1]).expand(2)\n 0\n sage: m([2,1]).expand(3,alphabet='z')\n z0^2*z1 + z0*z1^2 + z0^2*z2 + z1^2*z2 + z0*z2^2 + z1*z2^2\n sage: m([2,1]).expand(3,alphabet='x,y,z')\n x^2*y + x*y^2 + x^2*z + y^2*z + x*z^2 + y*z^2\n sage: m([1]).expand(0)\n 0\n sage: (3*m([])).expand(0)\n 3\n "
def condition(part):
return (len(part) > n)
return self._expand(condition, n, alphabet)
def principal_specialization(self, n=infinity, q=None):
'\n Return the principal specialization of a symmetric function.\n\n The *principal specialization* of order `n` at `q`\n is the ring homomorphism `ps_{n,q}` from the ring of\n symmetric functions to another commutative ring `R`\n given by `x_i \\mapsto q^{i-1}` for `i \\in \\{1,\\dots,n\\}`\n and `x_i \\mapsto 0` for `i > n`.\n Here, `q` is a given element of `R`, and we assume that\n the variables of our symmetric functions are\n `x_1, x_2, x_3, \\ldots`.\n (To be more precise, `ps_{n,q}` is a `K`-algebra\n homomorphism, where `K` is the base ring.)\n See Section 7.8 of [EnumComb2]_.\n\n The *stable principal specialization* at `q` is the ring\n homomorphism `ps_q` from the ring of symmetric functions\n to another commutative ring `R` given by\n `x_i \\mapsto q^{i-1}` for all `i`.\n This is well-defined only if the resulting infinite sums\n converge; thus, in particular, setting `q = 1` in the\n stable principal specialization is an invalid operation.\n\n INPUT:\n\n - ``n`` (default: ``infinity``) -- a nonnegative integer or\n ``infinity``, specifying whether to compute the principal\n specialization of order ``n`` or the stable principal\n specialization.\n\n - ``q`` (default: ``None``) -- the value to use for `q`; the\n default is to create a ring of polynomials in ``q``\n (or a field of rational functions in ``q``) over the\n given coefficient ring.\n\n For ``q=1`` and finite ``n`` we use the formula from\n Proposition 7.8.3 of [EnumComb2]_:\n\n .. MATH::\n\n ps_{n,1}(m_\\lambda) = \\binom{n}{\\ell(\\lambda)}\n \\binom{\\ell(\\lambda)}{m_1(\\lambda), m_2(\\lambda),\\dots},\n\n where `\\ell(\\lambda)` denotes the length of `\\lambda`.\n\n In all other cases, we convert to complete homogeneous\n symmetric functions.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: x = m[3,1]\n sage: x.principal_specialization(3)\n q^7 + q^6 + q^5 + q^3 + q^2 + q\n\n sage: x = 5*m[2] + 3*m[1] + 1\n sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic\n -10*(q^3 - 1)*q/(q - 1) + 5*(q^3 - 1)^2/(q - 1)^2 + 3*(q^3 - 1)/(q - 1) + 1\n\n TESTS::\n\n sage: m.zero().principal_specialization(3)\n 0\n\n '
if (q == 1):
if (n == infinity):
raise ValueError('the stable principal specialization at q=1 is not defined')
f = (lambda partition: (binomial(n, len(partition)) * multinomial(partition.to_exp())))
return self.parent()._apply_module_morphism(self, f, q.parent())
return self.parent().realization_of().elementary()(self).principal_specialization(n=n, q=q)
def exponential_specialization(self, t=None, q=1):
'\n Return the exponential specialization of a\n symmetric function (when `q = 1`), or the\n `q`-exponential specialization (when `q \\neq 1`).\n\n The *exponential specialization* `ex` at `t` is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R`.\n It is defined whenever the base ring `K` is a\n `\\QQ`-algebra and `t` is an element of `R`.\n The easiest way to define it is by specifying its\n values on the powersum symmetric functions to be\n `p_1 = t` and `p_n = 0` for `n > 1`.\n Equivalently, on the homogeneous functions it is\n given by `ex(h_n) = t^n / n!`; see Proposition 7.8.4 of\n [EnumComb2]_.\n\n By analogy, the `q`-exponential specialization is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R` that\n depends on two elements `t` and `q` of `R` for which\n the elements `1 - q^i` for all positive integers `i`\n are invertible.\n It can be defined by specifying its values on the\n complete homogeneous symmetric functions to be\n\n .. MATH::\n\n ex_q(h_n) = t^n / [n]_q!,\n\n where `[n]_q!` is the `q`-factorial. Equivalently, for\n `q \\neq 1` and a homogeneous symmetric function `f` of\n degree `n`, we have\n\n .. MATH::\n\n ex_q(f) = (1-q)^n t^n ps_q(f),\n\n where `ps_q(f)` is the stable principal specialization of `f`\n (see :meth:`principal_specialization`).\n (See (7.29) in [EnumComb2]_.)\n\n The limit of `ex_q` as `q \\to 1` is `ex`.\n\n INPUT:\n\n - ``t`` (default: ``None``) -- the value to use for `t`;\n the default is to create a ring of polynomials in ``t``.\n\n - ``q`` (default: `1`) -- the value to use for `q`. If\n ``q`` is ``None``, then a ring (or fraction field) of\n polynomials in ``q`` is created.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: (m[3]+m[2,1]+m[1,1,1]).exponential_specialization()\n 1/6*t^3\n\n sage: x = 5*m[1,1,1] + 3*m[2,1] + 1\n sage: x.exponential_specialization()\n 5/6*t^3 + 1\n\n We also support the `q`-exponential_specialization::\n\n sage: factor(m[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic\n (q - 1)^2*t^3/(q^2 + q + 1)\n\n TESTS::\n\n sage: m.zero().exponential_specialization()\n 0\n\n '
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q == 1):
if (t is None):
t = get_variable(self.base_ring(), 't')
def f(partition):
n = 0
for part in partition:
if (part != 1):
return 0
n += 1
return ((t ** n) / factorial(n))
return self.parent()._apply_module_morphism(self, f, t.parent())
return self.parent().realization_of().elementary()(self).exponential_specialization(t=t, q=q)
|
class SymmetricFunctionAlgebra_multiplicative(classical.SymmetricFunctionAlgebra_classical):
'\n The class of multiplicative bases of the ring of symmetric functions.\n\n A realization `q` of the ring of symmetric functions is multiplicative if\n for a partition `\\lambda = (\\lambda_1,\\lambda_2,\\ldots)` we have\n `q_\\lambda = q_{\\lambda_1} q_{\\lambda_2} \\cdots` (with `q_0` meaning `1`).\n\n Examples of multiplicative realizations are the elementary symmetric basis,\n the complete homogeneous basis, the powersum basis (if the base ring is a\n `\\QQ`-algebra), and the Witt basis (but not the Schur basis or the\n monomial basis).\n '
def product_on_basis(self, left, right):
'\n Return the product of ``left`` and ``right``.\n\n INPUT:\n\n - ``left``, ``right`` -- partitions\n\n OUTPUT:\n\n - an element of ``self``\n\n EXAMPLES::\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: e([2,1])^2 # indirect doctest\n e[2, 2, 1, 1]\n\n ::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: h([2,1])^2\n h[2, 2, 1, 1]\n\n ::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p([2,1])^2\n p[2, 2, 1, 1]\n\n ::\n\n sage: QQx.<x> = QQ[]\n sage: p = SymmetricFunctions(QQx).p()\n sage: (x*p([2]))^2\n x^2*p[2, 2]\n\n sage: TestSuite(p).run() # to silence sage -coverage\n '
m = (list(left) + list(right))
m.sort(reverse=True)
return self.monomial(sage.combinat.partition.Partition(m))
def coproduct_on_basis(self, mu):
'\n Return the coproduct on a basis element for multiplicative bases.\n\n INPUT:\n\n - ``mu`` -- a partition\n\n OUTPUT:\n\n - the image of ``self[mu]`` under comultiplication; this is an\n element of the tensor square of ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.powersum()\n sage: p.coproduct_on_basis([2,1])\n p[] # p[2, 1] + p[1] # p[2] + p[2] # p[1] + p[2, 1] # p[]\n\n sage: e = Sym.elementary()\n sage: e.coproduct_on_basis([3,1])\n e[] # e[3, 1] + e[1] # e[2, 1] + e[1] # e[3] + e[1, 1] # e[2] + e[2] # e[1, 1] + e[2, 1] # e[1] + e[3] # e[1] + e[3, 1] # e[]\n\n sage: h = Sym.homogeneous()\n sage: h.coproduct_on_basis([3,1])\n h[] # h[3, 1] + h[1] # h[2, 1] + h[1] # h[3] + h[1, 1] # h[2] + h[2] # h[1, 1] + h[2, 1] # h[1] + h[3] # h[1] + h[3, 1] # h[]\n '
T = self.tensor_square()
return T.prod((self.coproduct_on_generators(p) for p in mu))
|
class KBoundedSubspace(UniqueRepresentation, Parent):
"\n This class implements the subspace of the ring of symmetric functions spanned by\n `\\{ s_{\\lambda}[X/(1-t)] \\}_{\\lambda_1\\le k} = \\{ s_{\\lambda}^{(k)}[X;t]\\}_{\\lambda_1 \\le k}`\n over the base ring `\\QQ[t]`. When `t=1`, this space is in fact a subring of\n the ring of symmetric functions generated by the complete homogeneous symmetric functions\n `h_i` for `1\\le i \\le k`.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: KB = Sym.kBoundedSubspace(3,1); KB\n 3-bounded Symmetric Functions over Rational Field with t=1\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: KB = Sym.kBoundedSubspace(3); KB\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n\n The `k`-Schur function basis can be constructed as follows::\n\n sage: ks = KB.kschur(); ks\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis\n "
def __init__(self, Sym, k, t='t'):
'\n The class modeling the abstract vector space of `k`-Schur\n functions.\n\n If `t=1` this is actually an abstract ring. Another\n way to describe this space is as the subspace of a ring of\n symmetric functions generated by the complete homogeneous\n symmetric functions `h_i` for `1\\le i \\le k`.\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: from sage.combinat.sf.new_kschur import KBoundedSubspace\n sage: L3 = KBoundedSubspace(Sym,3,1)\n sage: TestSuite(L3).run(skip=["_test_not_implemented_methods"])\n sage: Sym.kBoundedSubspace(0,1)\n Traceback (most recent call last):\n ...\n ValueError: k must be a positive integer\n\n sage: Sym = SymmetricFunctions(QQ[\'t\'])\n sage: TestSuite(Sym.kBoundedSubspace(1)).run(skip=["_test_not_implemented_methods"])\n '
if ((not isinstance(k, (int, Integer))) or (k < 1)):
raise ValueError('k must be a positive integer')
if (not isinstance(Sym, SymmetricFunctions)):
raise ValueError('Sym must be an algebra of symmetric functions')
self.indices = ConstantFunction(Partitions_all_bounded(k))
R = Sym.base_ring()
self.base_ring = ConstantFunction(R)
self.ambient = ConstantFunction(Sym)
self.k = k
self.t = R(t)
category = (GradedHopfAlgebras(R) if (t == 1) else GradedCoalgebras(R))
Parent.__init__(self, category=category.Subobjects().WithRealizations())
ks = self.kschur()
if (t == 1):
s = ks.ambient()
kh = self.khomogeneous()
h = kh.ambient()
h_to_s = s._internal_coerce_map_from(h)
kh_to_ks = ((ks.retract * h_to_s) * kh.lift)
ks.register_coercion(kh_to_ks)
s_to_h = h._internal_coerce_map_from(s)
ks_to_kh = ((kh.retract * s_to_h) * ks.lift)
kh.register_coercion(ks_to_kh)
self.one = ConstantFunction(ks.one())
self.zero = ConstantFunction(ks.zero())
def retract(self, sym):
'\n Return the retract of ``sym`` from the ring of symmetric functions to ``self``.\n\n INPUT:\n\n - ``sym`` -- a symmetric function\n\n OUTPUT:\n\n - the analogue of the symmetric function in the `k`-bounded\n subspace (if possible)\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: KB = Sym.kBoundedSubspace(3,1); KB\n 3-bounded Symmetric Functions over Rational Field with t=1\n sage: KB.retract(s[2]+s[3])\n ks3[2] + ks3[3]\n sage: KB.retract(s[2,1,1])\n Traceback (most recent call last):\n ...\n ValueError: s[2, 1, 1] is not in the image\n '
s = self.ambient().schur()
ks = self.kschur()
return ks.retract(s(sym))
def realizations(self):
"\n A list of realizations of this algebra.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).kBoundedSubspace(3,1).realizations()\n [3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis,\n 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-split basis,\n 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-bounded homogeneous basis,\n 3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis]\n sage: SymmetricFunctions(QQ['t']).kBoundedSubspace(3).realizations()\n [3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis,\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-split basis]\n "
if (self.t == 1):
return [self.kschur(), self.ksplit(), self.khomogeneous(), self.K_kschur()]
else:
return [self.kschur(), self.ksplit()]
def kschur(self):
'\n The `k`-Schur basis of this algebra.\n\n .. SEEALSO:: :meth:`kSchur`\n\n EXAMPLES::\n\n sage: ks3 = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur()\n sage: TestSuite(ks3).run()\n '
return kSchur(self)
def ksplit(self):
'\n The `k`-split basis of this algebra.\n\n .. SEEALSO:: :meth:`kSplit`\n\n EXAMPLES::\n\n sage: ksp3 = SymmetricFunctions(QQ).kBoundedSubspace(3,1).ksplit()\n sage: TestSuite(ksp3).run()\n '
return kSplit(self)
def khomogeneous(self):
'\n The homogeneous basis of this algebra.\n\n .. SEEALSO:: :meth:`kHomogeneous`\n\n EXAMPLES::\n\n sage: kh3 = SymmetricFunctions(QQ).kBoundedSubspace(3,1).khomogeneous()\n sage: TestSuite(kh3).run()\n '
if (self.t != 1):
raise ValueError('This basis only exists for t=1')
return kHomogeneous(self)
def K_kschur(self):
"\n Return the `k`-bounded basis called the K-`k`-Schur basis.\n\n See [Morse11]_ and [LamSchillingShimozono10]_.\n\n REFERENCES:\n\n .. [Morse11] \\J. Morse, Combinatorics of the K-theory of affine Grassmannians,\n Adv. in Math., Volume 229, Issue 5, pp. 2950--2984.\n\n .. [LamSchillingShimozono10] \\T. Lam, A. Schilling, M.Shimozono, K-theory Schubert calculus of the affine Grassmannian,\n Compositio Math. 146 (2010), 811-852.\n\n\n EXAMPLES::\n\n sage: kB = SymmetricFunctions(QQ).kBoundedSubspace(3,1)\n sage: g = kB.K_kschur()\n sage: g\n 3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis\n sage: kB = SymmetricFunctions(QQ['t']).kBoundedSubspace(3)\n sage: g = kB.K_kschur()\n Traceback (most recent call last):\n ...\n ValueError: This basis only exists for t=1\n "
if (self.t != 1):
raise ValueError('This basis only exists for t=1')
return K_kSchur(self)
def _repr_(self):
"\n Representation of this algebra.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).kBoundedSubspace(3,1) # indirect doctest\n 3-bounded Symmetric Functions over Rational Field with t=1\n\n sage: SymmetricFunctions(QQ['t']).kBoundedSubspace(3)\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n "
ending = ''
if (str(self.t) != 't'):
ending = (' with t=%s' % self.t)
return (('%s-bounded %s' % (self.k, self.ambient())) + ending)
|
class KBoundedSubspaceBases(Category_realization_of_parent):
'\n The category of bases for the `k`-bounded subspace of symmetric functions.\n '
def __init__(self, base, t='t'):
"\n Initialization of the bases of the `k`-bounded subspace\n\n INPUT:\n\n - ``base`` -- a basis in the `k`-bounded subspace\n - ``t`` -- a parameter (default: 't')\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: from sage.combinat.sf.new_kschur import KBoundedSubspaceBases\n sage: KB = Sym.kBoundedSubspace(3)\n sage: KBB = KBoundedSubspaceBases(KB); KBB\n Category of k bounded subspace bases of 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n "
self.t = t
Category_realization_of_parent.__init__(self, base)
def super_categories(self):
"\n The super categories of ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: from sage.combinat.sf.new_kschur import KBoundedSubspaceBases\n sage: KB = Sym.kBoundedSubspace(3)\n sage: KBB = KBoundedSubspaceBases(KB); KBB\n Category of k bounded subspace bases of 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n sage: KBB.super_categories()\n [Category of realizations of 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field,\n Join of Category of graded coalgebras with basis over Univariate Polynomial Ring in t over Rational Field\n and Category of subobjects of filtered modules with basis over Univariate Polynomial Ring in t over Rational Field]\n "
R = self.base().base_ring()
category = (GradedHopfAlgebrasWithBasis(R) if (self.t == 1) else GradedCoalgebrasWithBasis(R))
return [Realizations(self.base()), category.Subobjects()]
class ParentMethods():
def _element_constructor_(self, x):
'\n Needed to rewrite the element constructor because of a bug in free_module.py.\n Ideally _element_constructor_ would be inherited from free_module.py, but\n it allows for bad inputs.\n\n EXAMPLES::\n\n sage: kB = SymmetricFunctions(QQ).kBoundedSubspace(3,1)\n sage: ks = kB.kschur()\n sage: ks([2,1])\n ks3[2, 1]\n sage: ks([4,1])\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis)\n sage: ks(Partition([4,1]))\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis)\n '
R = self.base_ring()
if isinstance(x, int):
x = Integer(x)
if (x in R):
if (x == 0):
return self.zero()
else:
raise TypeError(('do not know how to make x (= %s) an element of %s' % (x, self)))
elif (x in self._indices):
return self.monomial(self._indices(x))
raise TypeError(('do not know how to make x (= %s) an element of self (=%s)' % (x, self)))
def _convert_map_from_(self, Q):
'\n Implement conversion from an arbitrary parent to ``self``.\n\n This is done by first coercing to the appropriate lift basis.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: e = Sym.elementary(); ks3 = Sym.kschur(3,1)\n sage: ks3(e[3, 2]) # indirect doctest\n ks3[1, 1, 1, 1, 1]\n '
P = self.lift.codomain()
if P.has_coerce_map_from(Q):
return (self.retract * P._internal_coerce_map_from(Q))
return None
def __getitem__(self, c):
'\n Implement shorthand for accessing basis elements.\n\n For a basis `X` indexed by partitions, this method allows for\n `X[[3,2]]` and `X[3,2]` to be equivalent to `X[Partition([3,2])]`.\n\n Due to limitations in Python syntax, one must use `X[[]]` and not\n `X[]` for the basis element indexed by the empty partition.\n\n EXAMPLES::\n\n sage: ks3 = SymmetricFunctions(QQ).kschur(3,1)\n sage: ks3[3,2]\n ks3[3, 2]\n sage: ks3[[]]\n ks3[]\n\n TESTS::\n\n sage: ks3 = SymmetricFunctions(QQ).kschur(3,1)\n sage: ks3[4,1]\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make [4, 1] an element of 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis\n sage: ks3[Partition([4,1])]\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make [4, 1] an element of 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis\n '
if (not isinstance(c, Partition)):
if (c in ZZ):
c = Partition([c])
else:
c = Partition(c)
if (c not in self._indices):
raise TypeError(('do not know how to make %s an element of %s' % (c, self)))
return self.monomial(c)
def _repr_term(self, c):
'\n Display elements with single brackets.\n\n The default implementation of CombinatorialFreeModule gives double\n brackets for basis elements indexed by partitions, i.e.,\n `X[[3,2]]`.\n\n EXAMPLES::\n\n sage: ks3 = SymmetricFunctions(QQ).kschur(3,1)\n sage: ks3[3,2] # indirect doctest\n ks3[3, 2]\n '
return (self.prefix() + str(c))
@cached_method
def one_basis(self):
'\n Return the basis element indexing ``1``.\n\n EXAMPLES::\n\n sage: ks3 = SymmetricFunctions(QQ).kschur(3,1)\n sage: ks3.one() # indirect doctest\n ks3[]\n '
return Partition([])
def transition_matrix(self, other, n):
"\n Return the degree ``n`` transition matrix between ``self`` and ``other``.\n\n INPUT:\n\n - ``other`` -- a basis in the ring of symmetric functions\n - ``n`` -- a positive integer\n\n The entry in the `i^{th}` row and `j^{th}` column is the\n coefficient obtained by writing the `i^{th}` element of the\n basis of ``self`` in terms of the basis ``other``, and extracting the\n `j^{th}` coefficient.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ); s = Sym.schur()\n sage: ks3 = Sym.kschur(3,1)\n sage: ks3.transition_matrix(s,5)\n [1 1 1 0 0 0 0]\n [0 1 0 1 0 0 0]\n [0 0 1 0 1 0 0]\n [0 0 0 1 0 1 0]\n [0 0 0 0 1 1 1]\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: s = Sym.schur()\n sage: ks = Sym.kschur(3)\n sage: ks.transition_matrix(s,5)\n [t^2 t 1 0 0 0 0]\n [ 0 t 0 1 0 0 0]\n [ 0 0 t 0 1 0 0]\n [ 0 0 0 t 0 1 0]\n [ 0 0 0 0 t^2 t 1]\n "
P = Partitions(n, max_part=self.k)
Q = Partitions(n)
return matrix([[other(self[row]).coefficient(col) for col in Q] for row in P])
def an_element(self):
"\n Return an element of ``self``.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ['t']).kschur(3).an_element()\n 2*ks3[] + 2*ks3[1] + 3*ks3[2]\n "
return self(Partition(srange(self.k, 0, (- 1))))
def degree_on_basis(self, b):
'\n Return the degree of the basis element indexed by `b`.\n\n INPUT:\n\n - ``b`` -- a partition\n\n EXAMPLES::\n\n sage: ks3 = SymmetricFunctions(QQ).kschur(3,1)\n sage: ks3.degree_on_basis(Partition([3,2]))\n 5\n '
return sum(b)
def coproduct(self, element):
"\n Return the coproduct operation on ``element``.\n\n The coproduct is first computed on the homogeneous basis if `t=1`\n and on the Hall-Littlewood ``Qp`` basis otherwise. The result is\n computed then converted to the tensor squared of ``self.parent()``.\n\n INPUT:\n\n - ``element`` -- an element in a basis of the ring of symmetric\n functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks3 = Sym.kschur(3,1)\n sage: ks3[2,1].coproduct()\n ks3[] # ks3[2, 1] + ks3[1] # ks3[1, 1] + ks3[1] # ks3[2] + ks3[1, 1] # ks3[1] + ks3[2] # ks3[1] + ks3[2, 1] # ks3[]\n sage: h3 = Sym.khomogeneous(3)\n sage: h3[2,1].coproduct()\n h3[] # h3[2, 1] + h3[1] # h3[1, 1] + h3[1] # h3[2] + h3[1, 1] # h3[1] + h3[2] # h3[1] + h3[2, 1] # h3[]\n sage: ks3t = SymmetricFunctions(FractionField(QQ['t'])).kschur(3)\n sage: ks3t[2,1].coproduct()\n ks3[] # ks3[2, 1] + ks3[1] # ks3[1, 1] + ks3[1] # ks3[2] + ks3[1, 1] # ks3[1] + ks3[2] # ks3[1] + ks3[2, 1] # ks3[]\n sage: ks3t[3,1].coproduct()\n ks3[] # ks3[3, 1] + ks3[1] # ks3[2, 1] + (t+1)*ks3[1] # ks3[3] + ks3[1, 1] # ks3[2] + ks3[2] # ks3[1, 1]\n + (t+1)*ks3[2] # ks3[2] + ks3[2, 1] # ks3[1] + (t+1)*ks3[3] # ks3[1] + ks3[3, 1] # ks3[]\n sage: h3.coproduct(h3[2,1])\n h3[] # h3[2, 1] + h3[1] # h3[1, 1] + h3[1] # h3[2] + h3[1, 1] # h3[1] + h3[2] # h3[1] + h3[2, 1] # h3[]\n "
lifted = element.lift()
ambient = self.realization_of().ambient()
t = self.realization_of().t
if (t == 1):
source_basis = ambient.h()
else:
source_basis = ambient.hall_littlewood(t=t).Qp()
def cpfunc(x, y):
return tensor([self(x), self(y)])
return source_basis(lifted).coproduct().apply_multilinear_morphism(cpfunc)
def antipode(self, element):
'\n Return the antipode on ``self`` by lifting to the space of\n symmetric functions, computing the antipode, and then converting\n to ``self.parent()``. This is only the antipode for `t = 1` and\n for other values of `t` the result may not be in the space where\n the `k`-Schur functions live.\n\n INPUT:\n\n - ``element`` -- an element in a basis of the ring of symmetric\n functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks3 = Sym.kschur(3,1)\n sage: ks3[3,2].antipode()\n -ks3[1, 1, 1, 1, 1]\n sage: ks3.antipode(ks3[3,2])\n -ks3[1, 1, 1, 1, 1]\n '
return self(element.lift().antipode())
def counit(self, element):
'\n Return the counit of ``element``.\n\n The counit is the constant term of ``element``.\n\n INPUT:\n\n - ``element`` -- an element in a basis of the ring of symmetric\n functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks3 = Sym.kschur(3,1)\n sage: f = 2*ks3[2,1] + 3*ks3[[]]\n sage: f.counit()\n 3\n sage: ks3.counit(f)\n 3\n '
return element.coefficient([])
class ElementMethods():
def _mul_(self, other):
"\n Return the product of two elements ``self`` and ``other``.\n\n When `t=1`, the `k`-bounded subspace is an algebra, so the\n product of two elements is always in the space. For generic\n `t`, the `k`-bounded subspace is not closed under\n multiplication, so the result is returned in the `k`-bounded\n subspace if possible and else in the ring of symmetric\n functions.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks = Sym.kschur(3)\n sage: ks[2]*ks[2] # indirect doctest\n s[2, 2] + s[3, 1] + s[4]\n sage: f = ks[2]*ks[3,1]; f\n s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + (t+1)*s[4, 2] + (t+1)*s[5, 1] + t*s[6]\n sage: f.parent()\n Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the Schur basis\n sage: ks(f)\n Traceback (most recent call last):\n ...\n ValueError: s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + (t+1)*s[4, 2] + (t+1)*s[5, 1] + t*s[6] is not in the image\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(3,1)\n sage: f = ks[2]*ks[3,1]; f\n ks3[3, 2, 1] + ks3[3, 3]\n sage: f.parent()\n 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: ks2 = Sym.kschur(2)\n sage: ks3 = Sym.kschur(3)\n sage: ks5 = Sym.kschur(5)\n sage: ks5(ks3[2]) * ks5(ks2[2,1])\n ks5[2, 2, 1] + ks5[3, 1, 1] + (t+1)*ks5[3, 2] + (t+1)*ks5[4, 1] + t*ks5[5]\n\n sage: ks3([1]) * ks3([1]) # indirect doctest\n ks3[1, 1] + ks3[2]\n sage: ks3([2,1]) * ks3([2,1])\n s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] +\n s[3, 3] + s[4, 1, 1] + s[4, 2]\n sage: ks3 = SymmetricFunctions(QQ).kschur(3, t=1)\n sage: ks3([2,1])^2\n ks3[2, 2, 1, 1] + ks3[2, 2, 2] + ks3[3, 1, 1, 1]\n "
if (self.parent().realization_of().t == 1):
return self.parent()((self.lift() * other.lift()))
result = (self.lift() * other.lift())
try:
result = self.parent()(result)
except ValueError:
pass
return result
def hl_creation_operator(self, nu, t=None):
"\n This is the vertex operator that generalizes Jing's operator.\n\n It is a linear operator that raises the degree by\n `|\\nu|`. This creation operator is a t-analogue of\n multiplication by ``s(nu)`` .\n\n .. SEEALSO:: Proposition 5 in [SZ2001]_.\n\n INPUT:\n\n - ``nu`` -- a partition or a list of integers\n\n - ``t`` -- (default: ``None``, in which case ``t`` is used) an\n element of the base ring\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: ks = Sym.kschur(4)\n sage: s = Sym.schur()\n sage: s(ks([3,1,1]).hl_creation_operator([1]))\n (t-1)*s[2, 2, 1, 1] + t^2*s[3, 1, 1, 1] + (t^3+t^2-t)*s[3, 2, 1] + (t^3-t^2)*s[3, 3] + (t^4+t^3)*s[4, 1, 1] + t^4*s[4, 2] + t^5*s[5, 1]\n sage: ks([3,1,1]).hl_creation_operator([1])\n (t-1)*ks4[2, 2, 1, 1] + t^2*ks4[3, 1, 1, 1] + t^3*ks4[3, 2, 1] + (t^3-t^2)*ks4[3, 3] + t^4*ks4[4, 1, 1]\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(4,t=1)\n sage: ks([3,1,1]).hl_creation_operator([1])\n ks4[3, 1, 1, 1] + ks4[3, 2, 1] + ks4[4, 1, 1]\n "
if (t is None):
t = self.parent().realization_of().t
return self.parent()(self.lift().hl_creation_operator(nu, t=t))
def omega(self):
"\n Return the `\\omega` operator on ``self``.\n\n At `t=1`, `\\omega` maps the `k`-Schur function `s^{(k)}_\\lambda` to `s^{(k)}_{\\lambda^{(k)}}`, where\n `\\lambda^{(k)}` is the `k`-conjugate of the partition `\\lambda`.\n\n .. SEEALSO:: :meth:`~sage.combinat.partition.Partition.k_conjugate`.\n\n For generic `t`, `\\omega` sends `s^{(k)}_\\lambda[X;t]` to `t^d s^{(k)}_{\\lambda^{(k)}}[X;1/t]`,\n where `d` is the size of the core of `\\lambda` minus the size of `\\lambda`. Most of the time,\n this result is not in the `k`-bounded subspace.\n\n .. SEEALSO:: :meth:`omega_t_inverse`.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(3,1)\n sage: ks[2,2,1,1].omega()\n ks3[2, 2, 2]\n sage: kh = Sym.khomogeneous(3)\n sage: kh[3].omega()\n h3[1, 1, 1] - 2*h3[2, 1] + h3[3]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: ks = Sym.kschur(3)\n sage: ks[3,1,1].omega()\n Traceback (most recent call last):\n ...\n ValueError: t*s[2, 1, 1, 1] + s[3, 1, 1] is not in the image\n "
return self.parent()(self.lift().omega())
def omega_t_inverse(self):
"\n Return the map `t\\to 1/t` composed with `\\omega` on ``self``.\n\n Unlike the map :meth:`omega`, the result of :meth:`omega_t_inverse` lives in\n the `k`-bounded subspace and hence will return an element even for generic\n `t`. For `t=1`, :meth:`omega` and :meth:`omega_t_inverse` return the same\n result.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: ks = Sym.kschur(3)\n sage: ks[3,1,1].omega_t_inverse()\n 1/t*ks3[2, 1, 1, 1]\n sage: ks[3,2].omega_t_inverse()\n 1/t^2*ks3[1, 1, 1, 1, 1]\n "
s = self.parent().realization_of().ambient()
t = s.base_ring().gen()
def invert(x):
return s.base_ring()(x.subs(t=(1 / t)))
return self.parent()(s(self).map_coefficients(invert).omega())
def is_schur_positive(self, *args, **kwargs):
"\n Return whether ``self`` is Schur positive.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(3,1)\n sage: f = ks[3,2]+ks[1]\n sage: f.is_schur_positive()\n True\n sage: f = ks[3,2]-ks[1]\n sage: f.is_schur_positive()\n False\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks = Sym.kschur(3)\n sage: f = ks[3,2]+ks[1]\n sage: f.is_schur_positive()\n True\n sage: f = ks[3,2]-ks[1]\n sage: f.is_schur_positive()\n False\n "
return self.lift().is_schur_positive(*args, **kwargs)
def expand(self, *args, **kwargs):
"\n Return the monomial expansion of ``self`` in `n` variables.\n\n INPUT:\n\n - ``n`` -- positive integer\n\n OUTPUT: monomial expansion of ``self`` in `n` variables\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(3,1)\n sage: ks[3,1].expand(2)\n x0^4 + 2*x0^3*x1 + 2*x0^2*x1^2 + 2*x0*x1^3 + x1^4\n sage: s = Sym.schur()\n sage: ks[3,1].expand(2) == s(ks[3,1]).expand(2)\n True\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks = Sym.kschur(3)\n sage: f = ks[3,2]-ks[1]\n sage: f.expand(2)\n t^2*x0^5 + (t^2 + t)*x0^4*x1 + (t^2 + t + 1)*x0^3*x1^2 + (t^2 + t + 1)*x0^2*x1^3 + (t^2 + t)*x0*x1^4 + t^2*x1^5 - x0 - x1\n "
return self.lift().expand(*args, **kwargs)
def scalar(self, x, zee=None):
"\n Return standard scalar product between ``self`` and ``x``.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n - ``zee`` -- an optional function on partitions giving\n the value for the scalar product between `p_{\\mu}` and `p_{\\mu}`\n (default is to use the standard :meth:`~sage.combinat.sf.sfa.zee` function)\n\n .. SEEALSO:: :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.scalar`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks3 = Sym.kschur(3)\n sage: ks3[3,2,1].scalar( ks3[2,2,2] )\n t^3 + t\n sage: dks3 = Sym.kBoundedQuotient(3).dks()\n sage: [ks3[3,2,1].scalar(dks3(la)) for la in Partitions(6, max_part=3)]\n [0, 1, 0, 0, 0, 0, 0]\n sage: dks3 = Sym.kBoundedQuotient(3,t=1).dks()\n sage: [ks3[2,2,2].scalar(dks3(la)) for la in Partitions(6, max_part=3)]\n [0, t - 1, 0, 1, 0, 0, 0]\n sage: ks3 = Sym.kschur(3,t=1)\n sage: [ks3[2,2,2].scalar(dks3(la)) for la in Partitions(6, max_part=3)]\n [0, 0, 0, 1, 0, 0, 0]\n sage: kH = Sym.khomogeneous(4)\n sage: kH([2,2,1]).scalar(ks3[2,2,1])\n 3\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks3 = Sym.kschur(3,1)\n sage: ks3(1).scalar(ks3([]))\n 1\n "
if hasattr(x, 'lift'):
return self.lift().scalar(x.lift(), zee)
return self.lift().scalar(x, zee)
|
class kSchur(CombinatorialFreeModule):
'\n Space of `k`-Schur functions.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ[\'t\'])\n sage: KB = Sym.kBoundedSubspace(3); KB\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n\n The `k`-Schur function basis can be constructed as follows::\n\n sage: ks3 = KB.kschur(); ks3\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis\n\n We can convert to any basis of the ring of symmetric functions and,\n whenever it makes sense, also the other way round::\n\n sage: s = Sym.schur()\n sage: s(ks3([3,2,1]))\n s[3, 2, 1] + t*s[4, 1, 1] + t*s[4, 2] + t^2*s[5, 1]\n sage: t = Sym.base_ring().gen()\n sage: ks3(s([3, 2, 1]) + t*s([4, 1, 1]) + t*s([4, 2]) + t^2*s([5, 1]))\n ks3[3, 2, 1]\n sage: s(ks3[2, 1, 1])\n s[2, 1, 1] + t*s[3, 1]\n sage: ks3(s[2, 1, 1] + t*s[3, 1])\n ks3[2, 1, 1]\n\n `k`-Schur functions are indexed by partitions with first part `\\le k`. Constructing a\n `k`-Schur function for a larger partition raises an error::\n\n sage: ks3([4,3,2,1]) #\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 3, 2, 1]) an element of self (=3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis)\n\n Similarly, attempting to convert a function that is not in the\n linear span of the `k`-Schur functions raises an error::\n\n sage: ks3(s([4]))\n Traceback (most recent call last):\n ...\n ValueError: s[4] is not in the image\n\n Note that the product of `k`-Schur functions is not guaranteed to be in the\n space spanned by the `k`-Schurs. In general, we only have that a\n `k`-Schur times a `j`-Schur function is in the `(k+j)`-bounded subspace. The\n multiplication of two `k`-Schur functions thus generally returns the product of\n the lift of the functions to the ambient symmetric function space. If the result\n happens to lie in the `k`-bounded subspace, then the result is cast into the\n `k`-Schur basis::\n\n sage: ks2 = Sym.kBoundedSubspace(2).kschur()\n sage: ks2[1] * ks2[1]\n ks2[1, 1] + ks2[2]\n sage: ks2[1] * ks2[2]\n s[2, 1] + s[3]\n\n Because the target space of the product of a `k`-Schur and a `j`-Schur has several\n possibilities, the product of a `k`-Schur and `j`-Schur function is not\n implemented for distinct `k` and `j`. Let us show how to get around\n this \'manually\'::\n\n sage: ks3 = Sym.kBoundedSubspace(3).kschur()\n sage: ks2([2,1]) * ks3([3,1])\n Traceback (most recent call last):\n ...\n TypeError: unsupported operand parent(s) for *: \'2-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 2-Schur basis\' and \'3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis\'\n\n The workaround::\n\n sage: f = s(ks2([2,1])) * s(ks3([3,1])); f # Convert to Schur functions first and multiply there.\n s[3, 2, 1, 1] + s[3, 2, 2] + (t+1)*s[3, 3, 1] + s[4, 1, 1, 1]\n + (2*t+2)*s[4, 2, 1] + (t^2+t+1)*s[4, 3] + (2*t+1)*s[5, 1, 1]\n + (t^2+2*t+1)*s[5, 2] + (t^2+2*t)*s[6, 1] + t^2*s[7]\n\n or::\n\n sage: f = ks2[2,1].lift() * ks3[3,1].lift()\n sage: ks5 = Sym.kBoundedSubspace(5).kschur()\n sage: ks5(f) # The product of a \'ks2\' with a \'ks3\' is a \'ks5\'.\n ks5[3, 2, 1, 1] + ks5[3, 2, 2] + (t+1)*ks5[3, 3, 1] + ks5[4, 1, 1, 1]\n + (t+2)*ks5[4, 2, 1] + (t^2+t+1)*ks5[4, 3] + (t+1)*ks5[5, 1, 1] + ks5[5, 2]\n\n For other technical reasons, taking powers of `k`-Schur functions\n is not implemented, even when the answer is still in the `k`-bounded\n subspace::\n\n sage: ks2([1])^2\n Traceback (most recent call last):\n ...\n TypeError: unsupported operand parent(s) for ^: \'2-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 2-Schur basis\' and \'Integer Ring\'\n\n .. TODO::\n\n Get rid of said technical "reasons".\n\n However, at `t=1`, the product of `k`-Schur functions is in the span of the\n `k`-Schur functions always. Below are some examples at `t=1` ::\n\n sage: ks3 = Sym.kBoundedSubspace(3, t=1).kschur(); ks3\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field with t=1 in the 3-Schur basis\n sage: s = SymmetricFunctions(ks3.base_ring()).schur()\n sage: ks3(s([3]))\n ks3[3]\n sage: s(ks3([3,2,1]))\n s[3, 2, 1] + s[4, 1, 1] + s[4, 2] + s[5, 1]\n sage: ks3([2,1])^2 # taking powers works for t=1\n ks3[2, 2, 1, 1] + ks3[2, 2, 2] + ks3[3, 1, 1, 1]\n\n TESTS:\n\n Check that :trac:`13743` is fixed::\n\n sage: ks3 = SymmetricFunctions(QQ).kschur(3, 1)\n sage: f = ks3[2,1]\n sage: f.coefficient(f.support()[0])\n 1\n '
def __init__(self, kBoundedRing):
'\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: from sage.combinat.sf.new_kschur import kSchur\n sage: KB = Sym.kBoundedSubspace(3,t=1)\n sage: kSchur(KB)\n 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis\n '
CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category=KBoundedSubspaceBases(kBoundedRing, kBoundedRing.t), prefix=('ks%d' % kBoundedRing.k))
self._kBoundedRing = kBoundedRing
self.k = kBoundedRing.k
self.t = kBoundedRing.t
s = self.realization_of().ambient().schur()
self.ambient = ConstantFunction(s)
self.lift = self._module_morphism(self._to_schur_on_basis, codomain=s, triangular='lower', unitriangular=True, inverse_on_support=(lambda p: (p if (p.get_part(0) <= self.k) else None)))
self.lift.register_as_coercion()
self.retract = SetMorphism(Hom(s, self, SetsWithPartialMaps()), self.lift.preimage)
self.register_conversion(self.retract)
__getitem__ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '__getitem__')
_repr_term = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_repr_term')
_convert_map_from_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_convert_map_from_')
_element_constructor_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_element_constructor_')
def _repr_(self):
"\n Representation of ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(4,1); ks # indirect doctest\n 4-bounded Symmetric Functions over Rational Field with t=1 in the 4-Schur basis\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks = Sym.kschur(4); ks\n 4-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field in the 4-Schur basis\n "
return (self.realization_of()._repr_() + (' in the %s-Schur basis' % self.k))
@cached_method
def _to_schur_on_basis(self, p):
"\n Compute the change of basis from `k`-Schur functions to Schur functions.\n\n When `t=1` this procedure does this computation by first factoring out all\n maximal rectangles, computing all the atoms, and then taking the product\n again of the `k`-Schur function indexed by the `k`-irreducible partition and\n the Schur functions indexed by rectangles.\n\n INPUT:\n\n - ``p`` -- a partition\n\n OUTPUT: conversion of the `k`-Schur function indexed by ``p`` in terms of Schur functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks = Sym.kschur(4)\n sage: ks._to_schur_on_basis(Partition([3,3,2,1]))\n s[3, 3, 2, 1] + t*s[4, 3, 1, 1] + t*s[4, 3, 2] + t^2*s[4, 4, 1] + t^2*s[5, 3, 1] + t^3*s[5, 4]\n sage: ks = Sym.kschur(4,1)\n sage: ks._to_schur_on_basis(Partition([4,4,3,3,2,2,2,1])).coefficient([12,5,4])\n 5\n\n TESTS::\n\n sage: ks._to_schur_on_basis(Partition([]))\n s[]\n "
s = self.realization_of().ambient().schur()
if (self.t == 1):
pexp = (p.to_exp() + ([0] * self.k))
katom = p.k_irreducible(self.k).k_atom(self.k)
return (s.sum_of_monomials((tab.shape() for tab in katom)) * prod((s(([(r + 1)] * (self.k - r))) for r in range(self.k) for m in range((pexp[r] // (self.k - r))))))
katom = p.k_atom(self.k)
return s.sum_of_terms(((tab.shape(), (self.t ** tab.charge())) for tab in katom))
def _product_on_basis_via_rectangles(self, left, right):
'\n Multiply two `k`-Schur functions at `t=1` indexed by ``left`` and ``right``\n\n This algorithm uses the property that if `R` is an `r \\times (k+1-r)`\n rectangle, then\n\n .. MATH::\n\n s_{R} \\cdot s^{(k)}_\\lambda = s^{(k)}_{R \\cup \\lambda}\n\n To compute the product of two `k`-Schur functions, all rectangles are factored\n out, the product is performed in the Schur basis, then the rectangles are\n re-inserted.\n\n INPUT:\n\n - ``left``, ``right`` -- partitions\n\n OUTPUT:\n\n - the product of the `k`-Schur functions indexed by ``left`` and ``right``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(5,1)\n sage: ks._product_on_basis_via_rectangles(Partition([5,4,4,3,3,3]),Partition([4,4,2,2,2,2]))\n ks5[5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2]\n sage: ks._product_on_basis_via_rectangles(Partition([5,4,4,3,3,3,1]),Partition([4,4,2]))\n ks5[5, 4, 4, 4, 4, 3, 3, 3, 2, 1] + ks5[5, 4, 4, 4, 4, 3, 3, 3, 3]\n\n TESTS::\n\n sage: ks._product_on_basis_via_rectangles(Partition([]), Partition([]))\n ks5[]\n '
leftir = self._to_schur_on_basis(left.k_irreducible(self.k))
rightir = self._to_schur_on_basis(right.k_irreducible(self.k))
heart = self.retract((leftir * rightir))
leftexp = left.to_exp()
rightexp = right.to_exp()
rects = sum((([(r + 1)] * (self.k - r)) for r in range(len(leftexp)) for m in range((leftexp[r] // (self.k - r)))), [])
rects += sum((([(r + 1)] * (self.k - r)) for r in range(len(rightexp)) for m in range((rightexp[r] // (self.k - r)))), [])
return heart.map_support((lambda lam: Partition(sorted((lam + rects), reverse=True))))
def product_on_basis(self, left, right):
"\n Take the product of two `k`-Schur functions.\n\n If `t \\neq 1`, then take the product by lifting to the Schur functions and then\n retracting back into the `k`-bounded subspace (if possible).\n\n If `t=1`, then the product calls :meth:`_product_on_basis_via_rectangles`.\n\n INPUT:\n\n - ``left``, ``right`` -- partitions\n\n OUTPUT:\n\n - an element of the `k`-Schur functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks3 = Sym.kschur(3,1)\n sage: kH = Sym.khomogeneous(3)\n sage: ks3(kH[2,1,1])\n ks3[2, 1, 1] + ks3[2, 2] + ks3[3, 1]\n sage: ks3([])*kH[2,1,1]\n ks3[2, 1, 1] + ks3[2, 2] + ks3[3, 1]\n sage: ks3([3,3,3,2,2,1,1,1])^2\n ks3[3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n sage: ks3([3,3,3,2,2,1,1,1])*ks3([2,2,2,2,2,1,1,1,1])\n ks3[3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1]\n sage: ks3([2,2,1,1,1,1])*ks3([2,2,2,1,1,1,1])\n ks3[2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1] + ks3[2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n sage: ks3[2,1]^2\n ks3[2, 2, 1, 1] + ks3[2, 2, 2] + ks3[3, 1, 1, 1]\n sage: ks3 = Sym.kschur(3)\n sage: ks3[2,1]*ks3[2,1]\n s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + s[4, 2]\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks3 = Sym.kschur(3,1)\n sage: kH = Sym.khomogeneous(3)\n sage: ks3.product( ks3([]), ks3([]) )\n ks3[]\n sage: ks3.product( ks3([]), kH([]) )\n ks3[]\n sage: ks3 = Sym.kschur(3)\n sage: ks3([]) * ks3([])\n ks3[]\n "
if (self.t == 1):
return self._product_on_basis_via_rectangles(left, right)
left_s = self._to_schur_on_basis(left)
right_s = self._to_schur_on_basis(right)
return self.retract((left_s * right_s))
|
class kSplit(CombinatorialFreeModule):
def __init__(self, kBoundedRing):
"\n The `k`-split basis of the space of `k`-bounded-symmetric functions\n\n Fix ``k`` a positive integer and ``t`` an element of the base ring.\n\n The `k`-split functions are a basis for the space of `k`-bounded\n symmetric functions that also have the bases\n\n .. MATH::\n\n \\{ Q'_{\\lambda}[X;t] \\}_{\\lambda_1\\le k} =\n \\{ s_{\\lambda}^{(k)}[X;t] \\}_{\\lambda_1 \\le k}\n\n where `Q'_\\lambda[X;t]` are the Hall-Littlewood symmetric functions\n (using the notation of [MAC]_) and `s_{\\lambda}^{(k)}[X;t]` are the\n `k`-Schur functions. If `t` is not a root of unity, then\n\n .. MATH::\n\n \\{ s_{\\lambda}[X/(1-t)] \\}_{\\lambda_1\\le k}\n\n is also a basis of this space.\n\n The `k`-split basis has the property that `Q'_\\lambda[X;t]` expands\n positively in the `k`-split basis and the `k`-split basis\n conjecturally expands positively in the `k`-Schur functions.\n See [LLMSSZ]_ p. 81.\n\n The `k`-split basis is defined recursively using the\n Hall-Littlewood creation operator defined in [SZ2001]_. If a\n partition ``la`` is the concatenation (as lists) of a partition ``mu``\n and ``nu`` where ``mu`` has maximal hook length equal to ``k``\n then ``ksp(la) = ksp(nu).hl_creation_operator(mu)``. If the\n hook length of ``la`` is less than or equal to ``k``, then\n ``ksp(la)`` is equal to the Schur function indexed by ``la``.\n\n EXAMPLES::\n\n sage: Symt = SymmetricFunctions(QQ['t'].fraction_field())\n sage: kBS3 = Symt.kBoundedSubspace(3)\n sage: ks3 = kBS3.kschur()\n sage: ksp3 = kBS3.ksplit()\n sage: ks3(ksp3[2,1,1])\n ks3[2, 1, 1] + t*ks3[2, 2]\n sage: ksp3(ks3[2,1,1])\n ksp3[2, 1, 1] - t*ksp3[2, 2]\n sage: ksp3[2,1]*ksp3[1]\n s[2, 1, 1] + s[2, 2] + s[3, 1]\n sage: ksp3[2,1].hl_creation_operator([1])\n t*ksp3[2, 1, 1] + (-t^2+t)*ksp3[2, 2]\n\n sage: Qp = Symt.hall_littlewood().Qp()\n sage: ksp3(Qp[3,2,1])\n ksp3[3, 2, 1] + t*ksp3[3, 3]\n\n sage: kBS4 = Symt.kBoundedSubspace(4)\n sage: ksp4 = kBS4.ksplit()\n sage: ksp4(ksp3([3,2,1]))\n ksp4[3, 2, 1] - t*ksp4[3, 3] + t*ksp4[4, 1, 1]\n sage: ks4 = kBS4.kschur()\n sage: ks4(ksp4[3,2,2,1])\n ks4[3, 2, 2, 1] + t*ks4[3, 3, 1, 1] + t*ks4[3, 3, 2]\n "
CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category=KBoundedSubspaceBases(kBoundedRing, kBoundedRing.t), prefix=('ksp%d' % kBoundedRing.k))
self._kBoundedRing = kBoundedRing
self.k = kBoundedRing.k
self.t = kBoundedRing.t
s = self.realization_of().ambient().schur()
self.ambient = ConstantFunction(s)
self.lift = self._module_morphism(self._to_schur_on_basis, codomain=s, triangular='lower', unitriangular=True, inverse_on_support=(lambda p: (p if (p.get_part(0) <= self.k) else None)))
self.lift.register_as_coercion()
self.retract = SetMorphism(Hom(s, self, SetsWithPartialMaps()), self.lift.preimage)
self.register_conversion(self.retract)
__getitem__ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '__getitem__')
_repr_term = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_repr_term')
_convert_map_from_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_convert_map_from_')
_element_constructor_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_element_constructor_')
def _repr_(self):
"\n Representation of ``self``.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).kBoundedSubspace(3,1).ksplit()\n 3-bounded Symmetric Functions over Rational Field with t=1 in the\n 3-split basis\n sage: SymmetricFunctions(QQ['t']).kBoundedSubspace(3).ksplit()\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over\n Rational Field in the 3-split basis\n "
return (self.realization_of()._repr_() + (' in the %s-split basis' % self.k))
@cached_method
def _to_schur_on_basis(self, p):
'\n Computes the change of basis of `k`-split functions to Schur functions.\n\n When `t=1` the `k`-split basis is the product of the Schur functions\n indexed by the partitions in the `k`-split of the partition.\n For `t \\neq 1`, the elements are computed using the Hall-Littlewood\n creation operator defined in [SZ2001]_.\n\n .. MATH::\n\n ksplit_\\lambda = {\\mathbb H}^t_{\\nu^{(1)}} \\cdots\n {\\mathbb H}^t_{\\nu^{(r)}} 1\n\n where the operator `{\\mathbb H}^t_{\\nu}` is implemented in the method\n ``hl_creation_operator`` and the `k`-split of the partition `\\lambda`\n is `(\\nu^{(1)}, \\ldots, \\nu^{(r)})`.\n\n INPUT:\n\n - ``p`` -- a partition\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s()\n sage: ksp3 = Sym.kBoundedSubspace(3,1).ksplit()\n sage: ksp3._to_schur_on_basis(Partition([2,1,1,1]))\n s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2]\n '
s = self.realization_of().ambient().schur()
if (self.t == 1):
return s.prod((s(g) for g in Partition(p).k_split(self.k)))
if (not p):
return s(p)
ksp = Partition(p).k_split(self.k)
out = s(ksp[(- 1)])
for r in range((len(ksp) - 1)):
out = out.hl_creation_operator(ksp[((- r) - 2)], t=self.t)
return out
|
class kHomogeneous(CombinatorialFreeModule):
'\n Space of `k`-bounded homogeneous symmetric functions.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: kH = Sym.khomogeneous(3)\n sage: kH[2]\n h3[2]\n sage: kH[2].lift()\n h[2]\n '
def __init__(self, kBoundedRing):
'\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: from sage.combinat.sf.new_kschur import kHomogeneous\n sage: KB = Sym.kBoundedSubspace(3,t=1)\n sage: kHomogeneous(KB)\n 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-bounded homogeneous basis\n '
CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category=KBoundedSubspaceBases(kBoundedRing, kBoundedRing.t), prefix=('h%d' % kBoundedRing.k))
self._kBoundedRing = kBoundedRing
self.k = kBoundedRing.k
self.t = 1
h = self.realization_of().ambient().homogeneous()
self.lift = self._module_morphism((lambda x: h[x]), codomain=h, triangular='lower', unitriangular=True, inverse_on_support=(lambda p: (p if (p.get_part(0) <= self.k) else None)))
self.ambient = ConstantFunction(h)
self.lift.register_as_coercion()
self.retract = SetMorphism(Hom(h, self, SetsWithPartialMaps()), self.lift.preimage)
self.register_conversion(self.retract)
__getitem__ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '__getitem__')
_repr_term = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_repr_term')
_convert_map_from_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_convert_map_from_')
_element_constructor_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_element_constructor_')
def _repr_(self):
"\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: kH = Sym.khomogeneous(3)\n sage: kH._repr_()\n '3-bounded Symmetric Functions over Rational Field with t=1 in the 3-bounded homogeneous basis'\n "
return (self.realization_of()._repr_() + (' in the %s-bounded homogeneous basis' % self.k))
|
class K_kSchur(CombinatorialFreeModule):
'\n This class implements the basis of the `k`-bounded subspace called the K-`k`-Schur basis.\n\n See [Morse2011]_, [LamSchillingShimozono2010]_.\n\n REFERENCES:\n\n .. [Morse2011] \\J. Morse, Combinatorics of the K-theory of affine Grassmannians,\n Adv. in Math., Volume 229, Issue 5, pp. 2950--2984.\n\n .. [LamSchillingShimozono2010] \\T. Lam, A. Schilling, M.Shimozono, K-theory Schubert calculus of the affine Grassmannian,\n Compositio Math. 146 (2010), 811-852.\n '
def __init__(self, kBoundedRing):
'\n TESTS::\n\n sage: from sage.combinat.sf.new_kschur import K_kSchur\n sage: kB = SymmetricFunctions(QQ).kBoundedSubspace(3,1)\n sage: g = K_kSchur(kB)\n sage: g\n 3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis\n sage: g[2,1]*g[1] # takes a while but caches stuff\n -2*Kks3[2, 1] + Kks3[2, 1, 1] + Kks3[2, 2]\n sage: g([])\n Kks3[]\n sage: TestSuite(g).run() # long time (11s on sage.math, 2013)\n sage: h = SymmetricFunctions(QQ).h()\n sage: g(h[1,1])\n -Kks3[1] + Kks3[1, 1] + Kks3[2]\n '
CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category=KBoundedSubspaceBases(kBoundedRing, kBoundedRing.base_ring().one()), prefix=('Kks%d' % kBoundedRing.k))
self._kBoundedRing = kBoundedRing
self.k = kBoundedRing.k
self.t = 1
s = self.realization_of().ambient().schur()
self.ambient = ConstantFunction(s)
kh = self.realization_of().khomogeneous()
g_to_kh = self.module_morphism(self._g_to_kh_on_basis, codomain=kh)
g_to_kh.register_as_coercion()
kh_to_g = kh.module_morphism(self._kh_to_g_on_basis, codomain=self)
kh_to_g.register_as_coercion()
h = self.realization_of().ambient().h()
lift = self._module_morphism(self.lift, triangular='lower', unitriangular=True, codomain=h)
lift.register_as_coercion()
retract = h._module_morphism(self.retract, codomain=self)
self.register_conversion(retract)
__getitem__ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '__getitem__')
_repr_term = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_repr_term')
_element_constructor_ = raw_getattr(KBoundedSubspaceBases.ParentMethods, '_element_constructor_')
def _repr_(self):
"\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: kB = Sym.kBoundedSubspace(3,1)\n sage: g = kB.K_kschur()\n sage: g._repr_()\n '3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis'\n "
return (self.realization_of()._repr_() + (' in the K-%s-Schur basis' % self.k))
def _homogeneous_generators_noncommutative_variables_zero_Hecke(self, r):
'\n Return the ``r^{th}`` homogeneous generator, viewed as an element inside the\n affine zero Hecke algebra.\n\n This is the sum of all cyclically decreasing elements of order ``r``.\n\n INPUT:\n\n - ``r`` -- A positive integer\n\n OUTPUT:\n\n - An element of the affine zero Hecke algebra.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g._homogeneous_generators_noncommutative_variables_zero_Hecke(2)\n T[1,0] + T[2,0] + T[0,3] + T[3,2] + T[3,1] + T[2,1]\n sage: g._homogeneous_generators_noncommutative_variables_zero_Hecke(0)\n 1\n '
from sage.combinat.root_system.weyl_group import WeylGroup
from sage.algebras.iwahori_hecke_algebra import IwahoriHeckeAlgebra
W = WeylGroup(['A', self.k, 1])
H = IwahoriHeckeAlgebra(W, 0, base_ring=self.base_ring()).T()
Hgens = H.algebra_generators()
S = [w.reduced_word() for w in W.pieri_factors() if (w.length() == r)]
return sum((prod((Hgens[i] for i in w), 1) for w in S), 0)
@cached_method
def _homogeneous_basis(self, la):
'\n Return the homogeneous basis element indexed by ``la``, viewed as an element\n inside the affine zero Hecke algebra. This method is only here for caching purposes.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n OUTPUT:\n\n - An element of the affine zero Hecke algebra.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g._homogeneous_basis(Partition([2,1]))\n T[2,1,0] + T[3,1,0] + T[1,2,0] + T[3,2,0] + T[0,1,0] + T[2,0,1] + T[1,0,3] + T[0,3,0] + T[2,0,3] + T[0,3,2] + T[0,3,1] + T[2,3,2] + T[3,2,1] + T[2,3,1] + T[3,1,2] + T[1,2,1] - T[1,0] - 2*T[2,0] - T[0,3] - T[3,2] - 2*T[3,1] - T[2,1]\n sage: g._homogeneous_basis(Partition([]))\n 1\n '
return prod((self._homogeneous_generators_noncommutative_variables_zero_Hecke(la[i]) for i in range(len(la))))
def homogeneous_basis_noncommutative_variables_zero_Hecke(self, la):
'\n Return the homogeneous basis element indexed by ``la``, viewed as an element\n inside the affine zero Hecke algebra. For the code, see method _homogeneous_basis.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n OUTPUT:\n\n - An element of the affine zero Hecke algebra.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g.homogeneous_basis_noncommutative_variables_zero_Hecke([2,1])\n T[2,1,0] + T[3,1,0] + T[1,2,0] + T[3,2,0] + T[0,1,0] + T[2,0,1] + T[1,0,3] + T[0,3,0] + T[2,0,3] + T[0,3,2] + T[0,3,1] + T[2,3,2] + T[3,2,1] + T[2,3,1] + T[3,1,2] + T[1,2,1] - T[1,0] - 2*T[2,0] - T[0,3] - T[3,2] - 2*T[3,1] - T[2,1]\n sage: g.homogeneous_basis_noncommutative_variables_zero_Hecke([])\n 1\n '
return self._homogeneous_basis(Partition(la))
@cached_method
def _DualGrothMatrix(self, m):
'\n Return the change of basis matrix between the K_kschur basis and the `k`-bounded\n homogeneous basis.\n\n INPUT:\n\n - ``m`` -- An integer\n\n OUTPUT:\n\n - A matrix.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g._DualGrothMatrix(3)\n [ 1 1 1 0 0 0 0]\n [ 0 1 2 0 0 0 0]\n [ 0 0 1 0 0 0 0]\n [ 0 -1 -2 1 1 0 0]\n [ 0 0 -2 0 1 0 0]\n [ 0 0 1 0 -1 1 0]\n [ 0 0 0 0 0 0 1]\n sage: g._DualGrothMatrix(0)\n [1]\n '
new_mat = []
Sym = SymmetricFunctions(self.base_ring())
Q = Sym.kBoundedQuotient(self.k, t=1)
mon = Q.km()
G = Q.AffineGrothendieckPolynomial
for i in range((m + 1)):
for x in Partitions((m - i), max_part=self.k):
f = mon(G(x, m))
vec = []
for j in range((m + 1)):
for y in Partitions((m - j), max_part=self.k):
vec.append(f.coefficient(y))
new_mat.append(vec)
from sage.matrix.constructor import Matrix
return Matrix(new_mat)
@cached_method
def _DualGrothendieck(self, la):
'\n Return the expansion of the K-`k`-Schur function in the homogeneous basis. This\n method is here for caching purposes.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A symmetric function in the homogeneous basis.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g._DualGrothendieck(Partition([2,1]))\n h[2] + h[2, 1] - h[3]\n sage: g._DualGrothendieck(Partition([]))\n h[]\n sage: g._DualGrothendieck(Partition([4,1])) # long time (5s on sage.math, 2013)\n 0\n '
m = la.size()
h = SymmetricFunctions(self.base_ring()).h()
M = self._DualGrothMatrix(m)
vec = []
for i in range((m + 1)):
for x in Partitions((m - i), max_part=self.k):
if (x == la):
vec.append(1)
else:
vec.append(0)
from sage.modules.free_module_element import vector
vec = vector(vec)
sol = M.solve_right(vec)
new_function = h.zero()
count = 0
for i in range((m + 1)):
for x in Partitions((m - i), max_part=self.k):
new_function += (h(x) * sol[count])
count += 1
return new_function
def _g_to_kh_on_basis(self, la):
'\n Return the expansion of the K-`k`-Schur function in the homogeneous basis.\n\n See method :meth:`_DualGrothendieck` for the code.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition.\n\n OUTPUT:\n\n - A symmetric function in the homogeneous basis.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g._g_to_kh_on_basis([2,1])\n h[2] + h[2, 1] - h[3]\n sage: g._g_to_kh_on_basis([])\n h[]\n sage: g._g_to_kh_on_basis([4,1])\n Traceback (most recent call last):\n ...\n ValueError: Partition should be 3-bounded\n '
if (la and (la[0] > self.k)):
raise ValueError(('Partition should be %d-bounded' % self.k))
return self._DualGrothendieck(Partition(la))
def K_k_Schur_non_commutative_variables(self, la):
'\n Return the K-`k`-Schur function, as embedded inside the affine zero Hecke algebra.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded Partition\n\n OUTPUT:\n\n - An element of the affine zero Hecke algebra.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g.K_k_Schur_non_commutative_variables([2,1])\n T[3,1,0] + T[1,2,0] + T[3,2,0] + T[0,1,0] + T[2,0,1] + T[0,3,0] + T[2,0,3] + T[0,3,1] + T[2,3,2] + T[2,3,1] + T[3,1,2] + T[1,2,1] - T[2,0] - T[3,1]\n sage: g.K_k_Schur_non_commutative_variables([])\n 1\n sage: g.K_k_Schur_non_commutative_variables([4,1])\n Traceback (most recent call last):\n ...\n ValueError: Partition should be 3-bounded\n '
SF = SymmetricFunctions(self.base_ring())
h = SF.h()
S = h(self._g_to_kh_on_basis(la)).support()
return sum(((h(self._g_to_kh_on_basis(la)).coefficient(x) * self.homogeneous_basis_noncommutative_variables_zero_Hecke(x)) for x in S))
def _kh_to_g_on_basis(self, la):
'\n Given a `k`-homogeneous basis element, this returns the element written in the\n K-`k`-Schur basis.\n\n INPUT:\n\n - ``la`` -- A `k`-bounded partition\n\n OUTPUT:\n\n - An element of the `k`-bounded subspace, written in the K-`k`-Schur basis.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g._kh_to_g_on_basis([2,1])\n -Kks3[2] + Kks3[2, 1] + Kks3[3]\n sage: g._kh_to_g_on_basis([])\n Kks3[]\n sage: g._kh_to_g_on_basis([4,1])\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis)\n '
if (not la):
return self([])
h = self.realization_of().khomogeneous()
f = (h(self(la)) - h(la))
return (self(la) - sum(((self._kh_to_g_on_basis(x) * f.coefficient(x)) for x in f.support())))
def product(self, x, y):
'\n Return the product of the two K-`k`-Schur functions.\n\n INPUT:\n\n - ``x``, ``y`` -- elements of the `k`-bounded subspace, in the K-`k`-Schur basis.\n\n OUTPUT:\n\n - An element of the `k`-bounded subspace, in the K-`k`-Schur basis\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g.product(g([2,1]), g[1])\n -2*Kks3[2, 1] + Kks3[2, 1, 1] + Kks3[2, 2]\n sage: g.product(g([2,1]), g([]))\n Kks3[2, 1]\n '
kh = self.realization_of().khomogeneous()
return self((kh(x) * kh(y)))
def lift(self, x):
'\n Return the lift of a `k`-bounded symmetric function.\n\n INPUT:\n\n - ``x`` -- An expression in the K-`k`-Schur basis. Equivalently, ``x`` can be a\n `k`-bounded partition (then ``x`` corresponds to the basis element indexed by ``x``)\n\n OUTPUT:\n\n - A symmetric function.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: g.lift([2,1])\n h[2] + h[2, 1] - h[3]\n sage: g.lift([])\n h[]\n sage: g.lift([4,1])\n Traceback (most recent call last):\n ...\n TypeError: do not know how to make x (= [4, 1]) an element of self (=3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis)\n '
kh = self.realization_of().khomogeneous()
return kh(self(x)).lift()
def retract(self, x):
'\n Return the retract of a symmetric function.\n\n INPUT:\n\n - ``x`` -- A symmetric function.\n\n OUTPUT:\n\n - A `k`-bounded symmetric function in the K-`k`-Schur basis.\n\n EXAMPLES::\n\n sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()\n sage: m = SymmetricFunctions(QQ).m()\n sage: g.retract(m[2,1])\n -2*Kks3[1] + 4*Kks3[1, 1] - 2*Kks3[1, 1, 1] - Kks3[2] + Kks3[2, 1]\n sage: g.retract(m([]))\n Kks3[]\n '
kh = self.realization_of().khomogeneous()
return self(kh.retract(x))
|
class LatticeDiagram(CombinatorialObject):
def boxes(self):
'\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,0,2])\n sage: a.boxes()\n [(1, 1), (1, 2), (1, 3), (3, 1), (3, 2)]\n sage: a = LatticeDiagram([2, 1, 3, 0, 0, 2])\n sage: a.boxes()\n [(1, 1), (1, 2), (2, 1), (3, 1), (3, 2), (3, 3), (6, 1), (6, 2)]\n '
res = []
for i in range(1, (len(self) + 1)):
res += [(i, (j + 1)) for j in range(self[i])]
return res
def __getitem__(self, i):
'\n Return the `i^{th}` entry of ``self``.\n\n Note that the indexing for lattice diagrams starts at `1`.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,0,2])\n sage: a[1]\n 3\n sage: a[0]\n Traceback (most recent call last):\n ...\n ValueError: indexing starts at 1\n sage: a[-1]\n 2\n '
if (i == 0):
raise ValueError('indexing starts at 1')
elif (i < 0):
i += 1
return self._list[(i - 1)]
def leg(self, i, j):
'\n Return the leg of the box ``(i,j)`` in ``self``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.leg(5,2)\n [(5, 3)]\n '
return [(i, k) for k in range((j + 1), (self[i] + 1))]
def arm_left(self, i, j):
'\n Return the left arm of the box ``(i,j)`` in ``self``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.arm_left(5,2)\n [(1, 2), (3, 2)]\n '
return [(ip, j) for ip in range(1, i) if (j <= self[ip] <= self[i])]
def arm_right(self, i, j):
'\n Return the right arm of the box ``(i,j)`` in ``self``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.arm_right(5,2)\n [(8, 1)]\n '
return [(ip, (j - 1)) for ip in range((i + 1), (len(self) + 1)) if ((j - 1) <= self[ip] < self[i])]
def arm(self, i, j):
'\n Return the arm of the box ``(i,j)`` in ``self``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.arm(5,2)\n [(1, 2), (3, 2), (8, 1)]\n '
return (self.arm_left(i, j) + self.arm_right(i, j))
def l(self, i, j):
'\n Return ``self[i] - j``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.l(5,2)\n 1\n '
return (self[i] - j)
def a(self, i, j):
'\n Return the length of the arm of the box ``(i,j)`` in ``self``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.a(5,2)\n 3\n '
return len(self.arm(i, j))
def size(self):
'\n Return the number of boxes in ``self``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,1,2,4,3,0,4,2,3])\n sage: a.size()\n 22\n '
return sum(self._list)
def flip(self):
'\n Return the flip of ``self``, where flip is defined as follows. Let\n ``r = max(self)``. Then ``self.flip()[i] = r - self[i]``.\n\n EXAMPLES::\n\n sage: a = LatticeDiagram([3,0,2])\n sage: a.flip()\n [0, 3, 1]\n '
r = max(self)
return LatticeDiagram([(r - i) for i in self])
def boxes_same_and_lower_right(self, ii, jj):
'\n Return a list of the boxes of ``self`` that are in row ``jj``\n but not identical with ``(ii, jj)``, or lie in the row\n ``jj - 1`` (the row directly below ``jj``; this might be the\n basement) and strictly to the right of ``(ii, jj)``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a = a.shape()\n sage: a.boxes_same_and_lower_right(1,1)\n [(2, 1), (3, 1), (6, 1), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0)]\n sage: a.boxes_same_and_lower_right(1,2)\n [(3, 2), (6, 2), (2, 1), (3, 1), (6, 1)]\n sage: a.boxes_same_and_lower_right(3,3)\n [(6, 2)]\n sage: a.boxes_same_and_lower_right(2,3)\n [(3, 3), (3, 2), (6, 2)]\n '
res = []
for i in range(1, (len(self) + 1)):
if ((self[i] >= jj) and (i != ii)):
res.append((i, jj))
for i in range((ii + 1), (len(self) + 1)):
if (self[i] >= (jj - 1)):
res.append((i, (jj - 1)))
return res
|
class AugmentedLatticeDiagramFilling(CombinatorialObject):
def __init__(self, l, pi=None):
'\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a == loads(dumps(a))\n True\n sage: pi = Permutation([2,3,1]).to_permutation_group_element()\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]],pi)\n sage: a == loads(dumps(a))\n True\n '
if (pi is None):
pi = Permutation([1]).to_permutation_group_element()
self._list = [([pi((i + 1))] + li) for (i, li) in enumerate(l)]
def __getitem__(self, i):
'\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a[0]\n Traceback (most recent call last):\n ...\n ValueError: indexing starts at 1\n sage: a[1,0]\n 1\n sage: a[2,0]\n 2\n sage: a[3,2]\n 4\n sage: a[3][2]\n 4\n '
if isinstance(i, tuple):
(i, j) = i
return self._list[(i - 1)][j]
if (i < 1):
raise ValueError('indexing starts at 1')
return self._list[(i - 1)]
def shape(self):
'\n Return the shape of ``self``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.shape()\n [2, 1, 3, 0, 0, 2]\n '
return LatticeDiagram([max(0, (len(self[i]) - 1)) for i in range(1, (len(self) + 1))])
def __contains__(self, ij):
'\n Return ``True`` if the box ``(i,j) (= ij)`` is in ``self``. Note that this\n does not include the basement row.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: (1,1) in a\n True\n sage: (1,0) in a\n False\n '
(i, j) = ij
return ((0 < i <= len(self)) and (0 < j <= len(self[i])))
def are_attacking(self, i, j, ii, jj):
'\n Return ``True`` if the boxes ``(i,j)`` and ``(ii,jj)`` in ``self`` are attacking.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: all( a.are_attacking(i,j,ii,jj) for (i,j),(ii,jj) in a.attacking_boxes())\n True\n sage: a.are_attacking(1,1,3,2)\n False\n '
if (j == jj):
return True
if (jj < j):
(i, j, ii, jj) = (ii, jj, i, j)
return ((j == (jj - 1)) and (i > ii))
def boxes(self):
"\n Return a list of the coordinates of the boxes of ``self``, including\n the 'basement row'.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.boxes()\n [(1, 1),\n (1, 2),\n (2, 1),\n (3, 1),\n (3, 2),\n (3, 3),\n (6, 1),\n (6, 2),\n (1, 0),\n (2, 0),\n (3, 0),\n (4, 0),\n (5, 0),\n (6, 0)]\n "
return (self.shape().boxes() + [(i, 0) for i in range(1, (len(self.shape()) + 1))])
def attacking_boxes(self):
'\n Return a list of pairs of boxes in ``self`` that are attacking.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.attacking_boxes()[:5]\n [((1, 1), (2, 1)),\n ((1, 1), (3, 1)),\n ((1, 1), (6, 1)),\n ((1, 1), (2, 0)),\n ((1, 1), (3, 0))]\n '
boxes = self.boxes()
res = []
for ((i, j), (ii, jj)) in Combinations(boxes, 2):
if self.are_attacking(i, j, ii, jj):
res.append(((i, j), (ii, jj)))
return res
def is_non_attacking(self):
'\n Return ``True`` if ``self`` is non-attacking.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.is_non_attacking()\n True\n sage: a = AugmentedLatticeDiagramFilling([[1, 1, 1], [2, 3], [3]])\n sage: a.is_non_attacking()\n False\n sage: a = AugmentedLatticeDiagramFilling([[2,2],[1]])\n sage: a.is_non_attacking()\n False\n sage: pi = Permutation([2,1]).to_permutation_group_element()\n sage: a = AugmentedLatticeDiagramFilling([[2,2],[1]],pi)\n sage: a.is_non_attacking()\n True\n '
for (a, b) in self.attacking_boxes():
if (self[a] == self[b]):
return False
return True
def weight(self):
'\n Return the weight of ``self``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.weight()\n [1, 2, 1, 1, 2, 1]\n '
ed = self.reading_word().evaluation_dict()
entries = list(ed)
m = ((max(entries) + 1) if entries else (- 1))
return [ed.get(k, 0) for k in range(1, m)]
def descents(self):
'\n Return a list of the descents of ``self``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.descents()\n [(1, 2), (3, 2)]\n '
res = []
for (i, j) in self.shape().boxes():
if (self[(i, j)] > self[(i, (j - 1))]):
res.append((i, j))
return res
def maj(self):
'\n Return the major index of ``self``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.maj()\n 3\n '
res = 0
shape = self.shape()
for (i, j) in self.descents():
res += (shape.l(i, j) + 1)
return res
def reading_order(self):
"\n Return a list of coordinates of the boxes in ``self``, starting from\n the top right, and reading from right to left.\n\n Note that this includes the 'basement row' of ``self``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.reading_order()\n [(3, 3),\n (6, 2),\n (3, 2),\n (1, 2),\n (6, 1),\n (3, 1),\n (2, 1),\n (1, 1),\n (6, 0),\n (5, 0),\n (4, 0),\n (3, 0),\n (2, 0),\n (1, 0)]\n "
boxes = self.boxes()
def fn(ij):
return ((- ij[1]), (- ij[0]))
boxes.sort(key=fn)
return boxes
def reading_word(self):
'\n Return the reading word of ``self``, obtained by reading the boxes\n entries of self from right to left, starting in the upper right.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.reading_word()\n word: 25465321\n '
w = [self[(i, j)] for (i, j) in self.reading_order() if (j > 0)]
return Word(w)
def inversions(self):
'\n Return a list of the inversions of ``self``.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.inversions()[:5]\n [((6, 2), (3, 2)),\n ((1, 2), (6, 1)),\n ((1, 2), (3, 1)),\n ((1, 2), (2, 1)),\n ((6, 1), (3, 1))]\n sage: len(a.inversions())\n 25\n '
atboxes = [set(x) for x in self.attacking_boxes()]
res = []
order = self.reading_order()
for a in range(len(order)):
(i, j) = order[a]
for b in range((a + 1), len(order)):
(ii, jj) = order[b]
if ((self[(i, j)] > self[(ii, jj)]) and (set(((i, j), (ii, jj))) in atboxes)):
res.append(((i, j), (ii, jj)))
return res
def _inv_aux(self):
'\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a._inv_aux()\n 7\n '
res = 0
shape = self.shape()
for i in range(1, (len(self) + 1)):
for j in range((i + 1), (len(self) + 1)):
if (shape[i] <= shape[j]):
res += 1
return res
def inv(self):
"\n Return ``self``'s inversion statistic.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.inv()\n 15\n "
res = len(self.inversions())
res -= sum((self.shape().a(i, j) for (i, j) in self.descents()))
res -= self._inv_aux()
return res
def coinv(self):
"\n Return ``self``'s co-inversion statistic.\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: a.coinv()\n 2\n "
shape = self.shape()
return (sum((shape.a(i, j) for (i, j) in shape.boxes())) - self.inv())
def coeff(self, q, t):
"\n Return the coefficient in front of ``self`` in the HHL formula for the\n expansion of the non-symmetric Macdonald polynomial\n E(self.shape()).\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: q,t = var('q,t') # needs sage.symbolic\n sage: a.coeff(q,t) # needs sage.symbolic\n (t - 1)^4/((q^2*t^3 - 1)^2*(q*t^2 - 1)^2)\n "
res = 1
shape = self.shape()
for (i, j) in shape.boxes():
if (self[(i, j)] != self[(i, (j - 1))]):
res *= ((1 - t) / (1 - ((q ** (shape.l(i, j) + 1)) * (t ** (shape.a(i, j) + 1)))))
return res
def coeff_integral(self, q, t):
"\n Return the coefficient in front of ``self`` in the HHL formula for the\n expansion of the integral non-symmetric Macdonald polynomial\n E(self.shape())\n\n EXAMPLES::\n\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: q,t = var('q,t') # needs sage.symbolic\n sage: a.coeff_integral(q,t) # needs sage.symbolic\n (q^2*t^3 - 1)^2*(q*t^2 - 1)^2*(t - 1)^4\n "
res = 1
shape = self.shape()
for (i, j) in shape.boxes():
if (self[(i, j)] != self[(i, (j - 1))]):
res *= (1 - ((q ** (shape.l(i, j) + 1)) * (t ** (shape.a(i, j) + 1))))
for (i, j) in shape.boxes():
if (self[(i, j)] == self[(i, (j - 1))]):
res *= (1 - t)
return res
def permuted_filling(self, sigma):
'\n EXAMPLES::\n\n sage: pi=Permutation([2,1,4,3]).to_permutation_group_element()\n sage: fill=[[2],[1,2,3],[],[3,1]]\n sage: AugmentedLatticeDiagramFilling(fill).permuted_filling(pi)\n [[2, 1], [1, 2, 1, 4], [4], [3, 4, 2]]\n '
new_filling = []
for col in self:
nc = [sigma(x) for x in col]
nc.pop(0)
new_filling.append(nc)
return AugmentedLatticeDiagramFilling(new_filling, sigma)
|
def NonattackingFillings(shape, pi=None):
'\n Returning the finite set of nonattacking fillings of a\n given shape.\n\n EXAMPLES::\n\n sage: NonattackingFillings([0,1,2])\n Nonattacking fillings of [0, 1, 2]\n sage: NonattackingFillings([0,1,2]).list()\n [[[1], [2, 1], [3, 2, 1]],\n [[1], [2, 1], [3, 2, 2]],\n [[1], [2, 1], [3, 2, 3]],\n [[1], [2, 1], [3, 3, 1]],\n [[1], [2, 1], [3, 3, 2]],\n [[1], [2, 1], [3, 3, 3]],\n [[1], [2, 2], [3, 1, 1]],\n [[1], [2, 2], [3, 1, 2]],\n [[1], [2, 2], [3, 1, 3]],\n [[1], [2, 2], [3, 3, 1]],\n [[1], [2, 2], [3, 3, 2]],\n [[1], [2, 2], [3, 3, 3]]]\n '
return NonattackingFillings_shape(tuple(shape), pi)
|
class NonattackingFillings_shape(Parent, UniqueRepresentation):
def __init__(self, shape, pi=None):
'\n EXAMPLES::\n\n sage: n = NonattackingFillings([0,1,2])\n sage: n == loads(dumps(n))\n True\n '
self.pi = pi
self._shape = LatticeDiagram(shape)
self._name = ('Nonattacking fillings of %s' % list(shape))
Parent.__init__(self, category=FiniteEnumeratedSets())
def __repr__(self):
'\n EXAMPLES::\n\n sage: NonattackingFillings([0,1,2])\n Nonattacking fillings of [0, 1, 2]\n '
return self._name
def flip(self):
'\n Return the nonattacking fillings of the flipped shape.\n\n EXAMPLES::\n\n sage: NonattackingFillings([0,1,2]).flip()\n Nonattacking fillings of [2, 1, 0]\n '
return NonattackingFillings(list(self._shape.flip()), self.pi)
def __iter__(self):
'\n EXAMPLES::\n\n sage: NonattackingFillings([0,1,2]).list() #indirect doctest\n [[[1], [2, 1], [3, 2, 1]],\n [[1], [2, 1], [3, 2, 2]],\n [[1], [2, 1], [3, 2, 3]],\n [[1], [2, 1], [3, 3, 1]],\n [[1], [2, 1], [3, 3, 2]],\n [[1], [2, 1], [3, 3, 3]],\n [[1], [2, 2], [3, 1, 1]],\n [[1], [2, 2], [3, 1, 2]],\n [[1], [2, 2], [3, 1, 3]],\n [[1], [2, 2], [3, 3, 1]],\n [[1], [2, 2], [3, 3, 2]],\n [[1], [2, 2], [3, 3, 3]]]\n sage: len(_)\n 12\n\n TESTS::\n\n sage: NonattackingFillings([3,2,1,1]).cardinality()\n 3\n sage: NonattackingFillings([3,2,1,2]).cardinality()\n 4\n sage: NonattackingFillings([1,2,3]).cardinality()\n 12\n sage: NonattackingFillings([2,2,2]).cardinality()\n 1\n sage: NonattackingFillings([1,2,3,2]).cardinality()\n 24\n '
if (sum(self._shape) == 0):
(yield AugmentedLatticeDiagramFilling([[] for _ in self._shape], self.pi))
return
for z in NonattackingBacktracker(self._shape, self.pi):
(yield AugmentedLatticeDiagramFilling(z, self.pi))
|
class NonattackingBacktracker(GenericBacktracker):
def __init__(self, shape, pi=None):
'\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import NonattackingBacktracker\n sage: n = NonattackingBacktracker(LatticeDiagram([0,1,2]))\n sage: n._ending_position\n (3, 2)\n sage: n._initial_state\n (2, 1)\n '
self._shape = shape
self._n = sum(shape)
self._initial_data = [([None] * s) for s in shape]
if (pi is None):
pi = Permutation([1]).to_permutation_group_element()
self.pi = pi
ending_row = max(shape)
ending_col = (len(shape) - list(reversed(list(shape))).index(ending_row))
self._ending_position = (ending_col, ending_row)
starting_row = 1
nonzero = [i for i in shape if (i != 0)]
starting_col = (list(shape).index(nonzero[0]) + 1)
GenericBacktracker.__init__(self, self._initial_data, (starting_col, starting_row))
def _rec(self, obj, state):
'\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import NonattackingBacktracker\n sage: n = NonattackingBacktracker(LatticeDiagram([0,1,2]))\n sage: len(list(n))\n 12\n sage: obj = [ [], [None], [None, None]]\n sage: state = 2, 1\n sage: list(n._rec(obj, state))\n [([[], [1], [None, None]], (3, 1), False),\n ([[], [2], [None, None]], (3, 1), False)]\n '
(i, j) = state
new_state = self.get_next_pos(i, j)
yld = bool((new_state is None))
for k in range(1, (len(self._shape) + 1)):
if ((j == 1) and any(((self.pi((x + 1)) == k) for x in range(i, len(self._shape))))):
continue
if any(((obj[(ii - 1)][(jj - 1)] == k) for (ii, jj) in self._shape.boxes_same_and_lower_right(i, j) if (jj != 0))):
continue
obj[(i - 1)][(j - 1)] = k
(yield (copy.deepcopy(obj), new_state, yld))
def get_next_pos(self, ii, jj):
'\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import NonattackingBacktracker\n sage: a = AugmentedLatticeDiagramFilling([[1,6],[2],[3,4,2],[],[],[5,5]])\n sage: n = NonattackingBacktracker(a.shape())\n sage: n.get_next_pos(1, 1)\n (2, 1)\n sage: n.get_next_pos(6, 1)\n (1, 2)\n sage: n = NonattackingBacktracker(LatticeDiagram([2,2,2]))\n sage: n.get_next_pos(3, 1)\n (1, 2)\n '
if ((ii, jj) == self._ending_position):
return None
for i in range((ii + 1), (len(self._shape) + 1)):
if (self._shape[i] >= jj):
return (i, jj)
for i in range(1, (ii + 1)):
if (self._shape[i] >= (jj + 1)):
return (i, (jj + 1))
raise ValueError('we should never be here')
|
def _check_muqt(mu, q, t, pi=None):
"\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import _check_muqt\n sage: P, q, t, n, R, x = _check_muqt([0,0,1],None,None)\n sage: P\n Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field\n sage: q\n q\n sage: t\n t\n sage: n\n Nonattacking fillings of [0, 0, 1]\n sage: R\n Multivariate Polynomial Ring in x0, x1, x2 over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field\n sage: x\n (x0, x1, x2)\n\n ::\n\n sage: q,t = var('q,t') # needs sage.symbolic\n sage: P, q, t, n, R, x = _check_muqt([0,0,1],q,None) # needs sage.symbolic\n Traceback (most recent call last):\n ...\n ValueError: you must specify either both q and t or neither of them\n\n ::\n\n sage: P, q, t, n, R, x = _check_muqt([0,0,1],q,2) # needs sage.symbolic\n Traceback (most recent call last):\n ...\n ValueError: the parents of q and t must be the same\n "
if ((q is None) and (t is None)):
P = PolynomialRing(QQ, 'q,t').fraction_field()
(q, t) = P.gens()
elif ((q is not None) and (t is not None)):
if (q.parent() != t.parent()):
raise ValueError('the parents of q and t must be the same')
P = q.parent()
else:
raise ValueError('you must specify either both q and t or neither of them')
n = NonattackingFillings(mu, pi)
R = PolynomialRing(P, len(n._shape), 'x')
x = R.gens()
return (P, q, t, n, R, x)
|
def E(mu, q=None, t=None, pi=None):
'\n Return the non-symmetric Macdonald polynomial in type A\n corresponding to a shape ``mu``, with basement permuted according to\n ``pi``.\n\n Note that if both `q` and `t` are specified, then they must have\n the same parent.\n\n REFERENCE:\n\n - J. Haglund, M. Haiman, N. Loehr.\n *A combinatorial formula for non-symmetric Macdonald polynomials*.\n :arxiv:`math/0601693v3`.\n\n .. SEEALSO::\n\n :class:`~sage.combinat.root_system.non_symmetric_macdonald_polynomials.NonSymmetricMacdonaldPolynomials`\n for a type free implementation where the polynomials are\n constructed recursively by the application of intertwining\n operators.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import E\n sage: E([0,0,0])\n 1\n sage: E([1,0,0])\n x0\n sage: E([0,1,0])\n (t - 1)/(q*t^2 - 1)*x0 + x1\n sage: E([0,0,1])\n (t - 1)/(q*t - 1)*x0 + (t - 1)/(q*t - 1)*x1 + x2\n sage: E([1,1,0])\n x0*x1\n sage: E([1,0,1])\n (t - 1)/(q*t^2 - 1)*x0*x1 + x0*x2\n sage: E([0,1,1])\n (t - 1)/(q*t - 1)*x0*x1 + (t - 1)/(q*t - 1)*x0*x2 + x1*x2\n sage: E([2,0,0])\n x0^2 + (q*t - q)/(q*t - 1)*x0*x1 + (q*t - q)/(q*t - 1)*x0*x2\n sage: E([0,2,0])\n (t - 1)/(q^2*t^2 - 1)*x0^2 + (q^2*t^3 - q^2*t^2 + q*t^2 - 2*q*t + q - t + 1)/(q^3*t^3 - q^2*t^2 - q*t + 1)*x0*x1 + x1^2 + (q*t^2 - 2*q*t + q)/(q^3*t^3 - q^2*t^2 - q*t + 1)*x0*x2 + (q*t - q)/(q*t - 1)*x1*x2\n '
(P, q, t, n, R, x) = _check_muqt(mu, q, t, pi)
res = 0
for a in n:
weight = a.weight()
res += ((((q ** a.maj()) * (t ** a.coinv())) * a.coeff(q, t)) * prod(((x[i] ** weight[i]) for i in range(len(weight)))))
return res
|
def E_integral(mu, q=None, t=None, pi=None):
'\n Return the integral form for the non-symmetric Macdonald\n polynomial in type A corresponding to a shape mu.\n\n Note that if both q and t are specified, then they must have the\n same parent.\n\n REFERENCE:\n\n - J. Haglund, M. Haiman, N. Loehr.\n *A combinatorial formula for non-symmetric Macdonald polynomials*.\n :arxiv:`math/0601693v3`.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import E_integral\n sage: E_integral([0,0,0])\n 1\n sage: E_integral([1,0,0])\n (-t + 1)*x0\n sage: E_integral([0,1,0])\n (-q*t^2 + 1)*x0 + (-t + 1)*x1\n sage: E_integral([0,0,1])\n (-q*t + 1)*x0 + (-q*t + 1)*x1 + (-t + 1)*x2\n sage: E_integral([1,1,0])\n (t^2 - 2*t + 1)*x0*x1\n sage: E_integral([1,0,1])\n (q*t^3 - q*t^2 - t + 1)*x0*x1 + (t^2 - 2*t + 1)*x0*x2\n sage: E_integral([0,1,1])\n (q^2*t^3 + q*t^4 - q*t^3 - q*t^2 - q*t - t^2 + t + 1)*x0*x1 + (q*t^2 - q*t - t + 1)*x0*x2 + (t^2 - 2*t + 1)*x1*x2\n sage: E_integral([2,0,0])\n (t^2 - 2*t + 1)*x0^2 + (q^2*t^2 - q^2*t - q*t + q)*x0*x1 + (q^2*t^2 - q^2*t - q*t + q)*x0*x2\n sage: E_integral([0,2,0])\n (q^2*t^3 - q^2*t^2 - t + 1)*x0^2 + (q^4*t^3 - q^3*t^2 - q^2*t + q*t^2 - q*t + q - t + 1)*x0*x1 + (t^2 - 2*t + 1)*x1^2 + (q^4*t^3 - q^3*t^2 - q^2*t + q)*x0*x2 + (q^2*t^2 - q^2*t - q*t + q)*x1*x2\n '
(P, q, t, n, R, x) = _check_muqt(mu, q, t, pi)
res = 0
for a in n:
weight = a.weight()
res += ((((q ** a.maj()) * (t ** a.coinv())) * a.coeff_integral(q, t)) * prod(((x[i] ** weight[i]) for i in range(len(weight)))))
return res
|
def Ht(mu, q=None, t=None, pi=None):
"\n Return the symmetric Macdonald polynomial using the Haiman,\n Haglund, and Loehr formula.\n\n Note that if both `q` and `t` are specified, then they must have the\n same parent.\n\n REFERENCE:\n\n - J. Haglund, M. Haiman, N. Loehr.\n *A combinatorial formula for non-symmetric Macdonald polynomials*.\n :arxiv:`math/0601693v3`.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.ns_macdonald import Ht\n sage: HHt = SymmetricFunctions(QQ['q','t'].fraction_field()).macdonald().Ht()\n sage: Ht([0,0,1])\n x0 + x1 + x2\n sage: HHt([1]).expand(3)\n x0 + x1 + x2\n sage: Ht([0,0,2])\n x0^2 + (q + 1)*x0*x1 + x1^2 + (q + 1)*x0*x2 + (q + 1)*x1*x2 + x2^2\n sage: HHt([2]).expand(3)\n x0^2 + (q + 1)*x0*x1 + x1^2 + (q + 1)*x0*x2 + (q + 1)*x1*x2 + x2^2\n "
(P, q, t, n, R, x) = _check_muqt(mu, q, t, pi)
res = 0
for a in n:
weight = a.weight()
res += (((q ** a.maj()) * (t ** a.inv())) * prod(((x[i] ** weight[i]) for i in range(len(weight)))))
return res
|
class SymmetricFunctionAlgebra_orthogonal(sfa.SymmetricFunctionAlgebra_generic):
'\n The orthogonal symmetric function basis (or orthogonal basis, to be short).\n\n The orthogonal basis `\\{ o_{\\lambda} \\}` where `\\lambda` is taken over\n all partitions is defined by the following change of basis with the\n Schur functions:\n\n .. MATH::\n\n s_{\\lambda} = \\sum_{\\mu} \\left( \\sum_{\\nu \\in H} c^{\\lambda}_{\\mu\\nu}\n \\right) o_{\\mu}\n\n where `H` is the set of all partitions with even-width rows and\n `c^{\\lambda}_{\\mu\\nu}` is the usual Littlewood-Richardson (LR)\n coefficients. By the properties of LR coefficients, this can be shown to\n be a upper unitriangular change of basis.\n\n .. NOTE::\n\n This is only a filtered basis, not a `\\ZZ`-graded basis. However this\n does respect the induced `(\\ZZ/2\\ZZ)`-grading.\n\n INPUT:\n\n - ``Sym`` -- an instance of the ring of the symmetric functions\n\n REFERENCES:\n\n - [ChariKleber2000]_\n - [KoikeTerada1987]_\n - [ShimozonoZabrocki2006]_\n\n EXAMPLES:\n\n Here are the first few orthogonal symmetric functions, in various bases::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: o = Sym.o()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n\n sage: p(o([1]))\n p[1]\n sage: m(o([1]))\n m[1]\n sage: e(o([1]))\n e[1]\n sage: h(o([1]))\n h[1]\n sage: s(o([1]))\n s[1]\n\n sage: p(o([2]))\n -p[] + 1/2*p[1, 1] + 1/2*p[2]\n sage: m(o([2]))\n -m[] + m[1, 1] + m[2]\n sage: e(o([2]))\n -e[] + e[1, 1] - e[2]\n sage: h(o([2]))\n -h[] + h[2]\n sage: s(o([2]))\n -s[] + s[2]\n\n sage: p(o([3]))\n -p[1] + 1/6*p[1, 1, 1] + 1/2*p[2, 1] + 1/3*p[3]\n sage: m(o([3]))\n -m[1] + m[1, 1, 1] + m[2, 1] + m[3]\n sage: e(o([3]))\n -e[1] + e[1, 1, 1] - 2*e[2, 1] + e[3]\n sage: h(o([3]))\n -h[1] + h[3]\n sage: s(o([3]))\n -s[1] + s[3]\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: o = Sym.o()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: p = Sym.p()\n sage: m(o([4]))\n -m[1, 1] + m[1, 1, 1, 1] - m[2] + m[2, 1, 1] + m[2, 2] + m[3, 1] + m[4]\n sage: e(o([4]))\n -e[1, 1] + e[1, 1, 1, 1] + e[2] - 3*e[2, 1, 1] + e[2, 2] + 2*e[3, 1] - e[4]\n sage: h(o([4]))\n -h[2] + h[4]\n sage: s(o([4]))\n -s[2] + s[4]\n\n Some examples of conversions the other way::\n\n sage: o(h[3])\n o[1] + o[3]\n sage: o(e[3])\n o[1, 1, 1]\n sage: o(m[2,1])\n o[1] - 2*o[1, 1, 1] + o[2, 1]\n sage: o(p[3])\n o[1, 1, 1] - o[2, 1] + o[3]\n\n Some multiplication::\n\n sage: o([2]) * o([1,1])\n o[1, 1] + o[2] + o[2, 1, 1] + o[3, 1]\n sage: o([2,1,1]) * o([2])\n o[1, 1] + o[1, 1, 1, 1] + 2*o[2, 1, 1] + o[2, 2] + o[2, 2, 1, 1]\n + o[3, 1] + o[3, 1, 1, 1] + o[3, 2, 1] + o[4, 1, 1]\n sage: o([1,1]) * o([2,1])\n o[1] + o[1, 1, 1] + 2*o[2, 1] + o[2, 1, 1, 1] + o[2, 2, 1]\n + o[3] + o[3, 1, 1] + o[3, 2]\n\n Examples of the Hopf algebra structure::\n\n sage: o([1]).antipode()\n -o[1]\n sage: o([2]).antipode()\n -o[] + o[1, 1]\n sage: o([1]).coproduct()\n o[] # o[1] + o[1] # o[]\n sage: o([2]).coproduct()\n o[] # o[] + o[] # o[2] + o[1] # o[1] + o[2] # o[]\n sage: o([1]).counit()\n 0\n sage: o.one().counit()\n 1\n '
def __init__(self, Sym):
'\n Initialize ``self``.\n\n TESTS::\n\n sage: o = SymmetricFunctions(QQ).o()\n sage: TestSuite(o).run()\n '
sfa.SymmetricFunctionAlgebra_generic.__init__(self, Sym, 'orthogonal', 'o', graded=False)
self._s = Sym.schur()
M = self._s.module_morphism(self._s_to_o_on_basis, codomain=self, triangular='upper', unitriangular=True)
M.register_as_coercion()
Mi = self.module_morphism(self._o_to_s_on_basis, codomain=self._s, triangular='upper', unitriangular=True)
Mi.register_as_coercion()
@cached_method
def _o_to_s_on_basis(self, lam):
'\n Return the orthogonal symmetric function ``o[lam]`` expanded in\n the Schur basis, where ``lam`` is a partition.\n\n TESTS:\n\n Check that this is the inverse::\n\n sage: o = SymmetricFunctions(QQ).o()\n sage: s = SymmetricFunctions(QQ).s()\n sage: all(o(s(o[la])) == o[la] for i in range(5) for la in Partitions(i))\n True\n sage: all(s(o(s[la])) == s[la] for i in range(5) for la in Partitions(i))\n True\n '
R = self.base_ring()
n = sum(lam)
return self._s._from_dict({mu: R.sum(((((- 1) ** j) * lrcalc.lrcoef_unsafe(lam, mu, nu)) for nu in Partitions((2 * j)) if all(((nu.arm_length(i, i) == (nu.leg_length(i, i) + 1)) for i in range(nu.frobenius_rank()))))) for j in range(((n // 2) + 1)) for mu in Partitions((n - (2 * j)))})
@cached_method
def _s_to_o_on_basis(self, lam):
'\n Return the Schur symmetric function ``s[lam]`` expanded in\n the orthogonal basis, where ``lam`` is a partition.\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``s[lam]`` in the orthogonal basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: o = Sym.orthogonal()\n sage: o._s_to_o_on_basis(Partition([]))\n o[]\n sage: o._s_to_o_on_basis(Partition([4,2,1]))\n o[1] + 2*o[2, 1] + o[2, 2, 1] + o[3]\n + o[3, 1, 1] + o[3, 2] + o[4, 1] + o[4, 2, 1]\n sage: s(o._s_to_o_on_basis(Partition([3,1]))) == s[3,1]\n True\n '
R = self.base_ring()
n = sum(lam)
return self._from_dict({mu: R.sum((lrcalc.lrcoef_unsafe(lam, mu, [(2 * x) for x in nu]) for nu in Partitions(j))) for j in range(((n // 2) + 1)) for mu in Partitions((n - (2 * j)))})
|
class SymmetricFunctionAlgebra_orthotriang(sfa.SymmetricFunctionAlgebra_generic):
class Element(sfa.SymmetricFunctionAlgebra_generic.Element):
pass
def __init__(self, Sym, base, scalar, prefix, basis_name, leading_coeff=None):
'\n Initialization of the symmetric function algebra defined via orthotriangular rules.\n\n INPUT:\n\n - ``self`` -- a basis determined by an orthotriangular definition\n - ``Sym`` -- ring of symmetric functions\n - ``base`` -- an instance of a basis of the ring of symmetric functions\n (e.g. the Schur functions)\n - ``scalar`` -- a function ``zee`` on partitions. The function\n ``zee`` determines the scalar product on the power sum basis\n with normalization `\\langle p_{\\mu}, p_{\\mu} \\rangle =\n \\mathrm{zee}(\\mu)`.\n - ``prefix`` -- the prefix used to display the basis\n - ``basis_name`` -- the name used for the basis\n\n .. NOTE::\n\n The base ring is required to be a `\\QQ`-algebra for this\n method to be usable, since the scalar product is defined by\n its values on the power sum basis.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, \'s\', \'Schur\'); s\n Symmetric Functions over Rational Field in the Schur basis\n\n TESTS::\n\n sage: TestSuite(s).run(elements = [s[1,1]+2*s[2], s[1]+3*s[1,1]])\n sage: TestSuite(s).run(skip = ["_test_associativity", "_test_prod"]) # long time (7s on sage.math, 2011)\n\n Note: ``s.an_element()`` is of degree 4; so we skip\n ``_test_associativity`` and ``_test_prod`` which involve\n (currently?) expensive calculations up to degree 12.\n '
self._sym = Sym
self._sf_base = base
self._scalar = scalar
self._leading_coeff = leading_coeff
sfa.SymmetricFunctionAlgebra_generic.__init__(self, Sym, prefix=prefix, basis_name=basis_name)
self._self_to_base_cache = {}
self._base_to_self_cache = {}
self.register_coercion(SetMorphism(Hom(base, self), self._base_to_self))
base.register_coercion(SetMorphism(Hom(self, base), self._self_to_base))
def _base_to_self(self, x):
"\n Coerce a symmetric function in base ``x`` into ``self``.\n\n INPUT:\n\n - ``self`` -- a basis determined by an orthotriangular definition\n - ``x`` -- an element of the basis `base` to which ``self`` is triangularly related\n\n OUTPUT:\n\n - an element of ``self`` equivalent to ``x``\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')\n sage: s._base_to_self(m([2,1]))\n -2*s[1, 1, 1] + s[2, 1]\n "
return self._from_cache(x, self._base_cache, self._base_to_self_cache)
def _self_to_base(self, x):
"\n Coerce a symmetric function in ``self`` into base ``x``.\n\n INPUT:\n\n - ``self`` -- a basis determined by an orthotriangular definition\n - ``x`` -- an element of ``self`` as a basis of the ring of symmetric functions.\n\n OUTPUT:\n\n - the element ``x`` expressed in the basis to which ``self`` is triangularly related\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')\n sage: s._self_to_base(s([2,1]))\n 2*m[1, 1, 1] + m[2, 1]\n "
return self._sf_base._from_cache(x, self._base_cache, self._self_to_base_cache)
def _base_cache(self, n):
"\n Computes the change of basis between ``self`` and base for the\n homogeneous component of size ``n``\n\n INPUT:\n\n - ``self`` -- a basis determined by an orthotriangular definition\n - ``n`` -- a nonnegative integer\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')\n sage: s._base_cache(2)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(s._base_to_self_cache[2])\n [([1, 1], [([1, 1], 1)]), ([2], [([1, 1], -1), ([2], 1)])]\n sage: l(s._self_to_base_cache[2])\n [([1, 1], [([1, 1], 1)]), ([2], [([1, 1], 1), ([2], 1)])]\n "
if (n in self._self_to_base_cache):
return
else:
self._self_to_base_cache[n] = {}
self._gram_schmidt(n, self._sf_base, self._scalar, self._self_to_base_cache, leading_coeff=self._leading_coeff, upper_triangular=True)
self._invert_morphism(n, self.base_ring(), self._self_to_base_cache, self._base_to_self_cache, to_other_function=self._to_base)
def _to_base(self, part):
"\n Return a function which takes in a partition `\\mu` and returns the\n coefficient of a partition in the expansion of ``self`` `(part)` in base.\n\n INPUT:\n\n - ``self`` -- a basis determined by an orthotriangular definition\n - ``part`` -- a partition\n\n .. note::\n\n We assume that self._gram_schmidt has been called before\n self._to_base is called.\n\n OUTPUT:\n\n - a function which accepts a partition ``mu`` and returns the coefficients\n in the expansion of ``self(part)`` in the triangularly related basis.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')\n sage: m(s([2,1]))\n 2*m[1, 1, 1] + m[2, 1]\n sage: f = s._to_base(Partition([2,1]))\n sage: [f(p) for p in Partitions(3)]\n [0, 1, 2]\n "
f = (lambda mu: self._self_to_base_cache[part].get(mu, 0))
return f
def product(self, left, right):
"\n Return ``left`` * ``right`` by converting both to the base and then\n converting back to ``self``.\n\n INPUT:\n\n - ``self`` -- a basis determined by an orthotriangular definition\n - ``left``, ``right`` -- elements in ``self``\n\n OUTPUT:\n\n - the expansion of the product of ``left`` and ``right`` in the basis ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur functions')\n sage: s([1])*s([2,1]) #indirect doctest\n s[2, 1, 1] + s[2, 2] + s[3, 1]\n "
return self((self._sf_base(left) * self._sf_base(right)))
|
class SymmetricFunctionAlgebra_power(multiplicative.SymmetricFunctionAlgebra_multiplicative):
def __init__(self, Sym):
"\n A class for methods associated to the power sum basis of the symmetric functions\n\n INPUT:\n\n - ``self`` -- the power sum basis of the symmetric functions\n - ``Sym`` -- an instance of the ring of symmetric functions\n\n TESTS::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p == loads(dumps(p))\n True\n sage: TestSuite(p).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])\n sage: TestSuite(p).run(elements = [p[1,1]+p[2], p[1]+2*p[1,1]])\n "
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, 'powersum', 'p')
def coproduct_on_generators(self, i):
'\n Return coproduct on generators for power sums `p_i`\n (for `i > 0`).\n\n The elements `p_i` are primitive elements.\n\n INPUT:\n\n - ``self`` -- the power sum basis of the symmetric functions\n - ``i`` -- a positive integer\n\n OUTPUT:\n\n - the result of the coproduct on the generator `p(i)`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.powersum()\n sage: p.coproduct_on_generators(2)\n p[] # p[2] + p[2] # p[]\n '
Pi = Partition([i])
P0 = Partition([])
T = self.tensor_square()
return T.sum_of_monomials([(Pi, P0), (P0, Pi)])
def antipode_on_basis(self, partition):
'\n Return the antipode of ``self[partition]``.\n\n The antipode on the generator `p_i` (for `i > 0`) is `-p_i`,\n and the antipode on `p_\\mu` is `(-1)^{length(\\mu)} p_\\mu`.\n\n INPUT:\n\n - ``self`` -- the power sum basis of the symmetric functions\n - ``partition`` -- a partition\n\n OUTPUT:\n\n - the result of the antipode on ``self(partition)``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p()\n sage: p.antipode_on_basis([2])\n -p[2]\n sage: p.antipode_on_basis([3])\n -p[3]\n sage: p.antipode_on_basis([2,2])\n p[2, 2]\n sage: p.antipode_on_basis([])\n p[]\n '
if ((len(partition) % 2) == 0):
return self[partition]
return (- self[partition])
def bottom_schur_function(self, partition, degree=None):
'\n Return the least-degree component of ``s[partition]``,\n where ``s`` denotes the Schur basis of the symmetric\n functions, and the grading is not the usual grading on the\n symmetric functions but rather the grading which gives\n every `p_i` degree `1`.\n\n This least-degree component has its degree equal to the\n Frobenius rank of ``partition``, while the degree with respect\n to the usual grading is still the size of ``partition``.\n\n This method requires the base ring to be a (commutative)\n `\\QQ`-algebra. This restriction is unavoidable, since\n the least-degree component (in general) has noninteger\n coefficients in all classical bases of the symmetric\n functions.\n\n The optional keyword ``degree`` allows taking any\n homogeneous component rather than merely the least-degree\n one. Specifically, if ``degree`` is set, then the\n ``degree``-th component will be returned.\n\n REFERENCES:\n\n .. [ClSt03] Peter Clifford, Richard P. Stanley,\n *Bottom Schur functions*.\n :arxiv:`math/0311382v2`.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p()\n sage: p.bottom_schur_function([2,2,1])\n -1/6*p[3, 2] + 1/4*p[4, 1]\n sage: p.bottom_schur_function([2,1])\n -1/3*p[3]\n sage: p.bottom_schur_function([3])\n 1/3*p[3]\n sage: p.bottom_schur_function([1,1,1])\n 1/3*p[3]\n sage: p.bottom_schur_function(Partition([1,1,1]))\n 1/3*p[3]\n sage: p.bottom_schur_function([2,1], degree=1)\n -1/3*p[3]\n sage: p.bottom_schur_function([2,1], degree=2)\n 0\n sage: p.bottom_schur_function([2,1], degree=3)\n 1/3*p[1, 1, 1]\n sage: p.bottom_schur_function([2,2,1], degree=3)\n 1/8*p[2, 2, 1] - 1/6*p[3, 1, 1]\n '
from sage.combinat.partition import _Partitions
s = self.realization_of().schur()
partition = _Partitions(partition)
if (degree is None):
degree = partition.frobenius_rank()
s_partition = self(s[partition])
return self.sum_of_terms([(p, coeff) for (p, coeff) in s_partition if (len(p) == degree)], distinct=True)
def eval_at_permutation_roots_on_generators(self, k, rho):
'\n Evaluate `p_k` at eigenvalues of permutation matrix.\n\n This function evaluates a symmetric function ``p([k])``\n at the eigenvalues of a permutation matrix with cycle\n structure ``\\rho``.\n\n This function evaluates a `p_k` at the roots of unity\n\n .. MATH::\n\n \\Xi_{\\rho_1},\\Xi_{\\rho_2},\\ldots,\\Xi_{\\rho_\\ell}\n\n where\n\n .. MATH::\n\n \\Xi_{m} = 1,\\zeta_m,\\zeta_m^2,\\ldots,\\zeta_m^{m-1}\n\n and `\\zeta_m` is an `m` root of unity.\n This is characterized by `p_k[ A , B ] = p_k[A] + p_k[B]` and\n `p_k[ \\Xi_m ] = 0` unless `m` divides `k` and `p_{rm}[\\Xi_m]=m`.\n\n INPUT:\n\n - ``k`` -- a non-negative integer\n - ``rho`` -- a partition or a list of non-negative integers\n\n OUTPUT:\n\n - an element of the base ring\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p.eval_at_permutation_roots_on_generators(3, [6])\n 0\n sage: p.eval_at_permutation_roots_on_generators(3, [3])\n 3\n sage: p.eval_at_permutation_roots_on_generators(3, [1])\n 1\n sage: p.eval_at_permutation_roots_on_generators(3, [3,3])\n 6\n sage: p.eval_at_permutation_roots_on_generators(3, [1,1,1,1,1])\n 5\n '
return self.base_ring().sum(((d * list(rho).count(d)) for d in divisors(k)))
class Element(classical.SymmetricFunctionAlgebra_classical.Element):
def omega(self):
'\n Return the image of ``self`` under the omega automorphism.\n\n The *omega automorphism* is defined to be the unique algebra\n endomorphism `\\omega` of the ring of symmetric functions that\n satisfies `\\omega(e_k) = h_k` for all positive integers `k`\n (where `e_k` stands for the `k`-th elementary symmetric\n function, and `h_k` stands for the `k`-th complete homogeneous\n symmetric function). It furthermore is a Hopf algebra\n endomorphism and an involution, and it is also known as the\n *omega involution*. It sends the power-sum symmetric function\n `p_k` to `(-1)^{k-1} p_k` for every positive integer `k`.\n\n The images of some bases under the omega automorphism are given by\n\n .. MATH::\n\n \\omega(e_{\\lambda}) = h_{\\lambda}, \\qquad\n \\omega(h_{\\lambda}) = e_{\\lambda}, \\qquad\n \\omega(p_{\\lambda}) = (-1)^{|\\lambda| - \\ell(\\lambda)}\n p_{\\lambda}, \\qquad\n \\omega(s_{\\lambda}) = s_{\\lambda^{\\prime}},\n\n where `\\lambda` is any partition, where `\\ell(\\lambda)` denotes\n the length (:meth:`~sage.combinat.partition.Partition.length`)\n of the partition `\\lambda`, where `\\lambda^{\\prime}` denotes the\n conjugate partition\n (:meth:`~sage.combinat.partition.Partition.conjugate`) of\n `\\lambda`, and where the usual notations for bases are used\n (`e` = elementary, `h` = complete homogeneous, `p` = powersum,\n `s` = Schur).\n\n :meth:`omega_involution()` is a synonym for the :meth:`omega()`\n method.\n\n OUTPUT:\n\n - the image of ``self`` under the omega automorphism\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: a = p([2,1]); a\n p[2, 1]\n sage: a.omega()\n -p[2, 1]\n sage: p([]).omega()\n p[]\n sage: p(0).omega()\n 0\n sage: p = SymmetricFunctions(ZZ).p()\n sage: (p([3,1,1]) - 2 * p([2,1])).omega()\n 2*p[2, 1] + p[3, 1, 1]\n '
f = (lambda part, coeff: (part, (((- 1) ** (sum(part) - len(part))) * coeff)))
return self.map_item(f)
omega_involution = omega
def scalar(self, x, zee=None):
'\n Return the standard scalar product of ``self`` and ``x``.\n\n INPUT:\n\n - ``x`` -- a power sum symmetric function\n - ``zee`` -- (default: uses standard ``zee`` function) optional\n input specifying the scalar product on the power sum basis with\n normalization `\\langle p_{\\mu}, p_{\\mu} \\rangle =\n \\mathrm{zee}(\\mu)`. ``zee`` should be a function on partitions.\n\n Note that the power-sum symmetric functions are orthogonal under\n this scalar product. With the default value of ``zee``, the value\n of `\\langle p_{\\lambda}, p_{\\lambda} \\rangle` is given by the\n size of the centralizer in `S_n` of a permutation of cycle\n type `\\lambda`.\n\n OUTPUT:\n\n - the standard scalar product between ``self`` and ``x``, or, if\n the optional parameter ``zee`` is specified, then the scalar\n product with respect to the normalization `\\langle p_{\\mu},\n p_{\\mu} \\rangle = \\mathrm{zee}(\\mu)` with the power sum basis\n elements being orthogonal\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p4 = Partitions(4)\n sage: matrix([ [p(a).scalar(p(b)) for a in p4] for b in p4])\n [ 4 0 0 0 0]\n [ 0 3 0 0 0]\n [ 0 0 8 0 0]\n [ 0 0 0 4 0]\n [ 0 0 0 0 24]\n sage: p(0).scalar(p(1))\n 0\n sage: p(1).scalar(p(2))\n 2\n\n sage: zee = lambda x : 1\n sage: matrix( [[p[la].scalar(p[mu], zee) for la in Partitions(3)] for mu in Partitions(3)])\n [1 0 0]\n [0 1 0]\n [0 0 1]\n '
parent = self.parent()
x = parent(x)
if (zee is None):
f = (lambda part1, part2: sfa.zee(part1))
else:
f = (lambda part1, part2: zee(part1))
return parent._apply_multi_module_morphism(self, x, f, orthogonal=True)
def _derivative(self, part):
"\n Return the 'derivative' of ``p([part])`` with respect to ``p([1])``\n (where ``p([part])`` is regarded as a polynomial in the\n indeterminates ``p([i])``).\n\n INPUT:\n\n - ``part`` -- a partition\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: a = p([2,1])\n sage: a._derivative(Partition([2,1]))\n p[2]\n sage: a._derivative(Partition([1,1,1]))\n 3*p[1, 1]\n "
p = self.parent()
if (1 not in part):
return p.zero()
else:
return (len([i for i in part if (i == 1)]) * p(part[:(- 1)]))
def _derivative_with_respect_to_p1(self):
"\n Return the 'derivative' of a symmetric function in the power sum\n basis with respect to ``p([1])`` (where ``p([part])`` is regarded\n as a polynomial in the indeterminates ``p([i])``).\n\n On the Frobenius image of an `S_n`-module, the resulting character\n is the Frobenius image of the restriction of this module\n to `S_{n-1}`.\n\n OUTPUT:\n\n - a symmetric function (in the power sum basis) of degree one\n smaller than ``self``, obtained by differentiating ``self``\n by `p_1`.\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: a = p([2,1,1,1])\n sage: a._derivative_with_respect_to_p1()\n 3*p[2, 1, 1]\n sage: a = p([3,2])\n sage: a._derivative_with_respect_to_p1()\n 0\n sage: p(0)._derivative_with_respect_to_p1()\n 0\n sage: p(1)._derivative_with_respect_to_p1()\n 0\n sage: p([1])._derivative_with_respect_to_p1()\n p[]\n sage: f = p[1] + p[2,1]\n sage: f._derivative_with_respect_to_p1()\n p[] + p[2]\n "
p = self.parent()
if (self == p.zero()):
return self
return p._apply_module_morphism(self, self._derivative)
def frobenius(self, n):
'\n Return the image of the symmetric function ``self`` under the\n `n`-th Frobenius operator.\n\n The `n`-th Frobenius operator `\\mathbf{f}_n` is defined to be the\n map from the ring of symmetric functions to itself that sends\n every symmetric function `P(x_1, x_2, x_3, \\ldots)` to\n `P(x_1^n, x_2^n, x_3^n, \\ldots)`. This operator `\\mathbf{f}_n`\n is a Hopf algebra endomorphism, and satisfies\n\n .. MATH::\n\n \\mathbf{f}_n m_{(\\lambda_1, \\lambda_2, \\lambda_3, \\ldots)} =\n m_{(n\\lambda_1, n\\lambda_2, n\\lambda_3, \\ldots)}\n\n for every partition `(\\lambda_1, \\lambda_2, \\lambda_3, \\ldots)`\n (where `m` means the monomial basis). Moreover,\n `\\mathbf{f}_n (p_r) = p_{nr}` for every positive integer `r` (where\n `p_k` denotes the `k`-th powersum symmetric function).\n\n The `n`-th Frobenius operator is also called the `n`-th\n Frobenius endomorphism. It is not related to the Frobenius map\n which connects the ring of symmetric functions with the\n representation theory of the symmetric group.\n\n The `n`-th Frobenius operator is also the `n`-th Adams operator\n of the `\\Lambda`-ring of symmetric functions over the integers.\n\n The `n`-th Frobenius operator can also be described via plethysm:\n Every symmetric function `P` satisfies\n `\\mathbf{f}_n(P) = p_n \\circ P = P \\circ p_n`,\n where `p_n` is the `n`-th powersum symmetric function, and `\\circ`\n denotes (outer) plethysm.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n The result of applying the `n`-th Frobenius operator (on the ring\n of symmetric functions) to ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: p = Sym.p()\n sage: p[3].frobenius(2)\n p[6]\n sage: p[4,2,1].frobenius(3)\n p[12, 6, 3]\n sage: p([]).frobenius(4)\n p[]\n sage: p[3].frobenius(1)\n p[3]\n sage: (p([3]) - p([2]) + p([])).frobenius(3)\n p[] - p[6] + p[9]\n\n TESTS:\n\n Let us check that this method on the powersum basis gives the\n same result as the implementation in :mod:`sage.combinat.sf.sfa`\n on the complete homogeneous basis::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p(); h = Sym.h()\n sage: all( h(p(lam)).frobenius(3) == h(p(lam).frobenius(3))\n ....: for lam in Partitions(3) )\n True\n sage: all( p(h(lam)).frobenius(2) == p(h(lam).frobenius(2))\n ....: for lam in Partitions(4) )\n True\n\n .. SEEALSO::\n\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.plethysm`\n '
dct = {lam.stretch(n): coeff for (lam, coeff) in self.monomial_coefficients().items()}
return self.parent()._from_dict(dct)
adams_operation = frobenius
def verschiebung(self, n):
'\n Return the image of the symmetric function ``self`` under the\n `n`-th Verschiebung operator.\n\n The `n`-th Verschiebung operator `\\mathbf{V}_n` is defined to be\n the unique algebra endomorphism `V` of the ring of symmetric\n functions that satisfies `V(h_r) = h_{r/n}` for every positive\n integer `r` divisible by `n`, and satisfies `V(h_r) = 0` for\n every positive integer `r` not divisible by `n`. This operator\n `\\mathbf{V}_n` is a Hopf algebra endomorphism. For every\n nonnegative integer `r` with `n \\mid r`, it satisfies\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = h_{r/n},\n \\quad \\mathbf{V}_n(p_r) = n p_{r/n},\n \\quad \\mathbf{V}_n(e_r) = (-1)^{r - r/n} e_{r/n}\n\n (where `h` is the complete homogeneous basis, `p` is the\n powersum basis, and `e` is the elementary basis). For every\n nonnegative integer `r` with `n \\nmid r`, it satisfes\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = \\mathbf{V}_n(p_r) = \\mathbf{V}_n(e_r) = 0.\n\n The `n`-th Verschiebung operator is also called the `n`-th\n Verschiebung endomorphism. Its name derives from the Verschiebung\n (German for "shift") endomorphism of the Witt vectors.\n\n The `n`-th Verschiebung operator is adjoint to the `n`-th\n Frobenius operator (see :meth:`frobenius` for its definition)\n with respect to the Hall scalar product (:meth:`scalar`).\n\n The action of the `n`-th Verschiebung operator on the Schur basis\n can also be computed explicitly. The following (probably clumsier\n than necessary) description can be obtained by solving exercise\n 7.61 in Stanley\'s [STA]_.\n\n Let `\\lambda` be a partition. Let `n` be a positive integer. If\n the `n`-core of `\\lambda` is nonempty, then\n `\\mathbf{V}_n(s_\\lambda) = 0`. Otherwise, the following method\n computes `\\mathbf{V}_n(s_\\lambda)`: Write the partition `\\lambda`\n in the form `(\\lambda_1, \\lambda_2, \\ldots, \\lambda_{ns})` for some\n nonnegative integer `s`. (If `n` does not divide the length of\n `\\lambda`, then this is achieved by adding trailing zeroes to\n `\\lambda`.) Set `\\beta_i = \\lambda_i + ns - i` for every\n `s \\in \\{ 1, 2, \\ldots, ns \\}`. Then,\n `(\\beta_1, \\beta_2, \\ldots, \\beta_{ns})` is a strictly decreasing\n sequence of nonnegative integers. Stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `-1 - \\beta_i` modulo `n`. Let `\\xi` be the sign of the\n permutation that is used for this sorting. Let `\\psi` be the sign\n of the permutation that is used to stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `i - 1` modulo `n`. (Notice that `\\psi = (-1)^{n(n-1)s(s-1)/4}`.)\n Then, `\\mathbf{V}_n(s_\\lambda) = \\xi \\psi \\prod_{i = 0}^{n - 1}\n s_{\\lambda^{(i)}}`, where\n `(\\lambda^{(0)}, \\lambda^{(1)}, \\ldots, \\lambda^{(n - 1)})`\n is the `n`-quotient of `\\lambda`.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n The result of applying the `n`-th Verschiebung operator (on the\n ring of symmetric functions) to ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: p = Sym.p()\n sage: p[3].verschiebung(2)\n 0\n sage: p[4].verschiebung(4)\n 4*p[1]\n\n The Verschiebung endomorphisms are multiplicative::\n\n sage: all( all( p(lam).verschiebung(2) * p(mu).verschiebung(2)\n ....: == (p(lam) * p(mu)).verschiebung(2)\n ....: for mu in Partitions(4) )\n ....: for lam in Partitions(4) )\n True\n\n Testing the adjointness between the Frobenius operators\n `\\mathbf{f}_n` and the Verschiebung operators\n `\\mathbf{V}_n`::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p()\n sage: all( all( p(lam).verschiebung(2).scalar(p(mu))\n ....: == p(lam).scalar(p(mu).frobenius(2))\n ....: for mu in Partitions(2) )\n ....: for lam in Partitions(4) )\n True\n\n TESTS:\n\n Let us check that this method on the powersum basis gives the\n same result as the implementation in :mod:`sage.combinat.sf.sfa`\n on the monomial basis::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p(); m = Sym.m()\n sage: all( m(p(lam)).verschiebung(3) == m(p(lam).verschiebung(3))\n ....: for lam in Partitions(6) )\n True\n sage: all( p(m(lam)).verschiebung(2) == p(m(lam).verschiebung(2))\n ....: for lam in Partitions(4) )\n True\n '
parent = self.parent()
p_coords_of_self = self.monomial_coefficients().items()
dct = {Partition([(i // n) for i in lam]): (coeff * (n ** len(lam))) for (lam, coeff) in p_coords_of_self if all((((i % n) == 0) for i in lam))}
result_in_p_basis = parent._from_dict(dct)
return parent(result_in_p_basis)
def expand(self, n, alphabet='x'):
"\n Expand the symmetric function ``self`` as a symmetric polynomial\n in ``n`` variables.\n\n INPUT:\n\n - ``n`` -- a nonnegative integer\n\n - ``alphabet`` -- (default: ``'x'``) a variable for the expansion\n\n OUTPUT:\n\n A monomial expansion of ``self`` in the `n` variables\n labelled by ``alphabet``.\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: a = p([2])\n sage: a.expand(2)\n x0^2 + x1^2\n sage: a.expand(3, alphabet=['a','b','c'])\n a^2 + b^2 + c^2\n sage: p([2,1,1]).expand(2)\n x0^4 + 2*x0^3*x1 + 2*x0^2*x1^2 + 2*x0*x1^3 + x1^4\n sage: p([7]).expand(4)\n x0^7 + x1^7 + x2^7 + x3^7\n sage: p([7]).expand(4,alphabet='t')\n t0^7 + t1^7 + t2^7 + t3^7\n sage: p([7]).expand(4,alphabet='x,y,z,t')\n x^7 + y^7 + z^7 + t^7\n sage: p(1).expand(4)\n 1\n sage: p(0).expand(4)\n 0\n sage: (p([]) + 2*p([1])).expand(3)\n 2*x0 + 2*x1 + 2*x2 + 1\n sage: p([1]).expand(0)\n 0\n sage: (3*p([])).expand(0)\n 3\n "
if (n == 0):
return self.counit()
condition = (lambda part: False)
return self._expand(condition, n, alphabet)
def eval_at_permutation_roots(self, rho):
'\n Evaluate at eigenvalues of a permutation matrix.\n\n Evaluate an element of the power sum basis at the eigenvalues\n of a permutation matrix with cycle structure `\\rho`.\n\n This function evaluates an element at the roots of unity\n\n .. MATH::\n\n \\Xi_{\\rho_1},\\Xi_{\\rho_2},\\ldots,\\Xi_{\\rho_\\ell}\n\n where\n\n .. MATH::\n\n \\Xi_{m} = 1,\\zeta_m,\\zeta_m^2,\\ldots,\\zeta_m^{m-1}\n\n and `\\zeta_m` is an `m` root of unity.\n These roots of unity represent the eigenvalues of permutation\n matrix with cycle structure `\\rho`.\n\n INPUT:\n\n - ``rho`` -- a partition or a list of non-negative integers\n\n OUTPUT:\n\n - an element of the base ring\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p([3,3]).eval_at_permutation_roots([6])\n 0\n sage: p([3,3]).eval_at_permutation_roots([3])\n 9\n sage: p([3,3]).eval_at_permutation_roots([1])\n 1\n sage: p([3,3]).eval_at_permutation_roots([3,3])\n 36\n sage: p([3,3]).eval_at_permutation_roots([1,1,1,1,1])\n 25\n sage: (p[1]+p[2]+p[3]).eval_at_permutation_roots([3,2])\n 5\n '
p = self.parent()
R = self.base_ring()
on_basis = (lambda lam: R.prod((p.eval_at_permutation_roots_on_generators(k, rho) for k in lam)))
return p._apply_module_morphism(self, on_basis, R)
def principal_specialization(self, n=infinity, q=None):
'\n Return the principal specialization of a symmetric function.\n\n The *principal specialization* of order `n` at `q`\n is the ring homomorphism `ps_{n,q}` from the ring of\n symmetric functions to another commutative ring `R`\n given by `x_i \\mapsto q^{i-1}` for `i \\in \\{1,\\dots,n\\}`\n and `x_i \\mapsto 0` for `i > n`.\n Here, `q` is a given element of `R`, and we assume that\n the variables of our symmetric functions are\n `x_1, x_2, x_3, \\ldots`.\n (To be more precise, `ps_{n,q}` is a `K`-algebra\n homomorphism, where `K` is the base ring.)\n See Section 7.8 of [EnumComb2]_.\n\n The *stable principal specialization* at `q` is the ring\n homomorphism `ps_q` from the ring of symmetric functions\n to another commutative ring `R` given by\n `x_i \\mapsto q^{i-1}` for all `i`.\n This is well-defined only if the resulting infinite sums\n converge; thus, in particular, setting `q = 1` in the\n stable principal specialization is an invalid operation.\n\n INPUT:\n\n - ``n`` (default: ``infinity``) -- a nonnegative integer or\n ``infinity``, specifying whether to compute the principal\n specialization of order ``n`` or the stable principal\n specialization.\n\n - ``q`` (default: ``None``) -- the value to use for `q`; the\n default is to create a ring of polynomials in ``q``\n (or a field of rational functions in ``q``) over the\n given coefficient ring.\n\n We use the formulas from Proposition 7.8.3 of [EnumComb2]_:\n\n .. MATH::\n\n ps_{n,q}(p_\\lambda) = \\prod_i (1-q^{n\\lambda_i}) / (1-q^{\\lambda_i}),\n\n ps_{n,1}(p_\\lambda) = n^{\\ell(\\lambda)},\n\n ps_q(p_\\lambda) = 1 / \\prod_i (1-q^{\\lambda_i}),\n\n where `\\ell(\\lambda)` denotes the length of `\\lambda`,\n and where the products range from `i=1` to `i=\\ell(\\lambda)`.\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: x = p[8,7,3,1]\n sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic\n (q^24 - 1)*(q^21 - 1)*(q^9 - 1)/((q^8 - 1)*(q^7 - 1)*(q - 1))\n\n sage: x = 5*p[1,1,1] + 3*p[2,1] + 1\n sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic\n 5*(q^3 - 1)^3/(q - 1)^3 + 3*(q^6 - 1)*(q^3 - 1)/((q^2 - 1)*(q - 1)) + 1\n\n By default, we return a rational function in `q`::\n\n sage: x.principal_specialization(3)\n 8*q^6 + 18*q^5 + 36*q^4 + 38*q^3 + 36*q^2 + 18*q + 9\n\n If ``n`` is not given we return the stable principal specialization::\n\n sage: x.principal_specialization(q=var("q")) # needs sage.symbolic\n 3/((q^2 - 1)*(q - 1)) - 5/(q - 1)^3 + 1\n\n TESTS::\n\n sage: p.zero().principal_specialization(3)\n 0\n\n '
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q is None):
q = get_variable(self.base_ring(), 'q')
if (q == 1):
if (n == infinity):
raise ValueError('the stable principal specialization at q=1 is not defined')
f = (lambda partition: (n ** len(partition)))
elif (n == infinity):
f = (lambda partition: prod(((1 / (1 - (q ** part))) for part in partition)))
else:
from sage.rings.integer_ring import ZZ
ZZq = PolynomialRing(ZZ, 'q')
q_lim = ZZq.gen()
def f(partition):
denom = prod(((1 - (q ** part)) for part in partition))
try:
(~ denom)
rational = (prod(((1 - (q ** (n * part))) for part in partition)) / denom)
return q.parent()(rational)
except (ZeroDivisionError, NotImplementedError, TypeError):
quotient = ZZq(prod((((1 - (q_lim ** (n * part))) / (1 - (q_lim ** part))) for part in partition)))
return quotient.subs({q_lim: q})
return self.parent()._apply_module_morphism(self, f, q.parent())
def exponential_specialization(self, t=None, q=1):
'\n Return the exponential specialization of a\n symmetric function (when `q = 1`), or the\n `q`-exponential specialization (when `q \\neq 1`).\n\n The *exponential specialization* `ex` at `t` is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R`.\n It is defined whenever the base ring `K` is a\n `\\QQ`-algebra and `t` is an element of `R`.\n The easiest way to define it is by specifying its\n values on the powersum symmetric functions to be\n `p_1 = t` and `p_n = 0` for `n > 1`.\n Equivalently, on the homogeneous functions it is\n given by `ex(h_n) = t^n / n!`; see Proposition 7.8.4 of\n [EnumComb2]_.\n\n By analogy, the `q`-exponential specialization is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R` that\n depends on two elements `t` and `q` of `R` for which\n the elements `1 - q^i` for all positive integers `i`\n are invertible.\n It can be defined by specifying its values on the\n complete homogeneous symmetric functions to be\n\n .. MATH::\n\n ex_q(h_n) = t^n / [n]_q!,\n\n where `[n]_q!` is the `q`-factorial. Equivalently, for\n `q \\neq 1` and a homogeneous symmetric function `f` of\n degree `n`, we have\n\n .. MATH::\n\n ex_q(f) = (1-q)^n t^n ps_q(f),\n\n where `ps_q(f)` is the stable principal specialization of `f`\n (see :meth:`principal_specialization`).\n (See (7.29) in [EnumComb2]_.)\n\n The limit of `ex_q` as `q \\to 1` is `ex`.\n\n INPUT:\n\n - ``t`` (default: ``None``) -- the value to use for `t`;\n the default is to create a ring of polynomials in ``t``.\n\n - ``q`` (default: `1`) -- the value to use for `q`. If\n ``q`` is ``None``, then a ring (or fraction field) of\n polynomials in ``q`` is created.\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: x = p[8,7,3,1]\n sage: x.exponential_specialization()\n 0\n sage: x = p[3] + 5*p[1,1] + 2*p[1] + 1\n sage: x.exponential_specialization(t=var("t")) # needs sage.symbolic\n 5*t^2 + 2*t + 1\n\n We also support the `q`-exponential_specialization::\n\n sage: factor(p[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic\n (q - 1)^2*t^3/(q^2 + q + 1)\n\n TESTS::\n\n sage: p.zero().exponential_specialization()\n 0\n\n '
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q == 1):
if (t is None):
t = get_variable(self.base_ring(), 't')
def f(partition):
n = 0
for part in partition:
if (part != 1):
return 0
n += 1
return (t ** n)
return self.parent()._apply_module_morphism(self, f, t.parent())
if ((q is None) and (t is None)):
q = get_variable(self.base_ring(), 'q')
t = get_variable(q.parent(), 't')
elif (q is None):
q = get_variable(t.parent(), 'q')
elif (t is None):
t = get_variable(q.parent(), 't')
def f(partition):
n = 0
m = 1
for part in partition:
n += part
m *= (1 - (q ** part))
return ((((1 - q) ** n) * (t ** n)) / m)
return self.parent()._apply_module_morphism(self, f, t.parent())
|
class SymmetricFunctionAlgebra_schur(classical.SymmetricFunctionAlgebra_classical):
def __init__(self, Sym):
"\n A class for methods related to the Schur symmetric function basis\n\n INPUT:\n\n - ``self`` -- a Schur symmetric function basis\n - ``Sym`` -- an instance of the ring of the symmetric functions\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s == loads(dumps(s))\n True\n sage: TestSuite(s).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])\n sage: TestSuite(s).run(elements = [s[1,1]+s[2], s[1]+2*s[1,1]])\n "
classical.SymmetricFunctionAlgebra_classical.__init__(self, Sym, 'Schur', 's')
def _dual_basis_default(self):
'\n Returns the default value for ``self.dual_basis()``\n\n This method returns the dual basis to the Schur basis with respect to the standard\n scalar product. Since the Schur basis is self-dual, it returns itself.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: ds = s.dual_basis()\n sage: s is ds\n True\n\n sage: zee = lambda x : x.centralizer_size()\n sage: S = s.dual_basis(zee); S\n Dual basis to Symmetric Functions over Rational Field in the Schur basis\n sage: S[2,1].scalar(s[2,1])\n 1\n\n TESTS::\n\n sage: s._dual_basis_default() is s.dual_basis()\n True\n '
return self
def product_on_basis(self, left, right):
'\n Return the product of ``left`` and ``right``.\n\n INPUT:\n\n - ``self`` -- a Schur symmetric function basis\n - ``left``, ``right`` -- partitions\n\n OUTPUT:\n\n - an element of the Schur basis, the product of ``left`` and ``right``\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1]) + 1; a\n s[] + s[2, 1]\n sage: a^2 # indirect doctest\n s[] + 2*s[2, 1] + s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1]\n + 2*s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + s[4, 2]\n\n Examples failing with three different messages in symmetrica::\n\n sage: s[123,1]*s[1,1]\n s[123, 1, 1, 1] + s[123, 2, 1] + s[124, 1, 1] + s[124, 2]\n sage: s[123]*s[2,1]\n s[123, 2, 1] + s[124, 1, 1] + s[124, 2] + s[125, 1]\n sage: s[125]*s[3]\n s[125, 3] + s[126, 2] + s[127, 1] + s[128]\n\n ::\n\n sage: QQx.<x> = QQ[]\n sage: s = SymmetricFunctions(QQx).s()\n sage: a = x^2*s([2,1]) + 2*x; a\n 2*x*s[] + x^2*s[2, 1]\n sage: a^2\n 4*x^2*s[] + 4*x^3*s[2, 1] + x^4*s[2, 2, 1, 1] + x^4*s[2, 2, 2]\n + x^4*s[3, 1, 1, 1] + 2*x^4*s[3, 2, 1] + x^4*s[3, 3]\n + x^4*s[4, 1, 1] + x^4*s[4, 2]\n\n ::\n\n sage: 0*s([2,1])\n 0\n\n Example over a field with positive characteristic::\n\n sage: s[2,1]^2\n s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1]\n + s[3, 3] + s[4, 1, 1] + s[4, 2]\n sage: s = SymmetricFunctions(GF(2)).s()\n sage: s[2,1]^2\n s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + s[3, 3] + s[4, 1, 1] + s[4, 2]\n '
return self.element_class(self, convert_remove_zeroes(lrcalc.mult(left, right), self.base_ring()))
def coproduct_on_basis(self, mu):
"\n Returns the coproduct of ``self(mu)``.\n\n Here ``self`` is the basis of Schur functions in the ring of symmetric functions.\n\n INPUT:\n\n - ``self`` -- a Schur symmetric function basis\n - ``mu`` -- a partition\n\n OUTPUT:\n\n - the image of the ``mu``-th Schur function under the comultiplication of\n the Hopf algebra of symmetric functions; this is an element of the\n tensor square of the Schur basis\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: s.coproduct_on_basis([2])\n s[] # s[2] + s[1] # s[1] + s[2] # s[]\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ['t']).s()\n sage: s[2].coproduct() / 2\n 1/2*s[] # s[2] + 1/2*s[1] # s[1] + 1/2*s[2] # s[]\n "
T = self.tensor_square()
return T.element_class(T, convert_remove_zeroes(lrcalc.coprod(mu, all=1), self.base_ring()))
def _element_constructor_(self, x):
'\n Construct an element of ``self`` from ``x``.\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([[2,1],[1]])\n s[1, 1] + s[2]\n sage: s([[],[]])\n s[]\n '
try:
return self.skew_schur(x)
except ValueError:
return super()._element_constructor_(x)
def _repeated_bernstein_creation_operator_on_basis(self, la, nu):
'\n A Schur function indexed by a partition or zero from applying creation\n operators on `s(la)`.\n\n INPUT:\n\n - ``la`` -- a partition\n - ``nu`` -- list of lintegers\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).schur()\n sage: rbco = s._repeated_bernstein_creation_operator_on_basis\n sage: rbco(Partition([2,1]),[1])\n 0\n sage: rbco(Partition([2,1]),[2])\n s[2, 2, 1]\n sage: rbco(Partition([2,1]),[-2])\n s[1]\n sage: rbco(Partition([2,1]),[1, -2])\n s[1, 1]\n sage: rbco(Partition([2,1]),[1, 0])\n -s[1, 1, 1, 1]\n sage: rbco(Partition([2,1]),[-3, 0])\n s[]\n '
r = (len(nu) + len(la))
ga = [(a - b) for (a, b) in zip((nu + la.to_list()), range((- r), 0))]
if ((r == len(set(ga))) and (min(ga) > 0)):
m = sum((1 for i in range(len(ga)) for j in range(i, len(ga)) if (ga[i] < ga[j])))
ga.sort(reverse=True)
return (((- 1) ** m) * self([(a + b) for (a, b) in zip(ga, range((- r), 0))]))
return self.zero()
class Element(classical.SymmetricFunctionAlgebra_classical.Element):
def __pow__(self, n):
"\n Returns the naive powering of an instance of ``self``.\n\n INPUT:\n\n - ``self`` -- an element of the Schur symmetric function basis\n - ``n`` -- a nonnegative integer\n\n OUTPUT:\n\n - the ``n`-th power of an instance of ``self`` in the Schur basis\n\n See ``Monoids.Element.__pow__`` and ``Monoids.Element._pow_naive``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ['x']).s()\n sage: len(s([2,1])^8) # long time (~ 4 s)\n 1485\n sage: len(s([2,1])^9) # long time (~10 s)\n 2876\n\n Binary exponentiation does not seem to bring any speedup for\n Schur functions. This most likely is because of the\n explosion of the number of terms.\n\n # sage: s = SymmetricFunctions(QQ).s(); y = s([1])\n # sage: n = 24\n # sage: %timeit y**n # using binary exponentiation\n # 10 loops, best of 3: 1.22 s per loop\n # sage: %timeit prod(y for i in range(n))\n # 10 loops, best of 3: 1.06 s per loop\n\n With polynomial coefficients, this is actually much *slower*\n (although this should be profiled further; there seems to\n be an unreasonable number of polynomial multiplication involved,\n besides the fact that 1 * QQ['x'].one() currently involves a\n polynomial multiplication)\n\n # sage: sage: s = SymmetricFunctions(QQ['x']).s()\n # sage: y = s([2,1])\n # sage: %timeit y**7\n # 10 loops, best of 3: 18.9 s per loop\n # sage: %timeit y*y*y*y*y*y*y\n # 10 loops, best of 3: 1.73 s per loop\n\n Todo: do the same for the other non multiplicative bases?\n\n "
return self._pow_naive(n)
def omega(self):
'\n Return the image of ``self`` under the omega automorphism.\n\n The *omega automorphism* is defined to be the unique algebra\n endomorphism `\\omega` of the ring of symmetric functions that\n satisfies `\\omega(e_k) = h_k` for all positive integers `k`\n (where `e_k` stands for the `k`-th elementary symmetric\n function, and `h_k` stands for the `k`-th complete homogeneous\n symmetric function). It furthermore is a Hopf algebra\n endomorphism and an involution, and it is also known as the\n *omega involution*. It sends the power-sum symmetric function\n `p_k` to `(-1)^{k-1} p_k` for every positive integer `k`.\n\n The images of some bases under the omega automorphism are given by\n\n .. MATH::\n\n \\omega(e_{\\lambda}) = h_{\\lambda}, \\qquad\n \\omega(h_{\\lambda}) = e_{\\lambda}, \\qquad\n \\omega(p_{\\lambda}) = (-1)^{|\\lambda| - \\ell(\\lambda)}\n p_{\\lambda}, \\qquad\n \\omega(s_{\\lambda}) = s_{\\lambda^{\\prime}},\n\n where `\\lambda` is any partition, where `\\ell(\\lambda)` denotes\n the length (:meth:`~sage.combinat.partition.Partition.length`)\n of the partition `\\lambda`, where `\\lambda^{\\prime}` denotes the\n conjugate partition\n (:meth:`~sage.combinat.partition.Partition.conjugate`) of\n `\\lambda`, and where the usual notations for bases are used\n (`e` = elementary, `h` = complete homogeneous, `p` = powersum,\n `s` = Schur).\n\n :meth:`omega_involution()` is a synonym for the :meth:`omega()`\n method.\n\n OUTPUT:\n\n - the image of ``self`` under the omega automorphism\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([2,1]).omega()\n s[2, 1]\n sage: s([2,1,1]).omega()\n s[3, 1]\n '
conj = (lambda part: part.conjugate())
return self.map_support(conj)
omega_involution = omega
def scalar(self, x, zee=None):
'\n Return the standard scalar product between ``self`` and `x`.\n\n Note that the Schur functions are self-dual with respect to this\n scalar product. They are also lower-triangularly related to the\n monomial symmetric functions with respect to this scalar product.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n - ``zee`` -- an optional function on partitions giving\n the value for the scalar product between the power-sum\n symmetric function `p_{\\mu}` and itself\n (the default value is the standard\n :meth:`~sage.combinat.sf.sfa.zee` function)\n\n OUTPUT:\n\n - the scalar product between ``self`` and ``x``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: a = s([2,1])\n sage: b = s([1,1,1])\n sage: c = 2*s([1,1,1])\n sage: d = a + b\n sage: a.scalar(a)\n 1\n sage: b.scalar(b)\n 1\n sage: b.scalar(a)\n 0\n sage: b.scalar(c)\n 2\n sage: c.scalar(c)\n 4\n sage: d.scalar(a)\n 1\n sage: d.scalar(b)\n 1\n sage: d.scalar(c)\n 2\n\n ::\n\n sage: m = SymmetricFunctions(ZZ).monomial()\n sage: p4 = Partitions(4)\n sage: l = [ [s(p).scalar(m(q)) for q in p4] for p in p4]\n sage: matrix(l)\n [ 1 0 0 0 0]\n [-1 1 0 0 0]\n [ 0 -1 1 0 0]\n [ 1 -1 -1 1 0]\n [-1 2 1 -3 1]\n '
if (zee is None):
s = self.parent()
R = s.base_ring()
one = R.one()
f = (lambda p1, p2: one)
x = s(x)
return s._apply_multi_module_morphism(self, x, f, orthogonal=True)
else:
p = self.parent().realization_of().power()
return p(self).scalar(x, zee=zee)
def verschiebung(self, n):
'\n Return the image of the symmetric function ``self`` under the\n `n`-th Verschiebung operator.\n\n The `n`-th Verschiebung operator `\\mathbf{V}_n` is defined to be\n the unique algebra endomorphism `V` of the ring of symmetric\n functions that satisfies `V(h_r) = h_{r/n}` for every positive\n integer `r` divisible by `n`, and satisfies `V(h_r) = 0` for\n every positive integer `r` not divisible by `n`. This operator\n `\\mathbf{V}_n` is a Hopf algebra endomorphism. For every\n nonnegative integer `r` with `n \\mid r`, it satisfies\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = h_{r/n},\n \\quad \\mathbf{V}_n(p_r) = n p_{r/n},\n \\quad \\mathbf{V}_n(e_r) = (-1)^{r - r/n} e_{r/n}\n\n (where `h` is the complete homogeneous basis, `p` is the\n powersum basis, and `e` is the elementary basis). For every\n nonnegative integer `r` with `n \\nmid r`, it satisfes\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = \\mathbf{V}_n(p_r) = \\mathbf{V}_n(e_r) = 0.\n\n The `n`-th Verschiebung operator is also called the `n`-th\n Verschiebung endomorphism. Its name derives from the Verschiebung\n (German for "shift") endomorphism of the Witt vectors.\n\n The `n`-th Verschiebung operator is adjoint to the `n`-th\n Frobenius operator (see :meth:`frobenius` for its definition)\n with respect to the Hall scalar product (:meth:`scalar`).\n\n The action of the `n`-th Verschiebung operator on the Schur basis\n can also be computed explicitly. The following (probably clumsier\n than necessary) description can be obtained by solving exercise\n 7.61 in Stanley\'s [STA]_.\n\n Let `\\lambda` be a partition. Let `n` be a positive integer. If\n the `n`-core of `\\lambda` is nonempty, then\n `\\mathbf{V}_n(s_\\lambda) = 0`. Otherwise, the following method\n computes `\\mathbf{V}_n(s_\\lambda)`: Write the partition `\\lambda`\n in the form `(\\lambda_1, \\lambda_2, \\ldots, \\lambda_{ns})` for some\n nonnegative integer `s`. (If `n` does not divide the length of\n `\\lambda`, then this is achieved by adding trailing zeroes to\n `\\lambda`.) Set `\\beta_i = \\lambda_i + ns - i` for every\n `s \\in \\{ 1, 2, \\ldots, ns \\}`. Then,\n `(\\beta_1, \\beta_2, \\ldots, \\beta_{ns})` is a strictly decreasing\n sequence of nonnegative integers. Stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `-1 - \\beta_i` modulo `n`. Let `\\xi` be the sign of the\n permutation that is used for this sorting. Let `\\psi` be the sign\n of the permutation that is used to stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `i - 1` modulo `n`. (Notice that `\\psi = (-1)^{n(n-1)s(s-1)/4}`.)\n Then, `\\mathbf{V}_n(s_\\lambda) = \\xi \\psi \\prod_{i = 0}^{n - 1}\n s_{\\lambda^{(i)}}`, where\n `(\\lambda^{(0)}, \\lambda^{(1)}, \\ldots, \\lambda^{(n - 1)})`\n is the `n`-quotient of `\\lambda`.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n The result of applying the `n`-th Verschiebung operator (on the ring of\n symmetric functions) to ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: s = Sym.s()\n sage: s[5].verschiebung(2)\n 0\n sage: s[6].verschiebung(6)\n s[1]\n sage: s[6,3].verschiebung(3)\n s[2, 1] + s[3]\n sage: s[6,3,1].verschiebung(2)\n -s[3, 2]\n sage: s[3,2,1].verschiebung(1)\n s[3, 2, 1]\n sage: s([]).verschiebung(1)\n s[]\n sage: s([]).verschiebung(4)\n s[]\n\n TESTS:\n\n Let us check that this method on the powersum basis gives the\n same result as the implementation in sfa.py on the monomial\n basis::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s(); h = Sym.h()\n sage: all( h(s(lam)).verschiebung(3) == h(s(lam).verschiebung(3))\n ....: for lam in Partitions(6) )\n True\n sage: all( s(h(lam)).verschiebung(2) == s(h(lam).verschiebung(2))\n ....: for lam in Partitions(4) )\n True\n sage: all( s(h(lam)).verschiebung(5) == s(h(lam).verschiebung(5))\n ....: for lam in Partitions(10) )\n True\n sage: all( s(h(lam)).verschiebung(2) == s(h(lam).verschiebung(2))\n ....: for lam in Partitions(8) )\n True\n sage: all( s(h(lam)).verschiebung(3) == s(h(lam).verschiebung(3))\n ....: for lam in Partitions(12) )\n True\n sage: all( s(h(lam)).verschiebung(3) == s(h(lam).verschiebung(3))\n ....: for lam in Partitions(9) )\n True\n '
if (n == 1):
return self
parent = self.parent()
s_coords_of_self = self.monomial_coefficients().items()
result = parent.zero()
from sage.combinat.permutation import Permutation
for (lam, coeff) in s_coords_of_self:
if (len(lam.core(n)) == 0):
quotient = lam.quotient(n)
quotient_prod = parent.prod((parent(part) for part in quotient))
len_lam = len(lam)
ns = (len_lam + ((- len_lam) % n))
s = (ns // n)
beta_list = lam.beta_numbers(ns)
zipped_beta_list = sorted(zip(beta_list, range(1, (ns + 1))), key=(lambda a: (((- 1) - a[0]) % n)))
perm_list = [a[1] for a in zipped_beta_list]
if (Permutation(perm_list).sign() == 1):
minus_sign = False
else:
minus_sign = True
if (((((n * s) * (n - 1)) * (s - 1)) % 8) == 4):
minus_sign = (not minus_sign)
if minus_sign:
result -= (coeff * quotient_prod)
else:
result += (coeff * quotient_prod)
return result
def expand(self, n, alphabet='x'):
"\n Expand the symmetric function ``self`` as a symmetric polynomial\n in ``n`` variables.\n\n INPUT:\n\n - ``n`` -- a nonnegative integer\n\n - ``alphabet`` -- (default: ``'x'``) a variable for the expansion\n\n OUTPUT:\n\n A monomial expansion of ``self`` in the `n` variables\n labelled by ``alphabet``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1])\n sage: a.expand(2)\n x0^2*x1 + x0*x1^2\n sage: a.expand(3)\n x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2\n sage: a.expand(4)\n x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2 + x0^2*x3 + 2*x0*x1*x3 + x1^2*x3 + 2*x0*x2*x3 + 2*x1*x2*x3 + x2^2*x3 + x0*x3^2 + x1*x3^2 + x2*x3^2\n sage: a.expand(2, alphabet='y')\n y0^2*y1 + y0*y1^2\n sage: a.expand(2, alphabet=['a','b'])\n a^2*b + a*b^2\n sage: s([1,1,1,1]).expand(3)\n 0\n sage: (s([]) + 2*s([1])).expand(3)\n 2*x0 + 2*x1 + 2*x2 + 1\n sage: s([1]).expand(0)\n 0\n sage: (3*s([])).expand(0)\n 3\n "
condition = (lambda part: (len(part) > n))
return self._expand(condition, n, alphabet)
def principal_specialization(self, n=infinity, q=None):
'\n Return the principal specialization of a symmetric function.\n\n The *principal specialization* of order `n` at `q`\n is the ring homomorphism `ps_{n,q}` from the ring of\n symmetric functions to another commutative ring `R`\n given by `x_i \\mapsto q^{i-1}` for `i \\in \\{1,\\dots,n\\}`\n and `x_i \\mapsto 0` for `i > n`.\n Here, `q` is a given element of `R`, and we assume that\n the variables of our symmetric functions are\n `x_1, x_2, x_3, \\ldots`.\n (To be more precise, `ps_{n,q}` is a `K`-algebra\n homomorphism, where `K` is the base ring.)\n See Section 7.8 of [EnumComb2]_.\n\n The *stable principal specialization* at `q` is the ring\n homomorphism `ps_q` from the ring of symmetric functions\n to another commutative ring `R` given by\n `x_i \\mapsto q^{i-1}` for all `i`.\n This is well-defined only if the resulting infinite sums\n converge; thus, in particular, setting `q = 1` in the\n stable principal specialization is an invalid operation.\n\n INPUT:\n\n - ``n`` (default: ``infinity``) -- a nonnegative integer or\n ``infinity``, specifying whether to compute the principal\n specialization of order ``n`` or the stable principal\n specialization.\n\n - ``q`` (default: ``None``) -- the value to use for `q`; the\n default is to create a ring of polynomials in ``q``\n (or a field of rational functions in ``q``) over the\n given coefficient ring.\n\n For `q=1` we use the formula from Corollary 7.21.4 of [EnumComb2]_:\n\n .. MATH::\n\n ps_{n,1}(s_\\lambda) = \\prod_{u\\in\\lambda} (n+c(u)) / h(u),\n\n where `h(u)` is the hook length of a cell `u` in `\\lambda`,\n and where `c(u)` is the content of a cell `u` in `\\lambda`.\n\n For `n=infinity` we use the formula from Corollary 7.21.3 of [EnumComb2]_\n\n .. MATH::\n\n ps_q(s_\\lambda) = q^{\\sum_i (i-1)\\lambda_i} / \\prod_{u\\in\\lambda} (1-q^{h(u)}).\n\n Otherwise, we use the formula from Theorem 7.21.2 of [EnumComb2]_,\n\n .. MATH::\n\n ps_{n,q}(s_\\lambda) = q^{\\sum_i (i-1)\\lambda_i}\n \\prod_{u\\in\\lambda} (1-q^{n+c(u)})/(1-q^{h(u)}).\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: x = s[2]\n sage: x.principal_specialization(3)\n q^4 + q^3 + 2*q^2 + q + 1\n\n sage: x = 3*s[2,2] + 2*s[1] + 1\n sage: x.principal_specialization(3, q=var("q")) # needs sage.symbolic\n 3*(q^4 - 1)*(q^3 - 1)*q^2/((q^2 - 1)*(q - 1)) + 2*(q^3 - 1)/(q - 1) + 1\n\n sage: x.principal_specialization(q=var("q")) # needs sage.symbolic\n -2/(q - 1) + 3*q^2/((q^3 - 1)*(q^2 - 1)^2*(q - 1)) + 1\n\n TESTS::\n\n sage: s.zero().principal_specialization(3)\n 0\n\n '
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q is None):
q = get_variable(self.base_ring(), 'q')
if (q == 1):
if (n == infinity):
raise ValueError('the stable principal specialization at q=1 is not defined')
f = (lambda partition: (prod((((n + j) - i) for (i, j) in partition.cells())) // prod((h for h in partition.hooks()))))
elif (n == infinity):
f = (lambda partition: ((q ** sum(((i * part) for (i, part) in enumerate(partition)))) / prod(((1 - (q ** h)) for h in partition.hooks()))))
else:
from sage.rings.integer_ring import ZZ
ZZq = PolynomialRing(ZZ, 'q')
q_lim = ZZq.gen()
def f(partition):
if (n < len(partition)):
return 0
power = (q ** sum(((i * part) for (i, part) in enumerate(partition))))
denom = prod(((1 - (q ** h)) for h in partition.hooks()))
try:
(~ denom)
rational = ((power * prod(((1 - (q ** ((n + j) - i))) for (i, j) in partition.cells()))) / denom)
return q.parent()(rational)
except (ZeroDivisionError, NotImplementedError, TypeError):
quotient = ZZq((prod(((1 - (q_lim ** ((n + j) - i))) for (i, j) in partition.cells())) / prod(((1 - (q_lim ** h)) for h in partition.hooks()))))
return (power * quotient.subs({q_lim: q}))
return self.parent()._apply_module_morphism(self, f, q.parent())
def exponential_specialization(self, t=None, q=1):
'\n Return the exponential specialization of a\n symmetric function (when `q = 1`), or the\n `q`-exponential specialization (when `q \\neq 1`).\n\n The *exponential specialization* `ex` at `t` is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R`.\n It is defined whenever the base ring `K` is a\n `\\QQ`-algebra and `t` is an element of `R`.\n The easiest way to define it is by specifying its\n values on the powersum symmetric functions to be\n `p_1 = t` and `p_n = 0` for `n > 1`.\n Equivalently, on the homogeneous functions it is\n given by `ex(h_n) = t^n / n!`; see Proposition 7.8.4 of\n [EnumComb2]_.\n\n By analogy, the `q`-exponential specialization is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R` that\n depends on two elements `t` and `q` of `R` for which\n the elements `1 - q^i` for all positive integers `i`\n are invertible.\n It can be defined by specifying its values on the\n complete homogeneous symmetric functions to be\n\n .. MATH::\n\n ex_q(h_n) = t^n / [n]_q!,\n\n where `[n]_q!` is the `q`-factorial. Equivalently, for\n `q \\neq 1` and a homogeneous symmetric function `f` of\n degree `n`, we have\n\n .. MATH::\n\n ex_q(f) = (1-q)^n t^n ps_q(f),\n\n where `ps_q(f)` is the stable principal specialization of `f`\n (see :meth:`principal_specialization`).\n (See (7.29) in [EnumComb2]_.)\n\n The limit of `ex_q` as `q \\to 1` is `ex`.\n\n INPUT:\n\n - ``t`` (default: ``None``) -- the value to use for `t`;\n the default is to create a ring of polynomials in ``t``.\n\n - ``q`` (default: `1`) -- the value to use for `q`. If\n ``q`` is ``None``, then a ring (or fraction field) of\n polynomials in ``q`` is created.\n\n We use the formula in the proof of Corollary 7.21.6 of\n [EnumComb2]_\n\n .. MATH::\n\n ex_{q}(s_\\lambda) = t^{|\\lambda|} q^{\\sum_i (i-1)\\lambda_i}\n / \\prod_{u\\in\\lambda} (1 + q + q^2 + \\dots + q^{h(u)-1})\n\n where `h(u)` is the hook length of a cell `u` in `\\lambda`.\n\n As a limit case, we obtain a formula for `q=1`\n\n .. MATH::\n\n ex_{1}(s_\\lambda) = f^\\lambda t^{|\\lambda|} / |\\lambda|!\n\n where `f^\\lambda` is the number of standard Young\n tableaux of shape `\\lambda`.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: x = s[5,3]\n sage: x.exponential_specialization()\n 1/1440*t^8\n\n sage: x = 5*s[1,1,1] + 3*s[2,1] + 1\n sage: x.exponential_specialization()\n 11/6*t^3 + 1\n\n We also support the `q`-exponential_specialization::\n\n sage: factor(s[3].exponential_specialization(q=var("q"), t=var("t"))) # needs sage.symbolic\n t^3/((q^2 + q + 1)*(q + 1))\n\n TESTS::\n\n sage: s.zero().exponential_specialization()\n 0\n\n '
def get_variable(ring, name):
try:
ring(name)
except TypeError:
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
return PolynomialRing(ring, name).gen()
else:
raise ValueError(('the variable %s is in the base ring, pass it explicitly' % name))
if (q == 1):
if (t is None):
t = get_variable(self.base_ring(), 't')
def f(partition):
n = partition.size()
return ((StandardTableaux(partition).cardinality() * (t ** n)) / factorial(n))
return self.parent()._apply_module_morphism(self, f, t.parent())
if ((q is None) and (t is None)):
q = get_variable(self.base_ring(), 'q')
t = get_variable(q.parent(), 't')
elif (q is None):
q = get_variable(t.parent(), 'q')
elif (t is None):
t = get_variable(q.parent(), 't')
f = (lambda partition: (((t ** partition.size()) * (q ** sum(((i * part) for (i, part) in enumerate(partition))))) / prod((sum(((q ** i) for i in range(h))) for h in partition.hooks()))))
return self.parent()._apply_module_morphism(self, f, t.parent())
|
class SymmetricFunctions(UniqueRepresentation, Parent):
'\n The abstract algebra of commutative symmetric functions\n\n .. rubric:: Symmetric Functions in Sage\n\n .. MODULEAUTHOR:: Jason Bandlow, Anne Schilling, Nicolas M. Thiery, Mike Zabrocki\n\n This document is an introduction to working with symmetric function\n theory in Sage.\n It is not intended to be an introduction to the theory\n of symmetric functions ([MAC]_ and [STA]_, Chapter 7, are two excellent\n references.) The reader is also expected to be familiar with Sage.\n\n .. rubric:: The algebra of symmetric functions\n\n The algebra of symmetric functions is the unique free commutative graded\n connected algebra over the given ring, with one generator in each degree. It\n can also be thought of as the inverse limit (in the category of graded\n algebras) of the algebra of symmetric polynomials in `n` variables as `n \\rightarrow \\infty`.\n Sage allows us to construct the algebra of symmetric functions over\n any ring. We will use a base ring of rational numbers in these first\n examples::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym\n Symmetric Functions over Rational Field\n\n Sage knows certain categorical information about this algebra::\n\n sage: Sym.category()\n Join of Category of Hopf algebras over Rational Field\n and Category of unique factorization domains\n and Category of graded algebras over Rational Field\n and Category of commutative algebras over Rational Field\n and Category of monoids with realizations\n and Category of graded coalgebras over Rational Field\n and Category of coalgebras over Rational Field with realizations\n and Category of cocommutative coalgebras over Rational Field\n\n Notice that ``Sym`` is an *abstract* algebra. This reflects the fact that\n there are multiple natural bases. To work with specific\n elements, we need a *realization* of this algebra. In practice, this\n means we need to specify a basis.\n\n .. rubric:: An example basis - power sums\n\n Here is an example of how one might use the power sum realization::\n\n sage: p = Sym.powersum()\n sage: p\n Symmetric Functions over Rational Field in the powersum basis\n\n ``p`` now represents the realization of the symmetric function algebra on\n the power sum basis. The basis itself is accessible through::\n\n sage: p.basis()\n Lazy family (Term map from Partitions to Symmetric Functions over Rational Field in the powersum basis(i))_{i in Partitions}\n sage: p.basis().keys()\n Partitions\n\n This last line means that ``p.basis()`` is an association between the set\n of Partitions and the basis elements of the algebra ``p``. To construct a\n specific element one can therefore do::\n\n sage: p.basis()[Partition([2,1,1])]\n p[2, 1, 1]\n\n As this is rather cumbersome, realizations of the symmetric function\n algebra allow for the following abuses of notation::\n\n sage: p[Partition([2, 1, 1])]\n p[2, 1, 1]\n sage: p[[2, 1, 1]]\n p[2, 1, 1]\n sage: p[2, 1, 1]\n p[2, 1, 1]\n\n or even::\n\n sage: p[(i for i in [2, 1, 1])]\n p[2, 1, 1]\n\n In the special case of the empty partition, due to a limitation in\n Python syntax, one cannot use::\n\n sage: p[] # todo: not implemented\n\n Please use instead::\n\n sage: p[[]]\n p[]\n\n .. note:: When elements are constructed using the ``p[something ]`` syntax ,\n an error will be raised if the input cannot be interpreted as a partition.\n This is *not* the case when ``p.basis()`` is used::\n\n sage: p[\'something\']\n Traceback (most recent call last):\n ...\n ValueError: all parts of \'something\' should be nonnegative integers\n sage: p.basis()[\'something\']\n p\'something\'\n\n Elements of ``p`` are linear combinations of such compositions::\n\n sage: p.an_element()\n 2*p[] + 2*p[1] + 3*p[2]\n\n .. rubric:: Algebra structure\n\n Algebraic combinations of basis elements can be entered in a natural way::\n\n sage: p[2,1,1] + 2 * p[1] * (p[4] + p[2,1])\n 3*p[2, 1, 1] + 2*p[4, 1]\n\n Let us explore the other operations of ``p``. We can ask for\n the mathematical properties of ``p``::\n\n sage: p.categories()\n [Category of graded bases of Symmetric Functions over Rational Field,\n Category of filtered bases of Symmetric Functions over Rational Field,\n Category of bases of Symmetric Functions over Rational Field,\n Category of graded Hopf algebras with basis over Rational Field,\n ...]\n\n To start with, ``p`` is a graded algebra, the grading being induced\n by the size of the partitions. Due to this, the one is the basis\n element indexed by the empty partition::\n\n sage: p.one()\n p[]\n\n The ``p`` basis is multiplicative; that is, multiplication is induced by\n linearity from the (nonincreasingly sorted) concatenation of partitions::\n\n sage: p[3,1] * p[2,1]\n p[3, 2, 1, 1]\n\n sage: (p.one() + 2 * p[3,1]) * p[4, 2]\n p[4, 2] + 2*p[4, 3, 2, 1]\n\n .. rubric:: The classical bases\n\n In addition to the power sum basis, other classical bases of the\n symmetric function algebra include the elementary, complete\n homogeneous, monomial, and Schur bases::\n\n sage: e = Sym.elementary()\n sage: h = Sym.homogeneous()\n sage: m = Sym.monomial()\n sage: s = Sym.schur()\n\n These and others can be defined all at once with the single command::\n\n sage: Sym.inject_shorthands()\n Defining e as shorthand for Symmetric Functions over Rational Field in the elementary basis\n Defining f as shorthand for Symmetric Functions over Rational Field in the forgotten basis\n Defining h as shorthand for Symmetric Functions over Rational Field in the homogeneous basis\n Defining m as shorthand for Symmetric Functions over Rational Field in the monomial basis\n Defining p as shorthand for Symmetric Functions over Rational Field in the powersum basis\n Defining s as shorthand for Symmetric Functions over Rational Field in the Schur basis\n\n We can then do conversions from one basis to another::\n\n sage: s(p[2,1])\n -s[1, 1, 1] + s[3]\n\n sage: m(p[3])\n m[3]\n sage: m(p[3,2])\n m[3, 2] + m[5]\n\n For computations which mix bases, Sage will return a result with respect\n to a single (not necessarily predictable) basis::\n\n sage: p[2] * s[2] - m[4]\n 1/2*p[2, 1, 1] + 1/2*p[2, 2] - p[4]\n\n sage: p( m[1] * ( e[3]*s[2] + 1 ))\n p[1] + 1/12*p[1, 1, 1, 1, 1, 1] - 1/6*p[2, 1, 1, 1, 1] - 1/4*p[2, 2, 1, 1] + 1/6*p[3, 1, 1, 1] + 1/6*p[3, 2, 1]\n\n\n The one for different bases such as the power sum and Schur function is the same::\n\n sage: s.one() == p.one()\n True\n\n .. rubric:: Basic computations\n\n In this section, we explore some of the many methods that can be applied\n to an arbitrary symmetric function::\n\n sage: f = s[2]^2; f\n s[2, 2] + s[3, 1] + s[4]\n\n For more methods than discussed here, create a symmetric function as\n above, and use ``f.<tab>``.\n\n .. _`Representation theory of the symmetric group`:\n\n .. rubric:: Representation theory of the symmetric group\n\n The Schur functions `s_\\lambda` can also be interpreted as irreducible characters of the symmetric\n group `S_n`, where `n` is the size of the partition `\\lambda`. Since the Schur functions of\n degree `n` form a basis of the symmetric functions of degree `n`, it\n follows that an arbitrary symmetric function (homogeneous of degree\n `n`) may be interpreted as a function on the symmetric group. In this\n interpretation the power sum symmetric function `p_\\lambda` is the characteristic\n function of the conjugacy class with shape `\\lambda`, multiplied by the order of\n the centralizer of an element. Hence the irreducible characters can be computed\n as follows::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: p = Sym.power()\n sage: P = Partitions(5).list()\n sage: P = [P[i] for i in range(len(P)-1,-1,-1)]\n sage: M = matrix([[s[P[i]].scalar(p[P[j]]) for j in range(len(P))] for i in range(len(P))])\n sage: M\n [ 1 -1 1 1 -1 -1 1]\n [ 4 -2 0 1 1 0 -1]\n [ 5 -1 1 -1 -1 1 0]\n [ 6 0 -2 0 0 0 1]\n [ 5 1 1 -1 1 -1 0]\n [ 4 2 0 1 -1 0 -1]\n [ 1 1 1 1 1 1 1]\n\n We can indeed check that this agrees with the character table of `S_5`::\n\n sage: SymmetricGroup(5).character_table() == M\n True\n\n In this interpretation of symmetric functions as characters on the\n symmetric group, the multiplication and comultiplication are\n interpreted as induction (from `S_n\\times S_m` to `S_{n+m}`)\n and restriction, respectively. The Schur functions can also be interpreted\n as characters of `GL_n`, see `Partitions and Schur functions`__.\n\n __ ../../../../../thematic_tutorials/lie/lie_basics.html#partitions-and-schur-polynomials\n\n .. rubric:: The omega involution\n\n The `\\omega` involution is the linear extension of the map which sends\n `e_\\lambda` to `h_{\\lambda}`::\n\n sage: h(f)\n h[2, 2]\n sage: e(f.omega())\n e[2, 2]\n\n .. rubric:: The Hall scalar product\n\n The Hall scalar product on the algebra of symmetric functions makes the\n Schur functions into an orthonormal basis::\n\n sage: f.scalar(f)\n 3\n\n .. rubric:: Skewing\n\n *Skewing* is the adjoint operation to multiplication with respect to\n this scalar product::\n\n sage: f.skew_by(s[1])\n 2*s[2, 1] + 2*s[3]\n\n In general, ``s[la].skew_by(s[mu])`` is the symmetric function typically\n denoted `s_{\\lambda \\setminus \\mu}` or `s_{\\lambda / \\mu}`.\n\n .. rubric:: Expanding into variables\n\n We can expand a symmetric function into a symmetric polynomial in a\n specified number of variables::\n\n sage: f.expand(2)\n x0^4 + 2*x0^3*x1 + 3*x0^2*x1^2 + 2*x0*x1^3 + x1^4\n\n See the documentation for ``expand`` for more examples.\n\n .. rubric:: The Kronecker product\n\n As in the section on the `Representation theory of\n the symmetric group`_, a symmetric function may be considered as a\n class function on the symmetric group where the elements\n `p_\\mu/z_\\mu` are the indicators of a permutation having\n cycle structure `\\mu`. The Kronecker product of two\n symmetric functions corresponds to the pointwise product\n of these class functions.\n\n Since the Schur functions are the irreducible characters\n of the symmetric group under this identification, the Kronecker\n product of two Schur functions corresponds to the internal\n tensor product of two irreducible symmetric group representations.\n\n Under this identification, the Kronecker\n product of `p_\\mu/z_\\mu` and `p_\\nu/z_\\nu` is `p_\\mu/z_\\mu`\n if `\\mu=\\nu`, and the result is equal to `0` otherwise.\n\n ``internal_product``, ``kronecker_product``, ``inner_tensor`` and\n ``itensor`` are different names for the same function.\n\n ::\n\n sage: f.kronecker_product(f)\n s[1, 1, 1, 1] + 3*s[2, 1, 1] + 4*s[2, 2] + 5*s[3, 1] + 3*s[4]\n\n .. rubric:: Plethysm\n\n The *plethysm* of symmetric functions is the operation corresponding to\n composition of representations of the general linear group. See [STA]_\n Chapter 7, Appendix 2 for details.\n ::\n\n sage: s[2].plethysm(s[2])\n s[2, 2] + s[4]\n\n Plethysm can also be written as a composition of functions::\n\n sage: s[2]( s[2] )\n s[2, 2] + s[4]\n\n If the coefficient ring contains degree 1 elements, these are handled\n properly by plethysm::\n\n sage: R.<t> = QQ[]; s = SymmetricFunctions(R).schur()\n sage: s[2]( (1-t)*s[1] )\n (t^2-t)*s[1, 1] + (-t+1)*s[2]\n\n See the documentation for ``plethysm`` for more information.\n\n .. rubric:: Inner plethysm\n\n The operation of inner plethysm ``f.inner_plethysm(g)`` models the\n composition of the `S_n` representation represented by `g` with the\n `GL_m` representation whose character is `f`. See the documentation of\n ``inner_plethysm``, [ST94]_ or [STA]_, exercise 7.74 solutions for more\n information::\n\n sage: s = SymmetricFunctions(QQ).schur()\n sage: f = s[2]^2\n sage: f.inner_plethysm(s[2])\n s[2]\n\n .. rubric:: Hopf algebra structure\n\n The ring of symmetric functions is further endowed with a coalgebra\n structure. The coproduct is an algebra morphism, and therefore\n determined by its values on the generators; the power sum generators\n are primitive::\n\n sage: p[1].coproduct()\n p[] # p[1] + p[1] # p[]\n sage: p[2].coproduct()\n p[] # p[2] + p[2] # p[]\n\n The coproduct, being cocommutative on the generators, is cocommutative everywhere::\n\n sage: p[2, 1].coproduct()\n p[] # p[2, 1] + p[1] # p[2] + p[2] # p[1] + p[2, 1] # p[]\n\n This coproduct, along with the counit which sends every symmetric function\n to its `0`-th homogeneous component, makes the ring of symmetric functions\n into a graded connected bialgebra. It is known that every graded connected\n bialgebra has an antipode. For the ring of symmetric functions, the antipode\n can be characterized explicitly: The antipode is an anti-algebra morphism\n (thus an algebra morphism, since our algebra is commutative) which sends\n `p_{\\lambda}` to `(-1)^{\\mathrm{length}(\\lambda)} p_{\\lambda}` for every\n partition `\\lambda`. Thus, in particular, it sends the generators on the\n ``p`` basis to their opposites::\n\n sage: p[3].antipode()\n -p[3]\n sage: p[3,2,1].antipode()\n -p[3, 2, 1]\n\n The graded connected bialgebra of symmetric functions over a `\\QQ`-algebra\n has a rather simply-understood structure: It is (isomorphic to) the\n symmetric algebra of its space of primitives (which is spanned by the\n power-sum symmetric functions).\n\n Here are further examples::\n\n sage: f = s[2]^2\n sage: f.antipode()\n s[1, 1, 1, 1] + s[2, 1, 1] + s[2, 2]\n sage: f.coproduct()\n s[] # s[2, 2] + s[] # s[3, 1] + s[] # s[4] + 2*s[1] # s[2, 1] + 2*s[1] # s[3] + s[1, 1] # s[1, 1]\n + s[1, 1] # s[2] + s[2] # s[1, 1] + 3*s[2] # s[2] + 2*s[2, 1] # s[1] + s[2, 2] # s[] + 2*s[3] # s[1]\n + s[3, 1] # s[] + s[4] # s[]\n sage: f.coproduct().apply_multilinear_morphism( lambda x,y: x*y.antipode() )\n 0\n\n .. rubric:: Transformations of symmetric functions\n\n There are many methods in Sage which make it easy to manipulate symmetric\n functions. For example, if we have some function which acts on partitions\n (say, conjugation), it is a simple matter to apply it to the support of a\n symmetric function. Here is an example::\n\n sage: conj = lambda mu: mu.conjugate()\n sage: f = h[4] + 2*h[3,1]\n sage: f.map_support(conj)\n h[1, 1, 1, 1] + 2*h[2, 1, 1]\n\n We can also easily modify the coefficients::\n\n sage: def foo(mu, coeff): return mu.conjugate(), -coeff\n sage: f.map_item(foo)\n -h[1, 1, 1, 1] - 2*h[2, 1, 1]\n\n See also ``map_coefficients``.\n\n There are also methods for building functions directly::\n\n sage: s.sum_of_monomials(mu for mu in Partitions(3))\n s[1, 1, 1] + s[2, 1] + s[3]\n sage: s.sum_of_monomials(Partitions(3))\n s[1, 1, 1] + s[2, 1] + s[3]\n sage: s.sum_of_terms( (mu, mu[0]) for mu in Partitions(3))\n s[1, 1, 1] + 2*s[2, 1] + 3*s[3]\n\n These are the preferred way to build elements within a program;\n the result will usually be faster than using :func:`sum`. It also\n guarantees that empty sums yields the zero of ``s`` (see also\n ``s.sum``).\n\n Note also that it is a good idea to use::\n\n sage: s.one()\n s[]\n sage: s.zero()\n 0\n\n instead of ``s(1)`` and ``s(0)`` within programs where speed is important,\n in order to prevent unnecessary coercions.\n\n .. rubric:: Different base rings\n\n Depending on the base ring, the different realizations of the symmetric\n function algebra may not span the same space::\n\n sage: SZ = SymmetricFunctions(ZZ)\n sage: p = SZ.power(); s = SZ.schur()\n sage: p(s[1,1,1])\n Traceback (most recent call last):\n ...\n TypeError: no conversion of this rational to integer\n\n Because of this, some functions may not behave as expected when working over\n the integers, even though they make mathematical sense::\n\n sage: s[1,1,1].plethysm(s[1,1,1])\n Traceback (most recent call last):\n ...\n TypeError: no conversion of this rational to integer\n\n It is possible to work over different base rings simultaneously::\n\n sage: s = SymmetricFunctions(QQ).schur()\n sage: p = SymmetricFunctions(QQ).power()\n sage: sz = SymmetricFunctions(ZZ).schur(); sz._prefix = \'sz\'\n sage: pz = SymmetricFunctions(ZZ).power(); pz._prefix = \'pz\'\n sage: p(sz[1,1,1])\n 1/6*p[1, 1, 1] - 1/2*p[2, 1] + 1/3*p[3]\n sage: sz( 1/6*p[1, 1, 1] - 1/2*p[2, 1] + 1/3*p[3] )\n sz[1, 1, 1]\n\n As shown in this example, if you are working over multiple base rings\n simultaneously, it is a good idea to change the prefix in some cases, so that\n you can tell from the output which realization your result is in.\n\n Let us change the notation back for the remainder of this tutorial::\n\n sage: sz._prefix = \'s\'\n sage: pz._prefix = \'p\'\n\n One can also use the Sage standard renaming idiom to get shorter outputs::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym.rename("Sym")\n sage: Sym\n Sym\n sage: Sym.rename()\n\n And we name it back::\n\n sage: Sym.rename("Symmetric Functions over Rational Field"); Sym\n Symmetric Functions over Rational Field\n\n .. rubric:: Other bases\n\n There are two additional basis of the symmetric functions which are not\n considered as classical bases:\n\n * forgotten basis\n * Witt basis\n\n The forgotten basis is the dual basis of the elementary symmetric\n functions basis with respect to the Hall scalar product. The Witt basis\n can be constructed by\n\n .. MATH::\n\n \\prod_{d=1}^{\\infty} (1 - w_d t^d)^{-1} = \\sum_{n=0}^{\\infty} h_n t^n\n\n where `t` is a formal variable.\n\n There are further bases of the ring of symmetric functions, in general over\n fields with parameters such as `q` and `t`:\n\n * Hall-Littlewood bases\n * Jack bases\n * Macdonald bases\n * `k`-Schur functions\n * Hecke character basis\n\n We briefly demonstrate how to access these bases. For more information, see\n the documentation of the individual bases.\n\n The *Jack polynomials* can be obtained as::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'t\']))\n sage: Jack = Sym.jack()\n sage: P = Jack.P(); J = Jack.J(); Q = Jack.Q()\n sage: J(P[2,1])\n (1/(t+2))*JackJ[2, 1]\n\n The parameter `t` can be specialized as follows::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Jack = Sym.jack(t = 1)\n sage: P = Jack.P(); J = Jack.J(); Q = Jack.Q()\n sage: J(P[2,1])\n 1/3*JackJ[2, 1]\n\n Similarly one can access the Hall-Littlewood and Macdonald polynomials, etc::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: Mcd = Sym.macdonald()\n sage: P = Mcd.P(); J = Mcd.J(); Q = Mcd.Q()\n sage: J(P[2,1])\n (1/(-q*t^4+2*q*t^3-q*t^2+t^2-2*t+1))*McdJ[2, 1]\n\n We can also construct the `\\bar{q}` basis that can be used\n to determine character tables for Hecke algebras (with quadratic\n relation `T_i^2 = (1-q) T_i + q`)::\n\n sage: Sym = SymmetricFunctions(ZZ[\'q\'].fraction_field())\n sage: qbar = Sym.hecke_character()\n sage: s = Sym.s()\n sage: s(qbar[2,1])\n -s[1, 1, 1] + (q-1)*s[2, 1] + q*s[3]\n\n .. rubric:: `k`-Schur functions\n\n The `k`-Schur functions live in the `k`-bounded subspace of the ring of\n symmetric functions. It is possible to compute in the `k`-bounded subspace\n directly::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(3,1)\n sage: f = ks[2,1]*ks[2,1]; f\n ks3[2, 2, 1, 1] + ks3[2, 2, 2] + ks3[3, 1, 1, 1]\n\n or to lift to the ring of symmetric functions::\n\n sage: f.lift()\n s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] + s[3, 3] + s[4, 1, 1] + s[4, 2]\n\n However, it is not always possible to convert a symmetric function to the `k`-bounded subspace::\n\n sage: s = Sym.schur()\n sage: ks(s[2,1,1])\n Traceback (most recent call last):\n ...\n ValueError: s[2, 1, 1] is not in the image\n\n The `k`-Schur functions are more generally defined with a parameter `t` and they are\n a basis of the subspace spanned by the Hall-Littlewood ``Qp`` symmetric functions\n indexed by partitions whose first part is less than or equal to `k`::\n\n sage: Sym = SymmetricFunctions(QQ[\'t\'].fraction_field())\n sage: SymS3 = Sym.kBoundedSubspace(3) # default t=\'t\'\n sage: ks = SymS3.kschur()\n sage: Qp = Sym.hall_littlewood().Qp()\n sage: ks(Qp[2,1,1,1])\n ks3[2, 1, 1, 1] + (t^2+t)*ks3[2, 2, 1] + (t^3+t^2)*ks3[3, 1, 1] + t^4*ks3[3, 2]\n\n The subspace spanned by the `k`-Schur functions with a parameter `t` are not known\n to form a natural algebra. However it is known that the product of a `k`-Schur\n function and an `\\ell`-Schur function is in the linear span of the `k+\\ell`-Schur\n functions::\n\n sage: ks(ks[2,1]*ks[1,1])\n Traceback (most recent call last):\n ...\n ValueError: s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2] is not in the image\n sage: ks[2,1]*ks[1,1]\n s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2]\n sage: ks6 = Sym.kBoundedSubspace(6).kschur()\n sage: ks6(ks[3,1,1]*ks[3])\n ks6[3, 3, 1, 1] + ks6[4, 2, 1, 1] + (t+1)*ks6[4, 3, 1] + t*ks6[4, 4]\n + ks6[5, 1, 1, 1] + ks6[5, 2, 1] + t*ks6[5, 3] + ks6[6, 1, 1]\n\n The `k`-split basis is a second basis of the ring spanned by the `k`-Schur\n functions with a parameter `t`. The `k`-split basis has the property that\n `Q\'_\\lambda[X;t]` expands positively in the `k`-split basis and the\n `k`-split basis conjecturally expands positively in the `k`-Schur functions.\n The definition can be found in [LLMSSZ]_ p. 81.::\n\n sage: ksp3 = SymS3.ksplit()\n sage: ksp3(Qp[2,1,1,1])\n ksp3[2, 1, 1, 1] + t^2*ksp3[2, 2, 1] + (t^3+t^2)*ksp3[3, 1, 1] + t^4*ksp3[3, 2]\n sage: [ks(ksp3(la)) for la in sorted(ksp3(Qp[2,1,1,1]).support())]\n [ks3[2, 1, 1, 1] + t*ks3[2, 2, 1], ks3[2, 2, 1], ks3[3, 1, 1], ks3[3, 2]]\n\n .. rubric:: dual `k`-Schur functions\n\n The dual space to the subspace spanned by the `k`-Schur functions is most naturally\n realized as a quotient of the ring of symmetric functions by an ideal. When `t=1`\n the ideal is generated by the monomial symmetric functions indexed by partitions\n whose first part is greater than `k`.::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: SymQ3 = Sym.kBoundedQuotient(3,t=1)\n sage: km = SymQ3.kmonomial()\n sage: km[2,1]*km[2,1]\n 4*m3[2, 2, 1, 1] + 6*m3[2, 2, 2] + 2*m3[3, 2, 1] + 2*m3[3, 3]\n sage: F = SymQ3.affineSchur()\n sage: F[2,1]*F[2,1]\n 2*F3[1, 1, 1, 1, 1, 1] + 4*F3[2, 1, 1, 1, 1] + 4*F3[2, 2, 1, 1] + 4*F3[2, 2, 2]\n + 2*F3[3, 1, 1, 1] + 4*F3[3, 2, 1] + 2*F3[3, 3]\n\n When `t` is not equal to `1`, the subspace spanned by the `k`-Schur functions is\n realized as a quotient of the ring of symmetric functions by the ideal generated by\n the Hall-Littlewood symmetric functions in the P basis indexed by partitions with\n first part greater than `k`.::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'t\']))\n sage: SymQ3 = Sym.kBoundedQuotient(3)\n sage: kHLP = SymQ3.kHallLittlewoodP()\n sage: kHLP[2,1]*kHLP[2,1]\n (t^2+2*t+1)*HLP3[2, 2, 1, 1] + (t^3+2*t^2+2*t+1)*HLP3[2, 2, 2]\n + (-t^4-t^3+t+1)*HLP3[3, 1, 1, 1] + (-t^2+t+2)*HLP3[3, 2, 1] + (t+1)*HLP3[3, 3]\n sage: HLP = Sym.hall_littlewood().P()\n sage: kHLP(HLP[3,1])\n HLP3[3, 1]\n sage: kHLP(HLP[4])\n 0\n\n In this space, the basis which is dual to the `k`-Schur functions conjecturally\n expands positively in the `k`-bounded Hall-Littlewood functions and has positive\n structure coefficients.::\n\n sage: dks = SymQ3.dual_k_Schur()\n sage: kHLP(dks[2,2])\n (t^4+t^2)*HLP3[1, 1, 1, 1] + t*HLP3[2, 1, 1] + HLP3[2, 2]\n sage: dks[2,1]*dks[1,1]\n (t^2+t)*dks3[1, 1, 1, 1, 1] + (t+1)*dks3[2, 1, 1, 1] + (t+1)*dks3[2, 2, 1]\n + dks3[3, 1, 1] + dks3[3, 2]\n\n At `t=1` the `k`-bounded Hall-Littlewood basis is equal to the `k`-bounded monomial\n basis and the dual `k`-Schur elements are equal to the affine Schur basis. The\n `k`-bounded monomial basis and affine Schur functions are faster and should be used\n instead of the `k`-bounded Hall-Littlewood P basis and dual `k`-Schur functions when\n `t=1`.::\n\n sage: SymQ3 = Sym.kBoundedQuotient(3,t=1)\n sage: dks = SymQ3.dual_k_Schur()\n sage: F = SymQ3.affineSchur()\n sage: F[3,1]==dks[3,1]\n True\n\n .. rubric:: Implementing new bases\n\n In order to implement a new symmetric function basis, Sage will need\n to know at a minimum how to change back and forth between at least one\n other basis (although they do not necessarily have to be the same basis).\n All of the standard functions associated with the basis will have a\n default implementation (although a more specific implementation may\n be more efficient).\n\n To present an idea of how this is done, we will create\n here the example of how to implement the basis `s_\\mu[X(1-t)]`.\n\n To begin, we import the class\n :class:`sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic()`. Our\n new basis will inherit all of the default methods from this class::\n\n sage: from sage.combinat.sf.sfa import SymmetricFunctionAlgebra_generic as SFA_generic\n\n Now the basis we are creating has a parameter `t` which is possible\n to specialize. In this example we will convert to and from the Schur\n basis. For this we implement methods ``_self_to_s`` and ``_s_to_self``.\n By registering these two functions as coercions, Sage then knows\n automatically how it possible to change between any two bases for\n which there is a path of changes of bases. ::\n\n sage: from sage.categories.morphism import SetMorphism\n sage: class SFA_st(SFA_generic):\n ....: def __init__(self, Sym, t):\n ....: SFA_generic.__init__(self, Sym, basis_name=\n ....: "Schur functions with a plethystic substitution of X -> X(1-t)",\n ....: prefix=\'st\')\n ....: self._s = Sym.s()\n ....: self.t = Sym.base_ring()(t)\n ....: cat = HopfAlgebras(Sym.base_ring()).WithBasis()\n ....: self.register_coercion(\n ....: SetMorphism(Hom(self._s, self, cat), self._s_to_self))\n ....: self._s.register_coercion(\n ....: SetMorphism(Hom(self, self._s, cat), self._self_to_s))\n ....: def _s_to_self(self, f):\n ....: # f is a Schur function and the output is in the st basis\n ....: return self._from_dict(f.theta_qt(0,self.t)._monomial_coefficients)\n ....: def _self_to_s(self, f):\n ....: # f is in the st basis and the output is in the Schur basis\n ....: return self._s.sum(cmu*self._s(mu).theta_qt(self.t,0) for mu,cmu in f)\n ....: class Element(SFA_generic.Element):\n ....: pass\n\n An instance of this basis is created by calling it with a symmetric\n function ring ``Sym`` and a parameter ``t`` which is in the base ring\n of ``Sym``. The ``Element`` class inherits all of the methods from\n :class:`sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element`.\n\n In the reference [MAC]_ on page 354, this basis is denoted\n `S_\\lambda(x;t)` and the change of basis coefficients of the\n Macdonald ``J`` basis are the coefficients `K_{\\lambda\\mu}(q,t)`.\n Here is an example of its use::\n\n sage: QQqt = QQ[\'q\',\'t\'].fraction_field()\n sage: (q,t) = QQqt.gens()\n sage: st = SFA_st(SymmetricFunctions(QQqt),t)\n sage: st\n Symmetric Functions over Fraction Field of Multivariate Polynomial\n Ring in q, t over Rational Field in the Schur functions with a\n plethystic substitution of X -> X(1-t) basis\n sage: st[2,1] * st[1]\n st[2, 1, 1] + st[2, 2] + st[3, 1]\n sage: st([2]).coproduct()\n st[] # st[2] + st[1] # st[1] + st[2] # st[]\n sage: J = st.symmetric_function_ring().macdonald().J()\n sage: st(J[2,1])\n q*st[1, 1, 1] + (q*t+1)*st[2, 1] + t*st[3]\n\n .. rubric:: Acknowledgements\n\n The design is heavily inspired from the implementation of\n symmetric functions in MuPAD-Combinat (see [HT04]_ and [FD06]_).\n\n REFERENCES:\n\n .. [FD06] Francois Descouens, Making research on symmetric functions using MuPAD-Combinat.\n In Andres Iglesias and Nobuki Takayama, editors, 2nd International Congress on Mathematical Software (ICMS\'06),\n volume 4151 of LNCS, pages 407-418, Castro Urdiales, Spain, September 2006. Springer-Verlag.\n :arxiv:`0806.1873`\n\n .. [HT04] Florent Hivert and Nicolas M. Thiery,\n MuPAD-Combinat, an open-source package for research in algebraic combinatorics.\n Sem. Lothar. Combin., 51 :Art. B51z, 70 pp. (electronic), 2004.\n http://mupad-combinat.sf.net/.\n\n .. [MAC] Ian Macdonald, Symmetric Functions and Orthogonal Polynomials,\n Second edition. With contributions by A. Zelevinsky. Oxford Mathematical Monographs.\n Oxford Science Publications. The Clarendon Press, Oxford University Press, New York, 1995. x+475 pp.\n ISBN: 0-19-853489-2\n\n .. [STA] Richard Stanley, Enumerative combinatorics. Vol. 2.\n With a foreword by Gian-Carlo Rota and appendix 1 by Sergey Fomin.\n Cambridge Studies in Advanced Mathematics, 62. Cambridge University Press, Cambridge, 1999. xii+581 pp.\n ISBN: 0-521-56069-1; 0-521-78987-7\n\n .. [ST94] Scharf, Thomas, Thibon, Jean-Yves,\n A Hopf-algebra approach to inner plethysm.\n Adv. Math. 104 (1994), no. 1, 30-58.\n :doi:`10.1006/aima.1994.1019`\n\n .. rubric:: Further tests\n\n TESTS::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym\n Symmetric Functions over Rational Field\n sage: h = Sym.h(); e = Sym.e(); s = Sym.s(); m = Sym.m(); p = Sym.p()\n sage: ( ( h[2,1] * ( 1 + 3 * h[2,1]) ) + s[2]. antipode()) . coproduct()\n h[] # h[1, 1] - h[] # h[2] + h[] # h[2, 1] + 3*h[] # h[2, 2, 1, 1] + h[1] # h[1] + h[1] # h[1, 1]\n + h[1] # h[2] + 6*h[1] # h[2, 1, 1, 1] + 6*h[1] # h[2, 2, 1] + h[1, 1] # h[] + h[1, 1] # h[1]\n + 3*h[1, 1] # h[1, 1, 1, 1] + 12*h[1, 1] # h[2, 1, 1] + 3*h[1, 1] # h[2, 2] + 6*h[1, 1, 1] # h[1, 1, 1]\n + 6*h[1, 1, 1] # h[2, 1] + 3*h[1, 1, 1, 1] # h[1, 1] - h[2] # h[] + h[2] # h[1] + 6*h[2] # h[2, 1, 1]\n + h[2, 1] # h[] + 6*h[2, 1] # h[1, 1, 1] + 12*h[2, 1] # h[2, 1] + 12*h[2, 1, 1] # h[1, 1]\n + 6*h[2, 1, 1] # h[2] + 6*h[2, 1, 1, 1] # h[1] + 3*h[2, 2] # h[1, 1] + 6*h[2, 2, 1] # h[1] + 3*h[2, 2, 1, 1] # h[]\n\n .. TODO::\n\n - Introduce fields with degree 1 elements as in\n MuPAD-Combinat, to get proper plethysm.\n - Use UniqueRepresentation to get rid of all the manual cache\n handling for the bases\n - Devise a mechanism so that pickling bases of symmetric\n functions pickles the coercions which have a cache.\n '
def __init__(self, R):
'\n Initialization of ``self``.\n\n INPUT:\n\n - ``R`` -- a ring\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n\n TESTS::\n\n sage: Sym1 = SymmetricFunctions(FiniteField(23))\n sage: Sym2 = SymmetricFunctions(Integers(23))\n sage: TestSuite(Sym).run()\n\n '
assert ((R in Fields()) or (R in Rings()))
self._base = R
cat = GradedHopfAlgebras(R).Commutative().Cocommutative()
if (R in PrincipalIdealDomains()):
cat &= UniqueFactorizationDomains()
Parent.__init__(self, category=cat.WithRealizations())
def a_realization(self):
'\n Return a particular realization of ``self`` (the Schur basis).\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym.a_realization()\n Symmetric Functions over Rational Field in the Schur basis\n '
return self.schur()
def _repr_(self):
'\n Representation of ``self``\n\n TESTS::\n\n sage: SymmetricFunctions(RR) # indirect doctest\n Symmetric Functions over Real Field with 53 bits of precision\n '
return ('Symmetric Functions over %s' % self.base_ring())
def schur(self):
'\n The Schur basis of the Symmetric Functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).schur()\n Symmetric Functions over Rational Field in the Schur basis\n '
return schur.SymmetricFunctionAlgebra_schur(self)
s = schur
Schur = schur
def powersum(self):
'\n The power sum basis of the Symmetric Functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).powersum()\n Symmetric Functions over Rational Field in the powersum basis\n '
return powersum.SymmetricFunctionAlgebra_power(self)
p = powersum
power = powersum
def complete(self):
'\n The complete basis of the Symmetric Functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).complete()\n Symmetric Functions over Rational Field in the homogeneous basis\n '
return homogeneous.SymmetricFunctionAlgebra_homogeneous(self)
h = complete
homogeneous = complete
def elementary(self):
'\n The elementary basis of the Symmetric Functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).elementary()\n Symmetric Functions over Rational Field in the elementary basis\n '
return elementary.SymmetricFunctionAlgebra_elementary(self)
e = elementary
def monomial(self):
'\n The monomial basis of the Symmetric Functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).monomial()\n Symmetric Functions over Rational Field in the monomial basis\n '
return monomial.SymmetricFunctionAlgebra_monomial(self)
m = monomial
def witt(self, coerce_h=True, coerce_e=False, coerce_p=False):
'\n The Witt basis of the symmetric functions.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).witt()\n Symmetric Functions over Rational Field in the Witt basis\n sage: SymmetricFunctions(QQ).witt(coerce_p=True)\n Symmetric Functions over Rational Field in the Witt basis\n sage: SymmetricFunctions(QQ).witt(coerce_h=False, coerce_e=True, coerce_p=True)\n Symmetric Functions over Rational Field in the Witt basis\n '
from . import witt
return witt.SymmetricFunctionAlgebra_witt(self, coerce_h=coerce_h, coerce_e=coerce_e, coerce_p=coerce_p)
w = witt
Witt = witt
def irreducible_symmetric_group_character(self):
'\n The irreducible `S_n` character basis of the Symmetric Functions.\n\n This basis has the property that if the element indexed by the\n partition `\\lambda` is evaluated at the roots of a permutation of\n cycle structure `\\rho` then the value is the irreducible character\n `\\chi^{(|\\rho|-|\\lambda|,\\lambda)}(\\rho)`.\n\n In terms of methods that are implemented in Sage, if ``n`` is\n a sufficiently large integer, then\n ``st(lam).character_to_frobenius_image(n)`` is equal the Schur function\n indexed by ``[n-sum(lam)]+lam``.\n\n This basis is introduced in [OZ2015]_.\n\n .. SEEALSO::\n\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.character_to_frobenius_image`,\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.eval_at_permutation_roots`\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).irreducible_symmetric_group_character()\n Symmetric Functions over Rational Field in the irreducible symmetric group character basis\n sage: st = SymmetricFunctions(QQ).st()\n sage: s = SymmetricFunctions(QQ).s()\n sage: s(st([3,2]).character_to_frobenius_image(9))\n s[4, 3, 2]\n sage: s(st([3,2]).character_to_frobenius_image(7))\n 0\n sage: s(st([3,2]).character_to_frobenius_image(6))\n -s[2, 2, 2]\n sage: list(SymmetricGroup(5).character_table()[-2])\n [4, 2, 0, 1, -1, 0, -1]\n sage: list(reversed([st([1]).eval_at_permutation_roots(rho)\n ....: for rho in Partitions(5)]))\n [4, 2, 0, 1, -1, 0, -1]\n '
from .character import irreducible_character_basis
return irreducible_character_basis(self, 'st')
st = irreducible_symmetric_group_character
def induced_trivial_character(self):
'\n The induced trivial character basis of the Symmetric Functions.\n\n The trivial character of\n\n .. MATH::\n\n S_{n-|\\lambda|} \\times S_{\\lambda_1} \\times S_{\\lambda_2} \\times\n \\cdots \\times S_{\\lambda_\\ell(\\lambda)}\n\n induced to the group `S_{n}` is a symmetric function in the\n eigenvalues of a permutation matrix. This basis is that character.\n\n It has the property that if the element indexed by the\n partition `\\lambda` is evaluated at the roots of a permutation of\n cycle structure `\\rho` then the value is the coefficient\n `\\left< h_{(n-|\\lambda|,\\lambda)}, p_\\rho \\right>`.\n\n In terms of methods that are implemented in Sage, if ``n`` is\n a sufficiently large integer, then\n ``ht(lam).character_to_frobenius_image(n)`` is equal the complete\n function indexed by ``[n-sum(lam)]+lam``.\n\n This basis is introduced in [OZ2015]_.\n\n .. SEEALSO::\n\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.character_to_frobenius_image`,\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.eval_at_permutation_roots`\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).induced_trivial_character()\n Symmetric Functions over Rational Field in the induced trivial symmetric group character basis\n sage: ht = SymmetricFunctions(QQ).ht()\n sage: h = SymmetricFunctions(QQ).h()\n sage: h(ht([3,2]).character_to_frobenius_image(9))\n h[4, 3, 2]\n sage: h(ht([3,2]).character_to_frobenius_image(7))\n h[3, 2, 2]\n sage: h(ht([3,2]).character_to_frobenius_image(5))\n h[3, 2]\n sage: h(ht([3,2]).character_to_frobenius_image(4))\n 0\n sage: p = SymmetricFunctions(QQ).p()\n sage: [h([4,1]).scalar(p(rho)) for rho in Partitions(5)]\n [0, 1, 0, 2, 1, 3, 5]\n sage: [ht([1]).eval_at_permutation_roots(rho) for rho in Partitions(5)]\n [0, 1, 0, 2, 1, 3, 5]\n '
from .character import induced_trivial_character_basis
return induced_trivial_character_basis(self, 'ht')
ht = induced_trivial_character
def forgotten(self):
'\n The forgotten basis of the Symmetric Functions (or the basis dual to\n the elementary basis with respect to the Hall scalar product).\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).forgotten()\n Symmetric Functions over Rational Field in the forgotten basis\n\n TESTS:\n\n Over the rationals::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: e = Sym.e()\n sage: f = Sym.f()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: e(f([2,1]))\n -2*e[1, 1, 1] + 5*e[2, 1] - 3*e[3]\n sage: f(e([2,1]))\n 3*f[1, 1, 1] + 2*f[2, 1] + f[3]\n sage: h(f([2,1]))\n h[2, 1] - 3*h[3]\n sage: f(h([2,1]))\n 3*f[1, 1, 1] + f[2, 1]\n sage: p(f([2,1]))\n -p[2, 1] - p[3]\n sage: f(p([2,1]))\n -f[2, 1] - f[3]\n sage: s(f([2,1]))\n s[2, 1] - 2*s[3]\n sage: f(s([2,1]))\n 2*f[1, 1, 1] + f[2, 1]\n sage: m(f([2,1]))\n -m[2, 1] - 2*m[3]\n sage: f(m([2,1]))\n -f[2, 1] - 2*f[3]\n\n Over the integers::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: e = Sym.e()\n sage: f = Sym.f()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: e(f([2,1]))\n -2*e[1, 1, 1] + 5*e[2, 1] - 3*e[3]\n sage: f(e([2,1]))\n 3*f[1, 1, 1] + 2*f[2, 1] + f[3]\n sage: h(f([2,1]))\n h[2, 1] - 3*h[3]\n sage: f(h([2,1]))\n 3*f[1, 1, 1] + f[2, 1]\n sage: f(p([2,1]))\n -f[2, 1] - f[3]\n sage: s(f([2,1]))\n s[2, 1] - 2*s[3]\n sage: f(s([2,1]))\n 2*f[1, 1, 1] + f[2, 1]\n sage: m(f([2,1]))\n -m[2, 1] - 2*m[3]\n sage: f(m([2,1]))\n -f[2, 1] - 2*f[3]\n\n Conversion from the forgotten basis to the power-sum basis over the\n integers is not well-defined in general, even if the result happens\n to have integral coefficients::\n\n sage: p(f([2,1]))\n Traceback (most recent call last):\n ...\n TypeError: no conversion of this rational to integer\n\n Fun exercise: prove that `p(f_{\\lambda})` and `p(m_{\\lambda})` have\n integral coefficients whenever `\\lambda` is a strict partition.\n '
return self.elementary().dual_basis()
f = forgotten
def symplectic(self):
'\n The symplectic basis of the symmetric functions.\n\n .. SEEALSO:: :class:`~sage.combinat.sf.symplectic.SymmetricFunctionAlgebra_symplectic`\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).symplectic()\n Symmetric Functions over Rational Field in the symplectic basis\n '
from . import symplectic
return symplectic.SymmetricFunctionAlgebra_symplectic(self)
sp = symplectic
def orthogonal(self):
'\n The orthogonal basis of the symmetric functions.\n\n .. SEEALSO:: :class:`~sage.combinat.sf.orthogonal.SymmetricFunctionAlgebra_orthogonal`\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).orthogonal()\n Symmetric Functions over Rational Field in the orthogonal basis\n '
from . import orthogonal
return orthogonal.SymmetricFunctionAlgebra_orthogonal(self)
o = orthogonal
def hecke_character(self, q='q'):
"\n The basis of symmetric functions that determines the character\n tables for Hecke algebras.\n\n EXAMPLES::\n\n sage: SymmetricFunctions(ZZ['q'].fraction_field()).hecke_character()\n Symmetric Functions over\n Fraction Field of Univariate Polynomial Ring in q over Integer Ring\n in the Hecke character with q=q basis\n sage: SymmetricFunctions(QQ).hecke_character(1/2)\n Symmetric Functions over Rational Field in the Hecke character with q=1/2 basis\n "
from sage.combinat.sf.hecke import HeckeCharacter
return HeckeCharacter(self, q)
qbar = hecke_character
def macdonald(self, q='q', t='t'):
"\n Returns the entry point for the various Macdonald bases.\n\n INPUT:\n\n - ``q``, ``t`` -- parameters\n\n Macdonald symmetric functions including bases `P`, `Q`, `J`, `H`, `Ht`.\n This also contains the `S` basis which is dual to the Schur basis with\n respect to the `q,t` scalar product.\n\n The parameters `q` and `t` must be in the base_ring of parent.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P(); P\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald P basis\n sage: P[2]\n McdP[2]\n sage: Q = Sym.macdonald().Q(); Q\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the Macdonald Q basis\n sage: S = Sym.macdonald().S()\n sage: s = Sym.schur()\n sage: matrix([[S(la).scalar_qt(s(mu)) for la in Partitions(3)] for mu in Partitions(3)])\n [1 0 0]\n [0 1 0]\n [0 0 1]\n sage: H = Sym.macdonald().H()\n sage: s(H[2,2])\n q^2*s[1, 1, 1, 1] + (q^2*t+q*t+q)*s[2, 1, 1] + (q^2*t^2+1)*s[2, 2] + (q*t^2+q*t+t)*s[3, 1] + t^2*s[4]\n\n sage: Sym = SymmetricFunctions(QQ['z','q'].fraction_field())\n sage: (z,q) = Sym.base_ring().gens()\n sage: Hzq = Sym.macdonald(q=z,t=q).H()\n sage: H1z = Sym.macdonald(q=1,t=z).H()\n sage: s = Sym.schur()\n sage: s(H1z([2,2]))\n s[1, 1, 1, 1] + (2*z+1)*s[2, 1, 1] + (z^2+1)*s[2, 2] + (z^2+2*z)*s[3, 1] + z^2*s[4]\n sage: s(Hzq[2,2])\n z^2*s[1, 1, 1, 1] + (z^2*q+z*q+z)*s[2, 1, 1] + (z^2*q^2+1)*s[2, 2] + (z*q^2+z*q+q)*s[3, 1] + q^2*s[4]\n sage: s(H1z(Hzq[2,2]))\n z^2*s[1, 1, 1, 1] + (z^2*q+z*q+z)*s[2, 1, 1] + (z^2*q^2+1)*s[2, 2] + (z*q^2+z*q+q)*s[3, 1] + q^2*s[4]\n "
return macdonald.Macdonald(self, q=q, t=t)
def hall_littlewood(self, t='t'):
"\n Returns the entry point for the various Hall-Littlewood bases.\n\n INPUT:\n\n - ``t`` -- parameter\n\n Hall-Littlewood symmetric functions including bases `P`, `Q`, `Qp`.\n The Hall-Littlewood `P` and `Q` functions at `t=-1` are the\n Schur-P and Schur-Q functions when indexed by strict partitions.\n\n The parameter `t` must be in the base ring of parent.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: P = Sym.hall_littlewood().P(); P\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Hall-Littlewood P basis\n sage: P[2]\n HLP[2]\n sage: Q = Sym.hall_littlewood().Q(); Q\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Hall-Littlewood Q basis\n sage: Q[2]\n HLQ[2]\n sage: Qp = Sym.hall_littlewood().Qp(); Qp\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Hall-Littlewood Qp basis\n sage: Qp[2]\n HLQp[2]\n "
return hall_littlewood.HallLittlewood(self, t=t)
def jack(self, t='t'):
"\n Returns the entry point for the various Jack bases.\n\n INPUT:\n\n - ``t`` -- parameter\n\n Jack symmetric functions including bases `P`, `Q`, `Qp`.\n\n The parameter `t` must be in the base ring of parent.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: JP = Sym.jack().P(); JP\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack P basis\n sage: JQ = Sym.jack().Q(); JQ\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack Q basis\n sage: JJ = Sym.jack().J(); JJ\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack J basis\n sage: JQp = Sym.jack().Qp(); JQp\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Jack Qp basis\n "
return jack.Jack(self, t=t)
def zonal(self):
'\n The zonal basis of the Symmetric Functions\n\n EXAMPLES::\n\n sage: SymmetricFunctions(QQ).zonal()\n Symmetric Functions over Rational Field in the zonal basis\n '
return jack.SymmetricFunctionAlgebra_zonal(self)
def llt(self, k, t='t'):
"\n The LLT symmetric functions.\n\n INPUT:\n\n - ``k`` -- a positive integer indicating the level\n - ``t`` -- a parameter (default: `t`)\n\n LLT polynomials in `hspin` and `hcospin` bases.\n\n EXAMPLES::\n\n sage: llt3 = SymmetricFunctions(QQ['t'].fraction_field()).llt(3); llt3\n level 3 LLT polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n sage: llt3.hspin()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT spin basis\n sage: llt3.hcospin()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT cospin basis\n sage: llt3.hcospin()\n Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT cospin basis\n "
return llt.LLT_class(self, k, t=t)
def from_polynomial(self, f):
"\n Converts a symmetric polynomial ``f`` to a symmetric function.\n\n INPUT:\n\n - ``f`` -- a symmetric polynomial\n\n This function converts a symmetric polynomial `f` in a polynomial ring in finitely\n many variables to a symmetric function in the monomial\n basis of the ring of symmetric functions over the same base ring.\n\n EXAMPLES::\n\n sage: P = PolynomialRing(QQ, 'x', 3)\n sage: x = P.gens()\n sage: f = x[0] + x[1] + x[2]\n sage: S = SymmetricFunctions(QQ)\n sage: S.from_polynomial(f)\n m[1]\n\n sage: f = x[0] + 2*x[1] + x[2]\n sage: S.from_polynomial(f)\n Traceback (most recent call last):\n ...\n ValueError: x0 + 2*x1 + x2 is not a symmetric polynomial\n "
return self.m().from_polynomial(f)
def register_isomorphism(self, morphism, only_conversion=False):
"\n Register an isomorphism between two bases of ``self``, as a canonical coercion\n (unless the optional keyword ``only_conversion`` is set to ``True``,\n in which case the isomorphism is registered as conversion only).\n\n EXAMPLES:\n\n We override the canonical coercion from the Schur basis to the\n powersum basis by a (stupid!) map `s_\\lambda\\mapsto 2p_\\lambda`.\n ::\n\n sage: Sym = SymmetricFunctions(QQ['zorglub']) # make sure we are not going to screw up later tests\n sage: s = Sym.s(); p = Sym.p().dual_basis()\n sage: phi = s.module_morphism(diagonal = lambda t: 2, codomain = p)\n sage: phi(s[2, 1])\n 2*d_p[2, 1]\n sage: Sym.register_isomorphism(phi)\n sage: p(s[2,1])\n 2*d_p[2, 1]\n\n The map is supposed to implement the canonical isomorphism\n between the two bases. Otherwise, the results will be\n mathematically wrong, as above. Use with care!\n "
if only_conversion:
morphism.codomain().register_conversion(morphism)
else:
morphism.codomain().register_coercion(morphism)
_shorthands = ['e', 'f', 'h', 'm', 'p', 's']
_shorthands_all = sorted((_shorthands + ['ht', 'o', 'sp', 'st', 'w']))
def __init_extra__(self):
'\n Sets up the coercions between the different bases\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ) # indirect doctest\n sage: s = Sym.s(); p = Sym.p()\n sage: f = s.coerce_map_from(p); f\n Generic morphism:\n From: Symmetric Functions over Rational Field in the powersum basis\n To: Symmetric Functions over Rational Field in the Schur basis\n sage: p.an_element()\n 2*p[] + 2*p[1] + 3*p[2]\n sage: f(p.an_element())\n 2*s[] + 2*s[1] - 3*s[1, 1] + 3*s[2]\n sage: f(p.an_element()) == p.an_element()\n True\n\n '
iso = self.register_isomorphism
from sage.combinat.sf.classical import conversion_functions
for (basis1_name, basis2_name) in conversion_functions:
basis1 = getattr(self, basis1_name)()
basis2 = getattr(self, basis2_name)()
on_basis = SymmetricaConversionOnBasis(t=conversion_functions[(basis1_name, basis2_name)], domain=basis1, codomain=basis2)
from sage.rings.rational_field import RationalField
if ((basis2_name != 'powersum') or self._base.has_coerce_map_from(RationalField())):
iso(basis1._module_morphism(on_basis, codomain=basis2))
else:
iso(basis1._module_morphism(on_basis, codomain=basis2), only_conversion=True)
def kBoundedSubspace(self, k, t='t'):
"\n Return the `k`-bounded subspace of the ring of symmetric functions.\n\n INPUT:\n\n - ``k`` - a positive integer\n - ``t`` a formal parameter; `t=1` yields a subring\n\n The subspace of the ring of symmetric functions spanned by\n `\\{ s_{\\lambda}[X/(1-t)] \\}_{\\lambda_1\\le k} = \\{ s_{\\lambda}^{(k)}[X,t]\\}_{\\lambda_1 \\le k}`\n over the base ring `\\QQ[t]`. When `t=1`, this space is in fact a subalgebra of\n the ring of symmetric functions generated by the complete homogeneous symmetric functions\n `h_i` for `1\\le i \\le k`.\n\n .. SEEALSO:: :meth:`sage.combinat.sf.new_kschur.KBoundedSubspace`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: KB = Sym.kBoundedSubspace(3,1); KB\n 3-bounded Symmetric Functions over Rational Field with t=1\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: Sym.kBoundedSubspace(3)\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n\n sage: Sym = SymmetricFunctions(QQ['z'])\n sage: z = Sym.base_ring().gens()[0]\n sage: Sym.kBoundedSubspace(3,t=z)\n 3-bounded Symmetric Functions over Univariate Polynomial Ring in z over Rational Field with t=z\n "
from sage.combinat.sf.new_kschur import KBoundedSubspace
return KBoundedSubspace(self, k, t=t)
def kschur(self, k, t='t'):
"\n Returns the `k`-Schur functions.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ks = Sym.kschur(3,1)\n sage: ks[2]*ks[2]\n ks3[2, 2] + ks3[3, 1]\n sage: ks[2,1,1].lift()\n s[2, 1, 1] + s[3, 1]\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ks = Sym.kschur(3)\n sage: ks[2,2,1].lift()\n s[2, 2, 1] + t*s[3, 2]\n "
return self.kBoundedSubspace(k, t=t).kschur()
def ksplit(self, k, t='t'):
"\n Return the `k`-split basis of the `k`-bounded subspace.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: ksp = Sym.ksplit(3,1)\n sage: ksp[2]*ksp[2]\n ksp3[2, 2] + ksp3[3, 1]\n sage: ksp[2,1,1].lift()\n s[2, 1, 1] + s[2, 2] + s[3, 1]\n\n sage: Sym = SymmetricFunctions(QQ['t'])\n sage: ksp = Sym.ksplit(3)\n sage: ksp[2,1,1].lift()\n s[2, 1, 1] + t*s[2, 2] + t*s[3, 1]\n "
return self.kBoundedSubspace(k, t=t).ksplit()
def khomogeneous(self, k):
'\n Returns the homogeneous symmetric functions in the `k`-bounded subspace.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: kh = Sym.khomogeneous(4)\n sage: kh[3]*kh[4]\n h4[4, 3]\n sage: kh[4].lift()\n h[4]\n '
return self.kBoundedSubspace(k, t=1).khomogeneous()
def kBoundedQuotient(self, k, t='t'):
"\n Returns the `k`-bounded quotient space of the ring of symmetric functions.\n\n INPUT:\n\n - ``k`` - a positive integer\n\n The quotient of the ring of symmetric functions ...\n\n .. SEEALSO:: :meth:`sage.combinat.sf.k_dual.KBoundedQuotient`\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: KQ = Sym.kBoundedQuotient(3); KQ\n Traceback (most recent call last):\n ...\n TypeError: unable to convert 't' to a rational\n sage: KQ = Sym.kBoundedQuotient(3,t=1); KQ\n 3-Bounded Quotient of Symmetric Functions over Rational Field with t=1\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: KQ = Sym.kBoundedQuotient(3); KQ\n 3-Bounded Quotient of Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field\n "
from sage.combinat.sf.k_dual import KBoundedQuotient
return KBoundedQuotient(self, k, t)
|
class SymmetricaConversionOnBasis():
def __init__(self, t, domain, codomain):
"\n Initialization of ``self``.\n\n INPUT:\n\n - ``t`` -- a function taking a monomial in CombinatorialFreeModule(QQ, Partitions()),\n and returning a (partition, coefficient) list.\n\n - ``domain``, ``codomain`` -- parents\n\n Construct a function mapping a partition to an element of ``codomain``.\n\n This is a temporary quick hack to wrap around the existing\n symmetrica conversions, without changing their specs.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['x'])\n sage: p = Sym.p(); s = Sym.s()\n sage: def t(x) : [(p,c)] = x; return [ (p,2*c), (p.conjugate(), c) ]\n sage: f = sage.combinat.sf.sf.SymmetricaConversionOnBasis(t, p, s)\n sage: f(Partition([3,1]))\n s[2, 1, 1] + 2*s[3, 1]\n "
self._domain = domain
self.fake_sym = CombinatorialFreeModule(QQ, Partitions())
self._codomain = codomain
self._t = t
def __call__(self, partition):
"\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['x'])\n sage: p = Sym.p(); s = Sym.s()\n sage: p[1] + s[1] # indirect doctest\n 2*p[1]\n "
return self._codomain._from_dict(dict(self._t(self.fake_sym.monomial(partition))), coerce=True)
|
def is_SymmetricFunctionAlgebra(x):
"\n Checks whether ``x`` is a symmetric function algebra.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import is_SymmetricFunctionAlgebra\n sage: is_SymmetricFunctionAlgebra(5)\n False\n sage: is_SymmetricFunctionAlgebra(ZZ)\n False\n sage: is_SymmetricFunctionAlgebra(SymmetricFunctions(ZZ).schur())\n True\n sage: is_SymmetricFunctionAlgebra(SymmetricFunctions(QQ).e())\n True\n sage: is_SymmetricFunctionAlgebra(SymmetricFunctions(QQ).macdonald(q=1,t=1).P())\n True\n sage: is_SymmetricFunctionAlgebra(SymmetricFunctions(FractionField(QQ['q','t'])).macdonald().P())\n True\n "
return isinstance(x, SymmetricFunctionAlgebra_generic)
|
def zee(part):
'\n Return the size of the centralizer of any permutation of cycle type\n ``part``.\n\n Note that the size of the centralizer is the inner product between\n ``p(part)`` and itself, where `p` is the power-sum symmetric\n functions.\n\n INPUT:\n\n - ``part`` -- an integer partition (for example, ``[2,1,1]``)\n\n OUTPUT:\n\n - the integer `\\prod_{i} i^{m_i(part)} m_i(part)!` where `m_i(part)` is\n the number of parts in the partition ``part`` equal to `i`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import zee\n sage: zee([2,1,1])\n 4\n '
if (not isinstance(part, Partition)):
part = _Partitions(part)
return part.centralizer_size()
|
def is_SymmetricFunction(x):
'\n Checks whether ``x`` is a symmetric function.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import is_SymmetricFunction\n sage: s = SymmetricFunctions(QQ).s()\n sage: is_SymmetricFunction(2)\n False\n sage: is_SymmetricFunction(s(2))\n True\n sage: is_SymmetricFunction(s([2,1]))\n True\n '
return isinstance(x, SymmetricFunctionAlgebra_generic.Element)
|
class SymmetricFunctionsBases(Category_realization_of_parent):
'\n The category of bases of the ring of symmetric functions.\n\n INPUT:\n\n - ``self`` -- a category of bases for the symmetric functions\n - ``base`` -- ring of symmetric functions\n\n TESTS::\n\n sage: from sage.combinat.sf.sfa import SymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = SymmetricFunctionsBases(Sym); bases\n Category of bases of Symmetric Functions over Rational Field\n sage: Sym.schur() in bases\n True\n '
def _repr_(self):
"\n Return the representation of ``self``.\n\n INPUT:\n\n - ``self`` -- a category of bases for the symmetric functions\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import SymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = SymmetricFunctionsBases(Sym)\n sage: bases._repr_()\n 'Category of bases of Symmetric Functions over Rational Field'\n "
return ('Category of bases of %s' % self.base())
def super_categories(self):
'\n The super categories of ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import SymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = SymmetricFunctionsBases(Sym)\n sage: bases.super_categories()\n [Category of realizations of Symmetric Functions over Rational Field,\n Category of commutative Hopf algebras with basis over Rational Field,\n Join of Category of realizations of Hopf algebras over Rational Field\n and Category of graded algebras over Rational Field\n and Category of graded coalgebras over Rational Field,\n Category of unique factorization domains]\n\n sage: Sym = SymmetricFunctions(ZZ["x"])\n sage: bases = SymmetricFunctionsBases(Sym)\n sage: bases.super_categories()\n [Category of realizations of Symmetric Functions over Univariate Polynomial Ring in x over Integer Ring,\n Category of commutative Hopf algebras with basis over Univariate Polynomial Ring in x over Integer Ring,\n Join of Category of realizations of Hopf algebras over Univariate Polynomial Ring in x over Integer Ring\n and Category of graded algebras over Univariate Polynomial Ring in x over Integer Ring\n and Category of graded coalgebras over Univariate Polynomial Ring in x over Integer Ring]\n '
R = self.base().base_ring()
cat = HopfAlgebras(R)
categories = [self.base().Realizations(), cat.Commutative().WithBasis(), cat.Graded().Realizations()]
if (R in PrincipalIdealDomains):
categories.append(UniqueFactorizationDomains())
return categories
class ParentMethods():
def is_integral_domain(self, proof=True):
'\n Return whether ``self`` is an integral domain. (It is if\n and only if the base ring is an integral domain.)\n\n INPUT:\n\n - ``self`` -- a basis of the symmetric functions\n - ``proof`` -- an optional argument (default value: ``True``)\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s.is_integral_domain()\n True\n\n sage: s = SymmetricFunctions(Zmod(14)).s()\n sage: s.is_integral_domain()\n False\n '
return self.base_ring().is_integral_domain()
def is_field(self, proof=True):
'\n Return whether ``self`` is a field. (It is not.)\n\n INPUT:\n\n - ``self`` -- a basis of the symmetric functions\n - ``proof`` -- an optional argument (default value: ``True``)\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s.is_field()\n False\n '
return False
def is_commutative(self):
'\n Return whether this symmetric function algebra is commutative.\n\n INPUT:\n\n - ``self`` -- a basis of the symmetric functions\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s.is_commutative()\n True\n '
return self.base_ring().is_commutative()
def _repr_(self):
'\n Text representation of this basis of symmetric functions\n\n INPUT:\n\n - ``self`` -- a basis of the symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q,t\'])); Sym\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field\n sage: Sym.p()\n Symmetric Functions over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field in the powersum basis\n\n In the following examples, we rename {{{Sym}}} for brevity::\n\n sage: Sym.rename("Sym"); Sym\n Sym\n\n Classical bases::\n\n sage: Sym.s()\n Sym in the Schur basis\n sage: Sym.p()\n Sym in the powersum basis\n sage: Sym.m()\n Sym in the monomial basis\n sage: Sym.e()\n Sym in the elementary basis\n sage: Sym.h()\n Sym in the homogeneous basis\n sage: Sym.f()\n Sym in the forgotten basis\n\n Macdonald polynomials::\n\n sage: Sym.macdonald().P()\n Sym in the Macdonald P basis\n sage: Sym.macdonald().Q()\n Sym in the Macdonald Q basis\n sage: Sym.macdonald().J()\n Sym in the Macdonald J basis\n sage: Sym.macdonald().H()\n Sym in the Macdonald H basis\n sage: Sym.macdonald().Ht()\n Sym in the Macdonald Ht basis\n sage: Sym.macdonald().S()\n Sym in the Macdonald S basis\n\n Macdonald polynomials, with specialized parameters::\n\n sage: Sym.macdonald(q=1).S()\n Sym in the Macdonald S with q=1 basis\n sage: Sym.macdonald(q=1,t=3).P()\n Sym in the Macdonald P with q=1 and t=3 basis\n\n Hall-Littlewood polynomials::\n\n sage: Sym.hall_littlewood().P()\n Sym in the Hall-Littlewood P basis\n sage: Sym.hall_littlewood().Q()\n Sym in the Hall-Littlewood Q basis\n sage: Sym.hall_littlewood().Qp()\n Sym in the Hall-Littlewood Qp basis\n\n Hall-Littlewood polynomials, with specialized parameter::\n\n sage: Sym.hall_littlewood(t=1).P()\n Sym in the Hall-Littlewood P with t=1 basis\n\n Jack polynomials::\n\n sage: Sym.jack().J()\n Sym in the Jack J basis\n sage: Sym.jack().P()\n Sym in the Jack P basis\n sage: Sym.jack().Q()\n Sym in the Jack Q basis\n sage: Sym.jack().Qp()\n Sym in the Jack Qp basis\n\n Jack polynomials, with specialized parameter::\n\n sage: Sym.jack(t=1).J()\n Sym in the Jack J with t=1 basis\n\n Zonal polynomials::\n\n sage: Sym.zonal()\n Sym in the zonal basis\n\n LLT polynomials::\n\n sage: Sym.llt(3).hspin()\n Sym in the level 3 LLT spin basis\n sage: Sym.llt(3).hcospin()\n Sym in the level 3 LLT cospin basis\n\n LLT polynomials, with specialized parameter::\n\n sage: Sym.llt(3, t=1).hspin()\n Sym in the level 3 LLT spin with t=1 basis\n sage: Sym.llt(3, t=1).hcospin()\n Sym in the level 3 LLT cospin with t=1 basis\n\n TESTS::\n\n sage: Sym.s()._repr_()\n \'Sym in the Schur basis\'\n sage: Sym.s()._repr_.__module__\n \'sage.combinat.sf.sfa\'\n\n ::\n\n sage: Sym.rename()\n '
return ('%s in the %s basis' % (self.realization_of(), self.basis_name()))
@cached_method
def one_basis(self):
"\n Return the empty partition, as per ``AlgebrasWithBasis.ParentMethods.one_basis``\n\n INPUT:\n\n - ``self`` -- a basis of the ring of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())\n sage: s = Sym.s()\n sage: s.one_basis()\n []\n sage: Q = Sym.hall_littlewood().Q()\n sage: Q.one_basis()\n []\n\n .. TODO:: generalize to Modules.Graded.Connected.ParentMethods\n "
return _Partitions([])
def degree_on_basis(self, b):
"\n Return the degree of the basis element indexed by ``b``.\n\n INPUT:\n\n - ``self`` -- a basis of the symmetric functions\n - ``b`` -- a partition\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ['q,t'].fraction_field())\n sage: m = Sym.monomial()\n sage: m.degree_on_basis(Partition([3,2]))\n 5\n sage: P = Sym.macdonald().P()\n sage: P.degree_on_basis(Partition([]))\n 0\n "
return sum(b)
def corresponding_basis_over(self, R):
"\n Return the realization of symmetric functions corresponding to\n ``self`` but over the base ring ``R``. Only works when ``self``\n is one of the classical bases, not one of the `q,t`-dependent\n ones. In the latter case, ``None`` is returned instead.\n\n INPUT:\n\n - ``R`` -- a commutative ring\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.monomial()\n sage: m.corresponding_basis_over(ZZ)\n Symmetric Functions over Integer Ring in the monomial basis\n\n sage: Sym = SymmetricFunctions(CyclotomicField())\n sage: s = Sym.schur()\n sage: s.corresponding_basis_over(Integers(13))\n Symmetric Functions over Ring of integers modulo 13 in the Schur basis\n\n sage: P = ZZ['q','t']\n sage: Sym = SymmetricFunctions(P)\n sage: mj = Sym.macdonald().J()\n sage: mj.corresponding_basis_over(Integers(13))\n\n TESTS:\n\n Let's check that this handles each of the bases properly::\n\n sage: P = QQ['q','t']\n sage: Sym = SymmetricFunctions(P)\n sage: Q = CyclotomicField()['q','t']\n sage: Sym.s().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the Schur basis\n sage: Sym.p().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the powersum basis\n sage: Sym.m().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the monomial basis\n sage: Sym.e().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the elementary basis\n sage: Sym.h().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the homogeneous basis\n sage: Sym.f().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the forgotten basis\n sage: Sym.w().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the Witt basis\n sage: Sym.macdonald().P().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald().Q().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald().J().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald().H().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald().Ht().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald().S().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald(q=1).S().corresponding_basis_over(CyclotomicField())\n sage: Sym.macdonald(q=1,t=3).P().corresponding_basis_over(CyclotomicField())\n sage: Sym.hall_littlewood().P().corresponding_basis_over(CyclotomicField())\n sage: Sym.hall_littlewood().Q().corresponding_basis_over(CyclotomicField())\n sage: Sym.hall_littlewood().Qp().corresponding_basis_over(CyclotomicField())\n sage: Sym.hall_littlewood(t=1).P().corresponding_basis_over(CyclotomicField())\n sage: Sym.jack().J().corresponding_basis_over(CyclotomicField())\n sage: Sym.jack().P().corresponding_basis_over(CyclotomicField())\n sage: Sym.jack().Q().corresponding_basis_over(CyclotomicField())\n sage: Sym.jack().Qp().corresponding_basis_over(CyclotomicField())\n sage: Sym.jack(t=1).J().corresponding_basis_over(CyclotomicField())\n sage: Sym.zonal().corresponding_basis_over(CyclotomicField())\n Symmetric Functions over Universal Cyclotomic Field in the zonal basis\n sage: Sym.llt(3).hspin().corresponding_basis_over(CyclotomicField())\n sage: Sym.llt(3).hcospin().corresponding_basis_over(CyclotomicField())\n sage: Sym.llt(3, t=1).hspin().corresponding_basis_over(CyclotomicField())\n sage: Sym.llt(3, t=1).hcospin().corresponding_basis_over(CyclotomicField())\n\n .. TODO::\n\n This function is an ugly hack using strings. It should be\n rewritten as soon as the bases of ``SymmetricFunctions`` are\n put on a more robust and systematic footing.\n "
from sage.combinat.sf.sf import SymmetricFunctions
from sage.misc.call import attrcall
try:
return attrcall(self._basis)(SymmetricFunctions(R))
except AttributeError:
return None
def skew_schur(self, x):
'\n Return the skew Schur function indexed by ``x`` in ``self``.\n\n INPUT:\n\n - ``x`` -- a skew partition\n\n EXAMPLES::\n\n sage: sp = SkewPartition([[5,3,3,1], [3,2,1]])\n sage: s = SymmetricFunctions(QQ).s()\n sage: s.skew_schur(sp)\n s[2, 2, 1, 1] + s[2, 2, 2] + s[3, 1, 1, 1] + 3*s[3, 2, 1]\n + s[3, 3] + 2*s[4, 1, 1] + 2*s[4, 2] + s[5, 1]\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: ess = e.skew_schur(sp); ess\n e[2, 1, 1, 1, 1] - e[2, 2, 1, 1] - e[3, 1, 1, 1] + e[3, 2, 1]\n sage: ess == e(s.skew_schur(sp))\n True\n\n TESTS::\n\n sage: s.skew_schur([[2,1], [1]])\n s[1, 1] + s[2]\n\n sage: s.skew_schur([[2,1], [3]])\n Traceback (most recent call last):\n ...\n ValueError: not a valid skew partition\n\n sage: s = SymmetricFunctions(GF(2)).s()\n sage: s.skew_schur([[3,2,1],[2,1]])\n s[1, 1, 1] + s[3]\n '
from sage.combinat.skew_partition import SkewPartitions
if (x not in SkewPartitions()):
raise ValueError('not a valid skew partition')
import sage.libs.lrcalc.lrcalc as lrcalc
s = self.realization_of().schur()
R = self.base_ring()
skewschur = lrcalc.skew(x[0], x[1])
return self(s.element_class(s, convert_remove_zeroes(skewschur, R)))
def Eulerian(self, n, j, k=None):
'\n Return the Eulerian symmetric function `Q_{n,j}` (with `n`\n either an integer or a partition) or `Q_{n,j,k}` (if the\n optional argument ``k`` is specified) in terms of the basis\n ``self``.\n\n It is known that the Eulerian quasisymmetric functions are\n in fact symmetric functions [SW2010]_. For more information,\n see :meth:`QuasiSymmetricFunctions.Fundamental.Eulerian()`,\n which accepts the same syntax as this method.\n\n INPUT:\n\n - ``n`` -- the nonnegative integer `n` or a partition\n - ``j`` -- the number of excedances\n - ``k`` -- (optional) if specified, determines the number of fixed\n points of the permutations which are being summed over\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.m()\n sage: m.Eulerian(3, 1)\n 4*m[1, 1, 1] + 3*m[2, 1] + 2*m[3]\n sage: h = Sym.h()\n sage: h.Eulerian(4, 2)\n h[2, 2] + h[3, 1] + h[4]\n sage: s = Sym.s()\n sage: s.Eulerian(5, 2)\n s[2, 2, 1] + s[3, 1, 1] + 5*s[3, 2] + 6*s[4, 1] + 6*s[5]\n sage: s.Eulerian([2,2,1], 2)\n s[2, 2, 1] + s[3, 2] + s[4, 1] + s[5]\n sage: s.Eulerian(5, 2, 2)\n s[3, 2] + s[4, 1] + s[5]\n\n We check Equation (5.4) in [SW2010]_::\n\n sage: h.Eulerian([6], 3)\n h[3, 2, 1] - h[4, 1, 1] + 2*h[4, 2] + h[5, 1]\n sage: s.Eulerian([6], 3)\n s[3, 2, 1] + s[3, 3] + 3*s[4, 2] + 3*s[5, 1] + 3*s[6]\n '
from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions
F = QuasiSymmetricFunctions(self.base_ring()).F()
if (n in _Partitions):
n = _Partitions(n)
return self(F.Eulerian(n, j, k).to_symmetric_function())
def gessel_reutenauer(self, lam):
'\n Return the Gessel-Reutenauer symmetric function\n corresponding to the partition ``lam`` written in the basis\n ``self``.\n\n Let `\\lambda` be a partition. The *Gessel-Reutenauer\n symmetric function* `\\mathbf{GR}_\\lambda` corresponding to\n `\\lambda` is the symmetric function denoted `L_\\lambda` in\n [GR1993]_ and in Exercise 7.89 of [STA]_ and denoted\n `\\mathbf{GR}_\\lambda` in Definition 6.6.34 of [GriRei18]_.\n It is also called the *higher Lie character*, for instance\n in [Sch2003b]_.\n It can be defined in several ways:\n\n - It is the sum of the monomials `\\mathbf{x}_w` over all\n words `w` over the alphabet\n `\\left\\{ 1, 2, 3, \\ldots \\right\\}` which have CFL type\n `\\lambda`. Here, the monomial `\\mathbf{x}_w` for a word\n `w = \\left(w_1, w_2, \\ldots, w_k\\right)` is defined as\n `x_{w_1} x_{w_2} \\cdots x_{w_k}`, and the *CFL type* of\n a word `w` is defined as the partition obtained by\n sorting (in decreasing order) the lengths of the factors\n in the Lyndon factorization\n (:meth:`~sage.combinat.words.finite_word.FiniteWord_class.lyndon_factorization`)\n of `w`. The fact that this power series\n `\\mathbf{GR}_\\lambda` is symmetric is not obvious.\n\n - It is the sum of the fundamental quasisymmetric\n functions `F_{\\operatorname{Des} \\sigma}` over all\n permutations `\\sigma` that have cycle type `\\lambda`. See\n :class:`sage.combinat.ncsf_qsym.qsym.QuasiSymmetricFunctions.Fundamental`\n for the definition of fundamental quasisymmetric functions,\n and :meth:`~sage.combinat.permutation.Permutation.cycle_type`\n for that of cycle type. For a permutation `\\sigma`, we use\n `\\operatorname{Des} \\sigma` to denote the descent composition\n (:meth:`~sage.combinat.permutation.Permutation.descents_composition`)\n of `\\sigma`. Again, this definition does not make the\n symmetry of `\\mathbf{GR}_\\lambda` obvious.\n\n - For every positive integer `n`, we have\n\n .. MATH::\n\n \\mathbf{GR}_{\\left(n\\right)}\n = \\frac{1}{n} \\sum_{d \\mid n} \\mu(d) p_d^{n/d},\n\n where `p_d` denotes the `d`-th power-sum symmetric\n function. This `\\mathbf{GR}_{\\left(n\\right)}` is also\n denoted by `L_n`, and is called the Lie character. Now,\n the higher Lie character `\\mathbf{GR}_\\lambda` is defined as the product:\n\n .. MATH::\n\n h_{m_1} \\left[L_1\\right] \\cdot h_{m_2} \\left[L_2\\right]\n \\cdot h_{m_3} \\left[L_3\\right] \\cdots,\n\n where `m_i` denotes the multiplicity of the part `i` in\n `\\lambda`, and where the square brackets stand for\n plethysm (:meth:`plethysm`). This definition makes\n the symmetry (but not the integrality!) of\n `\\mathbf{GR}_\\lambda` obvious.\n\n The equivalences of these three definitions are proven in\n [GR1993]_ Sections 2-3. (See also [GriRei18]_ Subsection\n 6.6.2 for the equivalence of the first two definitions and\n further formulas.)\n\n `\\mathbf{GR}_\\lambda` has further significance in representations afforded\n by the tensor algebra `T(V)` of a finite dimensional vector space.\n The Poincaré-Birkhoff-Witt theorem describes the universal enveloping algebra\n of a Lie algebra. It gives a decomposition of the degree-`n` component `T_n(V)`\n of `T(V)` into `GL(V)` representations indexed by partitions.\n The higher Lie characters are the symmetric group `S_n` characters corresponding\n to this decomposition via Schur-Weyl duality.\n\n Another important question, *Thrall\'s problem* (see e.g. [Sch2003b]_)\n asks, for `\\lambda` a partition of `n`, can we combinatorially interpret\n the coefficients `\\alpha_\\mu^\\lambda` in the Schur-expansion of\n `\\mathbf{GR}_\\lambda`:\n\n .. MATH::\n\n \\mathbf{GR}_\\lambda = \\sum_{\\mu \\vdash n} \\alpha_\\mu^\\lambda s_\\mu.\n\n INPUT:\n\n - ``lam`` -- a partition or a positive integer (in the latter\n case, it is understood to mean the partition ``[lam]``)\n\n OUTPUT:\n\n The Gessel-Reutenauer symmetric function\n `\\mathbf{GR}_\\lambda`, where `\\lambda` is ``lam``,\n expanded in the basis ``self``.\n\n EXAMPLES:\n\n The first few values of `\\mathbf{GR}_{(n)} = L_n`::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: h = Sym.h()\n sage: h.gessel_reutenauer(1)\n h[1]\n sage: h.gessel_reutenauer(2)\n h[1, 1] - h[2]\n sage: h.gessel_reutenauer(3)\n h[2, 1] - h[3]\n sage: h.gessel_reutenauer(4)\n h[2, 1, 1] - h[2, 2]\n sage: h.gessel_reutenauer(5)\n h[2, 1, 1, 1] - h[2, 2, 1] - h[3, 1, 1] + h[3, 2] + h[4, 1] - h[5]\n sage: h.gessel_reutenauer(6)\n h[2, 1, 1, 1, 1] - h[2, 2, 1, 1] - h[2, 2, 2]\n - 2*h[3, 1, 1, 1] + 5*h[3, 2, 1] - 2*h[3, 3] + h[4, 1, 1]\n - h[4, 2] - h[5, 1] + h[6]\n\n Gessel-Reutenauer functions indexed by partitions::\n\n sage: h.gessel_reutenauer([2, 1])\n h[1, 1, 1] - h[2, 1]\n sage: h.gessel_reutenauer([2, 2])\n h[1, 1, 1, 1] - 3*h[2, 1, 1] + 2*h[2, 2] + h[3, 1] - h[4]\n\n The Gessel-Reutenauer functions are Schur-positive::\n\n sage: s = Sym.s()\n sage: s.gessel_reutenauer([2, 1])\n s[1, 1, 1] + s[2, 1]\n sage: s.gessel_reutenauer([2, 2, 1])\n s[1, 1, 1, 1, 1] + s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 2]\n\n They do not form a basis, as the following example (from\n [GR1993]_ p. 201) shows::\n\n sage: s.gessel_reutenauer([4]) == s.gessel_reutenauer([2, 1, 1])\n True\n\n They also go by the name *higher Lie character*::\n\n sage: s.higher_lie_character([2, 2, 1]) == s.gessel_reutenauer([2, 2, 1])\n True\n\n Of the above three equivalent definitions of\n `\\mathbf{GR}_\\lambda`, we use the third one for\n computations. Let us check that the second one gives the\n same results::\n\n sage: QSym = QuasiSymmetricFunctions(ZZ)\n sage: F = QSym.F() # fundamental basis\n sage: def GR_def2(lam): # `\\mathbf{GR}_\\lambda`\n ....: n = lam.size()\n ....: r = F.sum_of_monomials([sigma.descents_composition()\n ....: for sigma in Permutations(n)\n ....: if sigma.cycle_type() == lam])\n ....: return r.to_symmetric_function()\n sage: all( GR_def2(lam) == h.gessel_reutenauer(lam)\n ....: for n in range(5) for lam in Partitions(n) )\n True\n\n And the first one, too (assuming symmetry)::\n\n sage: m = Sym.m()\n sage: def GR_def1(lam): # `\\mathbf{GR}_\\lambda`\n ....: n = lam.size()\n ....: Permus_mset = sage.combinat.permutation.Permutations_mset\n ....: def coeff_of_m_mu_in_result(mu):\n ....: words_to_check = Permus_mset([i for (i, l) in enumerate(mu)\n ....: for _ in range(l)])\n ....: return sum((1 for w in words_to_check if\n ....: Partition(list(reversed(sorted([len(v) for v in Word(w).lyndon_factorization()]))))\n ....: == lam))\n ....: r = m.sum_of_terms([(mu, coeff_of_m_mu_in_result(mu))\n ....: for mu in Partitions(n)],\n ....: distinct=True)\n ....: return r\n sage: all( GR_def1(lam) == h.gessel_reutenauer(lam)\n ....: for n in range(5) for lam in Partitions(n) )\n True\n\n TESTS:\n\n This works fine over other base rings::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ[\'q\',\'t\']))\n sage: P = Sym.macdonald().P()\n sage: h = Sym.h()\n sage: P.gessel_reutenauer(3) == P(h.gessel_reutenauer(3))\n True\n\n .. NOTE::\n\n The currently existing implementation of this function is\n technically unsatisfactory. It distinguishes the case when the\n base ring is a `\\QQ`-algebra from the case\n where it isn\'t. In the latter, it does a computation using\n universal coefficients, again distinguishing the case when it is\n able to compute the "corresponding" basis of the symmetric function\n algebra over `\\QQ` (using the ``corresponding_basis_over`` hack)\n from the case when it isn\'t (in which case it transforms everything\n into the Schur basis, which is slow).\n '
if (lam in ZZ):
lam = [lam]
lam = _Partitions(lam)
R = self.base_ring()
if self.has_coerce_map_from(QQ):
m = lam.to_exp_dict()
p = self.realization_of().power()
h = self.realization_of().complete()
from sage.arith.misc import moebius, squarefree_divisors
mu = moebius
def component(i, g):
L_i = (p.sum_of_terms([(_Partitions(([d] * (i // d))), R(mu(d))) for d in squarefree_divisors(i)], distinct=True) / i)
return p(h[g]).plethysm(L_i)
return self(p.prod((component(i, g) for (i, g) in m.items())))
comp_parent = self
corresponding_parent_over_QQ = self.corresponding_basis_over(QQ)
if (corresponding_parent_over_QQ is None):
comp_parent = self.realization_of().schur()
from sage.combinat.sf.sf import SymmetricFunctions
corresponding_parent_over_QQ = SymmetricFunctions(QQ).schur()
corresponding_result = corresponding_parent_over_QQ.gessel_reutenauer(lam)
comp_base_ring = comp_parent.base_ring()
result = comp_parent.sum_of_terms(((nu, comp_base_ring(c)) for (nu, c) in corresponding_result))
return self(result)
higher_lie_character = gessel_reutenauer
def lehrer_solomon(self, lam):
"\n Return the Lehrer-Solomon symmetric function (also known as the\n Whitney homology character) corresponding to the partition ``lam``\n written in the basis ``self``.\n\n Let `\\lambda \\vdash n` be a partition. The *Lehrer-Solomon\n symmetric function* `\\mathbf{LS}_\\lambda` corresponding to\n `\\lambda` is the Frobenius characteristic of the representation\n denoted `\\operatorname{Ind}_{Z_\\lambda}^{S_n}(\\xi_\\lambda)` in\n Theorem 4.5 of [LS1986]_ or `W_\\lambda` in Theorem 2.7 of\n [HR2017]_. It was first computed as a symmetric function in\n [Sun1994]_.\n\n It is the symmetric group representation corresponding to a\n summand of the Whitney homology of the set partition lattice.\n The summand comes from the orbit of set partitions with block\n sizes corresponding to `\\lambda` (after reordering appropriately).\n\n It can be computed using Sundaram's plethystic formula\n (see [Sun1994]_ Theorem 1.8):\n\n .. MATH::\n\n \\mathbf{LS}_\\lambda =\n \\prod_{\\text{odd } j \\geq 1} h_{m_j}[\\pi_j]\n \\prod_{\\text{even } j \\geq 2} e_{m_j}[\\pi_j],\n\n where `h_{m_j}` are complete homogeneous symmetric functions,\n `e_{m_j}` are elementary symmetric functions, and `\\pi_j` are\n the images of the Gessel-Reutenauer symmetric function\n `\\mathbf{GR}_{(j)}` (see :meth:`gessel_reutenauer`) under the\n involution `\\omega` (i.e. :meth:`omega_involution`)::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s()\n sage: pi_2 = (s.gessel_reutenauer(2)).omega_involution()\n sage: pi_1 = (s.gessel_reutenauer(1)).omega_involution()\n sage: s.lehrer_solomon([2,1]) == pi_2 * pi_1 # since h_1, e_1 are plethystic identities\n True\n\n Note that this also gives the `S_n`-equivariant structure of the\n Orlik-Solomon algebra of the braid arrangement (also known as the\n type-`A` reflection arrangement).\n\n The representation corresponding to `\\mathbf{LS}_\\lambda` exhibits\n representation stability [Chu2012]_, and a sharp bound is given\n in [HR2017]_.\n\n INPUT:\n\n - ``lam`` -- a partition or a positive integer (in the latter\n case, it is understood to mean the partition ``[lam]``)\n\n OUTPUT:\n\n The Lehrer-Solomon symmetric function\n `\\mathbf{LS}_\\lambda`, where `\\lambda` is ``lam``,\n expanded in the basis ``self``.\n\n EXAMPLES:\n\n The first few values of `\\mathbf{LS}_{(n)}`::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: h = Sym.h()\n sage: h.lehrer_solomon(1)\n h[1]\n sage: h.lehrer_solomon(2)\n h[2]\n sage: h.lehrer_solomon(3)\n h[2, 1] - h[3]\n sage: h.lehrer_solomon(4)\n h[2, 1, 1] - h[2, 2]\n sage: h.lehrer_solomon(5)\n h[2, 1, 1, 1] - h[2, 2, 1] - h[3, 1, 1] + h[3, 2] + h[4, 1] - h[5]\n\n The :meth:`whitney_homology_character` method is an alias::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: s = Sym.schur()\n sage: s.lehrer_solomon([2, 2, 1]) == s.whitney_homology_character([2, 2, 1])\n True\n\n Lehrer-Solomon functions indexed by partitions::\n\n sage: h.lehrer_solomon([2, 1])\n h[2, 1]\n sage: h.lehrer_solomon([2, 2])\n h[3, 1] - h[4]\n\n The Lehrer-Solomon functions are Schur-positive::\n\n sage: s = Sym.s()\n sage: s.lehrer_solomon([2, 1])\n s[2, 1] + s[3]\n sage: s.lehrer_solomon([2, 2, 1])\n s[3, 1, 1] + s[3, 2] + s[4, 1]\n sage: s.lehrer_solomon([4, 1])\n s[2, 1, 1, 1] + s[2, 2, 1] + 2*s[3, 1, 1] + s[3, 2] + s[4, 1]\n\n TESTS:\n\n This works fine over other base rings::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: h = Sym.h()\n sage: P.lehrer_solomon(3) == P(h.lehrer_solomon(3))\n True\n\n sage: s = SymmetricFunctions(GF(2)).s()\n sage: s.lehrer_solomon([4,1])\n s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 2] + s[4, 1]\n "
if (lam in ZZ):
lam = [lam]
lam = _Partitions(lam)
R = self.base_ring()
if self.has_coerce_map_from(QQ):
m = lam.to_exp_dict()
p = self.realization_of().power()
h = self.realization_of().complete()
e = self.realization_of().elementary()
from sage.arith.misc import moebius, squarefree_divisors
mu = moebius
def component(i, g):
L_i = (p.sum_of_terms(((_Partitions(([d] * (i // d))), R(mu(d))) for d in squarefree_divisors(i)), distinct=True) / i)
if (not (i % 2)):
return p(e[g]).plethysm(L_i.omega())
else:
return p(h[g]).plethysm(L_i.omega())
return self(p.prod((component(i, g) for (i, g) in m.items())))
comp_parent = self
corresponding_parent_over_QQ = self.corresponding_basis_over(QQ)
if (corresponding_parent_over_QQ is None):
comp_parent = self.realization_of().schur()
from sage.combinat.sf.sf import SymmetricFunctions
corresponding_parent_over_QQ = SymmetricFunctions(QQ).schur()
corresponding_result = corresponding_parent_over_QQ.lehrer_solomon(lam)
comp_base_ring = comp_parent.base_ring()
result = comp_parent.sum_of_terms(((nu, comp_base_ring(c)) for (nu, c) in corresponding_result))
return self(result)
whitney_homology_character = lehrer_solomon
def carlitz_shareshian_wachs(self, n, d, s, comparison=None):
"\n Return the Carlitz-Shareshian-Wachs symmetric function\n `X_{n, d, s}` (if ``comparison`` is ``None``), or\n `U_{n, d, s}` (if ``comparison`` is ``-1``), or\n `V_{n, d, s}` (if ``comparison`` is ``0``), or\n `W_{n, d, s}` (if ``comparison`` is ``1``) written in the\n basis ``self``. These functions are defined below.\n\n The Carlitz-Shareshian-Wachs symmetric functions have been\n introduced in [GriRei18]_, Exercise 2.9.11, as\n refinements of a certain particular case of chromatic\n quasisymmetric functions defined by Shareshian and Wachs.\n Their definitions are as follows:\n\n Let `n`, `d` and `s` be three nonnegative integers. Let\n `W(n, d, s)` denote the set of all `n`-tuples\n `(w_1, w_2, \\ldots, w_n)` of positive integers having the\n property that there exist precisely `d` elements `i`\n of `\\left\\{ 1, 2, \\ldots, n-1 \\right\\}` satisfying\n `w_i > w_{i+1}`, and precisely `s` elements `i` of\n `\\left\\{ 1, 2, \\ldots, n-1 \\right\\}` satisfying\n `w_i = w_{i+1}`. For every\n `w = (w_1, w_2, \\ldots, w_n) \\in W(n, d, s)`, let `x_w`\n be the monomial `x_{w_1} x_{w_2} \\cdots x_{w_n}`. We then\n define the power series `X_{n, d, s}` by\n\n .. MATH::\n\n X_{n, d, s} = \\sum_{w \\in W(n, d, s)} x_w .\n\n This is a symmetric function (according to\n [GriRei18]_, Exercise 2.9.11(b)), and for `s = 0` equals\n the `t^d`-coefficient of the descent enumerator of Smirnov\n words of length `n` (an example of a chromatic\n quasisymmetric function which happens to be symmetric --\n see [ShaWach2014]_, Example 2.5).\n\n Assume that `n > 0`. Then, we can define three further\n power series as follows:\n\n .. MATH::\n\n U_{n, d, s} = \\sum_{w_1 < w_n} x_w ; \\qquad\n V_{n, d, s} = \\sum_{w_1 = w_n} x_w ; \\qquad\n W_{n, d, s} = \\sum_{w_1 > w_n} x_w ,\n\n where all three sums range over\n `w = (w_1, w_2, \\ldots, w_n) \\in W(n, d, s)`. These\n three power series `U_{n, d, s}`, `V_{n, d, s}` and\n `W_{n, d, s}` are symmetric functions as well\n ([GriRei18]_, Exercise 2.9.11(c)). Their sum is\n `X_{n, d, s}`.\n\n REFERENCES:\n\n .. [ShaWach2014] John Shareshian, Michelle L. Wachs.\n *Chromatic quasisymmetric functions*.\n :arxiv:`1405.4629v2`.\n\n .. [GriRei18]_\n\n INPUT:\n\n - ``n`` -- a nonnegative integer\n\n - ``d`` -- a nonnegative integer\n\n - ``s`` -- a nonnegative integer\n\n - ``comparison`` (default: ``None``) -- a variable\n which can take the forms ``None``, ``-1``, ``0``\n and ``1``\n\n OUTPUT:\n\n The Carlitz-Shareshian-Wachs symmetric function\n `X_{n, d, s}` (if ``comparison`` is ``None``), or\n `U_{n, d, s}` (if ``comparison`` is ``-1``), or\n `V_{n, d, s}` (if ``comparison`` is ``0``), or\n `W_{n, d, s}` (if ``comparison`` is ``1``) written in the\n basis ``self``.\n\n EXAMPLES:\n\n The power series `X_{n, d, s}`::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: m = Sym.m()\n sage: m.carlitz_shareshian_wachs(3, 2, 1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 1, 1)\n m[2, 1]\n sage: m.carlitz_shareshian_wachs(3, 2, 0)\n m[1, 1, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 2)\n m[3]\n sage: m.carlitz_shareshian_wachs(3, 1, 0)\n 4*m[1, 1, 1] + m[2, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 1)\n m[2, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 0)\n m[1, 1, 1]\n sage: m.carlitz_shareshian_wachs(5, 2, 2)\n m[2, 2, 1] + m[3, 1, 1]\n sage: m.carlitz_shareshian_wachs(1, 0, 0)\n m[1]\n sage: m.carlitz_shareshian_wachs(0, 0, 0)\n m[]\n\n The power series `U_{n, d, s}`::\n\n sage: m.carlitz_shareshian_wachs(3, 2, 1, comparison=-1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 1, 1, comparison=-1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 2, 0, comparison=-1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 0, 2, comparison=-1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 1, 0, comparison=-1)\n 2*m[1, 1, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 1, comparison=-1)\n m[2, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 0, comparison=-1)\n m[1, 1, 1]\n sage: m.carlitz_shareshian_wachs(5, 2, 2, comparison=-1)\n 0\n sage: m.carlitz_shareshian_wachs(4, 2, 0, comparison=-1)\n 3*m[1, 1, 1, 1]\n sage: m.carlitz_shareshian_wachs(1, 0, 0, comparison=-1)\n 0\n\n The power series `V_{n, d, s}`::\n\n sage: m.carlitz_shareshian_wachs(3, 2, 1, comparison=0)\n 0\n sage: m.carlitz_shareshian_wachs(3, 1, 1, comparison=0)\n 0\n sage: m.carlitz_shareshian_wachs(3, 2, 0, comparison=0)\n 0\n sage: m.carlitz_shareshian_wachs(3, 0, 2, comparison=0)\n m[3]\n sage: m.carlitz_shareshian_wachs(3, 1, 0, comparison=0)\n m[2, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 1, comparison=0)\n 0\n sage: m.carlitz_shareshian_wachs(3, 0, 0, comparison=0)\n 0\n sage: m.carlitz_shareshian_wachs(5, 2, 2, comparison=0)\n 0\n sage: m.carlitz_shareshian_wachs(4, 2, 0, comparison=0)\n m[2, 1, 1]\n sage: m.carlitz_shareshian_wachs(1, 0, 0, comparison=0)\n m[1]\n\n The power series `W_{n, d, s}`::\n\n sage: m.carlitz_shareshian_wachs(3, 2, 1, comparison=1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 1, 1, comparison=1)\n m[2, 1]\n sage: m.carlitz_shareshian_wachs(3, 2, 0, comparison=1)\n m[1, 1, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 2, comparison=1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 1, 0, comparison=1)\n 2*m[1, 1, 1]\n sage: m.carlitz_shareshian_wachs(3, 0, 1, comparison=1)\n 0\n sage: m.carlitz_shareshian_wachs(3, 0, 0, comparison=1)\n 0\n sage: m.carlitz_shareshian_wachs(5, 2, 2, comparison=1)\n m[2, 2, 1] + m[3, 1, 1]\n sage: m.carlitz_shareshian_wachs(4, 2, 0, comparison=1)\n 8*m[1, 1, 1, 1] + 2*m[2, 1, 1] + m[2, 2]\n sage: m.carlitz_shareshian_wachs(1, 0, 0, comparison=1)\n 0\n\n TESTS:\n\n This works fine over other base rings::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: P = Sym.macdonald().P()\n sage: m = Sym.m()\n sage: m.carlitz_shareshian_wachs(4, 1, 1)\n 4*m[2, 1, 1] + 2*m[2, 2] + 2*m[3, 1]\n sage: P.carlitz_shareshian_wachs(4, 1, 1) == P(m.carlitz_shareshian_wachs(4, 1, 1))\n True\n "
R = self.base_ring()
m = self.realization_of().m()
from sage.combinat.permutation import Permutations_mset
if (comparison is None):
def check_word(w):
if (sum((1 for i in range((n - 1)) if (w[i] > w[(i + 1)]))) != d):
return False
if (sum((1 for i in range((n - 1)) if (w[i] == w[(i + 1)]))) != s):
return False
return True
elif (comparison == (- 1)):
def check_word(w):
if (sum((1 for i in range((n - 1)) if (w[i] > w[(i + 1)]))) != d):
return False
if (sum((1 for i in range((n - 1)) if (w[i] == w[(i + 1)]))) != s):
return False
return (w[0] < w[(- 1)])
elif (comparison == 0):
def check_word(w):
if (sum((1 for i in range((n - 1)) if (w[i] > w[(i + 1)]))) != d):
return False
if (sum((1 for i in range((n - 1)) if (w[i] == w[(i + 1)]))) != s):
return False
return (w[0] == w[(- 1)])
elif (comparison == 1):
def check_word(w):
if (sum((1 for i in range((n - 1)) if (w[i] > w[(i + 1)]))) != d):
return False
if (sum((1 for i in range((n - 1)) if (w[i] == w[(i + 1)]))) != s):
return False
return (w[0] > w[(- 1)])
def coeff_of_m_mu_in_result(mu):
words_to_check = Permutations_mset([i for (i, l) in enumerate(mu) for _ in range(l)])
return R(sum((1 for w in words_to_check if check_word(w))))
from sage.combinat.partition import Partitions_n
r = m.sum_of_terms([(mu, coeff_of_m_mu_in_result(mu)) for mu in Partitions_n(n)], distinct=True)
return self(r)
def formal_series_ring(self):
"\n Return the completion of all formal linear combinations of\n ``self`` with finite linear combinations in each homogeneous\n degree (computed lazily).\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: L = s.formal_series_ring()\n sage: L\n Lazy completion of Symmetric Functions over Integer Ring in the Schur basis\n\n TESTS::\n\n sage: type(L)\n <class 'sage.rings.lazy_series_ring.LazySymmetricFunctions_with_category'>\n "
from sage.rings.lazy_series_ring import LazySymmetricFunctions
return LazySymmetricFunctions(self)
|
class FilteredSymmetricFunctionsBases(Category_realization_of_parent):
'\n The category of filtered bases of the ring of symmetric functions.\n\n TESTS::\n\n sage: from sage.combinat.sf.sfa import FilteredSymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = FilteredSymmetricFunctionsBases(Sym); bases\n Category of filtered bases of Symmetric Functions over Rational Field\n sage: Sym.schur() in bases\n True\n sage: Sym.sp() in bases\n True\n '
def _repr_(self):
"\n Return the representation of ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import FilteredSymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = FilteredSymmetricFunctionsBases(Sym)\n sage: bases._repr_()\n 'Category of filtered bases of Symmetric Functions over Rational Field'\n "
return ('Category of filtered bases of %s' % self.base())
def super_categories(self):
'\n The super categories of ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import FilteredSymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = FilteredSymmetricFunctionsBases(Sym)\n sage: bases.super_categories()\n [Category of bases of Symmetric Functions over Rational Field,\n Category of commutative filtered Hopf algebras with basis over Rational Field]\n '
cat = HopfAlgebras(self.base().base_ring()).Commutative().WithBasis().Filtered()
return [SymmetricFunctionsBases(self.base()), cat]
|
class GradedSymmetricFunctionsBases(Category_realization_of_parent):
'\n The category of graded bases of the ring of symmetric functions.\n\n These are further required to have the property that the basis element\n indexed by the empty partition is `1`.\n\n TESTS::\n\n sage: from sage.combinat.sf.sfa import GradedSymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = GradedSymmetricFunctionsBases(Sym); bases\n Category of graded bases of Symmetric Functions over Rational Field\n sage: Sym.schur() in bases\n True\n sage: Sym.sp() in bases\n False\n '
def _repr_(self):
"\n Return the representation of ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import GradedSymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = GradedSymmetricFunctionsBases(Sym)\n sage: bases._repr_()\n 'Category of graded bases of Symmetric Functions over Rational Field'\n "
return ('Category of graded bases of %s' % self.base())
def super_categories(self):
'\n The super categories of ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import GradedSymmetricFunctionsBases\n sage: Sym = SymmetricFunctions(QQ)\n sage: bases = GradedSymmetricFunctionsBases(Sym)\n sage: bases.super_categories()\n [Category of filtered bases of Symmetric Functions over Rational Field,\n Category of commutative graded Hopf algebras with basis over Rational Field]\n '
cat = HopfAlgebras(self.base().base_ring()).Commutative().WithBasis().Graded()
return [FilteredSymmetricFunctionsBases(self.base()), cat]
class ParentMethods():
def antipode_by_coercion(self, element):
'\n The antipode of ``element``.\n\n INPUT:\n\n - ``element`` -- element in a basis of the ring of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: (h([]) + h([1])).antipode() # indirect doctest\n h[] - h[1]\n sage: (s([]) + s([1]) + s[2]).antipode()\n s[] - s[1] + s[1, 1]\n sage: (p([2]) + p([3])).antipode()\n -p[2] - p[3]\n sage: (e([2]) + e([3])).antipode()\n e[1, 1] - e[1, 1, 1] - e[2] + 2*e[2, 1] - e[3]\n sage: f = Sym.f()\n sage: f([3,2,1]).antipode()\n -f[3, 2, 1] - 4*f[3, 3] - 2*f[4, 2] - 2*f[5, 1] - 6*f[6]\n\n The antipode is an involution::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: s = Sym.s()\n sage: all( s[u].antipode().antipode() == s[u] for u in Partitions(4) )\n True\n\n The antipode is an algebra homomorphism::\n\n sage: Sym = SymmetricFunctions(FiniteField(23))\n sage: h = Sym.h()\n sage: all( all( (s[u] * s[v]).antipode() == s[u].antipode() * s[v].antipode()\n ....: for u in Partitions(3) )\n ....: for v in Partitions(3) )\n True\n\n TESTS:\n\n Everything works over `\\ZZ`::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: (h([]) + h([1])).antipode() # indirect doctest\n h[] - h[1]\n sage: (s([]) + s([1]) + s[2]).antipode()\n s[] - s[1] + s[1, 1]\n sage: (p([2]) + p([3])).antipode()\n -p[2] - p[3]\n sage: (e([2]) + e([3])).antipode()\n e[1, 1] - e[1, 1, 1] - e[2] + 2*e[2, 1] - e[3]\n '
return self.degree_negation(element.omega())
def counit(self, element):
'\n Return the counit of ``element``.\n\n The counit is the constant term of ``element``.\n\n INPUT:\n\n - ``element`` -- element in a basis of the ring of symmetric functions\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.monomial()\n sage: f = 2*m[2,1] + 3*m[[]]\n sage: f.counit()\n 3\n '
return element.degree_zero_coefficient()
def degree_negation(self, element):
'\n Return the image of ``element`` under the degree negation\n automorphism of the ring of symmetric functions.\n\n The degree negation is the automorphism which scales every\n homogeneous element of degree `k` by `(-1)^k` (for all `k`).\n\n INPUT:\n\n - ``element`` -- symmetric function written in ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: m = Sym.monomial()\n sage: f = 2*m[2,1] + 4*m[1,1] - 5*m[1] - 3*m[[]]\n sage: m.degree_negation(f)\n -3*m[] + 5*m[1] + 4*m[1, 1] - 2*m[2, 1]\n\n TESTS:\n\n Using :meth:`degree_negation` on an element of a different\n basis works correctly::\n\n sage: e = Sym.elementary()\n sage: m.degree_negation(e[3])\n -m[1, 1, 1]\n sage: m.degree_negation(m(e[3]))\n -m[1, 1, 1]\n '
return self.sum_of_terms([(lam, (((- 1) ** (sum(lam) % 2)) * a)) for (lam, a) in self(element)])
class ElementMethods():
def degree_negation(self):
'\n Return the image of ``self`` under the degree negation\n automorphism of the ring of symmetric functions.\n\n The degree negation is the automorphism which scales every\n homogeneous element of degree `k` by `(-1)^k` (for all `k`).\n\n Calling ``degree_negation(self)`` is equivalent to calling\n ``self.parent().degree_negation(self)``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: m = Sym.monomial()\n sage: f = 2*m[2,1] + 4*m[1,1] - 5*m[1] - 3*m[[]]\n sage: f.degree_negation()\n -3*m[] + 5*m[1] + 4*m[1, 1] - 2*m[2, 1]\n sage: x = m.zero().degree_negation(); x\n 0\n sage: parent(x) is m\n True\n '
return self.parent().sum_of_terms([(lam, (((- 1) ** (sum(lam) % 2)) * a)) for (lam, a) in self])
def degree_zero_coefficient(self):
'\n Return the degree zero coefficient of ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: m = Sym.monomial()\n sage: f = 2*m[2,1] + 3*m[[]]\n sage: f.degree_zero_coefficient()\n 3\n '
return self.coefficient([])
def is_unit(self):
'\n Return whether this element is a unit in the ring.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(ZZ).monomial()\n sage: (2*m[2,1] + m[[]]).is_unit()\n False\n\n sage: m = SymmetricFunctions(QQ).monomial()\n sage: (3/2*m([])).is_unit()\n True\n '
m = self.monomial_coefficients(copy=False)
return ((len(m) <= 1) and self.coefficient([]).is_unit())
|
class SymmetricFunctionAlgebra_generic(CombinatorialFreeModule):
'\n Abstract base class for symmetric function algebras.\n\n .. TODO::\n\n Most of the methods in this class are generic (manipulations of\n morphisms, ...) and should be generalized (or removed)\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: m = SymmetricFunctions(ZZ).m()\n sage: s(m([2,1]))\n -2*s[1, 1, 1] + s[2, 1]\n '
def __init__(self, Sym, basis_name=None, prefix=None, graded=True):
'\n Initializes the symmetric function algebra.\n\n INPUT:\n\n - ``Sym`` -- the ring of symmetric functions\n - ``basis_name`` -- name of basis (default: ``None``)\n - ``prefix`` -- prefix used to display basis\n - ``graded`` -- (default: ``True``) if ``True``, then the basis is\n considered to be graded, otherwise the basis is filtered\n\n TESTS::\n\n sage: from sage.combinat.sf.classical import SymmetricFunctionAlgebra_classical\n sage: s = SymmetricFunctions(QQ).s()\n sage: isinstance(s, SymmetricFunctionAlgebra_classical)\n True\n sage: TestSuite(s).run()\n '
R = Sym.base_ring()
from sage.categories.commutative_rings import CommutativeRings
if (R not in CommutativeRings()):
raise TypeError('argument R must be a commutative ring')
try:
R(Integer(1))
except (TypeError, ValueError):
raise ValueError('R must have a unit element')
if (basis_name is not None):
self._basis = basis_name
if (prefix is not None):
self._prefix = prefix
self._sym = Sym
if graded:
cat = GradedSymmetricFunctionsBases(Sym)
else:
cat = FilteredSymmetricFunctionsBases(Sym)
CombinatorialFreeModule.__init__(self, Sym.base_ring(), _Partitions, category=cat, bracket='', prefix=prefix)
_print_style = 'lex'
def __getitem__(self, c):
"\n This method implements the abuses of notations ``p[2,1]``,\n ``p[[2,1]]``, ``p[Partition([2,1])]``.\n\n INPUT:\n\n - ``c`` -- a list, list of lists, or partition\n\n .. TODO::\n\n Should call ``super.term`` so as not to interfere with the\n standard notation ``p['x,y,z']``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s[2,1]\n s[2, 1]\n sage: s[[2,1]]\n s[2, 1]\n sage: s[Partition([2,1])]\n s[2, 1]\n\n TESTS:\n\n Check that a single number which is in ``ZZ`` can be used::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s[QQbar(2)]\n s[2]\n "
C = self.basis().keys()
if (not isinstance(c, C.element_class)):
if (c in ZZ):
c = C([c])
else:
c = C(c)
return self.monomial(c)
def _change_by_proportionality(self, x, function):
'\n Return the symmetric function obtained from ``x`` by scaling\n each basis element corresponding to the partition `\\lambda` by\n the value of ``function`` on `\\lambda`.\n\n INPUT:\n\n - ``x`` -- a symmetric function\n - ``function`` -- a function which takes in a partition\n and returns a scalar\n\n OUTPUT:\n\n A symmetric function in ``self`` which is a scaled version of ``x``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([3])+s([2,1])+s([1,1,1]); a\n s[1, 1, 1] + s[2, 1] + s[3]\n sage: f = lambda part: len(part)\n sage: s._change_by_proportionality(a, f)\n 3*s[1, 1, 1] + 2*s[2, 1] + s[3]\n '
BR = self.base_ring()
z_elt = {}
for (m, c) in x._monomial_coefficients.items():
coeff = function(m)
z_elt[m] = BR((c * coeff))
return self._from_dict(z_elt)
def _change_by_plethysm(self, x, expr, deg_one):
'\n Return the plethysm of ``x`` by ``expr``.\n\n INPUT:\n\n - ``x`` -- a symmetric function\n - ``expr`` -- an expression used in the plethysm\n - ``deg_one`` -- a list (or iterable) specifying the degree one\n variables (that is, the terms to be treated as degree-one\n elements when encountered in ``x``; they will be taken to the\n appropriate powers when computing the plethysm)\n\n OUTPUT:\n\n The plethysm of ``x`` by ``expr``.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: a = m([2,1])\n sage: a.omega()\n -m[2, 1] - 2*m[3]\n sage: m._change_by_plethysm(-a,-1,[])\n -m[2, 1] - 2*m[3]\n\n ::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([3])\n sage: s._change_by_plethysm(-a,-1,[])\n s[1, 1, 1]\n '
p = self.realization_of().power()
p_x = p(x)
expr_k = (lambda k: expr.subs(**dict([(str(x), (x ** k)) for x in deg_one])))
f = (lambda m, c: (m, (c * prod([expr_k(k) for k in m]))))
return self(p_x.map_item(f))
def _apply_multi_module_morphism(self, x, y, f, orthogonal=False):
'\n Applies morphism specified by ``f`` on (``x``, ``y``).\n\n INPUT:\n\n - ``x`` -- an element of ``self``\n - ``y`` -- an element of ``self``\n - ``f`` -- a function that takes in two partitions\n (basis elements) and returns an element of the target domain\n - ``orthogonal`` -- if orthogonal is set to ``True``, then\n ``f(part1, part2)`` is assumed to be 0 if ``part1 != part2``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1])+s([1,1,1])\n sage: b = s([3])+s([2,1])\n sage: f1 = lambda p1, p2: len(p1)*len(p2)\n sage: f2 = lambda p1, p2: len(p1)+len(p2)\n sage: s._apply_multi_module_morphism(a,b,f1,orthogonal=False) #(2+3)*(2+1)\n 15\n sage: s._apply_multi_module_morphism(a,b,f1,orthogonal=True) #(2)*(2)\n 4\n sage: s._apply_multi_module_morphism(a,b,f2,orthogonal=False) #2*(2+3+2+1)\n 16\n sage: s._apply_multi_module_morphism(a,b,f2,orthogonal=True) #2+2\n 4\n '
res = 0
if orthogonal:
if (len(x._monomial_coefficients) > len(y._monomial_coefficients)):
(x, y) = (y, x)
for (mx, cx) in x._monomial_coefficients.items():
if (mx not in y._monomial_coefficients):
continue
else:
cy = y._monomial_coefficients[mx]
res += ((cx * cy) * f(mx, mx))
return res
else:
for (mx, cx) in x._monomial_coefficients.items():
for (my, cy) in y._monomial_coefficients.items():
res += ((cx * cy) * f(mx, my))
return res
def _from_element(self, x):
"\n Return the element of ``self`` with the same 'internal structure' as\n ``x``. This means the element whose coefficients in the basis ``self``\n are the respective coefficients of ``x`` in the basis of ``x``.\n\n INPUT:\n\n - ``x`` -- a symmetric function\n\n EXAMPLES::\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = e([2,1]) + e([1,1,1]); a\n e[1, 1, 1] + e[2, 1]\n sage: s._from_element(a)\n s[1, 1, 1] + s[2, 1]\n "
return self._from_dict(x.monomial_coefficients())
def _from_cache(self, element, cache_function, cache_dict, **subs_dict):
'\n Return the image of an element ``element`` of some realization `M`\n of the ring of symmetric functions under a linear map from `M` to\n ``self`` whose matrix representation is cached (with ``cache_dict``\n serving as cache, and ``cache_function`` as the function which\n precomputes this cache).\n\n INPUT:\n\n - ``element`` -- an element of a realization `M` of the ring of\n symmetric functions. Note that `M` can be a different realization\n than the one in which ``self`` is written, and does not have to\n be specified. It is assumed that the basis of ``self`` is indexed\n by partitions, and the degree of a basis element is the size of\n the partition indexing it.\n\n - ``cache_function`` -- a function which accepts an\n integer `n` as its input and creates the cache for that homogeneous\n component (saving it in ``cache_dict``).\n\n - ``cache_dict`` -- a dictionary storing a cache.\n It should be indexed by the positive integers `n`. Its values\n are dictionaries indexed by the partitions of size `n`. The values\n of those latter dictionaries are, again, dictionaries indexed by\n partitions of size `n`. Altogether, ``cache_dict`` should be\n understood to encode a graded linear map from `M` to the\n realization ``self`` of the ring of symmetric functions; the\n encoding is done in such a way that, for any `n` and any partitions\n ``lam`` and ``mu`` of `n`, the ``self[mu]``-coordinate of the image\n of ``M[lam]`` under this linear map (in the basis ``self``) is\n ``cache_dict[lam][mu]``.\n\n - ``subs_dict`` -- (optional) a dictionary for any substitutions\n to make after the value is extracted from ``cache_dict``.\n\n EXAMPLES::\n\n sage: R.<x> = QQ[]\n sage: Sym = SymmetricFunctions(R)\n sage: s = Sym.s()\n sage: p21 = Partition([2,1])\n sage: a = s(p21)\n sage: e = Sym.e()\n sage: cache_dict = {}\n sage: cache_dict[3] = {}\n sage: cache_dict[3][p21] = {}\n sage: cache_dict[3][p21][p21] = x^2\n sage: cache_dict[3][p21][Partition([1,1,1])] = 3*x\n sage: cache_function = lambda n: 0 #do nothing\n sage: e._from_cache(a, cache_function, cache_dict)\n 3*x*e[1, 1, 1] + x^2*e[2, 1]\n sage: e._from_cache(a, cache_function, cache_dict, x=2)\n 6*e[1, 1, 1] + 4*e[2, 1]\n '
BR = self.base_ring()
zero = BR.zero()
z_elt = {}
for (part, c) in element.monomial_coefficients().items():
if (sum(part) not in cache_dict):
cache_function(sum(part))
part = _Partitions(part)
for (part2, c2) in cache_dict[sum(part)][part].items():
if hasattr(c2, 'subs'):
c3 = (c * BR(c2.subs(**subs_dict)))
else:
c3 = (c * BR(c2))
z_elt[part2] = (z_elt.get(part2, zero) + BR(c3))
return self._from_dict(z_elt)
def _invert_morphism(self, n, base_ring, self_to_other_cache, other_to_self_cache, to_other_function=None, to_self_function=None, upper_triangular=False, lower_triangular=False, ones_on_diagonal=False):
"\n Compute the inverse of a morphism between ``self`` and ``other``\n (more precisely, its `n`-th graded component).\n\n In order to use this, you must be able to compute the morphism in\n one direction. This method assumes that the morphism is indeed\n invertible.\n\n INPUT:\n\n - ``n`` -- an integer, the homogeneous component of\n symmetric functions for which we want to a morphism's inverse\n\n - ``base_ring`` -- the base ring being worked over\n\n - ``self_to_other_cache`` -- a dictionary which\n stores the transition from ``self`` to ``other``\n\n - ``other_to_self_cache`` -- a dictionary which\n stores the transition from ``other`` to ``self``\n\n - ``to_other_function`` -- a function which takes in\n a partition and returns a function which gives the coefficients of\n ``self(part)`` in the ``other`` basis\n\n - ``to_self_function`` -- a function which takes in a\n partition and returns a function which gives the coefficients of\n ``other(part)`` in ``self``\n\n - ``upper_triangular`` -- a boolean, if ``True``, the\n inverse will be computed by back substitution\n\n - ``lower_triangular`` -- a boolean, if ``True``, the\n inverse will be computed by forward substitution\n\n - ``ones_on_diagonal`` -- a boolean, if ``True``, the\n entries on the diagonal of the morphism (and inverse) matrix are\n assumed to be ones. This is used to remove divisions from the\n forward and back substitute algorithms.\n\n OUTPUT:\n\n Nothing is returned, but the caches ``self_to_other_cache``\n and ``other_to_self_cache`` are updated with the `n`-th degree\n components of the respective transition matrices.\n\n EXAMPLES:\n\n First, we will do an example of inverting the morphism\n which sends a Schur function to its conjugate Schur function. Note\n that this is an involution. ::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: conj = lambda p1: lambda p2: QQ(1) if p2 == p1.conjugate() else QQ(0)\n sage: c1 = {}\n sage: c2 = {}\n sage: s._invert_morphism(4, QQ, c1, c2, to_other_function = conj)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(c1[4])\n [([1, 1, 1, 1], [([4], 1)]),\n ([2, 1, 1], [([3, 1], 1)]),\n ([2, 2], [([2, 2], 1)]),\n ([3, 1], [([2, 1, 1], 1)]),\n ([4], [([1, 1, 1, 1], 1)])]\n sage: l(c2[4])\n [([1, 1, 1, 1], [([4], 1)]),\n ([2, 1, 1], [([3, 1], 1)]),\n ([2, 2], [([2, 2], 1)]),\n ([3, 1], [([2, 1, 1], 1)]),\n ([4], [([1, 1, 1, 1], 1)])]\n sage: c2 == c1\n True\n\n We can check that we get the same results if we specify\n ``to_self_function = conj``::\n\n sage: d1 = {}\n sage: d2 = {}\n sage: s._invert_morphism(4, QQ, d1, d2, to_self_function = conj)\n sage: d1 == c1\n True\n sage: d2 == c2\n True\n\n Now we do an example of upper triangularity and check that we get\n the same thing whether or not we specify ``ones_on_diagonal``::\n\n sage: f = lambda p1: lambda p2: QQ(1) if p2 <= p1 else QQ(0)\n sage: c1 = {}\n sage: c2 = {}\n sage: s._invert_morphism(3, QQ, c1, c2, to_other_function = f, upper_triangular=True)\n sage: l(c1[3])\n [([1, 1, 1], [([1, 1, 1], 1)]),\n ([2, 1], [([1, 1, 1], 1), ([2, 1], 1)]),\n ([3], [([1, 1, 1], 1), ([2, 1], 1), ([3], 1)])]\n sage: l(c2[3])\n [([1, 1, 1], [([1, 1, 1], 1)]),\n ([2, 1], [([1, 1, 1], -1), ([2, 1], 1)]),\n ([3], [([2, 1], -1), ([3], 1)])]\n\n ::\n\n sage: d1 = {}\n sage: d2 = {}\n sage: s._invert_morphism(3, QQ, d1, d2, to_other_function = f,upper_triangular=True, ones_on_diagonal=True)\n sage: c1 == d1\n True\n sage: c2 == d2\n True\n\n Finally, we do the same thing for lower triangular matrices::\n\n sage: f = lambda p1: lambda p2: QQ(1) if p2 >= p1 else QQ(0)\n sage: c1 = {}\n sage: c2 = {}\n sage: s._invert_morphism(3, QQ, c1, c2, to_other_function = f, lower_triangular=True)\n sage: l(c1[3])\n [([1, 1, 1], [([1, 1, 1], 1), ([2, 1], 1), ([3], 1)]),\n ([2, 1], [([2, 1], 1), ([3], 1)]),\n ([3], [([3], 1)])]\n\n ::\n\n sage: l(c2[3])\n [([1, 1, 1], [([1, 1, 1], 1), ([2, 1], -1)]),\n ([2, 1], [([2, 1], 1), ([3], -1)]),\n ([3], [([3], 1)])]\n\n ::\n\n sage: d1 = {}\n sage: d2 = {}\n sage: s._invert_morphism(3, QQ, d1, d2, to_other_function = f,lower_triangular=True, ones_on_diagonal=True)\n sage: c1 == d1\n True\n sage: c2 == d2\n True\n "
if (to_other_function is not None):
known_cache = self_to_other_cache
unknown_cache = other_to_self_cache
known_function = to_other_function
else:
unknown_cache = self_to_other_cache
known_cache = other_to_self_cache
known_function = to_self_function
if ((n in known_cache) and (n in unknown_cache)):
return
one = base_ring.one()
zero = base_ring.zero()
pn = Partitions_n(n).list()
len_pn = len(pn)
known_cache_n = {}
known_matrix_n = matrix(base_ring, len_pn, len_pn)
unknown_cache_n = {}
for i in range(len_pn):
known_cache_part = {}
f = known_function(pn[i])
for j in range(len_pn):
if (lower_triangular and (j > i)):
break
if (upper_triangular and (i > j)):
continue
value = f(pn[j])
if (value != zero):
known_cache_part[pn[j]] = value
known_matrix_n[(i, j)] = value
known_cache_n[pn[i]] = known_cache_part
unknown_cache_n[pn[i]] = {}
if ((upper_triangular is not False) and (lower_triangular is not False)):
raise ValueError('only one of upper_triangular and lower_triangular can be specified')
elif (upper_triangular is not False):
inverse = copy(known_matrix_n.parent().zero_matrix())
delta = (lambda i: (lambda j: (one if (i == j) else zero)))
for column in range(len_pn):
e = delta(column)
x = ([0] * len_pn)
for i in range((len_pn - 1), (- 1), (- 1)):
value = e(i)
if (not ones_on_diagonal):
value /= known_matrix_n[(i, i)]
for j in range((i + 1), len_pn):
if ones_on_diagonal:
value -= (known_matrix_n[(i, j)] * x[j])
else:
value -= ((known_matrix_n[(i, j)] * x[j]) / known_matrix_n[(i, i)])
x[i] = value
for j in range((column + 1)):
if (x[j] != zero):
inverse[(j, column)] = x[j]
elif (lower_triangular is not False):
inverse = copy(known_matrix_n.parent().zero_matrix())
delta = (lambda i: (lambda j: (one if (i == j) else zero)))
for column in range(len_pn):
e = delta(column)
x = []
for i in range(len_pn):
value = e(i)
if (not ones_on_diagonal):
value /= known_matrix_n[(i, i)]
for j in range(len(x)):
if ones_on_diagonal:
value -= (known_matrix_n[(i, j)] * x[j])
else:
value -= ((known_matrix_n[(i, j)] * x[j]) / known_matrix_n[(i, i)])
x.append(value)
for j in range(column, len(x)):
if (x[j] != zero):
inverse[(j, column)] = x[j]
else:
inverse = (~ known_matrix_n)
for i in range(len_pn):
for j in range(len_pn):
if (inverse[(i, j)] != zero):
if hasattr(self, '_normalize_coefficients'):
unknown_cache_n[pn[i]][pn[j]] = self._normalize_coefficients(inverse[(i, j)])
else:
unknown_cache_n[pn[i]][pn[j]] = inverse[(i, j)]
known_cache[n] = known_cache_n
unknown_cache[n] = unknown_cache_n
def symmetric_function_ring(self):
"\n Return the family of symmetric functions associated to the\n basis ``self``.\n\n OUTPUT:\n\n - returns an instance of the ring of symmetric functions\n\n EXAMPLES::\n\n sage: schur = SymmetricFunctions(QQ).schur()\n sage: schur.symmetric_function_ring()\n Symmetric Functions over Rational Field\n sage: power = SymmetricFunctions(QQ['t']).power()\n sage: power.symmetric_function_ring()\n Symmetric Functions over Univariate Polynomial Ring in t over Rational Field\n "
return self.realization_of()
def prefix(self):
"\n Return the prefix on the elements of ``self``.\n\n EXAMPLES::\n\n sage: schur = SymmetricFunctions(QQ).schur()\n sage: schur([3,2,1])\n s[3, 2, 1]\n sage: schur.prefix()\n 's'\n "
return self._prefix
def transition_matrix(self, basis, n):
'\n Return the transition matrix between ``self`` and ``basis`` for the\n homogeneous component of degree ``n``.\n\n INPUT:\n\n - ``basis`` -- a basis of the ring of symmetric functions\n - ``n`` -- a nonnegative integer\n\n OUTPUT:\n\n - a matrix of coefficients giving the expansion of the\n homogeneous degree-`n` elements of ``self`` in the\n degree-`n` elements of ``basis``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: m = SymmetricFunctions(QQ).m()\n sage: s.transition_matrix(m,5)\n [1 1 1 1 1 1 1]\n [0 1 1 2 2 3 4]\n [0 0 1 1 2 3 5]\n [0 0 0 1 1 3 6]\n [0 0 0 0 1 2 5]\n [0 0 0 0 0 1 4]\n [0 0 0 0 0 0 1]\n sage: s.transition_matrix(m,1)\n [1]\n sage: s.transition_matrix(m,0)\n [1]\n\n ::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: s.transition_matrix(p, 4)\n [ 1/4 1/3 1/8 1/4 1/24]\n [-1/4 0 -1/8 1/4 1/8]\n [ 0 -1/3 1/4 0 1/12]\n [ 1/4 0 -1/8 -1/4 1/8]\n [-1/4 1/3 1/8 -1/4 1/24]\n sage: StoP = s.transition_matrix(p,4)\n sage: a = s([3,1])+5*s([1,1,1,1])-s([4])\n sage: a\n 5*s[1, 1, 1, 1] + s[3, 1] - s[4]\n sage: mon = sorted(a.support())\n sage: coeffs = [a[i] for i in mon]\n sage: coeffs\n [5, 1, -1]\n sage: mon\n [[1, 1, 1, 1], [3, 1], [4]]\n sage: cm = matrix([[-1,1,0,0,5]])\n sage: cm * StoP\n [-7/4 4/3 3/8 -5/4 7/24]\n sage: p(a)\n 7/24*p[1, 1, 1, 1] - 5/4*p[2, 1, 1] + 3/8*p[2, 2] + 4/3*p[3, 1] - 7/4*p[4]\n\n ::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: e = SymmetricFunctions(QQ).e()\n sage: s.transition_matrix(m,7) == h.transition_matrix(s,7).transpose()\n True\n\n ::\n\n sage: h.transition_matrix(m, 7) == h.transition_matrix(m, 7).transpose()\n True\n\n ::\n\n sage: h.transition_matrix(e, 7) == e.transition_matrix(h, 7)\n True\n\n ::\n\n sage: p.transition_matrix(s, 5)\n [ 1 -1 0 1 0 -1 1]\n [ 1 0 -1 0 1 0 -1]\n [ 1 -1 1 0 -1 1 -1]\n [ 1 1 -1 0 -1 1 1]\n [ 1 0 1 -2 1 0 1]\n [ 1 2 1 0 -1 -2 -1]\n [ 1 4 5 6 5 4 1]\n\n ::\n\n sage: e.transition_matrix(m,7) == e.transition_matrix(m,7).transpose()\n True\n '
P = Partitions_n(n)
Plist = P.list()
m = []
for row_part in Plist:
z = basis(self(row_part))
m.append([z.coefficient(col_part) for col_part in Plist])
return matrix(m)
def _gram_schmidt(self, n, source, scalar, cache, leading_coeff=None, upper_triangular=True):
"\n Apply Gram-Schmidt to ``source`` with respect to the scalar product\n ``scalar`` for all partitions of `n`. The scalar product is supposed\n to make the power-sum basis orthogonal. The Gram-Schmidt algorithm\n computes an orthogonal basis (with respect to the scalar product\n given by ``scalar``) of the `n`-th homogeneous component of the\n ring of symmetric functions such that the transition matrix from\n the basis ``source`` to this orthogonal basis is triangular.\n\n The result is not returned, but instead, the coefficients of the\n elements of the orthogonal basis with respect to the basis\n ``source`` are stored in the cache ``cache``.\n\n The implementation uses the powersum basis, so this function\n shouldn't be used unless the base ring is a `\\QQ`-algebra\n (or ``self`` and ``source`` are both the powersum basis).\n\n INPUT:\n\n - ``n`` -- nonnegative integer which specifies the size of\n the partitions\n - ``source`` -- a basis of the ring of symmetric functions\n - ``scalar`` -- a function ``zee`` from partitions to the base ring\n which specifies the scalar product by `\\langle p_{\\lambda},\n p_{\\lambda} \\rangle = \\mathrm{zee}(\\lambda)`.\n - ``cache`` -- a cache function\n - ``leading_coeff`` -- (default: ``None``) specifies the leading\n coefficients for Gram-Schmidt\n - ``upper_triangular`` -- (defaults to ``True``) boolean, indicates\n whether the transition is upper triangular or not\n\n EXAMPLES::\n\n sage: cache = {}\n sage: from sage.combinat.sf.sfa import zee\n sage: s = SymmetricFunctions(QQ).s()\n sage: m = SymmetricFunctions(QQ).m()\n sage: s._gram_schmidt(3, m, zee, cache)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(cache)\n [([1, 1, 1], [([1, 1, 1], 1)]),\n ([2, 1], [([1, 1, 1], 2), ([2, 1], 1)]),\n ([3], [([1, 1, 1], 1), ([2, 1], 1), ([3], 1)])]\n "
BR = self.base_ring()
one = BR.one()
p = self.realization_of().p()
pscalar = (lambda x, y: p._apply_multi_module_morphism(p(x), p(y), (lambda a, b: scalar(a)), orthogonal=True))
if (leading_coeff is None):
leading_coeff = (lambda x: one)
l = Partitions_n(n).list()
if upper_triangular:
l.reverse()
precomputed_elements = []
cache[l[0]] = {l[0]: leading_coeff(l[0])}
precomputed_elements.append((leading_coeff(l[0]) * source(l[0])))
for i in range(1, len(l)):
start = (leading_coeff(l[i]) * source(l[i]))
sub = 0
for j in range(i):
sub += ((pscalar(start, precomputed_elements[j]) / pscalar(precomputed_elements[j], precomputed_elements[j])) * precomputed_elements[j])
res = (start - sub)
if hasattr(self, '_normalize_coefficients'):
res = res.map_coefficients(self._normalize_coefficients)
precomputed_elements.append(res)
cache[l[i]] = {}
for j in range((i + 1)):
cache[l[i]][l[j]] = res.coefficient(l[j])
def _inner_plethysm_pk_g(self, k, g, cache):
'\n Return the inner plethysm between the power-sum symmetric\n function `p_k` and the symmetric function ``g``.\n\n See :meth:`inner_plethysm` for the definition of inner\n plethysm.\n\n .. WARNING::\n\n The function ``g`` *must* be given in the power-sum\n basis for this method to return a correct result.\n\n ALGORITHM:\n\n Express ``g`` in the power sum basis as\n `g = \\sum_\\mu c_\\mu p_\\mu/z_\\mu`\n (where `z_\\mu` is the size of the centralizer of any\n permutation with cycle type `\\mu`). Then, the inner plethysm\n is calculated as\n\n .. MATH::\n\n p_k \\{ g \\} = \\sum_\\mu c_\\mu p_k \\{ p_\\mu/z_\\mu \\}~.\n\n The inner plethysm `p_k \\{ p_mu/z_\\mu \\}` is given by the formula\n\n .. MATH::\n\n p_k \\{ p_\\mu/z_\\mu \\} = \\sum_{\\nu : \\nu^k = \\mu } p_{\\nu}/z_{\\nu}~,\n\n where `\\nu^k` is the `k`-th power of `nu` (see\n :~sage.combinat.partition.partition_power`).\n\n .. SEEALSO:: :func:`~sage.combinat.partition.partition_power`,\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.inner_plethysm`\n\n INPUT:\n\n - ``k`` -- a positive integer\n\n - ``g`` -- a symmetric function in the power sum basis\n\n - ``cache`` -- a dictionary whose keys are (k, g) pairs\n and values are the cached output of this function\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p._inner_plethysm_pk_g(2, p([1,1,1]), {})\n p[1, 1, 1] + 3*p[2, 1]\n sage: p._inner_plethysm_pk_g(5, p([2,2,1,1,1]), {})\n p[2, 2, 1, 1, 1]\n '
try:
return cache[(k, g)]
except KeyError:
pass
p = self.realization_of().p()
res = 0
degrees = sorted(set((sum(m) for m in g.support())))
for d in degrees:
for mu in Partitions_n(d):
mu_k = mu.power(k)
if (mu_k in g.support()):
res += (((g.coefficient(mu_k) * mu_k.centralizer_size()) / mu.centralizer_size()) * p(mu))
cache[(k, g)] = res
return res
def _inner_plethysm_pnu_g(self, p_x, cache, nu):
'\n Return the inner plethysm of the power-sum symmetric function\n `p_\\nu` with another symmetric function ``p_x`` in the\n power-sum basis.\n\n See :meth:`inner_plethysm` for the definition of inner\n plethysm.\n\n .. WARNING::\n\n The function ``p_x`` *must* be given in the power-sum\n basis for this method to return a correct result.\n\n The computation uses the inner plethysm of `p_k` and ``p_x``\n and the identity\n\n .. MATH::\n\n (f \\cdot g) \\{ h \\} = (f \\{ h \\}) \\ast (g \\{ h \\})~.\n\n .. SEEALSO:: :meth:`_inner_plethysm_pk_g`,\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.itensor`,\n :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.inner_plethysm`\n\n INPUT:\n\n - ``p_x`` -- a symmetric function in the power sum basis\n\n - ``cache`` -- a cache function\n\n - ``nu`` -- a partition\n\n Note that the order of the arguments is somewhat strange in order\n to facilitate partial function application.\n\n OUTPUT:\n\n - an element of the basis ``self``\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: s = SymmetricFunctions(QQ).s()\n sage: p._inner_plethysm_pnu_g( p([1,1,1]), {}, Partition([2,1]))\n 6*p[1, 1, 1]\n sage: p._inner_plethysm_pnu_g( p([1,1,1]), {}, Partition([]))\n 1/6*p[1, 1, 1] + 1/2*p[2, 1] + 1/3*p[3]\n sage: s(_)\n s[3]\n '
if (not nu._list):
s = self.realization_of().s()
degrees = [part.size() for part in p_x.support()]
degrees = sorted(set(degrees))
if (0 in degrees):
ext = self([])
else:
ext = 0
return (ext + self(sum([s([n]) for n in degrees if (n != 0)])))
res = [self._inner_plethysm_pk_g(k, p_x, cache) for k in nu]
return self(reduce((lambda x, y: (0 if (x == 0) else x.itensor(y))), res))
def _dual_basis_default(self):
'\n Return the default value for ``self.dual_basis()``\n\n .. SEEALSO:: :meth:`dual_basis`\n\n EXAMPLES:\n\n This default implementation constructs the dual basis using\n the standard (Hall) scalar product::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: Sym.p()._dual_basis_default()\n Dual basis to Symmetric Functions over Rational Field in the powersum basis with respect to the Hall scalar product\n\n This is meant to be overridden by subclasses for which an\n explicit dual basis is known::\n\n sage: Sym.s()._dual_basis_default()\n Symmetric Functions over Rational Field in the Schur basis\n sage: Sym.h()._dual_basis_default()\n Symmetric Functions over Rational Field in the monomial basis\n sage: Sym.m()._dual_basis_default()\n Symmetric Functions over Rational Field in the homogeneous basis\n sage: Sym.f()._dual_basis_default()\n Symmetric Functions over Rational Field in the elementary basis\n sage: Sym.e()._dual_basis_default()\n Symmetric Functions over Rational Field in the forgotten basis\n sage: Sym.f()._dual_basis_default()\n Symmetric Functions over Rational Field in the elementary basis\n '
return self.dual_basis(scalar=zee, scalar_name='Hall scalar product')
def dual_basis(self, scalar=None, scalar_name='', basis_name=None, prefix=None):
"\n Return the dual basis of ``self`` with respect to the scalar\n product ``scalar``.\n\n INPUT:\n\n - ``scalar`` -- A function ``zee`` from partitions to the base ring\n which specifies the scalar product by `\\langle p_{\\lambda},\n p_{\\lambda} \\rangle = \\mathrm{zee}(\\lambda)`. (Independently on the\n function chosen, the power sum basis will always be orthogonal;\n the function ``scalar`` only determines the norms of the basis\n elements.) If ``scalar`` is None, then the standard (Hall) scalar\n product is used.\n - ``scalar_name`` -- name of the scalar function\n - ``prefix`` -- prefix used to display the basis\n\n EXAMPLES:\n\n The duals of the elementary symmetric functions with respect to the\n Hall scalar product are the forgotten symmetric functions.\n\n ::\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: f = e.dual_basis(prefix='f'); f\n Dual basis to Symmetric Functions over Rational Field in the elementary basis with respect to the Hall scalar product\n sage: f([2,1])^2\n 4*f[2, 2, 1, 1] + 6*f[2, 2, 2] + 2*f[3, 2, 1] + 2*f[3, 3] + 2*f[4, 1, 1] + f[4, 2]\n sage: f([2,1]).scalar(e([2,1]))\n 1\n sage: f([2,1]).scalar(e([1,1,1]))\n 0\n\n Since the power-sum symmetric functions are orthogonal, their duals\n with respect to the Hall scalar product are scalar multiples of\n themselves.\n\n ::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: q = p.dual_basis(prefix='q'); q\n Dual basis to Symmetric Functions over Rational Field in the powersum basis with respect to the Hall scalar product\n sage: q([2,1])^2\n 4*q[2, 2, 1, 1]\n sage: p([2,1]).scalar(q([2,1]))\n 1\n sage: p([2,1]).scalar(q([1,1,1]))\n 0\n "
from . import dual
if (scalar is None):
if ((basis_name is None) and (prefix is None)):
return self._dual_basis_default()
scalar = zee
scalar_name = 'Hall scalar product'
return dual.SymmetricFunctionAlgebra_dual(self, scalar, scalar_name, basis_name=basis_name, prefix=prefix)
def basis_name(self):
"\n Return the name of the basis of ``self``.\n\n This is used for output and, for the classical bases of\n symmetric functions, to connect this basis with Symmetrica.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s()\n sage: s.basis_name()\n 'Schur'\n sage: p = Sym.p()\n sage: p.basis_name()\n 'powersum'\n sage: h = Sym.h()\n sage: h.basis_name()\n 'homogeneous'\n sage: e = Sym.e()\n sage: e.basis_name()\n 'elementary'\n sage: m = Sym.m()\n sage: m.basis_name()\n 'monomial'\n sage: f = Sym.f()\n sage: f.basis_name()\n 'forgotten'\n "
return self._basis
def get_print_style(self):
"\n Return the value of the current print style for ``self``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s.get_print_style()\n 'lex'\n sage: s.set_print_style('length')\n sage: s.get_print_style()\n 'length'\n sage: s.set_print_style('lex')\n "
return self._print_style
def set_print_style(self, ps):
"\n Set the value of the current print style to ``ps``.\n\n INPUT:\n\n - ``ps`` -- a string specifying the printing style\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s.get_print_style()\n 'lex'\n sage: s.set_print_style('length')\n sage: s.get_print_style()\n 'length'\n sage: s.set_print_style('lex')\n "
if (ps == 'lex'):
self.print_options(sorting_key=(lambda x: x))
elif (ps == 'length'):
self.print_options(sorting_key=len)
elif (ps == 'maximal_part'):
self.print_options(sorting_key=_lmax)
else:
raise ValueError('the print style must be one of lex, length, or maximal_part ')
self._print_style = ps
def _latex_term(self, m):
"\n Latex terms (i.e. partitions) as plain lists (and not as\n ferrers diagrams).\n\n INPUT:\n\n - ``m`` -- a partition or list\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: m._latex_term(Partition([3,2,1]))\n 'm_{3,2,1}'\n sage: f = sum([m(p) for p in Partitions(3)])\n sage: m.set_print_style('lex')\n sage: latex(f)\n m_{1,1,1} + m_{2,1} + m_{3}\n sage: m.set_print_style('length')\n sage: latex(f)\n m_{3} + m_{2,1} + m_{1,1,1}\n sage: m.set_print_style('maximal_part')\n sage: latex(f)\n m_{1,1,1} + m_{2,1} + m_{3}\n "
return super()._latex_term(','.join((str(i) for i in m)))
def from_polynomial(self, poly, check=True):
'\n Convert polynomial to a symmetric function in the monomial basis\n and then to the basis ``self``.\n\n INPUT:\n\n - ``poly`` -- a symmetric polynomial\n - ``check`` -- (default: ``True``) boolean, specifies whether\n the computation checks that the polynomial is indeed symmetric\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: h = Sym.homogeneous()\n sage: f = (h([]) + h([2,1]) + h([3])).expand(3)\n sage: h.from_polynomial(f)\n h[] + h[2, 1] + h[3]\n sage: s = Sym.s()\n sage: g = (s([]) + s([2,1])).expand(3); g\n x0^2*x1 + x0*x1^2 + x0^2*x2 + 2*x0*x1*x2 + x1^2*x2 + x0*x2^2 + x1*x2^2 + 1\n sage: s.from_polynomial(g)\n s[] + s[2, 1]\n '
m = self.realization_of().m()
return self(m.from_polynomial(poly, check=check))
def product_by_coercion(self, left, right):
'\n Return the product of elements ``left`` and ``right`` by coercion to\n the Schur basis.\n\n INPUT:\n\n - ``left``, ``right`` -- instances of this basis\n\n OUTPUT:\n\n - the product of ``left`` and ``right`` expressed in the basis ``self``\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: p.product_by_coercion(p[3,1,1], p[2,2])\n p[3, 2, 2, 1, 1]\n sage: m = SymmetricFunctions(QQ).m()\n sage: m.product_by_coercion(m[2,1],m[1,1]) == m[2,1]*m[1,1]\n True\n '
s = self.realization_of().schur()
return self(s.product(s(left), s(right)))
def coproduct_by_coercion(self, elt):
"\n Return the coproduct of the element ``elt`` by coercion to\n the Schur basis.\n\n INPUT:\n\n - ``elt`` -- an instance of this basis\n\n OUTPUT:\n\n - The image of ``elt`` under the comultiplication (=coproduct)\n of the coalgebra of symmetric functions. The result is an\n element of the tensor squared of the basis ``self``.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: m[3,1,1].coproduct()\n m[] # m[3, 1, 1] + m[1] # m[3, 1] + m[1, 1] # m[3] + m[3] # m[1, 1] + m[3, 1] # m[1] + m[3, 1, 1] # m[]\n sage: m.coproduct_by_coercion(m[2,1])\n m[] # m[2, 1] + m[1] # m[2] + m[2] # m[1] + m[2, 1] # m[]\n sage: m.coproduct_by_coercion(m[2,1]) == m([2,1]).coproduct()\n True\n sage: McdH = SymmetricFunctions(QQ['q','t'].fraction_field()).macdonald().H()\n sage: McdH[2,1].coproduct()\n McdH[] # McdH[2, 1] + ((q^2*t-1)/(q*t-1))*McdH[1] # McdH[1, 1] + ((q*t^2-1)/(q*t-1))*McdH[1] # McdH[2] + ((q^2*t-1)/(q*t-1))*McdH[1, 1] # McdH[1] + ((q*t^2-1)/(q*t-1))*McdH[2] # McdH[1] + McdH[2, 1] # McdH[]\n sage: HLQp = SymmetricFunctions(QQ['t'].fraction_field()).hall_littlewood().Qp()\n sage: HLQp[2,1].coproduct()\n HLQp[] # HLQp[2, 1] + HLQp[1] # HLQp[1, 1] + HLQp[1] # HLQp[2] + HLQp[1, 1] # HLQp[1] + HLQp[2] # HLQp[1] + HLQp[2, 1] # HLQp[]\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: LLT = Sym.llt(3)\n sage: LLT.cospin([3,2,1]).coproduct()\n (t+1)*m[] # m[1, 1] + m[] # m[2] + (t+1)*m[1] # m[1] + (t+1)*m[1, 1] # m[] + m[2] # m[]\n sage: f = SymmetricFunctions(ZZ).f()\n sage: f[3].coproduct()\n f[] # f[3] + f[3] # f[]\n sage: f[3,2,1].coproduct()\n f[] # f[3, 2, 1] + f[1] # f[3, 2] + f[2] # f[3, 1] + f[2, 1] # f[3] + f[3] # f[2, 1] + f[3, 1] # f[2] + f[3, 2] # f[1] + f[3, 2, 1] # f[]\n "
from sage.categories.tensor import tensor
s = self.realization_of().schur()
return self.tensor_square().sum(((coeff * tensor([self(s[x]), self(s[y])])) for ((x, y), coeff) in s(elt).coproduct()))
|
class SymmetricFunctionAlgebra_generic_Element(CombinatorialFreeModule.Element):
"\n Class of generic elements for the symmetric function algebra.\n\n TESTS::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: f = sum([m(p) for p in Partitions(3)])\n sage: m.set_print_style('lex')\n sage: f\n m[1, 1, 1] + m[2, 1] + m[3]\n sage: m.set_print_style('length')\n sage: f\n m[3] + m[2, 1] + m[1, 1, 1]\n sage: m.set_print_style('maximal_part')\n sage: f\n m[1, 1, 1] + m[2, 1] + m[3]\n sage: m.set_print_style('lex')\n "
def factor(self):
'\n Return the factorization of this symmetric function.\n\n EXAMPLES::\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: factor((5*e[3] + e[2,1] + e[1])*(7*e[2] + e[5,1]))\n (e[1] + e[2, 1] + 5*e[3]) * (7*e[2] + e[5, 1])\n\n sage: R.<x, y> = QQ[]\n sage: s = SymmetricFunctions(R.fraction_field()).s()\n sage: factor((s[3] + x*s[2,1] + 1)*(3*y*s[2] + s[4,1] + x*y))\n (-s[] + (-x)*s[2, 1] - s[3]) * ((-x*y)*s[] + (-3*y)*s[2] - s[4, 1])\n\n TESTS::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: factor((p[3] + p[2,1])*(p[2] + p[4,1]))\n (p[2, 1] + p[3]) * (p[2] + p[4, 1])\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: factor((s[3] + s[2,1])*(s[2] + s[4,1]))\n (-1) * s[1] * s[2] * (-s[2] - s[4, 1])\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: factor((s[3] + s[2,1])*(s[2] + s[4,1]))\n (-1) * s[1] * s[2] * (-s[2] - s[4, 1])\n\n sage: R.<t> = QQ[]\n sage: JP = SymmetricFunctions(FractionField(R)).jack(t).P()\n sage: f = (JP[2,1]*t + JP[1,1,1])^2\n sage: f.factor()\n (1/(t^2 + 4*t + 4)) * ((-t-2)*JackP[1, 1, 1] + (-t^2-2*t)*JackP[2, 1])^2\n\n Some corner cases::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: factor(s(6))\n 2 * 3\n\n sage: factor(6*s[1])\n 2*s[] * 3*s[] * s[1]\n\n '
from sage.combinat.sf.multiplicative import SymmetricFunctionAlgebra_multiplicative
L = self.parent()
if isinstance(L, SymmetricFunctionAlgebra_multiplicative):
M = L
else:
M = L.realization_of().h()
self = M(self)
poly = _to_polynomials([self], self.base_ring())[0]
factors = poly.factor()
unit = factors.unit()
if (factors.universe() == self.base_ring()):
return Factorization(factors, unit=unit)
factors = [(_from_polynomial(factor, M), exponent) for (factor, exponent) in factors]
if (not isinstance(L, SymmetricFunctionAlgebra_multiplicative)):
factors = [(L(factor), exponent) for (factor, exponent) in factors]
return Factorization(factors, unit=unit)
def _floordiv_(self, other):
'\n Perform division with remainder and return the quotient.\n\n INPUT:\n\n - ``right`` - something coercible to a symmetric function in\n ``self.parent()``\n\n EXAMPLES::\n\n sage: e = SymmetricFunctions(ZZ).e()\n sage: h = SymmetricFunctions(ZZ).h()\n sage: e[3,2,1] // h[2]\n -e[3, 1]\n\n TESTS::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: s(0) // s[1]\n 0\n\n sage: s(6) // s(2)\n 3*s[]\n\n '
from sage.combinat.sf.multiplicative import SymmetricFunctionAlgebra_multiplicative
L = self.parent()
if isinstance(L, SymmetricFunctionAlgebra_multiplicative):
M = L
else:
M = L.realization_of().h()
self = M(self)
other = M(other)
(p1, p2) = _to_polynomials([self, other], self.base_ring())
g = (p1 // p2)
return L(_from_polynomial(g, M))
@coerce_binop
def gcd(self, other):
'\n Return the greatest common divisor with ``other``.\n\n INPUT:\n\n - ``other`` -- the other symmetric function\n\n EXAMPLES::\n\n sage: e = SymmetricFunctions(ZZ).e()\n sage: A = 5*e[3] + e[2,1] + e[1]\n sage: B = 7*e[2] + e[5,1]\n sage: C = 3*e[1,1] + e[2]\n sage: gcd(A*B^2, B*C)\n 7*e[2] + e[5, 1]\n\n sage: p = SymmetricFunctions(ZZ).p()\n sage: gcd(e[2,1], p[1,1]-p[2])\n e[2]\n sage: gcd(p[2,1], p[3,2]-p[2,1])\n p[2]\n\n TESTS::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: gcd(s(0), s[1])\n s[1]\n\n sage: gcd(s(0), s(1))\n s[]\n\n sage: gcd(s(9), s(6))\n 3*s[]\n\n '
from sage.combinat.sf.multiplicative import SymmetricFunctionAlgebra_multiplicative
L = self.parent()
if isinstance(L, SymmetricFunctionAlgebra_multiplicative):
M = L
else:
M = L.realization_of().h()
self = M(self)
other = M(other)
(p1, p2) = _to_polynomials([self, other], self.base_ring())
g = p1.gcd(p2)
return L(_from_polynomial(g, M))
def plethysm(self, x, include=None, exclude=None):
"\n Return the outer plethysm of ``self`` with ``x``.\n\n This is implemented only over base rings which are\n `\\QQ`-algebras. (To compute outer plethysms over general\n binomial rings, change bases to the fraction field.)\n\n The outer plethysm of `f` with `g` is commonly denoted by\n `f \\left[ g \\right]` or by `f \\circ g`. It is an algebra map\n in `f`, but not (generally) in `g`.\n\n By default, the degree one elements are taken to be the\n generators for the ``self``'s base ring. This setting can be\n modified by specifying the ``include`` and ``exclude`` keywords.\n\n INPUT:\n\n - ``x`` -- a symmetric function over the same base ring as\n ``self``\n - ``include`` -- a list of variables to be treated as\n degree one elements instead of the default degree one elements\n - ``exclude`` -- a list of variables to be excluded\n from the default degree one elements\n\n OUTPUT:\n\n An element in the parent of ``x`` or the base ring `R` of ``self``\n when ``x`` is in `R`.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s()\n sage: h = Sym.h()\n sage: h3h2 = h[3](h[2]); h3h2\n h[2, 2, 2] - 2*h[3, 2, 1] + h[3, 3] + h[4, 1, 1] - h[5, 1] + h[6]\n sage: s(h3h2)\n s[2, 2, 2] + s[4, 2] + s[6]\n sage: p = Sym.p()\n sage: p3s21 = p[3](s[2,1]); p3s21\n s[2, 2, 2, 1, 1, 1] - s[2, 2, 2, 2, 1] - s[3, 2, 1, 1, 1, 1]\n + s[3, 2, 2, 2] + s[3, 3, 1, 1, 1] - s[3, 3, 2, 1] + 2*s[3, 3, 3]\n + s[4, 1, 1, 1, 1, 1] - s[4, 3, 2] + s[4, 4, 1] - s[5, 1, 1, 1, 1]\n + s[5, 2, 2] - s[5, 4] + s[6, 1, 1, 1] - s[6, 2, 1] + s[6, 3]\n sage: p(p3s21)\n 1/3*p[3, 3, 3] - 1/3*p[9]\n sage: e = Sym.e()\n sage: e[3](e[2])\n e[3, 3] + e[4, 1, 1] - 2*e[4, 2] - e[5, 1] + e[6]\n\n Note that the output is in the basis of the input ``x``::\n\n sage: s[2,1](h[3])\n h[4, 3, 2] - h[4, 4, 1] - h[5, 2, 2] + h[5, 3, 1] + h[5, 4]\n + h[6, 2, 1] - 2*h[6, 3] - h[7, 1, 1] + h[7, 2] + h[8, 1] - h[9]\n\n sage: h[2,1](s[3])\n s[4, 3, 2] + s[4, 4, 1] + s[5, 2, 2] + s[5, 3, 1] + s[5, 4]\n + s[6, 2, 1] + 2*s[6, 3] + 2*s[7, 2] + s[8, 1] + s[9]\n\n Examples over a polynomial ring::\n\n sage: R.<t> = QQ[]\n sage: s = SymmetricFunctions(R).s()\n sage: a = s([3])\n sage: f = t * s([2])\n sage: a(f)\n t^3*s[2, 2, 2] + t^3*s[4, 2] + t^3*s[6]\n sage: f(a)\n t*s[4, 2] + t*s[6]\n sage: s(0).plethysm(s[1])\n 0\n sage: s(1).plethysm(s[1])\n s[]\n sage: s(1).plethysm(s(0))\n s[]\n\n When ``x`` is a constant, then it is returned as an element\n of the base ring::\n\n sage: s[3](2).parent() is R\n True\n\n Sage also handles plethysm of tensor products of symmetric functions::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: X = tensor([s[1],s[[]]])\n sage: Y = tensor([s[[]],s[1]])\n sage: s[1,1,1](X+Y)\n s[] # s[1, 1, 1] + s[1] # s[1, 1] + s[1, 1] # s[1] + s[1, 1, 1] # s[]\n sage: s[1,1,1](X*Y)\n s[1, 1, 1] # s[3] + s[2, 1] # s[2, 1] + s[3] # s[1, 1, 1]\n\n One can use this to work with symmetric functions in two sets of\n commuting variables. For example, we verify the Cauchy identities\n (in degree 5)::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: P5 = Partitions(5)\n sage: sum(s[mu](X)*s[mu](Y) for mu in P5) == sum(m[mu](X)*h[mu](Y) for mu in P5)\n True\n sage: sum(s[mu](X)*s[mu.conjugate()](Y) for mu in P5) == sum(m[mu](X)*e[mu](Y) for mu in P5)\n True\n\n Sage can also do the plethysm with an element in the completion::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: L = LazySymmetricFunctions(s)\n sage: f = s[2,1]\n sage: g = L(s[1]) / (1 - L(s[1])); g\n s[1] + (s[1,1]+s[2]) + (s[1,1,1]+2*s[2,1]+s[3])\n + (s[1,1,1,1]+3*s[2,1,1]+2*s[2,2]+3*s[3,1]+s[4])\n + (s[1,1,1,1,1]+4*s[2,1,1,1]+5*s[2,2,1]+6*s[3,1,1]+5*s[3,2]+4*s[4,1]+s[5])\n + ... + O^8\n sage: fog = f(g)\n sage: fog[:8]\n [s[2, 1],\n s[1, 1, 1, 1] + 3*s[2, 1, 1] + 2*s[2, 2] + 3*s[3, 1] + s[4],\n 2*s[1, 1, 1, 1, 1] + 8*s[2, 1, 1, 1] + 10*s[2, 2, 1]\n + 12*s[3, 1, 1] + 10*s[3, 2] + 8*s[4, 1] + 2*s[5],\n 3*s[1, 1, 1, 1, 1, 1] + 17*s[2, 1, 1, 1, 1] + 30*s[2, 2, 1, 1]\n + 16*s[2, 2, 2] + 33*s[3, 1, 1, 1] + 54*s[3, 2, 1] + 16*s[3, 3]\n + 33*s[4, 1, 1] + 30*s[4, 2] + 17*s[5, 1] + 3*s[6],\n 5*s[1, 1, 1, 1, 1, 1, 1] + 30*s[2, 1, 1, 1, 1, 1] + 70*s[2, 2, 1, 1, 1]\n + 70*s[2, 2, 2, 1] + 75*s[3, 1, 1, 1, 1] + 175*s[3, 2, 1, 1]\n + 105*s[3, 2, 2] + 105*s[3, 3, 1] + 100*s[4, 1, 1, 1] + 175*s[4, 2, 1]\n + 70*s[4, 3] + 75*s[5, 1, 1] + 70*s[5, 2] + 30*s[6, 1] + 5*s[7]]\n sage: parent(fog)\n Lazy completion of Symmetric Functions over Rational Field in the Schur basis\n\n .. SEEALSO::\n\n :meth:`frobenius`\n\n TESTS::\n\n sage: (1+p[2]).plethysm(p[2])\n p[] + p[4]\n\n Check that degree one elements are treated in the correct way::\n\n sage: R.<a1,a2,a11,b1,b21,b111> = QQ[]\n sage: p = SymmetricFunctions(R).p()\n sage: f = a1*p[1] + a2*p[2] + a11*p[1,1]\n sage: g = b1*p[1] + b21*p[2,1] + b111*p[1,1,1]\n sage: r = f(g); r\n a1*b1*p[1] + a11*b1^2*p[1, 1] + a1*b111*p[1, 1, 1]\n + 2*a11*b1*b111*p[1, 1, 1, 1] + a11*b111^2*p[1, 1, 1, 1, 1, 1]\n + a2*b1^2*p[2] + a1*b21*p[2, 1] + 2*a11*b1*b21*p[2, 1, 1]\n + 2*a11*b21*b111*p[2, 1, 1, 1, 1] + a11*b21^2*p[2, 2, 1, 1]\n + a2*b111^2*p[2, 2, 2] + a2*b21^2*p[4, 2]\n sage: r - f(g, include=[])\n (a2*b1^2-a2*b1)*p[2] + (a2*b111^2-a2*b111)*p[2, 2, 2] + (a2*b21^2-a2*b21)*p[4, 2]\n\n Check that we can compute the plethysm with a constant::\n\n sage: p[2,2,1](2)\n 8\n\n sage: p[2,2,1](int(2))\n 8\n\n sage: p[2,2,1](a1)\n a1^5\n\n sage: X = algebras.Shuffle(QQ, 'ab')\n sage: Y = algebras.Shuffle(QQ, 'bc')\n sage: T = tensor([X, Y])\n sage: s = SymmetricFunctions(T).s()\n sage: s[2](5)\n 15*B[] # B[]\n\n .. TODO::\n\n The implementation of plethysm in\n :class:`sage.data_structures.stream.Stream_plethysm` seems\n to be faster. This should be investigated.\n "
from sage.structure.element import parent as get_parent
Px = get_parent(x)
parent = self.parent()
R = parent.base_ring()
if (not self):
return R(0)
tHA = HopfAlgebrasWithBasis(R).TensorProducts()
tensorflag = (Px in tHA)
if (not is_SymmetricFunction(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
if isinstance(x, LazySymmetricFunction):
from sage.rings.lazy_series_ring import LazySymmetricFunctions
L = LazySymmetricFunctions(parent)
return L(self)(x)
phi = parent.coerce_map_from(Px)
if (phi is not None):
x = phi(x)
elif (not tensorflag):
raise TypeError('only know how to compute plethysms between symmetric functions or tensors of symmetric functions')
p = parent.realization_of().power()
degree_one = _variables_recursive(R, include=include, exclude=exclude)
if tensorflag:
tparents = Px._sets
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)
def pn_pleth(f, n):
return f.map_support((lambda mu: mu.stretch(n)))
p_x = p(x)
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))
ret = p._apply_module_morphism(p(self), f, codomain=p)
if (Px is R):
return next(iter(ret._monomial_coefficients.values()))
return Px(ret)
__call__ = plethysm
def inner_plethysm(self, x):
"\n Return the inner plethysm of ``self`` with ``x``.\n\n Whenever `R` is a `\\QQ`-algebra, and `f` and `g` are two\n symmetric functions over `R` such that the constant term of `f`\n is zero, the inner plethysm of `f` with `g` is a symmetric\n function over `R`, and the degree of this symmetric function is\n the same as the degree of `g`. We will denote the inner plethysm\n of `f` with `g` by `f \\{ g \\}` (in contrast to the notation of\n outer plethysm which is generally denoted `f [ g ]`); in Sage\n syntax, it is ``f.inner_plethysm(g)``.\n\n First we describe the axiomatic definition of the operation; see\n below for a representation-theoretic interpretation.\n In the following equations, we denote the outer product\n (i.e., the standard product on the ring of symmetric functions,\n :meth:`~sage.categories.algebras_with_basis.AlgebrasWithBasis.ParentMethods.product`)\n by `\\cdot` and the Kronecker product (:meth:`itensor`) by `\\ast`).\n\n .. MATH::\n\n (f + g) \\{ h \\} = f \\{ h \\} + g \\{ h \\}\n\n (f \\cdot g) \\{ h \\} = (f \\{ h \\}) \\ast (g \\{ h \\})\n\n p_k \\{ f + g \\} = p_k \\{ f \\} + p_k \\{ g \\}\n\n where `p_k` is the `k`-th power-sum symmetric function for every\n `k > 0`.\n\n Let `\\sigma` be a permutation of cycle type `\\mu` and let `\\mu^k`\n be the cycle type of `\\sigma^k`. Then,\n\n .. MATH::\n\n p_k \\{ p_\\mu/z_\\mu \\} = \\sum_{\\nu : \\nu^k = \\mu } p_{\\nu}/z_{\\nu}\n\n Since `(p_\\mu/z_\\mu)_{\\mu}` is a basis for the symmetric\n functions, these four formulas define the symmetric function\n operation `f \\{ g \\}` for any symmetric functions `f` and `g`\n (where `f` has constant term `0`) by expanding `f` in the\n power sum basis and `g` in the dual basis `p_\\mu/z_\\mu`.\n\n .. SEEALSO:: :meth:`itensor`, :func:`~sage.combinat.partition.partition_power`,\n :meth:`plethysm`\n\n This operation admits a representation-theoretic interpretation\n in the case where `f` is a Schur function `s_\\lambda` and\n `g` is a homogeneous degree `n` symmetric function with\n nonnegative integral coefficients in the Schur basis.\n The symmetric function `f \\{ g \\}` is the Frobenius\n image of the `S_n`-representation constructed as follows.\n\n The assumptions on `g` imply that `g` is the Frobenius image of a\n representation `\\rho` of the symmetric group `S_n`:\n\n .. MATH::\n\n \\rho : S_n \\to GL_N.\n\n If the degree `N` of this representation is greater than or equal\n to the number of parts of `\\lambda`, then `f`, which denotes `s_\\lambda`,\n corresponds to the character of some irreducible `GL_N`-representation, say\n\n .. MATH::\n\n \\sigma : GL_N \\to GL_M.\n\n The composition `\\sigma \\circ \\rho : S_n \\to GL_M` is a representation\n of `S_n` whose Frobenius image is precisely `f \\{ g \\}`.\n\n If `N` is less than the number of parts of `\\lambda`,\n then `f \\{ g \\}` is `0` by definition.\n\n When `f` is a symmetric function with constant term `\\neq 0`, the\n inner plethysm `f \\{ g \\}` isn't well-defined in the ring of\n symmetric functions. Indeed, it is not clear how to define\n `1 \\{ g \\}`. The most sensible way to get around this probably is\n defining it as the infinite sum `h_0 + h_1 + h_2 + \\cdots` (where\n `h_i` means the `i`-th complete homogeneous symmetric function)\n in the completion of this ring with respect to its grading. This is\n how [SchaThi1994]_ defines `1 \\{ g \\}`. The present method,\n however, sets it to be the sum of `h_i` over all `i` for which the\n `i`-th homogeneous component of `g` is nonzero. This is rather a\n hack than a reasonable definition. Use with caution!\n\n .. NOTE::\n\n If a symmetric function `g` is written in the form\n `g = g_0 + g_1 + g_2 + \\cdots` with each `g_i` homogeneous\n of degree `i`, then\n `f \\{ g \\} = f \\{ g_0 \\} + f \\{ g_1 \\} + f \\{ g_2 \\} + \\cdots`\n for every `f` with constant term `0`. But in general, inner\n plethysm is not linear in the second variable.\n\n REFERENCES:\n\n .. [King] King, R. Branching rules for `GL_m \\supset \\Sigma_n`\n and the evaluation of inner plethysms.\n J. Math. Phys. 15, 258 (1974) :doi:`10.1063/1.1666632`\n\n .. [SchaThi1994] Thomas Scharf, Jean-Yves Thibon.\n *A Hopf-algebra approach to inner plethysm*.\n Advances in Mathematics 104 (1994), pp. 30-58.\n ftp://ftp.mathe2.uni-bayreuth.de/axel/papers/scharf:a_hopf_algebra_approach_to_inner_plethysm.ps.gz\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the same\n base ring as ``self``\n\n OUTPUT:\n\n - an element of symmetric functions in the parent of ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: p = Sym.power()\n sage: h = Sym.complete()\n sage: s([2,1]).inner_plethysm(s([1,1,1]))\n 0\n sage: s([2]).inner_plethysm(s([2,1]))\n s[2, 1] + s[3]\n sage: s([1,1]).inner_plethysm(s([2,1]))\n s[1, 1, 1]\n sage: s[2,1].inner_tensor(s[2,1])\n s[1, 1, 1] + s[2, 1] + s[3]\n\n ::\n\n sage: f = s([2,1]) + 2*s([3,1])\n sage: f.itensor(f)\n s[1, 1, 1] + s[2, 1] + 4*s[2, 1, 1] + 4*s[2, 2] + s[3] + 4*s[3, 1] + 4*s[4]\n sage: s( h([1,1]).inner_plethysm(f) )\n s[1, 1, 1] + s[2, 1] + 4*s[2, 1, 1] + 4*s[2, 2] + s[3] + 4*s[3, 1] + 4*s[4]\n\n ::\n\n sage: s([]).inner_plethysm(s([1,1]) + 2*s([2,1])+s([3]))\n s[2] + s[3]\n sage: [s([]).inner_plethysm(s(la)) for la in Partitions(4)]\n [s[4], s[4], s[4], s[4], s[4]]\n sage: s([3]).inner_plethysm(s([]))\n s[]\n sage: s[1,1,1,1].inner_plethysm(s[2,1])\n 0\n sage: s[1,1,1,1].inner_plethysm(2*s[2,1])\n s[3]\n\n ::\n\n sage: p[3].inner_plethysm(p[3])\n 0\n sage: p[3,3].inner_plethysm(p[3])\n 0\n sage: p[3].inner_plethysm(p[1,1,1])\n p[1, 1, 1] + 2*p[3]\n sage: p[4].inner_plethysm(p[1,1,1,1]/24)\n 1/24*p[1, 1, 1, 1] + 1/4*p[2, 1, 1] + 1/8*p[2, 2] + 1/4*p[4]\n sage: p[3,3].inner_plethysm(p[1,1,1])\n 6*p[1, 1, 1] + 12*p[3]\n\n TESTS::\n\n sage: s(0).inner_plethysm(s(0))\n 0\n sage: s(1).inner_plethysm(s(0))\n 0\n sage: s(0).inner_plethysm(s(1))\n 0\n sage: s(1).inner_plethysm(s(1))\n s[]\n sage: s(2).inner_plethysm(s(1))\n 2*s[]\n sage: s(1).inner_plethysm(s(2))\n s[]\n "
parent = self.parent()
if (self == parent.zero()):
return self
p = parent.realization_of().power()
cache = {}
ip_pnu_g = parent._inner_plethysm_pnu_g
return parent.sum(((c * ip_pnu_g(p(x), cache, nu)) for (nu, c) in p(self).monomial_coefficients().items()))
def omega(self):
'\n Return the image of ``self`` under the omega automorphism.\n\n The *omega automorphism* is defined to be the unique algebra\n endomorphism `\\omega` of the ring of symmetric functions that\n satisfies `\\omega(e_k) = h_k` for all positive integers `k`\n (where `e_k` stands for the `k`-th elementary symmetric\n function, and `h_k` stands for the `k`-th complete homogeneous\n symmetric function). It furthermore is a Hopf algebra\n endomorphism and an involution, and it is also known as the\n *omega involution*. It sends the power-sum symmetric function\n `p_k` to `(-1)^{k-1} p_k` for every positive integer `k`.\n\n The images of some bases under the omega automorphism are given by\n\n .. MATH::\n\n \\omega(e_{\\lambda}) = h_{\\lambda}, \\qquad\n \\omega(h_{\\lambda}) = e_{\\lambda}, \\qquad\n \\omega(p_{\\lambda}) = (-1)^{|\\lambda| - \\ell(\\lambda)}\n p_{\\lambda}, \\qquad\n \\omega(s_{\\lambda}) = s_{\\lambda^{\\prime}},\n\n where `\\lambda` is any partition, where `\\ell(\\lambda)` denotes\n the length (:meth:`~sage.combinat.partition.Partition.length`)\n of the partition `\\lambda`, where `\\lambda^{\\prime}` denotes the\n conjugate partition\n (:meth:`~sage.combinat.partition.Partition.conjugate`) of\n `\\lambda`, and where the usual notations for bases are used\n (`e` = elementary, `h` = complete homogeneous, `p` = powersum,\n `s` = Schur).\n\n The default implementation converts to the Schur basis, then\n performs the automorphism and changes back.\n\n :meth:`omega_involution()` is a synonym for the :meth:`omega()` method.\n\n EXAMPLES::\n\n sage: J = SymmetricFunctions(QQ).jack(t=1).P()\n sage: a = J([2,1]) + J([1,1,1])\n sage: a.omega()\n JackP[2, 1] + JackP[3]\n sage: J(0).omega()\n 0\n sage: J(1).omega()\n JackP[]\n\n The forgotten symmetric functions are the images of the monomial\n symmetric functions under omega::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: m = Sym.m()\n sage: f = Sym.f()\n sage: all( f(lam) == m(lam).omega() for lam in Partitions(3) )\n True\n sage: all( m(lam) == f(lam).omega() for lam in Partitions(3) )\n True\n '
parent = self.parent()
s = parent.realization_of().schur()
return parent(s(self).omega())
omega_involution = omega
def theta(self, a):
'\n Return the image of ``self`` under the theta endomorphism which sends\n `p_k` to `a \\cdot p_k` for every positive integer `k`.\n\n In general, this is well-defined outside of the powersum basis only\n if the base ring is a `\\QQ`-algebra.\n\n INPUT:\n\n - ``a`` -- an element of the base ring\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([2,1]).theta(2)\n 2*s[1, 1, 1] + 6*s[2, 1] + 2*s[3]\n sage: p = SymmetricFunctions(QQ).p()\n sage: p([2]).theta(2)\n 2*p[2]\n sage: p(0).theta(2)\n 0\n sage: p(1).theta(2)\n p[]\n '
p = self.parent().realization_of().power()
p_self = p(self)
res = p_self.map_item((lambda m, c: (m, (c * (a ** len(m))))))
return self.parent()(res)
def theta_qt(self, q=None, t=None):
"\n Return the image of ``self`` under the `q,t`-deformed theta\n endomorphism which sends `p_k` to `\\frac{1-q^k}{1-t^k} \\cdot p_k`\n for all positive integers `k`.\n\n In general, this is well-defined outside of the powersum basis only\n if the base ring is a `\\QQ`-algebra.\n\n INPUT:\n\n - ``q``, ``t`` -- parameters (default: ``None``, in which case 'q'\n and 't' are used)\n\n EXAMPLES::\n\n sage: QQqt = QQ['q,t'].fraction_field()\n sage: q,t = QQqt.gens()\n sage: p = SymmetricFunctions(QQqt).p()\n sage: p([2]).theta_qt(q,t)\n ((-q^2+1)/(-t^2+1))*p[2]\n sage: p([2,1]).theta_qt(q,t)\n ((q^3-q^2-q+1)/(t^3-t^2-t+1))*p[2, 1]\n sage: p(0).theta_qt(q=1,t=3)\n 0\n sage: p([2,1]).theta_qt(q=2,t=3)\n 3/16*p[2, 1]\n sage: s = p.realization_of().schur()\n sage: s([3]).theta_qt(q=0)*(1-t)*(1-t^2)*(1-t^3)\n t^3*s[1, 1, 1] + (t^2+t)*s[2, 1] + s[3]\n sage: p(1).theta_qt()\n p[]\n "
parent = self.parent()
BR = parent.base_ring()
p = parent.realization_of().power()
p_self = p(self)
if (t is None):
if hasattr(parent, 't'):
t = parent.t
else:
t = BR(QQ['t'].gen())
if (q is None):
if hasattr(parent, 'q'):
q = parent.q
else:
q = BR(QQ['q'].gen())
one = BR.one()
if (not t):
res = p._from_dict({m: BR((prod(((one - (q ** k)) for k in m)) * c)) for (m, c) in p_self})
else:
res = p._from_dict({m: BR((prod((((one - (q ** k)) / (one - (t ** k))) for k in m)) * c)) for (m, c) in p_self})
return parent(res)
def omega_qt(self, q=None, t=None):
"\n Return the image of ``self`` under the `q,t`-deformed omega\n automorphism which sends `p_k` to\n `(-1)^{k-1} \\cdot \\frac{1-q^k}{1-t^k} \\cdot p_k` for all positive\n integers `k`.\n\n In general, this is well-defined outside of the powersum basis only\n if the base ring is a `\\QQ`-algebra.\n\n If `q = t`, then this is the omega automorphism (:meth:`omega`).\n\n INPUT:\n\n - ``q``, ``t`` -- parameters (default: ``None``, in which case\n ``'q'`` and ``'t'`` are used)\n\n EXAMPLES::\n\n sage: QQqt = QQ['q,t'].fraction_field()\n sage: q,t = QQqt.gens()\n sage: p = SymmetricFunctions(QQqt).p()\n sage: p[5].omega_qt()\n ((-q^5+1)/(-t^5+1))*p[5]\n sage: p[5].omega_qt(q,t)\n ((-q^5+1)/(-t^5+1))*p[5]\n sage: p([2]).omega_qt(q,t)\n ((q^2-1)/(-t^2+1))*p[2]\n sage: p([2,1]).omega_qt(q,t)\n ((-q^3+q^2+q-1)/(t^3-t^2-t+1))*p[2, 1]\n sage: p([3,2]).omega_qt(5,q)\n -(2976/(q^5-q^3-q^2+1))*p[3, 2]\n sage: p(0).omega_qt()\n 0\n sage: p(1).omega_qt()\n p[]\n sage: H = SymmetricFunctions(QQqt).macdonald().H()\n sage: H([1,1]).omega_qt()\n ((2*q^2-2*q*t-2*q+2*t)/(t^3-t^2-t+1))*McdH[1, 1] + ((q-1)/(t-1))*McdH[2]\n sage: H([1,1]).omega_qt(q,t)\n ((2*q^2-2*q*t-2*q+2*t)/(t^3-t^2-t+1))*McdH[1, 1] + ((q-1)/(t-1))*McdH[2]\n sage: H([1,1]).omega_qt(t,q)\n ((-t^3+t^2+t-1)/(-q^3+q^2+q-1))*McdH[2]\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: S = Sym.macdonald().S()\n sage: S([1,1]).omega_qt()\n ((q^2-q*t-q+t)/(t^3-t^2-t+1))*McdS[1, 1] + ((-q^2*t+q*t+q-1)/(-t^3+t^2+t-1))*McdS[2]\n sage: s = Sym.schur()\n sage: s(S([1,1]).omega_qt())\n s[2]\n "
parent = self.parent()
BR = parent.base_ring()
p = parent.realization_of().power()
p_self = p(self)
if (t is None):
if hasattr(parent, 't'):
t = parent.t
else:
t = BR(QQ['t'].gen())
if (q is None):
if hasattr(parent, 'q'):
q = parent.q
else:
q = BR(QQ['q'].gen())
one = BR.one()
if (not t):
res = p._from_dict({m: ((c * ((- one) ** (sum(m) - len(m)))) * BR(prod(((one - (q ** i)) for i in m)))) for (m, c) in p_self})
else:
res = p._from_dict({m: ((c * ((- one) ** (sum(m) - len(m)))) * BR(prod((((one - (q ** i)) / (one - (t ** i))) for i in m)))) for (m, c) in p_self})
return parent(res)
def itensor(self, x):
'\n Return the internal (tensor) product of ``self`` and ``x`` in the\n basis of ``self``.\n\n The internal tensor product can be defined as the linear extension\n of the definition on power sums\n `p_{\\lambda} \\ast p_{\\mu} = \\delta_{\\lambda,\\mu} z_{\\lambda}\n p_{\\lambda}`, where `z_{\\lambda} = (1^{r_1} r_1!) (2^{r_2} r_2!)\n \\cdots` for `\\lambda = (1^{r_1} 2^{r_2} \\cdots )` and where `\\ast`\n denotes the internal tensor product.\n The internal tensor product is also known as the Kronecker product,\n or as the second multiplication on the ring of symmetric functions.\n\n Note that the internal product of any two homogeneous symmetric\n functions of equal degrees is a homogeneous symmetric function of the\n same degree. On the other hand, the internal product of two homogeneous\n symmetric functions of distinct degrees is `0`.\n\n .. NOTE::\n\n The internal product is sometimes referred to as "inner product"\n in the literature, but unfortunately this name is shared by a\n different operation, namely the Hall inner product\n (see :meth:`scalar`).\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n OUTPUT:\n\n - the internal product of ``self`` with ``x`` (an element of the\n ring of symmetric functions in the same basis as ``self``)\n\n The methods :meth:`itensor`, :meth:`internal_product`,\n :meth:`kronecker_product`, :meth:`inner_tensor` are all\n synonyms.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1])\n sage: b = s([3])\n sage: a.itensor(b)\n s[2, 1]\n sage: c = s([3,2,1])\n sage: c.itensor(c)\n s[1, 1, 1, 1, 1, 1] + 2*s[2, 1, 1, 1, 1] + 3*s[2, 2, 1, 1] + 2*s[2, 2, 2]\n + 4*s[3, 1, 1, 1] + 5*s[3, 2, 1] + 2*s[3, 3] + 4*s[4, 1, 1]\n + 3*s[4, 2] + 2*s[5, 1] + s[6]\n\n There are few quantitative results pertaining to Kronecker products\n in general, which makes their computation so difficult. Let us test\n a few of them in different bases.\n\n The Kronecker product of any homogeneous symmetric function `f` of\n degree `n` with the `n`-th complete homogeneous symmetric function\n ``h[n]`` (a.k.a. ``s[n]``) is `f`::\n\n sage: h = SymmetricFunctions(ZZ).h()\n sage: all( h([5]).itensor(h(p)) == h(p) for p in Partitions(5) )\n True\n\n The Kronecker product of a Schur function `s_{\\lambda}` with the `n`-th\n elementary symmetric function ``e[n]``, where `n = \\left| \\lambda\n \\right|`, is `s_{\\lambda\'}` (where `\\lambda\'` is the conjugate\n partition of `\\lambda`)::\n\n sage: F = CyclotomicField(12)\n sage: s = SymmetricFunctions(F).s()\n sage: e = SymmetricFunctions(F).e()\n sage: all( e([5]).itensor(s(p)) == s(p.conjugate()) for p in Partitions(5) )\n True\n\n The Kronecker product is commutative::\n\n sage: e = SymmetricFunctions(FiniteField(19)).e()\n sage: m = SymmetricFunctions(FiniteField(19)).m()\n sage: all( all( e(p).itensor(m(q)) == m(q).itensor(e(p)) for q in Partitions(4) )\n ....: for p in Partitions(4) )\n True\n\n sage: F = FractionField(QQ[\'q\',\'t\'])\n sage: mq = SymmetricFunctions(F).macdonald().Q()\n sage: mh = SymmetricFunctions(F).macdonald().H()\n sage: all( all( mq(p).itensor(mh(r)) == mh(r).itensor(mq(p)) # long time\n ....: for r in Partitions(4) )\n ....: for p in Partitions(3) )\n True\n\n Let us check (on examples) Proposition 5.2 of Gelfand, Krob, Lascoux, Leclerc,\n Retakh, Thibon, "Noncommutative symmetric functions", :arxiv:`hep-th/9407124`, for\n `r = 2`::\n\n sage: e = SymmetricFunctions(FiniteField(29)).e()\n sage: s = SymmetricFunctions(FiniteField(29)).s()\n sage: m = SymmetricFunctions(FiniteField(29)).m()\n sage: def tensor_copr(u, v, w): # computes \\mu ((u \\otimes v) * \\Delta(w)) with\n ....: # * meaning Kronecker product and \\mu meaning the\n ....: # usual multiplication.\n ....: result = w.parent().zero()\n ....: for partition_pair, coeff in w.coproduct():\n ....: result += coeff * w.parent()(u).itensor(partition_pair[0]) * w.parent()(v).itensor(partition_pair[1])\n ....: return result\n sage: all( all( all( tensor_copr(e[u], s[v], m[w]) # long time\n ....: == (e[u] * s[v]).itensor(m[w])\n ....: for w in Partitions(5) )\n ....: for v in Partitions(2) )\n ....: for u in Partitions(3) )\n True\n\n Some examples from Briand, Orellana, Rosas, "The stability of the Kronecker\n products of Schur functions." :arxiv:`0907.4652`::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: s[2,2].itensor(s[2,2])\n s[1, 1, 1, 1] + s[2, 2] + s[4]\n sage: s[3,2].itensor(s[3,2])\n s[2, 1, 1, 1] + s[2, 2, 1] + s[3, 1, 1] + s[3, 2] + s[4, 1] + s[5]\n sage: s[4,2].itensor(s[4,2])\n s[2, 2, 2] + s[3, 1, 1, 1] + 2*s[3, 2, 1] + s[4, 1, 1] + 2*s[4, 2] + s[5, 1] + s[6]\n\n An example from p. 220 of Thibon, "Hopf algebras of symmetric functions\n and tensor products of symmetric group representations", International\n Journal of Algebra and Computation, 1991::\n\n sage: s = SymmetricFunctions(QQbar).s()\n sage: s[2,1].itensor(s[2,1])\n s[1, 1, 1] + s[2, 1] + s[3]\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([8,8])\n sage: a.itensor(a) # long time\n s[4, 4, 4, 4] + s[5, 5, 3, 3] + s[5, 5, 5, 1] + s[6, 4, 4, 2]\n + s[6, 6, 2, 2] + s[6, 6, 4] + s[7, 3, 3, 3] + s[7, 5, 3, 1]\n + s[7, 7, 1, 1] + s[8, 4, 2, 2] + s[8, 4, 4] + s[8, 6, 2]\n + s[8, 8] + s[9, 3, 3, 1] + s[9, 5, 1, 1] + s[10, 2, 2, 2]\n + s[10, 4, 2] + s[10, 6] + s[11, 3, 1, 1] + s[12, 2, 2]\n + s[12, 4] + s[13, 1, 1, 1] + s[14, 2] + s[16]\n sage: s[8].itensor(s[7])\n 0\n sage: s(0).itensor(s(0))\n 0\n sage: s(1).itensor(s(0))\n 0\n sage: s(0).itensor(s(1))\n 0\n sage: s(1).itensor(s(1))\n s[]\n\n Same over the ring of integers::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: a = s([8,8])\n sage: a.itensor(a) # long time\n s[4, 4, 4, 4] + s[5, 5, 3, 3] + s[5, 5, 5, 1] + s[6, 4, 4, 2]\n + s[6, 6, 2, 2] + s[6, 6, 4] + s[7, 3, 3, 3] + s[7, 5, 3, 1]\n + s[7, 7, 1, 1] + s[8, 4, 2, 2] + s[8, 4, 4] + s[8, 6, 2]\n + s[8, 8] + s[9, 3, 3, 1] + s[9, 5, 1, 1] + s[10, 2, 2, 2]\n + s[10, 4, 2] + s[10, 6] + s[11, 3, 1, 1] + s[12, 2, 2]\n + s[12, 4] + s[13, 1, 1, 1] + s[14, 2] + s[16]\n sage: s[8].itensor(s[7])\n 0\n sage: s(0).itensor(s(0))\n 0\n sage: s(1).itensor(s(0))\n 0\n sage: s(0).itensor(s(1))\n 0\n sage: s(1).itensor(s(1))\n s[]\n\n Theorem 2.1 in Bessenrodt, van Willigenburg, :arxiv:`1105.3170v2`::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: all( all( max( r[0] for r in s(p).itensor(s(q)).monomial_coefficients().keys() )\n ....: == sum( min(p[i], q.get_part(i)) for i in range(len(p)) )\n ....: for p in Partitions(4) )\n ....: for q in Partitions(4) )\n True\n sage: all( all( max( len(r) for r in s(p).itensor(s(q)).monomial_coefficients().keys() )\n ....: == sum( min(p[i], q.conjugate().get_part(i)) for i in range(len(p)) )\n ....: for p in Partitions(4) )\n ....: for q in Partitions(4) )\n True\n\n Check that the basis and ground ring of ``self`` are preserved::\n\n sage: F = CyclotomicField(12)\n sage: s = SymmetricFunctions(F).s()\n sage: e = SymmetricFunctions(F).e()\n sage: e[3].itensor(s[3])\n e[3]\n sage: s[3].itensor(e[3])\n s[1, 1, 1]\n sage: parent(e[3].itensor(s[3]))\n Symmetric Functions over Cyclotomic Field of order 12 and degree 4 in the elementary basis\n sage: parent(s[3].itensor(e[3]))\n Symmetric Functions over Cyclotomic Field of order 12 and degree 4 in the Schur basis\n\n .. NOTE::\n\n The currently existing implementation of this function is\n technically unsatisfactory. It distinguishes the case when the\n base ring is a `\\QQ`-algebra (in which case the Kronecker product\n can be easily computed using the power sum basis) from the case\n where it isn\'t. In the latter, it does a computation using\n universal coefficients, again distinguishing the case when it is\n able to compute the "corresponding" basis of the symmetric function\n algebra over `\\QQ` (using the ``corresponding_basis_over`` hack)\n from the case when it isn\'t (in which case it transforms everything\n into the Schur basis, which is slow).\n '
parent = self.parent()
if parent.has_coerce_map_from(QQ):
p = parent.realization_of().power()
f = (lambda part1, part2: (zee(part1) * p(part1)))
return parent(p._apply_multi_module_morphism(p(self), p(x), f, orthogonal=True))
else:
comp_parent = parent
comp_self = self
corresponding_parent_over_QQ = parent.corresponding_basis_over(QQ)
if (corresponding_parent_over_QQ is None):
comp_parent = parent.realization_of().schur()
comp_self = comp_parent(self)
from sage.combinat.sf.sf import SymmetricFunctions
corresponding_parent_over_QQ = SymmetricFunctions(QQ).schur()
comp_x = comp_parent(x)
result = comp_parent.zero()
for (lam, a) in comp_self:
for (mu, b) in comp_x:
lam_star_mu = corresponding_parent_over_QQ(lam).itensor(corresponding_parent_over_QQ(mu))
for (nu, c) in lam_star_mu:
result += (((a * b) * comp_parent.base_ring()(c)) * comp_parent(nu))
return parent(result)
internal_product = itensor
kronecker_product = itensor
inner_tensor = itensor
def reduced_kronecker_product(self, x):
'\n Return the reduced Kronecker product of ``self`` and ``x`` in the\n basis of ``self``.\n\n The reduced Kronecker product is a bilinear map mapping two\n symmetric functions to another, not necessarily preserving degree.\n It can be defined as follows: Let `*` denote the Kronecker product\n (:meth:`itensor`) on the space of symmetric functions. For any\n partitions `\\alpha`, `\\beta`, `\\gamma`, let\n `g^{\\gamma}_{\\alpha, \\beta}` denote the coefficient of the Schur\n function `s_{\\gamma}` in the Kronecker product\n `s_{\\alpha} * s_{\\beta}` (this is called a Kronecker coefficient).\n For every partition\n `\\lambda = (\\lambda_1, \\lambda_2, \\lambda_3, \\ldots)`\n and every integer `n > \\left| \\lambda \\right| + \\lambda_1`, let\n `\\lambda[n]` denote the `n`-completion of `\\lambda` (this is the\n partition\n `(n - \\left| \\lambda \\right|, \\lambda_1, \\lambda_2, \\lambda_3, \\ldots)`;\n see :meth:`~sage.combinat.partition.Partition.t_completion`).\n Then, Theorem 1.2 of [BOR2009]_ shows that for any partitions\n `\\alpha` and `\\beta` and every integer\n `n \\geq \\left|\\alpha\\right| + \\left|\\beta\\right| + \\alpha_1 + \\beta_1`,\n we can write the Kronecker product `s_{\\alpha[n]} * s_{\\beta[n]}`\n in the form\n\n .. MATH::\n\n s_{\\alpha[n]} * s_{\\beta[n]} = \\sum_{\\gamma} g^{\\gamma[n]}_{\\alpha[n], \\beta[n]} s_{\\gamma[n]}\n\n with `\\gamma` ranging over all partitions. The\n coefficients `g^{\\gamma[n]}_{\\alpha[n], \\beta[n]}`\n are independent on `n`. These coefficients\n `g^{\\gamma[n]}_{\\alpha[n], \\beta[n]}` are denoted by\n `\\overline{g}^{\\gamma}_{\\alpha, \\beta}`, and the symmetric\n function\n\n .. MATH::\n\n \\sum_{\\gamma} \\overline{g}^{\\gamma}_{\\alpha, \\beta} s_{\\gamma}\n\n is said to be the *reduced Kronecker product* of `s_{\\alpha}` and\n `s_{\\beta}`. By bilinearity, this extends to a definition of a\n reduced Kronecker product of any two symmetric functions.\n\n The definition of the reduced Kronecker product goes back to\n Murnaghan, and has recently been studied in [BOR2009]_, [BdVO2012]_\n and other places (our notation\n `\\overline{g}^{\\gamma}_{\\alpha, \\beta}` appears in these two\n sources).\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n OUTPUT:\n\n - the reduced Kronecker product of ``self`` with ``x`` (an element\n of the ring of symmetric functions in the same basis as\n ``self``)\n\n EXAMPLES:\n\n The example from page 2 of [BOR2009]_::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: s[2].reduced_kronecker_product(s[2])\n s[] + s[1] + s[1, 1] + s[1, 1, 1] + 2*s[2] + 2*s[2, 1] + s[2, 2] + s[3] + s[3, 1] + s[4]\n\n Taking the reduced Kronecker product with `1 = s_{\\emptyset}`\n is the identity map on the ring of symmetric functions::\n\n sage: all( s[Partition([])].reduced_kronecker_product(s[lam])\n ....: == s[lam] for i in range(4)\n ....: for lam in Partitions(i) )\n True\n\n While reduced Kronecker products are hard to compute in general,\n there is a rule for taking reduced Kronecker products with\n `s_1`. Namely, for every partition `\\lambda`, the reduced\n Kronecker product of `s_{\\lambda}` with `s_1` is\n `\\sum_{\\mu} a_{\\mu} s_{\\mu}`, where the sum runs over all\n partitions `\\mu`, and the coefficient `a_{\\mu}` is defined as the\n number of ways to obtain `\\mu` from `\\lambda` by one of the\n following three operations:\n\n - Add an addable cell\n (:meth:`~sage.combinat.partition.Partition.addable_cells`) to\n `\\lambda`.\n - Remove a removable cell\n (:meth:`~sage.combinat.partition.Partition.removable_cells`)\n from `\\lambda`.\n - First remove a removable cell from `\\lambda`, then add an\n addable cell to the resulting Young diagram.\n\n This is, in fact, Proposition 5.15 of [CO2010]_ in an elementary\n wording. We check this for partitions of size `\\leq 4`::\n\n sage: def mults1(lam):\n ....: # Reduced Kronecker multiplication by s[1], according\n ....: # to [CO2010]_.\n ....: res = s.zero()\n ....: for mu in lam.up_list():\n ....: res += s(mu)\n ....: for mu in lam.down_list():\n ....: res += s(mu)\n ....: for nu in mu.up_list():\n ....: res += s(nu)\n ....: return res\n sage: all( mults1(lam) == s[1].reduced_kronecker_product(s[lam])\n ....: for i in range(5) for lam in Partitions(i) )\n True\n\n Here is the example on page 3 of Christian Gutschwager\'s\n :arxiv:`0912.4411v3`::\n\n sage: s[1,1].reduced_kronecker_product(s[2])\n s[1] + 2*s[1, 1] + s[1, 1, 1] + s[2] + 2*s[2, 1] + s[2, 1, 1] + s[3] + s[3, 1]\n\n Example 39 from F. D. Murnaghan, "The analysis of the Kronecker\n product of irreducible representations of the symmetric group",\n American Journal of Mathematics, Vol. 60, No. 3, Jul. 1938::\n\n sage: s[3].reduced_kronecker_product(s[2,1])\n s[1] + 2*s[1, 1] + 2*s[1, 1, 1] + s[1, 1, 1, 1] + 2*s[2] + 5*s[2, 1] + 4*s[2, 1, 1]\n + s[2, 1, 1, 1] + 3*s[2, 2] + 2*s[2, 2, 1] + 2*s[3] + 5*s[3, 1] + 3*s[3, 1, 1]\n + 3*s[3, 2] + s[3, 2, 1] + 2*s[4] + 3*s[4, 1] + s[4, 1, 1] + s[4, 2] + s[5]\n + s[5, 1]\n\n TESTS::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: (2*h([])).reduced_kronecker_product(3*h([]))\n 6*h[]\n\n Different bases and base rings::\n\n sage: h = SymmetricFunctions(ZZ).h()\n sage: e = SymmetricFunctions(ZZ).e()\n sage: h(e[2].reduced_kronecker_product(h[2]))\n h[1] + 2*h[1, 1] + h[1, 1, 1] - h[2] + h[2, 1, 1] - h[2, 2]\n\n sage: F = CyclotomicField(12)\n sage: s = SymmetricFunctions(F).s()\n sage: e = SymmetricFunctions(F).e()\n sage: v = e[2].reduced_kronecker_product(e[2]); v\n e[] + e[1] + 2*e[1, 1] + e[1, 1, 1] + (-1)*e[2] + e[2, 2]\n sage: parent(v)\n Symmetric Functions over Cyclotomic Field of order 12 and degree 4 in the elementary basis\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: v = s[1].reduced_kronecker_product(s[1]); parent(v)\n Symmetric Functions over Integer Ring in the Schur basis\n\n .. TODO::\n\n This implementation of the reduced Kronecker product is\n painfully slow.\n '
parent = self.parent()
comp_parent = parent.realization_of().schur()
comp_self = comp_parent(self)
comp_x = comp_parent(x)
schur_Q = comp_parent.corresponding_basis_over(QQ)
result = comp_parent.zero()
for (lam, a) in comp_self:
lam_list = lam._list
if (not lam_list):
result += (a * comp_x)
continue
sum_lam = sum(lam_list)
for (mu, b) in comp_x:
mu_list = mu._list
if (not mu_list):
result += ((a * b) * comp_parent(lam))
continue
sum_mu = sum(mu_list)
stab = (((lam_list[0] + mu_list[0]) + sum_lam) + sum_mu)
s_lam_stabilized = schur_Q(_Partitions(([(stab - sum_lam)] + lam_list)))
s_mu_stabilized = schur_Q(_Partitions(([(stab - sum_mu)] + mu_list)))
lam_star_mu = s_lam_stabilized.itensor(s_mu_stabilized)
for (nu, c) in lam_star_mu:
nu_unstabilized = _Partitions(nu[1:])
result += (((a * b) * comp_parent.base_ring()(c)) * comp_parent(nu_unstabilized))
return parent(result)
def left_padded_kronecker_product(self, x):
'\n Return the left-padded Kronecker product of ``self`` and ``x`` in\n the basis of ``self``.\n\n The left-padded Kronecker product is a bilinear map mapping two\n symmetric functions to another, not necessarily preserving degree.\n It can be defined as follows: Let `*` denote the Kronecker product\n (:meth:`itensor`) on the space of symmetric functions. For any\n partitions `\\alpha`, `\\beta`, `\\gamma`, let\n `g^{\\gamma}_{\\alpha, \\beta}` denote the coefficient of the\n complete homogeneous symmetric function `h_{\\gamma}` in the\n Kronecker product `h_{\\alpha} * h_{\\beta}`.\n For every partition\n `\\lambda = (\\lambda_1, \\lambda_2, \\lambda_3, \\ldots)`\n and every integer `n > \\left| \\lambda \\right| + \\lambda_1`, let\n `\\lambda[n]` denote the `n`-completion of `\\lambda` (this is the\n partition\n `(n - \\left| \\lambda \\right|, \\lambda_1, \\lambda_2, \\lambda_3, \\ldots)`;\n see :meth:`~sage.combinat.partition.Partition.t_completion`).\n Then, for any partitions `\\alpha` and `\\beta` and every integer\n `n \\geq \\left|\\alpha\\right| + \\left|\\beta\\right| + \\alpha_1 + \\beta_1`,\n we can write the Kronecker product `h_{\\alpha[n]} * h_{\\beta[n]}`\n in the form\n\n .. MATH::\n\n h_{\\alpha[n]} * h_{\\beta[n]} = \\sum_{\\gamma}\n g^{\\gamma[n]}_{\\alpha[n], \\beta[n]} h_{\\gamma[n]}\n\n with `\\gamma` ranging over all partitions. The\n coefficients `g^{\\gamma[n]}_{\\alpha[n], \\beta[n]}`\n are independent on `n`. These coefficients\n `g^{\\gamma[n]}_{\\alpha[n], \\beta[n]}` are denoted by\n `\\overline{g}^{\\gamma}_{\\alpha, \\beta}`, and the symmetric\n function\n\n .. MATH::\n\n \\sum_{\\gamma} \\overline{g}^{\\gamma}_{\\alpha, \\beta} h_{\\gamma}\n\n is said to be the *left-padded Kronecker product* of `h_{\\alpha}`\n and `h_{\\beta}`. By bilinearity, this extends to a definition of a\n left-padded Kronecker product of any two symmetric functions.\n\n This notion of left-padded Kronecker product can be lifted to the\n non-commutative symmetric functions\n (:meth:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Bases.ElementMethods.left_padded_kronecker_product`).\n\n .. WARNING::\n\n Do not mistake this product for the reduced Kronecker product\n (:meth:`reduced_kronecker_product`), which uses the Schur\n functions instead of the complete homogeneous functions in\n its definition.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n OUTPUT:\n\n - the left-padded Kronecker product of ``self`` with ``x`` (an\n element of the ring of symmetric functions in the same basis\n as ``self``)\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: h = Sym.h()\n sage: h[2,1].left_padded_kronecker_product(h[3])\n h[1, 1, 1, 1] + h[2, 1] + h[2, 1, 1] + h[2, 1, 1, 1] + h[2, 2, 1] + h[3, 2, 1]\n sage: h[2,1].left_padded_kronecker_product(h[1])\n h[1, 1, 1] + h[2, 1] + h[2, 1, 1]\n sage: h[1].left_padded_kronecker_product(h[2,1])\n h[1, 1, 1] + h[2, 1] + h[2, 1, 1]\n sage: h[1,1].left_padded_kronecker_product(h[2])\n h[1, 1] + 2*h[1, 1, 1] + h[2, 1, 1]\n sage: h[1].left_padded_kronecker_product(h[2,1,1])\n h[1, 1, 1, 1] + 2*h[2, 1, 1] + h[2, 1, 1, 1]\n sage: h[2].left_padded_kronecker_product(h[3])\n h[2, 1] + h[2, 1, 1] + h[3, 2]\n\n Taking the left-padded Kronecker product with `1 = h_{\\emptyset}`\n is the identity map on the ring of symmetric functions::\n\n sage: all( h[Partition([])].left_padded_kronecker_product(h[lam])\n ....: == h[lam] for i in range(4)\n ....: for lam in Partitions(i) )\n True\n\n Here is a rule for the left-padded Kronecker product of `h_1`\n (this is the same as `h_{(1)}`) with any complete homogeneous\n function: Let `\\lambda` be a partition. Then, the left-padded\n Kronecker product of `h_1` and `h_{\\lambda}` is\n `\\sum_{\\mu} a_{\\mu} h_{\\mu}`, where the sum runs over all\n partitions `\\mu`, and the coefficient `a_{\\mu}` is defined as the\n number of ways to obtain `\\mu` from `\\lambda` by one of the\n following two operations:\n\n - Insert a `1` into `\\lambda`.\n - Subtract `1` from one of the entries of `\\lambda` (and remove\n the entry if it thus becomes `0`), and insert a `1` into\n `\\lambda`.\n\n We check this for partitions of size `\\leq 4`::\n\n sage: def mults1(I):\n ....: # Left-padded Kronecker multiplication by h[1].\n ....: res = h[I[:] + [1]]\n ....: for k in range(len(I)):\n ....: I2 = I[:]\n ....: if I2[k] == 1:\n ....: I2 = I2[:k] + I2[k+1:]\n ....: else:\n ....: I2[k] -= 1\n ....: res += h[sorted(I2 + [1], reverse=True)]\n ....: return res\n sage: all( mults1(I) == h[1].left_padded_kronecker_product(h[I])\n ....: == h[I].left_padded_kronecker_product(h[1])\n ....: for i in range(5) for I in Partitions(i) )\n True\n\n The left-padded Kronecker product is commutative::\n\n sage: all( h[lam].left_padded_kronecker_product(h[mu])\n ....: == h[mu].left_padded_kronecker_product(h[lam])\n ....: for lam in Partitions(3) for mu in Partitions(3) )\n True\n\n TESTS::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: (2*h([])).left_padded_kronecker_product(3*h([]))\n 6*h[]\n\n Different bases and base rings::\n\n sage: h = SymmetricFunctions(ZZ).h()\n sage: e = SymmetricFunctions(ZZ).e()\n sage: h(e[2].left_padded_kronecker_product(h[2]))\n h[1, 1] + h[1, 1, 1] - h[2] + h[2, 1, 1] - h[2, 2]\n\n sage: F = CyclotomicField(12)\n sage: s = SymmetricFunctions(F).s()\n sage: e = SymmetricFunctions(F).e()\n sage: v = e[2].left_padded_kronecker_product(e[2]); v\n e[1, 1] + e[1, 1, 1] + (-1)*e[2] + e[2, 2]\n sage: parent(v)\n Symmetric Functions over Cyclotomic Field of order 12 and degree 4 in the elementary basis\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: v = s[1].left_padded_kronecker_product(s[1]); parent(v)\n Symmetric Functions over Integer Ring in the Schur basis\n '
from sage.combinat.composition import Compositions
_Compositions = Compositions()
parent = self.parent()
h = parent.realization_of().h()
h_self = h(self)
h_x = h(x)
R = self.base_ring()
from sage.combinat.ncsf_qsym.ncsf import NonCommutativeSymmetricFunctions
S = NonCommutativeSymmetricFunctions(R).S()
result = h.zero()
for (lam, a) in h_self:
if (not lam._list):
result += (a * h_x)
continue
c_lam = _Compositions(lam)
for (mu, b) in h_x:
if (not mu._list):
result += ((a * b) * h(lam))
continue
c_mu = _Compositions(mu)
result += ((a * b) * S[c_lam].left_padded_kronecker_product(S[c_mu]).to_symmetric_function())
return parent(result)
def internal_coproduct(self):
"\n Return the inner coproduct of ``self`` in the basis of ``self``.\n\n The inner coproduct (also known as the Kronecker coproduct, as the\n internal coproduct, or as the second comultiplication on the ring of\n symmetric functions) is a ring homomorphism `\\Delta^\\times` from the\n ring of symmetric functions to the tensor product (over the base\n ring) of this ring with itself. It is uniquely characterized by the\n formula\n\n .. MATH::\n\n \\Delta^{\\times}(h_n) = \\sum_{\\lambda \\vdash n} s_{\\lambda}\n \\otimes s_{\\lambda} = \\sum_{\\lambda \\vdash n} h_{\\lambda} \\otimes\n m_{\\lambda} = \\sum_{\\lambda \\vdash n} m_{\\lambda} \\otimes\n h_{\\lambda},\n\n where `\\lambda \\vdash n` means `\\lambda` is a partition of `n`, and\n `n` is any nonnegative integer. It also satisfies\n\n .. MATH::\n\n \\Delta^\\times (p_n) = p_n \\otimes p_n\n\n for any positive integer `n`. If the base ring is a `\\QQ`-algebra, it\n also satisfies\n\n .. MATH::\n\n \\Delta^{\\times}(h_n) = \\sum_{\\lambda \\vdash n} z_{\\lambda}^{-1}\n p_{\\lambda} \\otimes p_{\\lambda},\n\n where\n\n .. MATH::\n\n z_{\\lambda} = \\prod_{i=1}^\\infty i^{m_i(\\lambda)} m_i(\\lambda)!\n\n with `m_i(\\lambda)` meaning the number of appearances of `i`\n in `\\lambda` (see :meth:`~sage.combinat.sf.sfa.zee`).\n\n The method :meth:`kronecker_coproduct` is a synonym of\n :meth:`internal_coproduct`.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(ZZ).s()\n sage: a = s([2,1])\n sage: a.internal_coproduct()\n s[1, 1, 1] # s[2, 1] + s[2, 1] # s[1, 1, 1] + s[2, 1] # s[2, 1] + s[2, 1] # s[3] + s[3] # s[2, 1]\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: b = e([2])\n sage: b.internal_coproduct()\n e[1, 1] # e[2] + e[2] # e[1, 1] - 2*e[2] # e[2]\n\n The internal coproduct is adjoint to the internal product with respect\n to the Hall inner product: Any three symmetric functions `f`, `g` and\n `h` satisfy `\\langle f * g, h \\rangle = \\sum_i \\langle f, h^{\\prime}_i\n \\rangle \\langle g, h^{\\prime\\prime}_i \\rangle`, where we write\n `\\Delta^{\\times}(h)` as `\\sum_i h^{\\prime}_i \\otimes\n h^{\\prime\\prime}_i`. Let us check this in degree `4`::\n\n sage: e = SymmetricFunctions(FiniteField(29)).e()\n sage: s = SymmetricFunctions(FiniteField(29)).s()\n sage: m = SymmetricFunctions(FiniteField(29)).m()\n sage: def tensor_incopr(f, g, h): # computes \\sum_i \\left< f, h'_i \\right> \\left< g, h''_i \\right>\n ....: result = h.base_ring().zero()\n ....: for partition_pair, coeff in h.internal_coproduct():\n ....: result += coeff * h.parent()(f).scalar(partition_pair[0]) * h.parent()(g).scalar(partition_pair[1])\n ....: return result\n sage: all( all( all( tensor_incopr(e[u], s[v], m[w]) == (e[u].itensor(s[v])).scalar(m[w]) # long time (10s on sage.math, 2013)\n ....: for w in Partitions(5) )\n ....: for v in Partitions(2) )\n ....: for u in Partitions(3) )\n True\n\n Let us check the formulas for `\\Delta^{\\times}(h_n)` and\n `\\Delta^{\\times}(p_n)` given in the description of this method::\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: p = SymmetricFunctions(QQ).p()\n sage: h = SymmetricFunctions(QQ).h()\n sage: s = SymmetricFunctions(QQ).s()\n sage: all( s(h([n])).internal_coproduct() == sum([tensor([s(lam), s(lam)]) for lam in Partitions(n)])\n ....: for n in range(6) )\n True\n sage: all( h([n]).internal_coproduct() == sum([tensor([h(lam), h(m(lam))]) for lam in Partitions(n)])\n ....: for n in range(6) )\n True\n sage: all( factorial(n) * h([n]).internal_coproduct()\n ....: == sum([lam.conjugacy_class_size() * tensor([h(p(lam)), h(p(lam))])\n ....: for lam in Partitions(n)])\n ....: for n in range(6) )\n True\n\n TESTS::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([]).internal_coproduct()\n s[] # s[]\n "
parent = self.parent()
h = parent.realization_of().homogeneous()
s = parent.realization_of().schur()
from sage.categories.tensor import tensor
result = tensor([parent.zero(), parent.zero()])
result_parent = result.parent()
from sage.misc.cachefunc import cached_function
@cached_function
def hnimage(n):
return result_parent.sum((tensor([parent(s(lam)), parent(s(lam))]) for lam in Partitions(n)))
for (lam, a) in h(self):
result += (a * prod((hnimage(i) for i in lam)))
return result
kronecker_coproduct = internal_coproduct
def arithmetic_product(self, x):
'\n Return the arithmetic product of ``self`` and ``x`` in the\n basis of ``self``.\n\n The arithmetic product is a binary operation `\\boxdot` on the\n ring of symmetric functions which is bilinear in its two\n arguments and satisfies\n\n .. MATH::\n\n p_{\\lambda} \\boxdot p_{\\mu} = \\prod\\limits_{i \\geq 1, j \\geq 1}\n p_{\\mathrm{lcm}(\\lambda_i, \\mu_j)}^{\\mathrm{gcd}(\\lambda_i, \\mu_j)}\n\n for any two partitions `\\lambda = (\\lambda_1, \\lambda_2, \\lambda_3,\n \\dots )` and `\\mu = (\\mu_1, \\mu_2, \\mu_3, \\dots )` (where `p_{\\nu}`\n denotes the power-sum symmetric function indexed by the partition\n `\\nu`, and `p_i` denotes the `i`-th power-sum symmetric function).\n This is enough to define the arithmetic product if the base ring\n is torsion-free as a `\\ZZ`-module; for all other cases the\n arithmetic product is uniquely determined by requiring it to be\n functorial in the base ring. See\n http://mathoverflow.net/questions/138148/ for a discussion of\n this arithmetic product.\n\n If `f` and `g` are two symmetric functions which are homogeneous\n of degrees `a` and `b`, respectively, then `f \\boxdot g` is\n homogeneous of degree `ab`.\n\n The arithmetic product is commutative and associative and has\n unity `e_1 = p_1 = h_1`.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n OUTPUT:\n\n Arithmetic product of ``self`` with ``x``; this is a symmetric\n function over the same base ring as ``self``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([2]).arithmetic_product(s([2]))\n s[1, 1, 1, 1] + 2*s[2, 2] + s[4]\n sage: s([2]).arithmetic_product(s([1,1]))\n s[2, 1, 1] + s[3, 1]\n\n The symmetric function ``e[1]`` is the unity for the arithmetic\n product::\n\n sage: e = SymmetricFunctions(ZZ).e()\n sage: all( e([1]).arithmetic_product(e(q)) == e(q) for q in Partitions(4) )\n True\n\n The arithmetic product is commutative::\n\n sage: e = SymmetricFunctions(FiniteField(19)).e()\n sage: m = SymmetricFunctions(FiniteField(19)).m()\n sage: all( all( e(p).arithmetic_product(m(q)) == m(q).arithmetic_product(e(p)) # long time (26s on sage.math, 2013)\n ....: for q in Partitions(4) )\n ....: for p in Partitions(4) )\n True\n\n .. NOTE::\n\n The currently existing implementation of this function is\n technically unsatisfactory. It distinguishes the case when the\n base ring is a `\\QQ`-algebra (in which case the arithmetic product\n can be easily computed using the power sum basis) from the case\n where it isn\'t. In the latter, it does a computation using\n universal coefficients, again distinguishing the case when it is\n able to compute the "corresponding" basis of the symmetric function\n algebra over `\\QQ` (using the ``corresponding_basis_over`` hack)\n from the case when it isn\'t (in which case it transforms everything\n into the Schur basis, which is slow).\n '
parent = self.parent()
if parent.has_coerce_map_from(QQ):
from sage.combinat.partition import Partition
from sage.arith.misc import gcd
from sage.arith.functions import lcm
from itertools import product, repeat, chain
p = parent.realization_of().power()
def f(lam, mu):
term_iterable = chain.from_iterable((repeat(lcm(pair), gcd(pair)) for pair in product(lam, mu)))
return p(Partition(sorted(term_iterable, reverse=True)))
return parent(p._apply_multi_module_morphism(p(self), p(x), f))
comp_parent = parent
comp_self = self
corresponding_parent_over_QQ = parent.corresponding_basis_over(QQ)
if (corresponding_parent_over_QQ is None):
comp_parent = parent.realization_of().schur()
comp_self = comp_parent(self)
from sage.combinat.sf.sf import SymmetricFunctions
corresponding_parent_over_QQ = SymmetricFunctions(QQ).schur()
comp_x = comp_parent(x)
result = comp_parent.zero()
for (lam, a) in comp_self:
for (mu, b) in comp_x:
lam_star_mu = corresponding_parent_over_QQ(lam).arithmetic_product(corresponding_parent_over_QQ(mu))
for (nu, c) in lam_star_mu:
result += (((a * b) * comp_parent.base_ring()(c)) * comp_parent(nu))
return parent(result)
def nabla(self, q=None, t=None, power=1):
"\n Return the value of the nabla operator applied to ``self``.\n\n The eigenvectors of the nabla operator are the Macdonald polynomials in\n the Ht basis.\n\n If the parameter ``power`` is an integer then it calculates\n nabla to that integer. The default value of ``power`` is 1.\n\n INPUT:\n\n - ``q``, ``t`` -- optional parameters (default: ``None``, in which\n case ``q`` and ``t`` are used)\n - ``power`` -- (default: ``1``) an integer indicating how many times to\n apply the operator `\\nabla`. Negative values of ``power``\n indicate powers of `\\nabla^{-1}`.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['q','t']))\n sage: p = Sym.power()\n sage: p([1,1]).nabla()\n (-1/2*q*t+1/2*q+1/2*t+1/2)*p[1, 1] + (1/2*q*t-1/2*q-1/2*t+1/2)*p[2]\n sage: p([2,1]).nabla(q=1)\n (-t-1)*p[1, 1, 1] + t*p[2, 1]\n sage: p([2]).nabla(q=1)*p([1]).nabla(q=1)\n (-t-1)*p[1, 1, 1] + t*p[2, 1]\n sage: s = Sym.schur()\n sage: s([2,1]).nabla()\n (-q^3*t-q^2*t^2-q*t^3)*s[1, 1, 1] + (-q^2*t-q*t^2)*s[2, 1]\n sage: s([1,1,1]).nabla()\n (q^3+q^2*t+q*t^2+t^3+q*t)*s[1, 1, 1] + (q^2+q*t+t^2+q+t)*s[2, 1] + s[3]\n sage: s([1,1,1]).nabla(t=1)\n (q^3+q^2+2*q+1)*s[1, 1, 1] + (q^2+2*q+2)*s[2, 1] + s[3]\n sage: s(0).nabla()\n 0\n sage: s(1).nabla()\n s[]\n sage: s([2,1]).nabla(power=-1)\n ((-q-t)/(q^2*t^2))*s[2, 1] + ((q^2+q*t+t^2)/(-q^3*t^3))*s[3]\n sage: (s([2])+s([3])).nabla()\n (-q*t)*s[1, 1] + (q^3*t^2+q^2*t^3)*s[1, 1, 1] + q^2*t^2*s[2, 1]\n "
parent = self.parent()
BR = parent.base_ring()
if (q is None):
if hasattr(parent, 'q'):
q = parent.q
else:
q = BR(QQ['q'].gen())
if (t is None):
if hasattr(parent, 't'):
t = parent.t
else:
t = BR(QQ['t'].gen())
Ht = parent.realization_of().macdonald(q=q, t=t).Ht()
return parent(Ht(self).nabla(power=power))
def scalar(self, x, zee=None):
'\n Return the standard scalar product between ``self`` and ``x``.\n\n This is also known as the "Hall inner product" or the\n "Hall scalar product".\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n\n - ``zee`` -- an optional function on partitions giving\n the value for the scalar product between `p_{\\mu}` and `p_{\\mu}`\n (default is to use the standard :meth:`~sage.combinat.sf.sfa.zee` function)\n\n This is the default implementation that converts both ``self`` and\n ``x`` into either Schur functions (if ``zee`` is not specified) or\n power-sum functions (if ``zee`` is specified) and performs the scalar\n product in that basis.\n\n EXAMPLES::\n\n sage: e = SymmetricFunctions(QQ).e()\n sage: h = SymmetricFunctions(QQ).h()\n sage: m = SymmetricFunctions(QQ).m()\n sage: p4 = Partitions(4)\n sage: matrix([ [e(a).scalar(h(b)) for a in p4] for b in p4])\n [ 0 0 0 0 1]\n [ 0 0 0 1 4]\n [ 0 0 1 2 6]\n [ 0 1 2 5 12]\n [ 1 4 6 12 24]\n sage: matrix([ [h(a).scalar(e(b)) for a in p4] for b in p4])\n [ 0 0 0 0 1]\n [ 0 0 0 1 4]\n [ 0 0 1 2 6]\n [ 0 1 2 5 12]\n [ 1 4 6 12 24]\n sage: matrix([ [m(a).scalar(e(b)) for a in p4] for b in p4])\n [-1 2 1 -3 1]\n [ 0 1 0 -2 1]\n [ 0 0 1 -2 1]\n [ 0 0 0 -1 1]\n [ 0 0 0 0 1]\n sage: matrix([ [m(a).scalar(h(b)) for a in p4] for b in p4])\n [1 0 0 0 0]\n [0 1 0 0 0]\n [0 0 1 0 0]\n [0 0 0 1 0]\n [0 0 0 0 1]\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: m(p[3,2]).scalar(p[3,2], zee=lambda mu: 2**mu.length())\n 4\n sage: m(p[3,2]).scalar(p[2,2,1], lambda mu: 1)\n 0\n sage: m[3,2].scalar(h[3,2], zee=lambda mu: 2**mu.length())\n 2/3\n\n TESTS::\n\n sage: m(1).scalar(h(1))\n 1\n sage: m(0).scalar(h(1))\n 0\n sage: m(1).scalar(h(0))\n 0\n sage: m(0).scalar(h(0))\n 0\n\n Over the integers, too (as long as ``zee`` is not set)::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: m = Sym.m()\n sage: m([2]).scalar(m([2]))\n 2\n '
if (zee is None):
s = self.parent().realization_of().schur()
s_self = s(self)
s_x = s(x)
return s_self.scalar(s_x)
else:
p = self.parent().realization_of().power()
p_self = p(self)
p_x = p(x)
return sum((((zee(mu) * p_x.coefficient(mu)) * p_self.coefficient(mu)) for mu in p_self.support()))
def scalar_qt(self, x, q=None, t=None):
"\n Return the `q,t`-deformed standard Hall-Littlewood scalar product of\n ``self`` and ``x``.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the same\n base ring as ``self``\n\n - ``q``, ``t`` -- parameters (default: ``None`` in which case ``q``\n and ``t`` are used)\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1])\n sage: sp = a.scalar_qt(a); factor(sp)\n (t - 1)^-3 * (q - 1) * (t^2 + t + 1)^-1 * (q^2*t^2 - q*t^2 + q^2 - 2*q*t + t^2 - q + 1)\n sage: sp.parent()\n Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field\n sage: a.scalar_qt(a,q=0)\n (-t^2 - 1)/(t^5 - 2*t^4 + t^3 - t^2 + 2*t - 1)\n sage: a.scalar_qt(a,t=0)\n -q^3 + 2*q^2 - 2*q + 1\n sage: a.scalar_qt(a,5,7) # q=5 and t=7\n 490/1539\n sage: (x,y) = var('x,y') # needs sage.symbolic\n sage: a.scalar_qt(a, q=x, t=y) # needs sage.symbolic\n 1/3*(x^3 - 1)/(y^3 - 1) + 2/3*(x - 1)^3/(y - 1)^3\n sage: Rn = QQ['q','t','y','z'].fraction_field()\n sage: (q,t,y,z) = Rn.gens()\n sage: Mac = SymmetricFunctions(Rn).macdonald(q=y,t=z)\n sage: a = Mac._sym.schur()([2,1])\n sage: factor(Mac.P()(a).scalar_qt(Mac.Q()(a),q,t))\n (t - 1)^-3 * (q - 1) * (t^2 + t + 1)^-1 * (q^2*t^2 - q*t^2 + q^2 - 2*q*t + t^2 - q + 1)\n sage: factor(Mac.P()(a).scalar_qt(Mac.Q()(a)))\n (z - 1)^-3 * (y - 1) * (z^2 + z + 1)^-1 * (y^2*z^2 - y*z^2 + y^2 - 2*y*z + z^2 - y + 1)\n "
parent = self.parent()
p = parent.realization_of().power()
if (t is None):
if hasattr(parent, 't'):
t = self.parent().t
elif (q is None):
t = QQ[('q', 't')].gens()[1]
else:
t = QQ['t'].gen()
if (q is None):
if hasattr(parent, 'q'):
q = parent.q
else:
q = QQ[('q', 't')].gens()[0]
f = (lambda part1, part2: part1.centralizer_size(t=t, q=q))
return p._apply_multi_module_morphism(p(self), p(x), f, orthogonal=True)
def scalar_t(self, x, t=None):
'\n Return the `t`-deformed standard Hall-Littlewood scalar product of\n ``self`` and ``x``.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the same\n base ring as ``self``\n\n - ``t`` -- parameter (default: ``None``, in which case ``t`` is used)\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1])\n sage: sp = a.scalar_t(a); sp\n (-t^2 - 1)/(t^5 - 2*t^4 + t^3 - t^2 + 2*t - 1)\n sage: sp.parent()\n Fraction Field of Univariate Polynomial Ring in t over Rational Field\n '
return self.scalar_qt(x, q=self.base_ring().zero(), t=t)
scalar_hl = scalar_t
def scalar_jack(self, x, t=None):
"\n Return the Jack-scalar product between ``self`` and ``x``.\n\n This scalar product is defined so that the power sum elements\n `p_{\\mu}` are orthogonal and `\\langle p_{\\mu}, p_{\\mu} \\rangle =\n z_{\\mu} t^{\\ell(\\mu)}`, where `\\ell(\\mu)` denotes the length of\n `\\mu`.\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the\n same base ring as ``self``\n - ``t`` -- an optional parameter (default: ``None`` in which\n case ``t`` is used)\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ['t']).power()\n sage: matrix([[p(mu).scalar_jack(p(nu)) for nu in Partitions(4)] for mu in Partitions(4)])\n [ 4*t 0 0 0 0]\n [ 0 3*t^2 0 0 0]\n [ 0 0 8*t^2 0 0]\n [ 0 0 0 4*t^3 0]\n [ 0 0 0 0 24*t^4]\n sage: matrix([[p(mu).scalar_jack(p(nu),2) for nu in Partitions(4)] for mu in Partitions(4)])\n [ 8 0 0 0 0]\n [ 0 12 0 0 0]\n [ 0 0 32 0 0]\n [ 0 0 0 32 0]\n [ 0 0 0 0 384]\n sage: JQ = SymmetricFunctions(QQ['t'].fraction_field()).jack().Q()\n sage: matrix([[JQ(mu).scalar_jack(JQ(nu)) for nu in Partitions(3)] for mu in Partitions(3)])\n [(1/3*t^2 + 1/2*t + 1/6)/t^3 0 0]\n [ 0 (1/2*t + 1)/(t^3 + 1/2*t^2) 0]\n [ 0 0 6/(t^3 + 3*t^2 + 2*t)]\n "
parent = self.parent()
if (t is None):
if hasattr(parent, 't'):
t = self.parent().t
else:
t = QQ['t'].gen()
zee = (lambda part: (part.centralizer_size() * (t ** part.length())))
return self.scalar(x, zee)
def derivative_with_respect_to_p1(self, n=1):
"\n Return the symmetric function obtained by taking the derivative of\n ``self`` with respect to the power-sum symmetric function `p_1`\n when the expansion of ``self`` in the power-sum basis is considered\n as a polynomial in `p_k`'s (with `k \\geq 1`).\n\n This is the same as skewing ``self`` by the first power-sum symmetric\n function `p_1`.\n\n INPUT:\n\n - ``n`` -- (default: 1) nonnegative integer which determines\n which power of the derivative is taken\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: a = p([1,1,1])\n sage: a.derivative_with_respect_to_p1()\n 3*p[1, 1]\n sage: a.derivative_with_respect_to_p1(1)\n 3*p[1, 1]\n sage: a.derivative_with_respect_to_p1(2)\n 6*p[1]\n sage: a.derivative_with_respect_to_p1(3)\n 6*p[]\n\n ::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([3]).derivative_with_respect_to_p1()\n s[2]\n sage: s([2,1]).derivative_with_respect_to_p1()\n s[1, 1] + s[2]\n sage: s([1,1,1]).derivative_with_respect_to_p1()\n s[1, 1]\n sage: s(0).derivative_with_respect_to_p1()\n 0\n sage: s(1).derivative_with_respect_to_p1()\n 0\n sage: s([1]).derivative_with_respect_to_p1()\n s[]\n\n Let us check that taking the derivative with respect to ``p[1]``\n is equivalent to skewing by ``p[1]``::\n\n sage: p1 = s([1])\n sage: all( s(lam).derivative_with_respect_to_p1()\n ....: == s(lam).skew_by(p1) for lam in Partitions(4) )\n True\n "
p = self.parent().realization_of().power()
res = p(self)
for i in range(n):
res = res._derivative_with_respect_to_p1()
return self.parent()(res)
def frobenius(self, n):
'\n Return the image of the symmetric function ``self`` under the\n `n`-th Frobenius operator.\n\n The `n`-th Frobenius operator `\\mathbf{f}_n` is defined to be the\n map from the ring of symmetric functions to itself that sends\n every symmetric function `P(x_1, x_2, x_3, \\ldots)` to\n `P(x_1^n, x_2^n, x_3^n, \\ldots)`. This operator `\\mathbf{f}_n`\n is a Hopf algebra endomorphism, and satisfies\n\n .. MATH::\n\n \\mathbf{f}_n m_{(\\lambda_1, \\lambda_2, \\lambda_3, \\ldots)} =\n m_{(n\\lambda_1, n\\lambda_2, n\\lambda_3, \\ldots)}\n\n for every partition `(\\lambda_1, \\lambda_2, \\lambda_3, \\ldots)`\n (where `m` means the monomial basis). Moreover,\n `\\mathbf{f}_n (p_r) = p_{nr}` for every positive integer `r` (where\n `p_k` denotes the `k`-th powersum symmetric function).\n\n The `n`-th Frobenius operator is also called the `n`-th\n Frobenius endomorphism. It is not related to the Frobenius map\n which connects the ring of symmetric functions with the\n representation theory of the symmetric group.\n\n The `n`-th Frobenius operator is also the `n`-th Adams operator\n of the `\\Lambda`-ring of symmetric functions over the integers.\n\n The `n`-th Frobenius operator can also be described via plethysm:\n Every symmetric function `P` satisfies\n `\\mathbf{f}_n(P) = p_n \\circ P = P \\circ p_n`,\n where `p_n` is the `n`-th powersum symmetric function, and `\\circ`\n denotes (outer) plethysm.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n The result of applying the `n`-th Frobenius operator (on the ring of\n symmetric functions) to ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: p = Sym.p()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: s[3].frobenius(2)\n -s[3, 3] + s[4, 2] - s[5, 1] + s[6]\n sage: m[4,2,1].frobenius(3)\n m[12, 6, 3]\n sage: p[4,2,1].frobenius(3)\n p[12, 6, 3]\n sage: h[4].frobenius(2)\n h[4, 4] - 2*h[5, 3] + 2*h[6, 2] - 2*h[7, 1] + 2*h[8]\n\n The Frobenius endomorphisms are multiplicative::\n\n sage: all( all( s(lam).frobenius(3) * s(mu).frobenius(3) # long time\n ....: == (s(lam) * s(mu)).frobenius(3)\n ....: for mu in Partitions(3) )\n ....: for lam in Partitions(3) )\n True\n sage: all( all( m(lam).frobenius(2) * m(mu).frobenius(2)\n ....: == (m(lam) * m(mu)).frobenius(2)\n ....: for mu in Partitions(4) )\n ....: for lam in Partitions(4) )\n True\n sage: all( all( p(lam).frobenius(2) * p(mu).frobenius(2)\n ....: == (p(lam) * p(mu)).frobenius(2)\n ....: for mu in Partitions(3) )\n ....: for lam in Partitions(4) )\n True\n\n Being Hopf algebra endomorphisms, the Frobenius operators\n commute with the antipode::\n\n sage: all( p(lam).frobenius(4).antipode()\n ....: == p(lam).antipode().frobenius(4)\n ....: for lam in Partitions(3) )\n True\n\n Testing the `\\mathbf{f}_n(P) = p_n \\circ P = P \\circ p_n`\n equality (over `\\QQ`, since plethysm is currently not\n defined over `\\ZZ` in Sage)::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s()\n sage: p = Sym.p()\n sage: all( s(lam).frobenius(3) == s(lam).plethysm(p[3])\n ....: == s(p[3].plethysm(s(lam)))\n ....: for lam in Partitions(4) )\n True\n\n By Exercise 7.61 in Stanley\'s EC2 [STA]_ (see the errata on his\n website), `\\mathbf{f}_n(h_m)` is a linear combination of\n Schur polynomials (of straight shapes) using coefficients `0`,\n `1` and `-1` only; moreover, all partitions whose Schur\n polynomials occur with coefficient `\\neq 0` in this\n combination have empty `n`-cores. Let us check this on\n examples::\n\n sage: all( all( all( (coeff == -1 or coeff == 1)\n ....: and lam.core(n) == Partition([])\n ....: for lam, coeff in s([m]).frobenius(n) )\n ....: for n in range(2, 4) )\n ....: for m in range(4) )\n True\n\n .. SEEALSO::\n\n :meth:`plethysm`\n\n .. TODO::\n\n This method is fast on the monomial and the powersum\n bases, while all other bases get converted to the\n monomial basis. For most bases, this is probably the\n quickest way to do, but at least the Schur basis should\n have a better option. (Quoting from Stanley\'s EC2 [STA]_:\n "D. G. Duncan, J. London Math. Soc. 27 (1952), 235-236,\n or Y. M. Chen, A. M. Garsia, and J. B. Remmel, Contemp.\n Math. 34 (1984), 109-153".)\n '
parent = self.parent()
m = parent.realization_of().monomial()
dct = {lam.stretch(n): coeff for (lam, coeff) in m(self)}
result_in_m_basis = m._from_dict(dct)
return parent(result_in_m_basis)
def verschiebung(self, n):
'\n Return the image of the symmetric function ``self`` under the\n `n`-th Verschiebung operator.\n\n The `n`-th Verschiebung operator `\\mathbf{V}_n` is defined to be\n the unique algebra endomorphism `V` of the ring of symmetric\n functions that satisfies `V(h_r) = h_{r/n}` for every positive\n integer `r` divisible by `n`, and satisfies `V(h_r) = 0` for\n every positive integer `r` not divisible by `n`. This operator\n `\\mathbf{V}_n` is a Hopf algebra endomorphism. For every\n nonnegative integer `r` with `n \\mid r`, it satisfies\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = h_{r/n},\n \\quad \\mathbf{V}_n(p_r) = n p_{r/n},\n \\quad \\mathbf{V}_n(e_r) = (-1)^{r - r/n} e_{r/n}\n\n (where `h` is the complete homogeneous basis, `p` is the\n powersum basis, and `e` is the elementary basis). For every\n nonnegative integer `r` with `n \\nmid r`, it satisfes\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = \\mathbf{V}_n(p_r) = \\mathbf{V}_n(e_r) = 0.\n\n The `n`-th Verschiebung operator is also called the `n`-th\n Verschiebung endomorphism. Its name derives from the Verschiebung\n (German for "shift") endomorphism of the Witt vectors.\n\n The `n`-th Verschiebung operator is adjoint to the `n`-th\n Frobenius operator (see :meth:`frobenius` for its definition)\n with respect to the Hall scalar product (:meth:`scalar`).\n\n The action of the `n`-th Verschiebung operator on the Schur basis\n can also be computed explicitly. The following (probably clumsier\n than necessary) description can be obtained by solving exercise\n 7.61 in Stanley\'s [STA]_.\n\n Let `\\lambda` be a partition. Let `n` be a positive integer. If\n the `n`-core of `\\lambda` is nonempty, then\n `\\mathbf{V}_n(s_\\lambda) = 0`. Otherwise, the following method\n computes `\\mathbf{V}_n(s_\\lambda)`: Write the partition `\\lambda`\n in the form `(\\lambda_1, \\lambda_2, \\ldots, \\lambda_{ns})` for some\n nonnegative integer `s`. (If `n` does not divide the length of\n `\\lambda`, then this is achieved by adding trailing zeroes to\n `\\lambda`.) Set `\\beta_i = \\lambda_i + ns - i` for every\n `s \\in \\{ 1, 2, \\ldots, ns \\}`. Then,\n `(\\beta_1, \\beta_2, \\ldots, \\beta_{ns})` is a strictly decreasing\n sequence of nonnegative integers. Stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `-1 - \\beta_i` modulo `n`. Let `\\xi` be the sign of the\n permutation that is used for this sorting. Let `\\psi` be the sign\n of the permutation that is used to stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `i - 1` modulo `n`. (Notice that `\\psi = (-1)^{n(n-1)s(s-1)/4}`.)\n Then, `\\mathbf{V}_n(s_\\lambda) = \\xi \\psi \\prod_{i = 0}^{n - 1}\n s_{\\lambda^{(i)}}`, where\n `(\\lambda^{(0)}, \\lambda^{(1)}, \\ldots, \\lambda^{(n - 1)})`\n is the `n`-quotient of `\\lambda`.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n The result of applying the `n`-th Verschiebung operator (on the ring of\n symmetric functions) to ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: p = Sym.p()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: s[3].verschiebung(2)\n 0\n sage: s[3].verschiebung(3)\n s[1]\n sage: p[3].verschiebung(3)\n 3*p[1]\n sage: m[3,2,1].verschiebung(3)\n -18*m[1, 1] - 3*m[2]\n sage: p[3,2,1].verschiebung(3)\n 0\n sage: h[4].verschiebung(2)\n h[2]\n sage: p[2].verschiebung(2)\n 2*p[1]\n sage: m[3,2,1].verschiebung(6)\n 12*m[1]\n\n The Verschiebung endomorphisms are multiplicative::\n\n sage: all( all( s(lam).verschiebung(2) * s(mu).verschiebung(2)\n ....: == (s(lam) * s(mu)).verschiebung(2)\n ....: for mu in Partitions(4) )\n ....: for lam in Partitions(4) )\n True\n\n Being Hopf algebra endomorphisms, the Verschiebung operators\n commute with the antipode::\n\n sage: all( p(lam).verschiebung(3).antipode()\n ....: == p(lam).antipode().verschiebung(3)\n ....: for lam in Partitions(6) )\n True\n\n Testing the adjointness between the Frobenius operators\n `\\mathbf{f}_n` and the Verschiebung operators\n `\\mathbf{V}_n`::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.s()\n sage: p = Sym.p()\n sage: all( all( s(lam).verschiebung(2).scalar(p(mu))\n ....: == s(lam).scalar(p(mu).frobenius(2))\n ....: for mu in Partitions(3) )\n ....: for lam in Partitions(6) )\n True\n '
parent = self.parent()
h = parent.realization_of().homogeneous()
from sage.combinat.partition import Partition
dct = {Partition([(i // n) for i in lam]): coeff for (lam, coeff) in h(self) if all((((i % n) == 0) for i in lam))}
result_in_h_basis = h._from_dict(dct)
return parent(result_in_h_basis)
def bernstein_creation_operator(self, n):
'\n Return the image of ``self`` under the `n`-th Bernstein creation\n operator.\n\n Let `n` be an integer. The `n`-th Bernstein creation operator\n `\\mathbf{B}_n` is defined as the endomorphism of the space\n `Sym` of symmetric functions which sends every `f` to\n\n .. MATH::\n\n \\sum_{i \\geq 0} (-1)^i h_{n+i} e_i^\\perp,\n\n where usual notations are in place (`h` stands for the complete\n homogeneous symmetric functions, `e` for the elementary ones,\n and `e_i^\\perp` means skewing (:meth:`skew_by`) by `e_i`).\n\n This has been studied in [BBSSZ2012]_, section 2.2, where the\n following rule is given for computing `\\mathbf{B}_n` on a\n Schur function: If `(\\alpha_1, \\alpha_2, \\ldots, \\alpha_n)` is\n an `n`-tuple of integers (positive or not), then\n\n .. MATH::\n\n \\mathbf{B}_n s_{(\\alpha_1, \\alpha_2, \\ldots, \\alpha_n)}\n = s_{(n, \\alpha_1, \\alpha_2, \\ldots, \\alpha_n)}.\n\n Here, `s_{(\\alpha_1, \\alpha_2, \\ldots, \\alpha_n)}` is the\n "Schur function" associated to the `n`-tuple\n `(\\alpha_1, \\alpha_2, \\ldots, \\alpha_n)`, and defined by\n literally applying the Jacobi-Trudi identity, i.e., by\n\n .. MATH::\n\n s_{(\\alpha_1, \\alpha_2, \\ldots, \\alpha_n)}\n = \\det \\left( (h_{\\alpha_i - i + j})_{i, j = 1, 2, \\ldots, n} \\right).\n\n This notion of a Schur function clearly extends the classical\n notion of Schur function corresponding to a partition, but is\n easily reduced to the latter (in fact, for any `n`-tuple\n `\\alpha` of integers, one easily sees that `s_\\alpha` is\n either `0` or minus-plus a Schur function corresponding to a\n partition; and it is easy to determine which of these is the\n case and find the partition by a combinatorial algorithm).\n\n EXAMPLES:\n\n Let us check that what this method computes agrees with the\n definition::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: def bernstein_creation_by_def(n, f):\n ....: # `n`-th Bernstein creation operator applied to `f`\n ....: # computed according to its definition.\n ....: res = f.parent().zero()\n ....: if not f:\n ....: return res\n ....: max_degree = max(sum(m) for m, c in f)\n ....: for i in range(max_degree + 1):\n ....: if n + i >= 0:\n ....: res += (-1) ** i * h[n + i] * f.skew_by(e[i])\n ....: return res\n sage: all( bernstein_creation_by_def(n, s[l]) == s[l].bernstein_creation_operator(n)\n ....: for n in range(-2, 3) for l in Partitions(4) )\n True\n sage: all( bernstein_creation_by_def(n, s[l]) == s[l].bernstein_creation_operator(n)\n ....: for n in range(-3, 4) for l in Partitions(3) )\n True\n sage: all( bernstein_creation_by_def(n, e[l]) == e[l].bernstein_creation_operator(n)\n ....: for n in range(-3, 4) for k in range(3) for l in Partitions(k) )\n True\n\n Some examples::\n\n sage: s[3,2].bernstein_creation_operator(3)\n s[3, 3, 2]\n sage: s[3,2].bernstein_creation_operator(1)\n -s[2, 2, 2]\n sage: h[3,2].bernstein_creation_operator(-2)\n h[2, 1]\n sage: h[3,2].bernstein_creation_operator(-1)\n h[2, 1, 1] - h[2, 2] - h[3, 1]\n sage: h[3,2].bernstein_creation_operator(0)\n -h[3, 1, 1] + h[3, 2]\n sage: h[3,2].bernstein_creation_operator(1)\n -h[2, 2, 2] + h[3, 2, 1]\n sage: h[3,2].bernstein_creation_operator(2)\n -h[3, 3, 1] + h[4, 2, 1]\n '
from sage.combinat.partition import _Partitions
parent = self.parent()
s = parent.realization_of().schur()
res = s.zero()
for (m, c) in s(self):
for (j, p) in enumerate((m + [0])):
if (n == ((p - j) - 1)):
break
if (n > ((p - j) - 1)):
if ((n + j) < 0):
break
m_new = (([(k - 1) for k in m[:j]] + [(n + j)]) + m[j:])
m_new = _Partitions(m_new)
res += ((((- 1) ** j) * c) * s[m_new])
break
return parent(res)
def _expand(self, condition, n, alphabet='x'):
"\n Expand the symmetric function as a symmetric polynomial in ``n``\n variables.\n\n INPUT:\n\n - ``condition`` -- a function on partitions with a boolean output,\n selecting only certain terms (namely, only the items failing\n the condition are being expanded)\n\n - ``n`` -- a nonnegative integer\n\n - ``alphabet`` -- (default: ``'x'``) a variable for the expansion\n\n OUTPUT:\n\n A monomial expansion of ``self`` in the `n` variables labelled\n by ``alphabet``.\n\n EXAMPLES::\n\n sage: p = SymmetricFunctions(QQ).p()\n sage: a = p([2])+p([3])\n sage: a._expand(lambda part: False, 3)\n x0^3 + x1^3 + x2^3 + x0^2 + x1^2 + x2^2\n sage: a._expand(lambda part: max(part)>2, 3)\n x0^2 + x1^2 + x2^2\n sage: p(0).expand(3)\n 0\n sage: p([]).expand(3)\n 1\n\n .. NOTE::\n\n The term corresponding to the empty partition is always\n selected, even if ``condition`` returns ``False`` or an\n error when applied to the empty partition. This is in\n order to simplify using the ``_expand`` method with\n conditions like ``lambda part: max(part) < 3`` which\n would require extra work to handle the empty partition.\n "
from . import classical
parent = self.parent()
resPR = PolynomialRing(parent.base_ring(), n, alphabet)
if (self == parent.zero()):
return resPR.zero()
import sage.libs.symmetrica.all as symmetrica
e = getattr(symmetrica, 'compute_{}_with_alphabet'.format(classical.translate[parent.basis_name()].lower()))
def f(part):
if (not part):
return resPR.one()
else:
return (resPR.zero() if condition(part) else resPR(e(part, n, alphabet)))
return parent._apply_module_morphism(self, f)
def is_schur_positive(self):
"\n Return ``True`` if and only if ``self`` is Schur positive.\n\n If `s` is the space of Schur functions over ``self``'s base ring, then\n this is the same as ``self._is_positive(s)``.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1]) + s([3])\n sage: a.is_schur_positive()\n True\n sage: a = s([2,1]) - s([3])\n sage: a.is_schur_positive()\n False\n\n ::\n\n sage: QQx = QQ['x']\n sage: s = SymmetricFunctions(QQx).s()\n sage: x = QQx.gen()\n sage: a = (1+x)*s([2,1])\n sage: a.is_schur_positive()\n True\n sage: a = (1-x)*s([2,1])\n sage: a.is_schur_positive()\n False\n sage: s(0).is_schur_positive()\n True\n sage: s(1+x).is_schur_positive()\n True\n "
return self._is_positive(self.parent().realization_of().schur())
def _is_positive(self, s):
'\n Return ``True`` if and only if ``self`` has nonnegative coefficients\n in the basis `s`.\n\n INPUT:\n\n - ``s`` -- a basis of the ring of symmetric functions\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: a = s([2,1]) + s([3])\n sage: a._is_positive(s)\n True\n sage: a = s([2,1]) - s([3])\n sage: a._is_positive(s)\n False\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: a = s([2,1]) + s([3])\n sage: a._is_positive(m)\n True\n sage: a = -s[2,1]\n sage: a._is_positive(m)\n False\n\n sage: (s[2,1] - s[1,1,1])._is_positive(s)\n False\n sage: (s[2,1] - s[1,1,1])._is_positive(m)\n True\n '
s_self = s(self)
return all((_nonnegative_coefficients(c) for c in s_self.coefficients()))
def degree(self):
'\n Return the degree of ``self`` (which is defined to be `0`\n for the zero element).\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1]) + 3\n sage: z.degree()\n 4\n sage: s(1).degree()\n 0\n sage: s(0).degree()\n 0\n '
return max((sum(cfs) for cfs in self._monomial_coefficients), default=0)
def restrict_degree(self, d, exact=True):
'\n Return the degree ``d`` component of ``self``.\n\n INPUT:\n\n - ``d`` -- positive integer, degree of the terms to be returned\n\n - ``exact`` -- boolean, if ``True``, returns the terms of degree\n exactly ``d``, otherwise returns all terms of degree less than\n or equal to ``d``\n\n OUTPUT:\n\n - the homogeneous component of ``self`` of degree ``d``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1])\n sage: z.restrict_degree(2)\n 0\n sage: z.restrict_degree(1)\n s[1]\n sage: z.restrict_degree(3)\n s[1, 1, 1] + s[2, 1]\n sage: z.restrict_degree(3, exact=False)\n s[1] + s[1, 1, 1] + s[2, 1]\n sage: z.restrict_degree(0)\n 0\n '
if exact:
res = dict((x for x in self._monomial_coefficients.items() if (sum(x[0]) == d)))
else:
res = dict((x for x in self._monomial_coefficients.items() if (sum(x[0]) <= d)))
return self.parent()._from_dict(res)
def restrict_partition_lengths(self, l, exact=True):
'\n Return the terms of ``self`` labelled by partitions of length ``l``.\n\n INPUT:\n\n - ``l`` -- nonnegative integer\n\n - ``exact`` -- boolean, defaulting to ``True``\n\n OUTPUT:\n\n - if ``True``, returns the terms labelled by\n partitions of length precisely ``l``; otherwise returns all terms\n labelled by partitions of length less than or equal to ``l``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1])\n sage: z.restrict_partition_lengths(2)\n s[2, 1]\n sage: z.restrict_partition_lengths(0)\n 0\n sage: z.restrict_partition_lengths(2, exact = False)\n s[1] + s[2, 1] + s[4]\n '
if exact:
res = dict((x for x in self._monomial_coefficients.items() if (len(x[0]) == l)))
else:
res = dict((x for x in self._monomial_coefficients.items() if (len(x[0]) <= l)))
return self.parent()._from_dict(res)
def restrict_parts(self, n):
'\n Return the terms of ``self`` labelled by partitions `\\lambda` with\n `\\lambda_1 \\leq n`.\n\n INPUT:\n\n - ``n`` -- positive integer, to restrict the parts of the partitions\n of the terms to be returned\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: z = s([4]) + s([2,1]) + s([1,1,1]) + s([1])\n sage: z.restrict_parts(2)\n s[1] + s[1, 1, 1] + s[2, 1]\n sage: z.restrict_parts(1)\n s[1] + s[1, 1, 1]\n '
res = dict((x for x in self._monomial_coefficients.items() if (_lmax(x[0]) <= n)))
return self.parent()._from_dict(res)
def expand(self, n, alphabet='x'):
"\n Expand the symmetric function ``self`` as a symmetric polynomial\n in ``n`` variables.\n\n INPUT:\n\n - ``n`` -- a nonnegative integer\n\n - ``alphabet`` -- (default: ``'x'``) a variable for the expansion\n\n OUTPUT:\n\n A monomial expansion of ``self`` in the `n` variables\n labelled ``x0``, ``x1``, ..., ``x{n-1}`` (or just ``x``\n if `n = 1`), where ``x`` is ``alphabet``.\n\n EXAMPLES::\n\n sage: J = SymmetricFunctions(QQ).jack(t=2).J()\n sage: J([2,1]).expand(3)\n 4*x0^2*x1 + 4*x0*x1^2 + 4*x0^2*x2 + 6*x0*x1*x2 + 4*x1^2*x2 + 4*x0*x2^2 + 4*x1*x2^2\n sage: (2*J([2])).expand(0)\n 0\n sage: (3*J([])).expand(0)\n 3\n "
s = self.parent().realization_of().schur()
condition = (lambda part: (len(part) > n))
return s(self)._expand(condition, n, alphabet)
def skew_by(self, x):
"\n Return the result of skewing ``self`` by ``x``. (Skewing by ``x`` is\n the endomorphism (as additive group) of the ring of symmetric\n functions adjoint to multiplication by ``x`` with respect to the\n Hall inner product.)\n\n INPUT:\n\n - ``x`` -- element of the ring of symmetric functions over the same\n base ring as ``self``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([3,2]).skew_by(s([2]))\n s[2, 1] + s[3]\n sage: s([3,2]).skew_by(s([1,1,1]))\n 0\n sage: s([3,2,1]).skew_by(s([2,1]))\n s[1, 1, 1] + 2*s[2, 1] + s[3]\n\n ::\n\n sage: p = SymmetricFunctions(QQ).powersum()\n sage: p([4,3,3,2,2,1]).skew_by(p([2,1]))\n 4*p[4, 3, 3, 2]\n sage: zee = sage.combinat.sf.sfa.zee\n sage: zee([4,3,3,2,2,1])/zee([4,3,3,2])\n 4\n sage: s(0).skew_by(s([1]))\n 0\n sage: s(1).skew_by(s([1]))\n 0\n sage: s([]).skew_by(s([]))\n s[]\n sage: s([]).skew_by(s[1])\n 0\n\n TESTS::\n\n sage: f = s[3,2]\n sage: f.skew_by([1])\n Traceback (most recent call last):\n ...\n ValueError: x needs to be a symmetric function\n\n sage: s = SymmetricFunctions(QQ['t']).s()\n sage: f = s[3,2,1].skew_by(s[2,1]); f\n s[1, 1, 1] + 2*s[2, 1] + s[3]\n sage: f / 2\n 1/2*s[1, 1, 1] + s[2, 1] + 1/2*s[3]\n sage: s = SymmetricFunctions(GF(2)).s()\n sage: s[3,2,1].skew_by(s[2,1])\n s[1, 1, 1] + s[3]\n "
parent = self.parent()
Sym = parent.realization_of()
if (x not in Sym):
raise ValueError('x needs to be a symmetric function')
s = Sym.schur()
R = parent.base_ring()
import sage.libs.lrcalc.lrcalc as lrcalc
ret = linear_combination(((convert_remove_zeroes(lrcalc.skew(p1, p2), R), (c1 * c2)) for (p1, c1) in s(self)._monomial_coefficients.items() for (p2, c2) in s(x)._monomial_coefficients.items() if p1.contains(p2)))
return parent(s.element_class(s, ret))
def hl_creation_operator(self, nu, t=None):
"\n This is the vertex operator that generalizes Jing's operator.\n\n It is a linear operator that raises the degree by\n `|\\nu|`. This creation operator is a t-analogue of\n multiplication by ``s(nu)`` .\n\n .. SEEALSO:: Proposition 5 in [SZ2001]_.\n\n INPUT:\n\n - ``nu`` -- a partition or a list of integers\n\n - ``t`` -- (default: ``None``, in which case ``t`` is used) an element\n of the base ring\n\n REFERENCES:\n\n .. [SZ2001] \\M. Shimozono, M. Zabrocki,\n Hall-Littlewood vertex operators and generalized Kostka polynomials.\n Adv. Math. 158 (2001), no. 1, 66-85.\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ['t']).s()\n sage: s([2]).hl_creation_operator([3,2])\n s[3, 2, 2] + t*s[3, 3, 1] + t*s[4, 2, 1] + t^2*s[4, 3] + t^2*s[5, 2]\n\n sage: Sym = SymmetricFunctions(FractionField(QQ['t']))\n sage: HLQp = Sym.hall_littlewood().Qp()\n sage: s = Sym.s()\n sage: HLQp(s([2]).hl_creation_operator([2]).hl_creation_operator([3]))\n HLQp[3, 2, 2]\n sage: s([2,2]).hl_creation_operator([2,1])\n t*s[2, 2, 2, 1] + t^2*s[3, 2, 1, 1] + t^2*s[3, 2, 2] + t^3*s[3, 3, 1] + t^3*s[4, 2, 1] + t^4*s[4, 3]\n sage: s(1).hl_creation_operator([2,1,1])\n s[2, 1, 1]\n sage: s(0).hl_creation_operator([2,1,1])\n 0\n sage: s([3,2]).hl_creation_operator([2,1,1])\n (t^2-t)*s[2, 2, 2, 2, 1] + t^3*s[3, 2, 2, 1, 1]\n + (t^3-t^2)*s[3, 2, 2, 2] + t^3*s[3, 3, 1, 1, 1]\n + t^4*s[3, 3, 2, 1] + t^3*s[4, 2, 1, 1, 1] + t^4*s[4, 2, 2, 1]\n + 2*t^4*s[4, 3, 1, 1] + t^5*s[4, 3, 2] + t^5*s[4, 4, 1]\n + t^4*s[5, 2, 1, 1] + t^5*s[5, 3, 1]\n sage: s([3,2]).hl_creation_operator([-2])\n (-t^2+t)*s[1, 1, 1] + (-t^2+1)*s[2, 1]\n sage: s([3,2]).hl_creation_operator(-2)\n Traceback (most recent call last):\n ...\n ValueError: nu must be a list of integers\n sage: s = SymmetricFunctions(FractionField(ZZ['t'])).schur()\n sage: s[2].hl_creation_operator([3])\n s[3, 2] + t*s[4, 1] + t^2*s[5]\n\n TESTS::\n\n sage: s(0).hl_creation_operator([1])\n 0\n sage: s.one().hl_creation_operator([2,-1])\n 0\n "
s = self.parent().realization_of().schur()
if (t is None):
if hasattr(self.parent(), 't'):
t = self.parent().t
else:
t = self.parent().base_ring()('t')
P = self.parent()
if (nu in _Partitions):
self = s(self)
return P(((self * s(nu)) + s.sum(((s.sum_of_terms(((lam, c) for (lam, c) in (s(mu) * s(nu)) if (len(lam) <= len(nu)))) * self.skew_by(s(mu).plethysm(((t - 1) * s([1]))))) for d in range(self.degree()) for mu in Partitions((d + 1), max_length=len(nu))))))
elif (isinstance(nu, list) and all((isinstance(a, (int, Integer)) for a in nu))):
return P(s.sum(((((((t ** la.size()) * c) * d) * s(la)) * s._repeated_bernstein_creation_operator_on_basis(ga, nu)) for ((la, mu), c) in s(self).coproduct() for (ga, d) in s(mu).plethysm(((1 - t) * s[1])))))
else:
raise ValueError('nu must be a list of integers')
def eval_at_permutation_roots(self, rho):
'\n Evaluate at eigenvalues of a permutation matrix.\n\n Evaluate a symmetric function at the eigenvalues of a permutation\n matrix whose cycle structure is ``rho``. This computation is\n computed by coercing to the power sum basis where the value may\n be computed on the generators.\n\n This function evaluates an element at the roots of unity\n\n .. MATH::\n\n \\Xi_{\\rho_1},\\Xi_{\\rho_2},\\ldots,\\Xi_{\\rho_\\ell}\n\n where\n\n .. MATH::\n\n \\Xi_{m} = 1,\\zeta_m,\\zeta_m^2,\\ldots,\\zeta_m^{m-1}\n\n and `\\zeta_m` is an `m` root of unity.\n These roots of unity represent the eigenvalues of permutation\n matrix with cycle structure `\\rho`.\n\n INPUT:\n\n - ``rho`` -- a partition or a list of non-negative integers\n\n OUTPUT:\n\n - an element of the base ring\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([3,3]).eval_at_permutation_roots([6])\n 0\n sage: s([3,3]).eval_at_permutation_roots([3])\n 1\n sage: s([3,3]).eval_at_permutation_roots([1])\n 0\n sage: s([3,3]).eval_at_permutation_roots([3,3])\n 4\n sage: s([3,3]).eval_at_permutation_roots([1,1,1,1,1])\n 175\n sage: (s[1]+s[2]+s[3]).eval_at_permutation_roots([3,2])\n 2\n '
p = self.parent().symmetric_function_ring().p()
return p(self).eval_at_permutation_roots(rho)
def character_to_frobenius_image(self, n):
'\n Interpret ``self`` as a `GL_n` character and then take the Frobenius\n image of this character of the permutation matrices `S_n` which\n naturally sit inside of `GL_n`.\n\n To know the value of this character at a permutation of cycle structure\n `\\rho` the symmetric function ``self`` is evaluated at the\n eigenvalues of a permutation of cycle structure `\\rho`. The\n Frobenius image is then defined as\n `\\sum_{\\rho \\vdash n} f[ \\Xi_\\rho ] p_\\rho/z_\\rho`.\n\n .. SEEALSO::\n\n :meth:`eval_at_permutation_roots`\n\n INPUT:\n\n - ``n`` -- a non-negative integer to interpret ``self`` as\n a character of `GL_n`\n\n OUTPUT:\n\n - a symmetric function of degree ``n``\n\n EXAMPLES::\n\n sage: s = SymmetricFunctions(QQ).s()\n sage: s([1,1]).character_to_frobenius_image(5)\n s[3, 1, 1] + s[4, 1]\n sage: s([2,1]).character_to_frobenius_image(5)\n s[2, 2, 1] + 2*s[3, 1, 1] + 2*s[3, 2] + 3*s[4, 1] + s[5]\n sage: s([2,2,2]).character_to_frobenius_image(3)\n s[3]\n sage: s([2,2,2]).character_to_frobenius_image(4)\n s[2, 2] + 2*s[3, 1] + 2*s[4]\n sage: s([2,2,2]).character_to_frobenius_image(5)\n 2*s[2, 2, 1] + s[3, 1, 1] + 4*s[3, 2] + 3*s[4, 1] + 2*s[5]\n '
p = self.parent().symmetric_function_ring().p()
return self.parent()(p.sum((((self.eval_at_permutation_roots(rho) * p(rho)) / rho.centralizer_size()) for rho in Partitions(n))))
def principal_specialization(self, n=infinity, q=None):
'\n Return the principal specialization of a symmetric function.\n\n The *principal specialization* of order `n` at `q`\n is the ring homomorphism `ps_{n,q}` from the ring of\n symmetric functions to another commutative ring `R`\n given by `x_i \\mapsto q^{i-1}` for `i \\in \\{1,\\dots,n\\}`\n and `x_i \\mapsto 0` for `i > n`.\n Here, `q` is a given element of `R`, and we assume that\n the variables of our symmetric functions are\n `x_1, x_2, x_3, \\ldots`.\n (To be more precise, `ps_{n,q}` is a `K`-algebra\n homomorphism, where `K` is the base ring.)\n See Section 7.8 of [EnumComb2]_.\n\n The *stable principal specialization* at `q` is the ring\n homomorphism `ps_q` from the ring of symmetric functions\n to another commutative ring `R` given by\n `x_i \\mapsto q^{i-1}` for all `i`.\n This is well-defined only if the resulting infinite sums\n converge; thus, in particular, setting `q = 1` in the\n stable principal specialization is an invalid operation.\n\n INPUT:\n\n - ``n`` (default: ``infinity``) -- a nonnegative integer or\n ``infinity``, specifying whether to compute the principal\n specialization of order ``n`` or the stable principal\n specialization.\n\n - ``q`` (default: ``None``) -- the value to use for `q`; the\n default is to create a ring of polynomials in ``q``\n (or a field of rational functions in ``q``) over the\n given coefficient ring.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: x = m[1,1]\n sage: x.principal_specialization(3)\n q^3 + q^2 + q\n\n By default we return a rational function in ``q``. Sometimes\n it is better to obtain an element of the symbolic ring::\n\n sage: h = SymmetricFunctions(QQ).h()\n sage: (h[3]+h[2]).principal_specialization(q=var("q")) # needs sage.symbolic\n 1/((q^2 - 1)*(q - 1)) - 1/((q^3 - 1)*(q^2 - 1)*(q - 1))\n\n In case ``q`` is in the base ring, it must be passed explicitly::\n\n sage: R = QQ[\'q,t\']\n sage: Ht = SymmetricFunctions(R).macdonald().Ht()\n sage: Ht[2].principal_specialization()\n Traceback (most recent call last):\n ...\n ValueError: the variable q is in the base ring, pass it explicitly\n\n sage: Ht[2].principal_specialization(q=R("q"))\n (q^2 + 1)/(q^3 - q^2 - q + 1)\n\n Note that the principal specialization can be obtained as a plethysm::\n\n sage: R = QQ[\'q\'].fraction_field()\n sage: s = SymmetricFunctions(R).s()\n sage: one = s.one()\n sage: q = R("q")\n sage: f = s[3,2,2]\n sage: f.principal_specialization(q=q) == f(one/(1-q)).coefficient([])\n True\n sage: f.principal_specialization(n=4, q=q) == f(one*(1-q^4)/(1-q)).coefficient([])\n True\n\n TESTS::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: m.zero().principal_specialization(3)\n 0\n\n sage: x = 5*m[1,1,1] + 3*m[2,1] + 1\n sage: x.principal_specialization(3)\n 3*q^5 + 6*q^4 + 5*q^3 + 6*q^2 + 3*q + 1\n\n Check that the principal specializations in different bases\n are all the same. When specific implementations for further\n bases are added, this test should be adapted::\n\n sage: S = SymmetricFunctions(QQ)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: m = S.m(); x = m[2,1]\n sage: len(set([b(x).principal_specialization(n=3) for b in B]))\n 1\n sage: len(set([b(x).principal_specialization() for b in B]))\n 1\n sage: len(set([b(x).principal_specialization(n=4, q=1) for b in B]))\n 1\n sage: len(set([b(x).principal_specialization(n=4, q=2) for b in B]))\n 1\n\n Check that the stable principal specialization at `q = 1`\n raises a :class:`ValueError`:\n\n sage: def test_error(x):\n ....: message = "the stable principal specialization of %s at q=1 should raise a ValueError"\n ....: try:\n ....: x.principal_specialization(q=1)\n ....: except ValueError as e:\n ....: return(e)\n ....: except StandardError as e:\n ....: raise ValueError((message + ", but raised \'%s\' instead") % (x, e))\n ....: raise ValueError((message + ", but didn\'t") % x)\n\n sage: set([str(test_error(b(x))) for b in B])\n {\'the stable principal specialization at q=1 is not defined\'}\n\n Check that specifying `q` which is a removable singularity works::\n\n sage: S = SymmetricFunctions(QQ)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: m = S.m(); x = m[2,2,1]\n sage: set([b(x).principal_specialization(n=4, q=QQbar.zeta(3)) for b in B])\n {-3}\n\n sage: S = SymmetricFunctions(GF(3))\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: m = S.m(); x = m[3,2,1]\n sage: set([b(x).principal_specialization(n=4, q=GF(3)(2)) for b in B])\n {1}\n\n sage: S = SymmetricFunctions(Zmod(4))\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: m = S.m(); x = m[3,2,1]\n sage: set([b(x).principal_specialization(n=4, q=Zmod(4)(2)) for b in B])\n {0}\n sage: y = m[3,1]\n sage: set([b(y).principal_specialization(n=4, q=Zmod(4)(2)) for b in B])\n {2}\n sage: B = [S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: z = m[1,1]\n sage: set([b(z).principal_specialization(n=4) for b in B])\n {q^5 + q^4 + 2*q^3 + q^2 + q}\n\n Check that parents are correct over `\\mathbb{F}_3`::\n\n sage: S = SymmetricFunctions(GF(3))\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: lams = [Partition([]), Partition([1]), Partition([2,1])]\n sage: set(b[lam].principal_specialization(n=2, q=GF(3)(0)).parent() for b in B for lam in lams)\n {Finite Field of size 3}\n sage: set(b[lam].principal_specialization(n=2, q=GF(3)(1)).parent() for b in B for lam in lams)\n {Finite Field of size 3}\n sage: set(b[lam].principal_specialization(n=2, q=GF(3)(2)).parent() for b in B for lam in lams)\n {Finite Field of size 3}\n sage: set(b[lam].principal_specialization(n=2).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in q over Finite Field of size 3}\n sage: set(b[lam].principal_specialization().parent() for b in B for lam in lams)\n {Fraction Field of Univariate Polynomial Ring in q over Finite Field of size 3,\n Univariate Polynomial Ring in q over Finite Field of size 3}\n\n sage: a = S.e()[2,1].principal_specialization(n=2, q=GF(3)(2)); a\n 0\n sage: a = S.e()[1,1,1].principal_specialization(n=2); a\n q^3 + 1\n\n sage: set(b.one().principal_specialization(n=2, q=GF(3)(2)) for b in B)\n {1}\n sage: set(b.one().principal_specialization(n=2, q=GF(3)(1)) for b in B)\n {1}\n sage: set(b.one().principal_specialization(n=2) for b in B)\n {1}\n sage: set(b.one().principal_specialization() for b in B)\n {1}\n\n Check that parents are correct over the integer ring::\n\n sage: S = SymmetricFunctions(ZZ)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: lams = [Partition([]), Partition([1]), Partition([2,1])]\n sage: set(b[lam].principal_specialization(n=2, q=0).parent() for b in B for lam in lams)\n {Integer Ring}\n sage: set(b[lam].principal_specialization(n=2, q=1).parent() for b in B for lam in lams)\n {Integer Ring}\n sage: set(b[lam].principal_specialization(n=2, q=2).parent() for b in B for lam in lams)\n {Integer Ring}\n sage: set(b[lam].principal_specialization(n=2).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in q over Integer Ring}\n sage: sorted(set(b[lam].principal_specialization().parent() for b in B for lam in lams), key=str)\n [Fraction Field of Univariate Polynomial Ring in q over Integer Ring,\n Univariate Polynomial Ring in q over Integer Ring,\n Univariate Polynomial Ring in q over Rational Field]\n\n Check that parents are correct over a polynomial ring::\n\n sage: P = PolynomialRing(ZZ, "q")\n sage: q = P.gen()\n sage: S = SymmetricFunctions(P)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: lams = [Partition([]), Partition([1]), Partition([2,1])]\n sage: set(b[lam].principal_specialization(n=2, q=P(0)).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in q over Integer Ring}\n sage: set(b[lam].principal_specialization(n=2, q=P(1)).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in q over Integer Ring}\n sage: set(b[lam].principal_specialization(n=2, q=P(2)).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in q over Integer Ring}\n sage: set(b[lam].principal_specialization(n=2, q=q).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in q over Integer Ring}\n sage: sorted(set(b[lam].principal_specialization(q=q).parent() for b in B for lam in lams), key=str)\n [Fraction Field of Univariate Polynomial Ring in q over Integer Ring,\n Univariate Polynomial Ring in q over Integer Ring,\n Univariate Polynomial Ring in q over Rational Field]\n\n sage: a = S.e()[2,1].principal_specialization(n=2, q=2); a\n 6\n sage: a = S.e()[2,1].principal_specialization(n=2, q=q); a\n q^2 + q\n\n sage: set(b.one().principal_specialization(n=2, q=P(2)) for b in B)\n {1}\n sage: set(b.one().principal_specialization(n=2, q=P(1)) for b in B)\n {1}\n sage: set(b.one().principal_specialization(n=2, q=q) for b in B)\n {1}\n sage: set(b.one().principal_specialization(q=q) for b in B)\n {1}\n\n '
e = self.parent().realization_of().elementary()
return e(self).principal_specialization(n, q=q)
def exponential_specialization(self, t=None, q=1):
'\n Return the exponential specialization of a\n symmetric function (when `q = 1`), or the\n `q`-exponential specialization (when `q \\neq 1`).\n\n The *exponential specialization* `ex` at `t` is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R`.\n It is defined whenever the base ring `K` is a\n `\\QQ`-algebra and `t` is an element of `R`.\n The easiest way to define it is by specifying its\n values on the powersum symmetric functions to be\n `p_1 = t` and `p_n = 0` for `n > 1`.\n Equivalently, on the homogeneous functions it is\n given by `ex(h_n) = t^n / n!`; see Proposition 7.8.4 of\n [EnumComb2]_.\n\n By analogy, the `q`-exponential specialization is a\n `K`-algebra homomorphism from the `K`-algebra of\n symmetric functions to another `K`-algebra `R` that\n depends on two elements `t` and `q` of `R` for which\n the elements `1 - q^i` for all positive integers `i`\n are invertible.\n It can be defined by specifying its values on the\n complete homogeneous symmetric functions to be\n\n .. MATH::\n\n ex_q(h_n) = t^n / [n]_q!,\n\n where `[n]_q!` is the `q`-factorial. Equivalently, for\n `q \\neq 1` and a homogeneous symmetric function `f` of\n degree `n`, we have\n\n .. MATH::\n\n ex_q(f) = (1-q)^n t^n ps_q(f),\n\n where `ps_q(f)` is the stable principal specialization of `f`\n (see :meth:`principal_specialization`).\n (See (7.29) in [EnumComb2]_.)\n\n The limit of `ex_q` as `q \\to 1` is `ex`.\n\n INPUT:\n\n - ``t`` (default: ``None``) -- the value to use for `t`;\n the default is to create a ring of polynomials in ``t``.\n\n - ``q`` (default: `1`) -- the value to use for `q`. If\n ``q`` is ``None``, then a ring (or fraction field) of\n polynomials in ``q`` is created.\n\n EXAMPLES::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: (m[2,1]+m[1,1]).exponential_specialization()\n 1/2*t^2\n sage: (m[2,1]+m[1,1]).exponential_specialization(q=1)\n 1/2*t^2\n sage: m[1,1].exponential_specialization(q=None)\n (q/(q + 1))*t^2\n sage: Qq = PolynomialRing(QQ, "q"); q = Qq.gen()\n sage: m[1,1].exponential_specialization(q=q)\n (q/(q + 1))*t^2\n sage: Qt = PolynomialRing(QQ, "t"); t = Qt.gen()\n sage: m[1,1].exponential_specialization(t=t)\n 1/2*t^2\n sage: Qqt = PolynomialRing(QQ, ["q", "t"]); q, t = Qqt.gens()\n sage: m[1,1].exponential_specialization(q=q, t=t)\n q*t^2/(q + 1)\n\n sage: x = m[3]+m[2,1]+m[1,1,1]\n sage: d = x.homogeneous_degree()\n sage: var("q t") # needs sage.symbolic\n (q, t)\n sage: factor((x.principal_specialization()*(1-q)^d*t^d)) # needs sage.symbolic\n t^3/((q^2 + q + 1)*(q + 1))\n sage: factor(x.exponential_specialization(q=q, t=t)) # needs sage.symbolic\n t^3/((q^2 + q + 1)*(q + 1))\n\n TESTS::\n\n sage: m = SymmetricFunctions(QQ).m()\n sage: m.zero().exponential_specialization()\n 0\n\n Check that the exponential specializations in different bases\n are all the same. When specific implementations for further\n bases are added, this test should be adapted::\n\n sage: S = SymmetricFunctions(QQ)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: m = S.m(); x = m[3]+m[2,1]+m[1,1,1]\n sage: len(set([b(x).exponential_specialization(q=None, t=None) for b in B]))\n 1\n sage: len(set([b(x).exponential_specialization(q=1) for b in B]))\n 1\n sage: len(set([b(x).exponential_specialization(q=2) for b in B]))\n 1\n sage: len(set([b(x).exponential_specialization(t=2) for b in B]))\n 1\n\n Check that parents are correct over `\\mathbb{F}_3`::\n\n sage: S = SymmetricFunctions(GF(3))\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: lams = [Partition([]), Partition([1]), Partition([2,1])]\n sage: sorted(set(b[lam].exponential_specialization(q=None).parent() for b in B for lam in lams), key=str)\n [Univariate Polynomial Ring in t over Fraction Field\n of Univariate Polynomial Ring in q over Finite Field of size 3,\n Univariate Polynomial Ring in t over Univariate Polynomial Ring\n in q over Finite Field of size 3]\n sage: P2 = PolynomialRing(GF(3), ["q", "t"])\n sage: q2, t2 = P2.gens()\n sage: sorted(set(b[lam].exponential_specialization(q=q2, t=t2).parent() for b in B for lam in lams), key=str)\n [Fraction Field of Multivariate Polynomial Ring in q, t over Finite Field of size 3,\n Multivariate Polynomial Ring in q, t over Finite Field of size 3]\n\n Check that parents are correct over `\\QQ` for `q = 1`::\n\n sage: S = SymmetricFunctions(QQ)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: lams = [Partition([]), Partition([1]), Partition([2,1])]\n sage: set(b[lam].exponential_specialization(q=1).parent() for b in B for lam in lams)\n {Univariate Polynomial Ring in t over Rational Field}\n sage: set(b[lam].exponential_specialization(q=1, t=1).parent() for b in B for lam in lams)\n {Rational Field}\n sage: P2 = PolynomialRing(QQ, ["q", "t"])\n sage: q2, t2 = P2.gens()\n sage: set(b[lam].exponential_specialization(q=1, t=t2).parent() for b in B for lam in lams)\n {Multivariate Polynomial Ring in q, t over Rational Field}\n\n Check that parents are correct over a polynomial ring::\n\n sage: P = PolynomialRing(QQ, "q")\n sage: q = P.gen()\n sage: S = SymmetricFunctions(P)\n sage: B = [S.p(), S.m(), S.e(), S.h(), S.s(), S.f()]\n sage: lams = [Partition([]), Partition([1]), Partition([2,1])]\n sage: sorted(set(b[lam].exponential_specialization(q=q).parent() for b in B for lam in lams), key=str)\n [Univariate Polynomial Ring in t over\n Fraction Field of Univariate Polynomial Ring in q over Rational Field,\n Univariate Polynomial Ring in t over Univariate Polynomial Ring\n in q over Rational Field]\n sage: sorted(set(b[lam].exponential_specialization(q=q, t=1).parent() for b in B for lam in lams), key=str)\n [Fraction Field of Univariate Polynomial Ring in q over Rational Field,\n Univariate Polynomial Ring in q over Rational Field]\n '
e = self.parent().realization_of().elementary()
return e(self).exponential_specialization(t=t, q=q)
|
def _lmax(x):
'\n Return the max of ``x`` where ``x`` is a list.\n\n If ``x`` is the empty list, ``_lmax`` returns 0.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import _lmax\n sage: _lmax([3,2,1])\n 3\n sage: _lmax([])\n 0\n '
return (max(x) if x else 0)
|
def _nonnegative_coefficients(x):
'\n Return ``True`` if ``x`` has nonnegative coefficients.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import _nonnegative_coefficients\n sage: _nonnegative_coefficients(2)\n True\n sage: _nonnegative_coefficients(-2)\n False\n sage: R.<x> = ZZ[]\n sage: _nonnegative_coefficients(x^2+4)\n True\n sage: _nonnegative_coefficients(x^2-4)\n False\n '
if (isinstance(x, Polynomial) or isinstance(x, MPolynomial)):
return all(((c >= 0) for c in x.coefficients(sparse=False)))
else:
return (x >= 0)
|
def _variables_recursive(R, include=None, exclude=None):
'\n Return all variables appearing in the ring ``R``.\n\n INPUT:\n\n - ``R`` -- a :class:`Ring`\n - ``include``, ``exclude`` -- (optional) iterables of variables in ``R``\n\n OUTPUT:\n\n If ``include`` is specified, only these variables are returned\n as elements of ``R``. Otherwise, all variables in ``R``\n (recursively) with the exception of those in ``exclude`` are\n returned.\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import _variables_recursive\n sage: R.<a, b> = QQ[]\n sage: S.<t> = R[]\n sage: _variables_recursive(S)\n [a, b, t]\n\n sage: _variables_recursive(S, exclude=[b])\n [a, t]\n\n sage: _variables_recursive(S, include=[b])\n [b]\n\n TESTS::\n\n sage: _variables_recursive(R.fraction_field(), exclude=[b])\n [a]\n\n sage: _variables_recursive(S.fraction_field(), exclude=[b]) # known bug\n [a, t]\n '
if ((include is not None) and (exclude is not None)):
raise RuntimeError('include and exclude cannot both be specified')
if (include is not None):
degree_one = [R(g) for g in include]
else:
try:
degree_one = [R(g) for g in R.variable_names_recursive()]
except AttributeError:
try:
degree_one = R.gens()
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):
'\n Replace the given variables in the ring element ``c`` with their\n ``n``-th power.\n\n INPUT:\n\n - ``c`` -- an element of a ring\n - ``n`` -- the power to raise the given variables to\n - ``variables`` -- the variables to raise\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import _raise_variables\n sage: R.<a, b> = QQ[]\n sage: S.<t> = R[]\n sage: _raise_variables(2*a + 3*b*t, 2, [a, t])\n 3*b*t^2 + 2*a^2\n '
try:
return c.subs(**{str(g): (g ** n) for g in variables})
except AttributeError:
return c
|
def _to_polynomials(lf, R):
'\n Return the symmetric functions as polynomials, where each\n part of a partition corresponds to a variable.\n\n The result makes sense only if the symmetric functions are all\n given in the same basis, which is multiplicative, but we do not\n check this.\n\n INPUT:\n\n - ``lf`` -- a list of symmetric functions\n - ``R`` -- the base ring\n\n .. SEEALSO::\n\n :func:`_from_polynomial`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import _to_polynomials\n sage: e = SymmetricFunctions(QQ).e()\n sage: _to_polynomials([5*e[3] + e[2,1] + e[1]], QQ)\n [v1*v2 + v1 + 5*v3]\n '
n = max((max((part[0] for part in f.support() if part), default=0) for f in lf))
n = max(n, 1)
P = PolynomialRing(R, [('v%s' % a) for a in range(1, (n + 1))])
if (n == 1):
return [P({part.to_exp(n)[0]: c for (part, c) in f}) for f in lf]
return [P({tuple(part.to_exp(n)): c for (part, c) in f}) for f in lf]
|
def _from_polynomial(p, f):
'\n Return the polynomial as a symmetric function in the given\n basis , where the `n`th variable corresponds to the symmetric\n function`f[n]`.\n\n INPUT:\n\n - ``p`` -- a polynomial\n - ``f`` -- a basis of the ring of symmetric functions\n\n .. SEEALSO::\n\n :func:`_to_polynomials`\n\n EXAMPLES::\n\n sage: from sage.combinat.sf.sfa import _to_polynomials, _from_polynomial\n sage: e = SymmetricFunctions(QQ).e()\n sage: p = _to_polynomials([5*e[3] + e[2,1] + e[1]], ZZ)[0]; p\n v1*v2 + v1 + 5*v3\n sage: _from_polynomial(p, e)\n e[1] + e[2, 1] + 5*e[3]\n '
n = p.parent().ngens()
if (n == 1):
d = {_Partitions.from_exp([e]): c for (e, c) in p.dict().items()}
else:
d = {_Partitions.from_exp(e): c for (e, c) in p.iterator_exp_coeff(False)}
return f.element_class(f, d)
|
class SymmetricFunctionAlgebra_symplectic(sfa.SymmetricFunctionAlgebra_generic):
'\n The symplectic symmetric function basis (or symplectic basis, to be short).\n\n The symplectic basis `\\{ sp_{\\lambda} \\}` where `\\lambda` is taken over\n all partitions is defined by the following change of basis with the\n Schur functions:\n\n .. MATH::\n\n s_{\\lambda} = \\sum_{\\mu} \\left( \\sum_{\\nu \\in V} c^{\\lambda}_{\\mu\\nu}\n \\right) sp_{\\mu}\n\n where `V` is the set of all partitions with even-height columns and\n `c^{\\lambda}_{\\mu\\nu}` is the usual Littlewood-Richardson (LR)\n coefficients. By the properties of LR coefficients, this can be shown to\n be a upper unitriangular change of basis.\n\n .. NOTE::\n\n This is only a filtered basis, not a `\\ZZ`-graded basis. However this\n does respect the induced `(\\ZZ/2\\ZZ)`-grading.\n\n INPUT:\n\n - ``Sym`` -- an instance of the ring of the symmetric functions\n\n REFERENCES:\n\n .. [ChariKleber2000] Vyjayanthi Chari and Michael Kleber.\n *Symmetric functions and representations of quantum affine algebras*.\n :arxiv:`math/0011161v1`\n\n .. [KoikeTerada1987] \\K. Koike, I. Terada, *Young-diagrammatic methods for\n the representation theory of the classical groups of type Bn, Cn, Dn*.\n J. Algebra 107 (1987), no. 2, 466-511.\n\n .. [ShimozonoZabrocki2006] Mark Shimozono and Mike Zabrocki.\n *Deformed universal characters for classical and affine algebras*.\n Journal of Algebra, **299** (2006). :arxiv:`math/0404288`.\n\n EXAMPLES:\n\n Here are the first few symplectic symmetric functions, in various bases::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: sp = Sym.sp()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n\n sage: p(sp([1]))\n p[1]\n sage: m(sp([1]))\n m[1]\n sage: e(sp([1]))\n e[1]\n sage: h(sp([1]))\n h[1]\n sage: s(sp([1]))\n s[1]\n\n sage: p(sp([2]))\n 1/2*p[1, 1] + 1/2*p[2]\n sage: m(sp([2]))\n m[1, 1] + m[2]\n sage: e(sp([2]))\n e[1, 1] - e[2]\n sage: h(sp([2]))\n h[2]\n sage: s(sp([2]))\n s[2]\n\n sage: p(sp([3]))\n 1/6*p[1, 1, 1] + 1/2*p[2, 1] + 1/3*p[3]\n sage: m(sp([3]))\n m[1, 1, 1] + m[2, 1] + m[3]\n sage: e(sp([3]))\n e[1, 1, 1] - 2*e[2, 1] + e[3]\n sage: h(sp([3]))\n h[3]\n sage: s(sp([3]))\n s[3]\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: sp = Sym.sp()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: p = Sym.p()\n sage: m(sp([4]))\n m[1, 1, 1, 1] + m[2, 1, 1] + m[2, 2] + m[3, 1] + m[4]\n sage: e(sp([4]))\n e[1, 1, 1, 1] - 3*e[2, 1, 1] + e[2, 2] + 2*e[3, 1] - e[4]\n sage: h(sp([4]))\n h[4]\n sage: s(sp([4]))\n s[4]\n\n Some examples of conversions the other way::\n\n sage: sp(h[3])\n sp[3]\n sage: sp(e[3])\n sp[1] + sp[1, 1, 1]\n sage: sp(m[2,1])\n -sp[1] - 2*sp[1, 1, 1] + sp[2, 1]\n sage: sp(p[3])\n sp[1, 1, 1] - sp[2, 1] + sp[3]\n\n Some multiplication::\n\n sage: sp([2]) * sp([1,1])\n sp[1, 1] + sp[2] + sp[2, 1, 1] + sp[3, 1]\n sage: sp([2,1,1]) * sp([2])\n sp[1, 1] + sp[1, 1, 1, 1] + 2*sp[2, 1, 1] + sp[2, 2] + sp[2, 2, 1, 1]\n + sp[3, 1] + sp[3, 1, 1, 1] + sp[3, 2, 1] + sp[4, 1, 1]\n sage: sp([1,1]) * sp([2,1])\n sp[1] + sp[1, 1, 1] + 2*sp[2, 1] + sp[2, 1, 1, 1] + sp[2, 2, 1]\n + sp[3] + sp[3, 1, 1] + sp[3, 2]\n\n Examples of the Hopf algebra structure::\n\n sage: sp([1]).antipode()\n -sp[1]\n sage: sp([2]).antipode()\n sp[] + sp[1, 1]\n sage: sp([1]).coproduct()\n sp[] # sp[1] + sp[1] # sp[]\n sage: sp([2]).coproduct()\n sp[] # sp[2] + sp[1] # sp[1] + sp[2] # sp[]\n sage: sp([1]).counit()\n 0\n sage: sp.one().counit()\n 1\n '
def __init__(self, Sym):
'\n Initialize ``self``.\n\n TESTS::\n\n sage: sp = SymmetricFunctions(QQ).sp()\n sage: TestSuite(sp).run()\n '
sfa.SymmetricFunctionAlgebra_generic.__init__(self, Sym, 'symplectic', 'sp', graded=False)
self._s = Sym.schur()
M = self._s.module_morphism(self._s_to_sp_on_basis, codomain=self, triangular='upper', unitriangular=True)
M.register_as_coercion()
Mi = self.module_morphism(self._sp_to_s_on_basis, codomain=self._s, triangular='upper', unitriangular=True)
Mi.register_as_coercion()
@cached_method
def _sp_to_s_on_basis(self, lam):
'\n Return the symplectic symmetric function ``sp[lam]`` expanded in\n the Schur basis, where ``lam`` is a partition.\n\n TESTS:\n\n Check that this is the inverse::\n\n sage: sp = SymmetricFunctions(QQ).sp()\n sage: s = SymmetricFunctions(QQ).s()\n sage: all(sp(s(sp[la])) == sp[la] for i in range(5) for la in Partitions(i))\n True\n sage: all(s(sp(s[la])) == s[la] for i in range(5) for la in Partitions(i))\n True\n '
R = self.base_ring()
n = sum(lam)
return self._s._from_dict({mu: R.sum(((((- 1) ** j) * lrcalc.lrcoef_unsafe(lam, mu, nu)) for nu in Partitions((2 * j)) if all(((nu.leg_length(i, i) == (nu.arm_length(i, i) + 1)) for i in range(nu.frobenius_rank()))))) for j in range(((n // 2) + 1)) for mu in Partitions((n - (2 * j)))})
@cached_method
def _s_to_sp_on_basis(self, lam):
'\n Return the Schur symmetric function ``s[lam]`` expanded in\n the symplectic basis, where ``lam`` is a partition.\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``s[lam]`` in the symplectic basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: s = Sym.schur()\n sage: sp = Sym.symplectic()\n sage: sp._s_to_sp_on_basis(Partition([]))\n sp[]\n sage: sp._s_to_sp_on_basis(Partition([4,2,1]))\n sp[2, 1] + sp[3] + sp[3, 1, 1] + sp[3, 2] + sp[4, 1] + sp[4, 2, 1]\n sage: s(sp._s_to_sp_on_basis(Partition([3,1]))) == s[3,1]\n True\n '
R = self.base_ring()
n = sum(lam)
return self._from_dict({mu: R.sum((lrcalc.lrcoef_unsafe(lam, mu, sum([[x, x] for x in nu], [])) for nu in Partitions(j))) for j in range(((n // 2) + 1)) for mu in Partitions((n - (2 * j)))})
|
class SymmetricFunctionAlgebra_witt(multiplicative.SymmetricFunctionAlgebra_multiplicative):
"\n The Witt symmetric function basis (or Witt basis, to be short).\n\n The Witt basis of the ring of symmetric functions is\n denoted by `(x_{\\lambda})` in [HazWitt1]_, section 9.63, and by\n `(q_{\\lambda})` in [DoranIV1996]_. We will denote this basis by\n `(w_{\\lambda})` (which is precisely how it is denoted in\n [GriRei18]_, Exercise 2.9.3(d)). It is a multiplicative basis\n (meaning that `w_{\\emptyset} = 1` and that every partition\n `\\lambda` satisfies\n `w_{\\lambda} = w_{\\lambda_1} w_{\\lambda_2} w_{\\lambda_3} \\cdots`,\n where `w_i` means `w_{(i)}` for every nonnegative integer `i`).\n\n This basis can be defined in various ways. Probably the most\n well-known one is using the equation\n\n .. MATH::\n\n \\prod_{d=1}^{\\infty} (1 - w_d t^d)^{-1} = \\sum_{n=0}^{\\infty} h_n t^n\n\n where `t` is a formal variable and `h_n` are the complete\n homogeneous symmetric functions, extended to `0` by `h_0 = 1`.\n This equation allows one to uniquely determine the functions\n `w_1, w_2, w_3, \\ldots` by recursion; one consequently extends the\n definition to all `w_{\\lambda}` by requiring multiplicativity.\n\n A way to rewrite the above equation without power series is:\n\n .. MATH::\n\n h_n = \\sum_{\\lambda \\vdash n} w_{\\lambda}\n\n for all nonnegative integers `n`, where `\\lambda \\vdash n` means\n that `\\lambda` is a partition of `n`.\n\n A similar equation (which is easily seen to be equivalent to the\n former) is\n\n .. MATH::\n\n e_n = \\sum_{\\lambda} (-1)^{n - \\ell(\\lambda)} w_{\\lambda},\n\n with the sum running only over *strict* partitions `\\lambda` of\n `n` this time. This equation can also be used to recursively\n define the `w_n`. Furthermore, every positive integer `n`\n satisfies\n\n .. MATH::\n\n p_n = \\sum_{d\\mid n} d w_d^{n/d},\n\n and this can be used to define the `w_n` recursively over any\n ring which is torsion-free as a `\\ZZ`-module. While these\n equations all yield easy formulas for classical bases of the\n ring of symmetric functions in terms of the Witt symmetric\n functions, it seems difficult to obtain explicit formulas in\n the other direction.\n\n The Witt symmetric functions owe their name to the fact that\n the ring of symmetric functions can be viewed as the coordinate\n ring of the group scheme of Witt vectors, and the Witt\n symmetric functions are the functions that send a Witt vector\n to its components (whereas the powersum symmetric functions\n send a Witt vector to its ghost components). Details can be\n found in [HazWitt1]_ or section 3.2 of [BorWi2004]_.\n\n INPUT:\n\n - ``Sym`` -- an instance of the ring of the symmetric functions.\n - ``coerce_h`` -- (default: ``True``) a boolean that determines\n whether the transition maps between the Witt basis and the\n complete homogeneous basis will be cached and registered as\n coercions.\n - ``coerce_e`` -- (default: ``False``) a boolean that determines\n whether the transition maps between the Witt basis and the\n elementary symmetric basis will be cached and registered as\n coercions.\n - ``coerce_p`` -- (default: ``False``) a boolean that determines\n whether the transition maps between the Witt basis and the\n powersum basis will be cached and registered as coercions (or\n conversions, if the base ring is not a `\\QQ`-algebra).\n\n REFERENCES:\n\n .. [HazWitt1] Michiel Hazewinkel. *Witt vectors. Part 1*.\n :arxiv:`0804.3888v1`\n\n .. [DoranIV1996] William F. Doran IV.\n *A Proof of Reutenauer's `-q_{(n)}` Conjecture*.\n Journal of combinatorial theory, Series A 74, pp. 342-344 (1996),\n article no. 0056. :doi:`10.1006/jcta.1996.0056`\n\n .. [BorWi2004] James Borger, Ben Wieland.\n *Plethystic algebra*.\n :arxiv:`math/0407227v1`\n\n .. [GriRei18]_\n\n EXAMPLES:\n\n Here are the first few Witt symmetric functions, in various bases::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: w = Sym.w()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n\n sage: p(w([1]))\n p[1]\n sage: m(w([1]))\n m[1]\n sage: e(w([1]))\n e[1]\n sage: h(w([1]))\n h[1]\n sage: s(w([1]))\n s[1]\n\n sage: p(w([2]))\n -1/2*p[1, 1] + 1/2*p[2]\n sage: m(w([2]))\n -m[1, 1]\n sage: e(w([2]))\n -e[2]\n sage: h(w([2]))\n -h[1, 1] + h[2]\n sage: s(w([2]))\n -s[1, 1]\n\n sage: p(w([3]))\n -1/3*p[1, 1, 1] + 1/3*p[3]\n sage: m(w([3]))\n -2*m[1, 1, 1] - m[2, 1]\n sage: e(w([3]))\n -e[2, 1] + e[3]\n sage: h(w([3]))\n -h[2, 1] + h[3]\n sage: s(w([3]))\n -s[2, 1]\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: w = Sym.w()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: p = Sym.p()\n sage: m(w([4]))\n -9*m[1, 1, 1, 1] - 4*m[2, 1, 1] - 2*m[2, 2] - m[3, 1]\n sage: e(w([4]))\n -e[2, 1, 1] + e[3, 1] - e[4]\n sage: h(w([4]))\n -h[1, 1, 1, 1] + 2*h[2, 1, 1] - h[2, 2] - h[3, 1] + h[4]\n sage: s(w([4]))\n -s[1, 1, 1, 1] - s[2, 1, 1] - s[2, 2] - s[3, 1]\n\n Some examples of conversions the other way::\n\n sage: w(h[3])\n w[1, 1, 1] + w[2, 1] + w[3]\n sage: w(e[3])\n -w[2, 1] + w[3]\n sage: w(m[2,1])\n 2*w[2, 1] - 3*w[3]\n sage: w(p[3])\n w[1, 1, 1] + 3*w[3]\n\n Antipodes::\n\n sage: w([1]).antipode()\n -w[1]\n sage: w([2]).antipode()\n -w[1, 1] - w[2]\n\n The following holds for all odd `i` and is easily proven by\n induction::\n\n sage: all( w([i]).antipode() == -w([i]) for i in range(1, 10, 2) )\n True\n\n The Witt basis does not allow for simple expressions for\n comultiplication and antipode in general (this is related to the\n fact that the sum of two Witt vectors isn't easily described in\n terms of the components). Therefore, most computations with Witt\n symmetric functions, as well as conversions and coercions, pass\n through the complete homogeneous symmetric functions by default.\n However, one can also use the elementary symmetric functions\n instead, or (if the base ring is a `\\QQ`-algebra) the powersum\n symmetric functions. This is what the optional keyword variables\n ``coerce_e``, ``coerce_h`` and ``coerce_p`` are for. These\n variables do not affect the results of the (non-underscored)\n methods of ``self``, but they affect the speed of the computations\n (the more of these variables are set to ``True``, the\n faster these are) and the size of the cache (the more of\n these variables are set to ``True``, the bigger the cache). Let us\n check that the results are the same no matter to what the\n variables are set::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p()\n sage: wh = Sym.w()\n sage: we = Sym.w(coerce_h=False, coerce_e=True)\n sage: wp = Sym.w(coerce_h=False, coerce_p=True)\n sage: all( p(wh(lam)) == p(we(lam)) == p(wp(lam)) for lam in Partitions(4) )\n True\n sage: all ( wh(p(lam)).monomial_coefficients()\n ....: == we(p(lam)).monomial_coefficients()\n ....: == wp(p(lam)).monomial_coefficients() for lam in Partitions(4) )\n True\n\n TESTS:\n\n Let us check that all the above computations work with a\n non-default setting as well::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: w = Sym.w(coerce_h=False, coerce_p=True)\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n\n sage: p(w([1]))\n p[1]\n sage: m(w([1]))\n m[1]\n sage: e(w([1]))\n e[1]\n sage: h(w([1]))\n h[1]\n sage: s(w([1]))\n s[1]\n\n sage: p(w([2]))\n -1/2*p[1, 1] + 1/2*p[2]\n sage: m(w([2]))\n -m[1, 1]\n sage: e(w([2]))\n -e[2]\n sage: h(w([2]))\n -h[1, 1] + h[2]\n sage: s(w([2]))\n -s[1, 1]\n\n sage: p(w([3]))\n -1/3*p[1, 1, 1] + 1/3*p[3]\n sage: m(w([3]))\n -2*m[1, 1, 1] - m[2, 1]\n sage: e(w([3]))\n -e[2, 1] + e[3]\n sage: h(w([3]))\n -h[2, 1] + h[3]\n sage: s(w([3]))\n -s[2, 1]\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: w = Sym.w()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: p = Sym.p()\n sage: m(w([4]))\n -9*m[1, 1, 1, 1] - 4*m[2, 1, 1] - 2*m[2, 2] - m[3, 1]\n sage: e(w([4]))\n -e[2, 1, 1] + e[3, 1] - e[4]\n sage: h(w([4]))\n -h[1, 1, 1, 1] + 2*h[2, 1, 1] - h[2, 2] - h[3, 1] + h[4]\n sage: s(w([4]))\n -s[1, 1, 1, 1] - s[2, 1, 1] - s[2, 2] - s[3, 1]\n\n sage: w(h[3])\n w[1, 1, 1] + w[2, 1] + w[3]\n sage: w(e[3])\n -w[2, 1] + w[3]\n sage: w(m[2,1])\n 2*w[2, 1] - 3*w[3]\n sage: w(p[3])\n w[1, 1, 1] + 3*w[3]\n\n sage: w([1]).antipode()\n -w[1]\n sage: w([2]).antipode()\n -w[1, 1] - w[2]\n sage: all( w([i]).antipode() == -w([i]) for i in range(1, 10, 2) )\n True\n\n Another non-default setting::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: w = Sym.w(coerce_h=False, coerce_e=True)\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: p = Sym.p()\n sage: s = Sym.s()\n sage: m = Sym.m()\n\n sage: p(w([1]))\n p[1]\n sage: m(w([1]))\n m[1]\n sage: e(w([1]))\n e[1]\n sage: h(w([1]))\n h[1]\n sage: s(w([1]))\n s[1]\n\n sage: p(w([2]))\n -1/2*p[1, 1] + 1/2*p[2]\n sage: m(w([2]))\n -m[1, 1]\n sage: e(w([2]))\n -e[2]\n sage: h(w([2]))\n -h[1, 1] + h[2]\n sage: s(w([2]))\n -s[1, 1]\n\n sage: p(w([3]))\n -1/3*p[1, 1, 1] + 1/3*p[3]\n sage: m(w([3]))\n -2*m[1, 1, 1] - m[2, 1]\n sage: e(w([3]))\n -e[2, 1] + e[3]\n sage: h(w([3]))\n -h[2, 1] + h[3]\n sage: s(w([3]))\n -s[2, 1]\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: w = Sym.w()\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: m = Sym.m()\n sage: p = Sym.p()\n sage: m(w([4]))\n -9*m[1, 1, 1, 1] - 4*m[2, 1, 1] - 2*m[2, 2] - m[3, 1]\n sage: e(w([4]))\n -e[2, 1, 1] + e[3, 1] - e[4]\n sage: h(w([4]))\n -h[1, 1, 1, 1] + 2*h[2, 1, 1] - h[2, 2] - h[3, 1] + h[4]\n sage: s(w([4]))\n -s[1, 1, 1, 1] - s[2, 1, 1] - s[2, 2] - s[3, 1]\n sage: [type(coeff) for a, coeff in h(w([4]))]\n [<class 'sage.rings.integer.Integer'>,\n <class 'sage.rings.integer.Integer'>,\n <class 'sage.rings.integer.Integer'>,\n <class 'sage.rings.integer.Integer'>,\n <class 'sage.rings.integer.Integer'>]\n\n sage: w(h[3])\n w[1, 1, 1] + w[2, 1] + w[3]\n sage: w(e[3])\n -w[2, 1] + w[3]\n sage: w(m[2,1])\n 2*w[2, 1] - 3*w[3]\n sage: w(p[3])\n w[1, 1, 1] + 3*w[3]\n\n sage: w([1]).antipode()\n -w[1]\n sage: w([2]).antipode()\n -w[1, 1] - w[2]\n sage: all( w([i]).antipode() == -w([i]) for i in range(1, 10, 2) )\n ....: #this holds for all odd i and is easily proven by induction\n True\n "
def __init__(self, Sym, coerce_h=True, coerce_e=False, coerce_p=False):
"\n Initialize ``self``.\n\n TESTS::\n\n sage: w = SymmetricFunctions(QQ).w()\n sage: TestSuite(w).run(skip=['_test_associativity', '_test_distributivity', '_test_prod'])\n sage: TestSuite(w).run(elements = [w[1,1]+w[2], w[1]+2*w[1,1]])\n "
self._coerce_h = coerce_h
self._coerce_e = coerce_e
self._coerce_p = coerce_p
multiplicative.SymmetricFunctionAlgebra_multiplicative.__init__(self, Sym, 'Witt', 'w')
def _precompute_cache(self, n, to_self_cache, from_self_cache, transition_matrices, inverse_transition_matrices, to_self_gen_function):
'\n Compute the transition matrices between ``self`` and another\n multiplicative homogeneous basis in the homogeneous components of\n degree `n`.\n\n The results are not returned, but rather stored in the caches.\n\n This assumes that the transition matrices in all degrees smaller\n than `n` have already been computed and cached!\n\n INPUT:\n\n - ``n`` -- nonnegative integer\n - ``to_self_cache`` -- a cache which stores the coordinates of\n the elements of the other basis with respect to the\n basis ``self``\n - ``from_self_cache`` -- a cache which stores the coordinates\n of the elements of ``self`` with respect to the other\n basis\n - ``transition_matrices`` -- a cache for transition matrices\n which contain the coordinates of the elements of the other\n basis with respect to ``self``\n - ``inverse_transition_matrices`` -- a cache for transition\n matrices which contain the coordinates of the elements of\n ``self`` with respect to the other basis\n - ``to_self_gen_function`` -- a function which takes a\n positive integer `n` and returns the element of the other\n basis corresponding to the partition `[n]` expanded with\n respect to the Witt basis ``self`` (as an element of\n ``self``, not as a dictionary)\n\n Examples for usage of this function are the ``_precompute_h``,\n ``_precompute_e`` and ``_precompute_p`` methods of this class.\n\n EXAMPLES:\n\n The examples below demonstrate how the caches are built\n step by step using the ``_precompute_cache`` method. In order\n not to influence the outcome of other doctests, we make sure\n not to use the caches internally used by this class, but\n rather to create new caches::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: w = Sym.w()\n sage: toy_to_self_cache = {}\n sage: toy_from_self_cache = {}\n sage: toy_transition_matrices = {}\n sage: toy_inverse_transition_matrices = {}\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(toy_to_self_cache)\n []\n sage: def toy_gen_function(n):\n ....: if n > 1:\n ....: return w(Partition([n])) + n * w(Partition([n-1,1]))\n ....: return w(Partition([n]))\n sage: w._precompute_cache(0, toy_to_self_cache,\n ....: toy_from_self_cache,\n ....: toy_transition_matrices,\n ....: toy_inverse_transition_matrices,\n ....: toy_gen_function)\n sage: l(toy_to_self_cache)\n [([], [([], 1)])]\n sage: w._precompute_cache(1, toy_to_self_cache,\n ....: toy_from_self_cache,\n ....: toy_transition_matrices,\n ....: toy_inverse_transition_matrices,\n ....: toy_gen_function)\n sage: l(toy_to_self_cache)\n [([], [([], 1)]), ([1], [([1], 1)])]\n sage: w._precompute_cache(2, toy_to_self_cache,\n ....: toy_from_self_cache,\n ....: toy_transition_matrices,\n ....: toy_inverse_transition_matrices,\n ....: toy_gen_function)\n sage: l(toy_to_self_cache)\n [([], [([], 1)]),\n ([1], [([1], 1)]),\n ([1, 1], [([1, 1], 1)]),\n ([2], [([1, 1], 2), ([2], 1)])]\n sage: toy_transition_matrices[2]\n [1 2]\n [0 1]\n sage: toy_inverse_transition_matrices[2]\n [ 1 -2]\n [ 0 1]\n sage: sorted(toy_transition_matrices)\n [0, 1, 2]\n '
base_ring = self.base_ring()
zero = base_ring.zero()
from sage.combinat.partition import Partition, Partitions_n
if (n == 0):
part = Partition([])
one = base_ring.one()
to_self_cache[part] = {part: one}
from_self_cache[part] = {part: one}
transition_matrices[n] = matrix(base_ring, [[one]])
inverse_transition_matrices[n] = matrix(base_ring, [[one]])
return
partitions_n = Partitions_n(n).list()
transition_matrix_n = matrix(base_ring, len(partitions_n), len(partitions_n))
i = 0
for s_part in partitions_n:
s_mcs = {}
hsp_in_w_basis = self.one()
for p in s_part:
hsp_in_w_basis *= to_self_gen_function(p)
j = 0
for p_part in partitions_n:
if (p_part in hsp_in_w_basis._monomial_coefficients):
sp = hsp_in_w_basis._monomial_coefficients[p_part]
s_mcs[p_part] = sp
transition_matrix_n[(i, j)] = sp
j += 1
to_self_cache[s_part] = s_mcs
i += 1
transition_matrices[n] = transition_matrix_n
inverse_transition = (~ transition_matrix_n).change_ring(base_ring)
for i in range(len(partitions_n)):
d_mcs = {}
for j in range(len(partitions_n)):
if (inverse_transition[(i, j)] != zero):
d_mcs[partitions_n[j]] = inverse_transition[(i, j)]
from_self_cache[partitions_n[i]] = d_mcs
inverse_transition_matrices[n] = inverse_transition
def _precompute_h(self, n):
"\n Compute the transition matrices between ``self`` and the complete\n homogeneous basis in the homogeneous components of degree `n`\n (and in those of smaller degree, if not already computed).\n The result is not returned, but rather stored in the cache.\n\n This assumes that the ``coerce_h`` keyword has been set to\n ``True`` in the initialization of ``self`` (otherwise the cache\n does not exist).\n\n INPUT:\n\n - ``n`` -- nonnegative integer\n\n EXAMPLES:\n\n The examples below demonstrate how the caches of ``w`` are built\n step by step using the ``_precompute_h`` method. Thus they rely on\n an untouched Witt symmetric basis that hasn't already seen some\n of its cache filled by other computations. We obtain such a basis\n by choosing a ground ring unlikely to appear elsewhere::\n\n sage: Sym = SymmetricFunctions(ZZ['hell', 'yeah'])\n sage: w = Sym.Witt()\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(w._h_to_self_cache)\n []\n sage: w._precompute_h(0)\n sage: l(w._h_to_self_cache)\n [([], [([], 1)])]\n sage: w._precompute_h(1)\n sage: l(w._h_to_self_cache)\n [([], [([], 1)]), ([1], [([1], 1)])]\n sage: w._precompute_h(2)\n sage: l(w._h_to_self_cache)\n [([], [([], 1)]),\n ([1], [([1], 1)]),\n ([1, 1], [([1, 1], 1)]),\n ([2], [([1, 1], 1), ([2], 1)])]\n sage: w._h_transition_matrices[2]\n [1 1]\n [0 1]\n sage: w._h_inverse_transition_matrices[2]\n [ 1 -1]\n [ 0 1]\n sage: sorted(w._h_transition_matrices)\n [0, 1, 2]\n "
l = len(self._h_transition_matrices)
if (l <= n):
from sage.combinat.partition import Partitions_n
from sage.misc.cachefunc import cached_function
@cached_function
def wsum(m):
return self._from_dict({lam: 1 for lam in Partitions_n(m)})
for i in range(l, (n + 1)):
self._precompute_cache(i, self._h_to_self_cache, self._h_from_self_cache, self._h_transition_matrices, self._h_inverse_transition_matrices, wsum)
def _precompute_e(self, n):
"\n Compute the transition matrices between ``self`` and the elementary\n symmetric basis in the homogeneous components of degree `n`\n (and in those of smaller degree, if not already computed).\n The result is not returned, but rather stored in the cache.\n\n This assumes that the ``coerce_e`` keyword has been set to\n ``True`` in the initialization of ``self`` (otherwise the cache\n does not exist).\n\n INPUT:\n\n - ``n`` -- nonnegative integer\n\n EXAMPLES:\n\n The examples below demonstrate how the caches of ``w`` are built\n step by step using the ``_precompute_e`` method. Thus they rely on\n an untouched Witt symmetric basis that hasn't already seen some\n of its cache filled by other computations. We obtain such a basis\n by choosing a ground ring unlikely to appear elsewhere::\n\n sage: Sym = SymmetricFunctions(ZZ['hell', 'yeah'])\n sage: w = Sym.Witt(coerce_e=True)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(w._e_to_self_cache)\n []\n sage: w._precompute_e(0)\n sage: l(w._e_to_self_cache)\n [([], [([], 1)])]\n sage: w._precompute_e(1)\n sage: l(w._e_to_self_cache)\n [([], [([], 1)]), ([1], [([1], 1)])]\n sage: w._precompute_e(2)\n sage: l(w._e_to_self_cache)\n [([], [([], 1)]),\n ([1], [([1], 1)]),\n ([1, 1], [([1, 1], 1)]),\n ([2], [([2], -1)])]\n sage: w._e_transition_matrices[2]\n [-1 0]\n [ 0 1]\n sage: w._e_inverse_transition_matrices[2]\n [-1 0]\n [ 0 1]\n "
l = len(self._e_transition_matrices)
if (l <= n):
from sage.combinat.partition import Partitions
from sage.misc.cachefunc import cached_function
@cached_function
def wsum_e(m):
return self._from_dict({lam: ((- 1) if (((m + len(lam)) % 2) == 1) else 1) for lam in Partitions(m, max_slope=(- 1))})
for i in range(l, (n + 1)):
self._precompute_cache(i, self._e_to_self_cache, self._e_from_self_cache, self._e_transition_matrices, self._e_inverse_transition_matrices, wsum_e)
def _precompute_p(self, n):
"\n Compute the transition matrices between ``self`` and the powersum\n basis in the homogeneous components of degree `n`\n (and in those of smaller degree, if not already computed).\n The result is not returned, but rather stored in the cache.\n\n This assumes that the ``coerce_p`` keyword has been set to\n ``True`` in the initialization of ``self`` (otherwise the cache\n does not exist).\n\n INPUT:\n\n - ``n`` -- nonnegative integer\n\n EXAMPLES:\n\n The examples below demonstrate how the caches of ``w`` are built\n step by step using the ``_precompute_p`` method. Thus they rely on\n an untouched Witt symmetric basis that hasn't already seen some\n of its cache filled by other computations. We obtain such a basis\n by choosing a ground ring unlikely to appear elsewhere::\n\n sage: Sym = SymmetricFunctions(QQ['hell', 'yeah'])\n sage: w = Sym.Witt(coerce_h=False, coerce_e=True, coerce_p=True)\n sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]\n sage: l(w._p_to_self_cache)\n []\n sage: w._precompute_p(0)\n sage: l(w._p_to_self_cache)\n [([], [([], 1)])]\n sage: w._precompute_p(1)\n sage: l(w._p_to_self_cache)\n [([], [([], 1)]), ([1], [([1], 1)])]\n sage: w._precompute_p(2)\n sage: l(w._p_to_self_cache)\n [([], [([], 1)]), ([1], [([1], 1)]), ([1, 1], [([1, 1], 1)]), ([2], [([1, 1], 1), ([2], 2)])]\n sage: w._p_transition_matrices[2]\n [2 1]\n [0 1]\n sage: w._p_inverse_transition_matrices[2]\n [ 1/2 -1/2]\n [ 0 1]\n "
l = len(self._p_transition_matrices)
if (l <= n):
from sage.arith.misc import divisors
from sage.combinat.partition import Partition
from sage.misc.cachefunc import cached_function
@cached_function
def wsum_p(m):
return self._from_dict({Partition(([d] * (m // d))): d for d in divisors(m)})
for i in range(l, (n + 1)):
self._precompute_cache(i, self._p_to_self_cache, self._p_from_self_cache, self._p_transition_matrices, self._p_inverse_transition_matrices, wsum_p)
def _h_to_w_on_basis(self, lam):
'\n Return the complete homogeneous symmetric function ``h[lam]``\n expanded in the Witt basis, where ``lam`` is a partition.\n\n This assumes that the ``coerce_h`` keyword has been set to ``True`` in\n the initialization of ``self`` (otherwise the cache does not exist).\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``h[lam]`` in the Witt basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: h = Sym.homogeneous()\n sage: w = Sym.w()\n sage: w._h_to_w_on_basis(Partition([]))\n w[]\n sage: w._h_to_w_on_basis(Partition([4,2,1]))\n w[1, 1, 1, 1, 1, 1, 1] + 2*w[2, 1, 1, 1, 1, 1] + 2*w[2, 2, 1, 1, 1] + w[2, 2, 2, 1] + w[3, 1, 1, 1, 1] + w[3, 2, 1, 1] + w[4, 1, 1, 1] + w[4, 2, 1]\n sage: h(w._h_to_w_on_basis(Partition([3,1]))) == h[3,1]\n True\n '
n = sum(lam)
self._precompute_h(n)
return self._from_dict(self._h_to_self_cache[lam])
def _w_to_h_on_basis(self, lam):
'\n Return the Witt symmetric function ``w[lam]`` expanded in the\n complete homogeneous basis, where ``lam`` is a partition.\n\n This assumes that the ``coerce_h`` keyword has been set to ``True`` in\n the initialization of ``self`` (otherwise the cache does not exist).\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``w[lam]`` in the complete\n homogeneous basis of ``self.realization_of()``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: h = Sym.homogeneous()\n sage: w = Sym.w()\n sage: w._w_to_h_on_basis(Partition([]))\n h[]\n sage: w._w_to_h_on_basis(Partition([4,2,1]))\n h[1, 1, 1, 1, 1, 1, 1] - 3*h[2, 1, 1, 1, 1, 1] + 3*h[2, 2, 1, 1, 1] - h[2, 2, 2, 1] + h[3, 1, 1, 1, 1] - h[3, 2, 1, 1] - h[4, 1, 1, 1] + h[4, 2, 1]\n sage: w(w._w_to_h_on_basis(Partition([3,1]))) == w[3,1]\n True\n '
n = sum(lam)
self._precompute_h(n)
return self._h._from_dict(self._h_from_self_cache[lam])
def _e_to_w_on_basis(self, lam):
'\n Return the elementary symmetric function ``e[lam]`` expanded in\n the Witt basis, where ``lam`` is a partition.\n\n This assumes that the ``coerce_e`` keyword has been set to ``True`` in\n the initialization of ``self`` (otherwise the cache does not exist).\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``e[lam]`` in the Witt basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: e = Sym.elementary()\n sage: w = Sym.w(coerce_e=True)\n sage: w._e_to_w_on_basis(Partition([]))\n w[]\n sage: w._e_to_w_on_basis(Partition([4,2,1]))\n -w[3, 2, 1, 1] + w[4, 2, 1]\n sage: e(w._e_to_w_on_basis(Partition([3,1]))) == e[3,1]\n True\n '
n = sum(lam)
self._precompute_e(n)
return self._from_dict(self._e_to_self_cache[lam])
def _w_to_e_on_basis(self, lam):
'\n Return the Witt symmetric function ``w[lam]``\n expanded in the elementary symmetric basis, where\n ``lam`` is a partition.\n\n This assumes that the ``coerce_e`` keyword has been set to ``True`` in\n the initialization of ``self`` (otherwise the cache does not exist).\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``w[lam]`` in the elementary\n symmetric basis of ``self.realization_of()``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: e = Sym.elementary()\n sage: w = Sym.w(coerce_e=True)\n sage: w._w_to_e_on_basis(Partition([]))\n e[]\n sage: w._w_to_e_on_basis(Partition([4,2,1]))\n e[2, 2, 1, 1, 1] - e[3, 2, 1, 1] + e[4, 2, 1]\n sage: w(w._w_to_e_on_basis(Partition([3,1]))) == w[3,1]\n True\n '
n = sum(lam)
self._precompute_e(n)
return self._e._from_dict(self._e_from_self_cache[lam])
def _p_to_w_on_basis(self, lam):
'\n Return the powersum symmetric function ``p[lam]`` expanded in\n the Witt basis, where ``lam`` is a partition.\n\n This assumes that the ``coerce_p`` keyword has been set to ``True`` in\n the initialization of ``self`` (otherwise the cache does not exist).\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``p[lam]`` in the Witt basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.power()\n sage: w = Sym.w(coerce_p=True)\n sage: w._p_to_w_on_basis(Partition([]))\n w[]\n sage: w._p_to_w_on_basis(Partition([4,2,1]))\n w[1, 1, 1, 1, 1, 1, 1] + 2*w[2, 1, 1, 1, 1, 1] + 2*w[2, 2, 1, 1, 1] + 4*w[2, 2, 2, 1] + 4*w[4, 1, 1, 1] + 8*w[4, 2, 1]\n sage: p(w._p_to_w_on_basis(Partition([3,1]))) == p[3,1]\n True\n '
n = sum(lam)
self._precompute_p(n)
return self._from_dict(self._p_to_self_cache[lam])
def _w_to_p_on_basis(self, lam):
'\n Return the Witt symmetric function ``w[lam]`` expanded in the\n powersum basis, where ``lam`` is a partition.\n\n This assumes that the ``coerce_p`` keyword has been set to ``True`` in\n the initialization of ``self`` (otherwise the cache does not exist).\n\n INPUT:\n\n - ``lam`` -- a partition\n\n OUTPUT:\n\n - the expansion of ``w[lam]`` in the powersum\n basis of ``self.realization_of()``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.power()\n sage: w = Sym.w(coerce_p=True)\n sage: w._w_to_p_on_basis(Partition([]))\n p[]\n sage: w._w_to_p_on_basis(Partition([4,2,1]))\n 3/16*p[1, 1, 1, 1, 1, 1, 1] - 5/16*p[2, 1, 1, 1, 1, 1] + 3/16*p[2, 2, 1, 1, 1] - 1/16*p[2, 2, 2, 1] - 1/8*p[4, 1, 1, 1] + 1/8*p[4, 2, 1]\n sage: w(w._w_to_p_on_basis(Partition([3,1]))) == w[3,1]\n True\n '
n = sum(lam)
self._precompute_p(n)
return self._p._from_dict(self._p_from_self_cache[lam])
def __init_extra__(self):
'\n Sets up caches for the transition maps to other bases, and registers\n them as coercions.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ) # indirect doctest\n sage: h = Sym.h(); w = Sym.w()\n\n sage: phi = h.coerce_map_from(w); phi\n Generic morphism:\n From: Symmetric Functions over Rational Field in the Witt basis\n To: Symmetric Functions over Rational Field in the homogeneous basis\n sage: phi(w.an_element()) == h(w.an_element())\n True\n sage: e = Sym.e(); w2 = Sym.w(coerce_e=True)\n sage: psi = e.coerce_map_from(w2); psi\n Generic morphism:\n From: Symmetric Functions over Rational Field in the Witt basis\n To: Symmetric Functions over Rational Field in the elementary basis\n sage: psi(w2.an_element()) == e(w2.an_element())\n True\n '
self._friendly = None
if self._coerce_p:
self._p = self.realization_of().p()
self._p_to_self_cache = {}
self._p_from_self_cache = {}
self._p_transition_matrices = {}
self._p_inverse_transition_matrices = {}
self.register_coercion(self._p._module_morphism(self._p_to_w_on_basis, codomain=self))
from sage.rings.rational_field import RationalField
if self.base_ring().has_coerce_map_from(RationalField):
self._p.register_coercion(self._module_morphism(self._w_to_p_on_basis, codomain=self._p))
self._friendly = self._p
else:
self._p.register_conversion(self._module_morphism(self._w_to_p_on_basis, codomain=self._p))
if ((not self._coerce_e) and (not self._coerce_h)):
self._coerce_h = True
elif ((not self._coerce_e) and (not self._coerce_h)):
self._coerce_h = True
if self._coerce_h:
self._h = self.realization_of().h()
self._h_to_self_cache = {}
self._h_from_self_cache = {}
self._h_transition_matrices = {}
self._h_inverse_transition_matrices = {}
self.register_coercion(self._h._module_morphism(self._h_to_w_on_basis, codomain=self))
self._h.register_coercion(self._module_morphism(self._w_to_h_on_basis, codomain=self._h))
if (self._friendly is None):
self._friendly = self._h
if self._coerce_e:
self._e = self.realization_of().e()
self._e_to_self_cache = {}
self._e_from_self_cache = {}
self._e_transition_matrices = {}
self._e_inverse_transition_matrices = {}
self.register_coercion(self._e._module_morphism(self._e_to_w_on_basis, codomain=self))
self._e.register_coercion(self._module_morphism(self._w_to_e_on_basis, codomain=self._e))
if (self._friendly is None):
self._friendly = self._e
def from_other_uncached(self, u):
"\n Return an element ``u`` of another basis of the ring of\n symmetric functions, expanded in the Witt basis ``self``.\n The result is the same as ``self(u)``, but the\n ``from_other_uncached`` method does not precompute a\n cache with transition matrices. Thus,\n ``from_other_uncached`` is faster when ``u`` is sparse.\n\n INPUT:\n\n - ``u`` -- an element of ``self.realization_of()``\n\n OUTPUT:\n\n - the expansion of ``u`` in the Witt basis ``self``\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: p = Sym.p()\n sage: w = Sym.w()\n sage: a = p([3,2]) - p([4,1]) + 27 * p([3])\n sage: w.from_other_uncached(a) == w(a)\n True\n\n Here's a verification of an obvious fact that would take\n long with regular coercion::\n\n sage: fouc = w.from_other_uncached\n sage: fouc(p([15]))\n w[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + 3*w[3, 3, 3, 3, 3] + 5*w[5, 5, 5] + 15*w[15]\n sage: fouc(p([15])) * fouc(p([14])) == fouc(p([15, 14]))\n True\n\n Other bases::\n\n sage: e = Sym.e()\n sage: h = Sym.h()\n sage: s = Sym.s()\n sage: all( fouc(e(lam)) == w(e(lam)) for lam in Partitions(5) )\n True\n sage: all( fouc(h(lam)) == w(h(lam)) for lam in Partitions(5) )\n True\n sage: all( fouc(p(lam)) == w(p(lam)) for lam in Partitions(5) )\n True\n sage: all( fouc(s(lam)) == w(s(lam)) for lam in Partitions(5) )\n True\n "
parent_name = u.parent().basis_name()
from sage.misc.cachefunc import cached_function
if (parent_name == 'homogeneous'):
from sage.combinat.partition import Partitions_n
@cached_function
def wsum(m):
return self._from_dict({lam: 1 for lam in Partitions_n(m)})
result = self.zero()
for (lam, a) in u.monomial_coefficients().items():
product = self.one()
for i in lam:
product *= wsum(i)
result += (a * product)
return result
if (parent_name == 'powersum'):
from sage.arith.misc import divisors
from sage.combinat.partition import Partition
@cached_function
def wsum_p(m):
return self._from_dict({Partition(([d] * (m // d))): d for d in divisors(m)})
result = self.zero()
for (lam, a) in u.monomial_coefficients().items():
product = self.one()
for i in lam:
product *= wsum_p(i)
result += (a * product)
return result
if (parent_name != 'elementary'):
u = u.parent().realization_of().elementary()(u)
from sage.combinat.partition import Partitions
@cached_function
def wsum_e(m):
return self._from_dict({lam: ((- 1) if ((m + len(lam)) % 2) else 1) for lam in Partitions(m, max_slope=(- 1))})
result = self.zero()
for (lam, a) in u.monomial_coefficients().items():
product = self.one()
for i in lam:
product *= wsum_e(i)
result += (a * product)
return result
def coproduct(self, elt):
'\n Return the coproduct of the element ``elt``.\n\n INPUT:\n\n - ``elt`` -- a symmetric function written in this basis\n\n OUTPUT:\n\n - The coproduct acting on ``elt``; the result is an element of the\n tensor squared of the basis ``self``\n\n EXAMPLES::\n\n sage: w = SymmetricFunctions(QQ).w()\n sage: w[2].coproduct()\n w[] # w[2] - w[1] # w[1] + w[2] # w[]\n sage: w.coproduct(w[2])\n w[] # w[2] - w[1] # w[1] + w[2] # w[]\n sage: w[2,1].coproduct()\n w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]\n sage: w.coproduct(w[2,1])\n w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]\n\n TESTS:\n\n The same, but with other settings::\n\n sage: w = SymmetricFunctions(QQ).w(coerce_h=False, coerce_e=True)\n sage: w[2].coproduct()\n w[] # w[2] - w[1] # w[1] + w[2] # w[]\n sage: w.coproduct(w[2])\n w[] # w[2] - w[1] # w[1] + w[2] # w[]\n sage: w[2,1].coproduct()\n w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]\n sage: w.coproduct(w[2,1])\n w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]\n\n sage: w = SymmetricFunctions(QQ).w(coerce_h=False, coerce_p=True)\n sage: w[2].coproduct()\n w[] # w[2] - w[1] # w[1] + w[2] # w[]\n sage: w.coproduct(w[2])\n w[] # w[2] - w[1] # w[1] + w[2] # w[]\n sage: w[2,1].coproduct()\n w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]\n sage: w.coproduct(w[2,1])\n w[] # w[2, 1] - w[1] # w[1, 1] + w[1] # w[2] - w[1, 1] # w[1] + w[2] # w[1] + w[2, 1] # w[]\n '
from sage.categories.tensor import tensor
friendly = self._friendly
return self.tensor_square().sum(((coeff * tensor([self(friendly[x]), self(friendly[y])])) for ((x, y), coeff) in friendly(elt).coproduct()))
def verschiebung(self, n):
'\n Return the image of the symmetric function ``self`` under the\n `n`-th Verschiebung operator.\n\n The `n`-th Verschiebung operator `\\mathbf{V}_n` is defined to be\n the unique algebra endomorphism `V` of the ring of symmetric\n functions that satisfies `V(h_r) = h_{r/n}` for every positive\n integer `r` divisible by `n`, and satisfies `V(h_r) = 0` for\n every positive integer `r` not divisible by `n`. This operator\n `\\mathbf{V}_n` is a Hopf algebra endomorphism. For every\n nonnegative integer `r` with `n \\mid r`, it satisfies\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = h_{r/n},\n \\quad \\mathbf{V}_n(p_r) = n p_{r/n},\n \\quad \\mathbf{V}_n(e_r) = (-1)^{r - r/n} e_{r/n},\n \\quad \\mathbf{V}_n(w_r) = w_{r/n},\n\n (where `h` is the complete homogeneous basis, `p` is the\n powersum basis, `e` is the elementary basis, and `w` is the\n Witt basis). For every nonnegative integer `r` with `n \\nmid r`,\n it satisfes\n\n .. MATH::\n\n \\mathbf{V}_n(h_r) = \\mathbf{V}_n(p_r) = \\mathbf{V}_n(e_r)\n = \\mathbf{V}_n(w_r) = 0.\n\n The `n`-th Verschiebung operator is also called the `n`-th\n Verschiebung endomorphism. Its name derives from the Verschiebung\n (German for "shift") endomorphism of the Witt vectors.\n\n The `n`-th Verschiebung operator is adjoint to the `n`-th\n Frobenius operator (see :meth:`frobenius` for its definition)\n with respect to the Hall scalar product (:meth:`scalar`).\n\n The action of the `n`-th Verschiebung operator on the Schur basis\n can also be computed explicitly. The following (probably clumsier\n than necessary) description can be obtained by solving exercise\n 7.61 in Stanley\'s [STA]_.\n\n Let `\\lambda` be a partition. Let `n` be a positive integer. If\n the `n`-core of `\\lambda` is nonempty, then\n `\\mathbf{V}_n(s_\\lambda) = 0`. Otherwise, the following method\n computes `\\mathbf{V}_n(s_\\lambda)`: Write the partition `\\lambda`\n in the form `(\\lambda_1, \\lambda_2, \\ldots, \\lambda_{ns})` for some\n nonnegative integer `s`. (If `n` does not divide the length of\n `\\lambda`, then this is achieved by adding trailing zeroes to\n `\\lambda`.) Set `\\beta_i = \\lambda_i + ns - i` for every\n `s \\in \\{ 1, 2, \\ldots, ns \\}`. Then,\n `(\\beta_1, \\beta_2, \\ldots, \\beta_{ns})` is a strictly decreasing\n sequence of nonnegative integers. Stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `-1 - \\beta_i` modulo `n`. Let `\\xi` be the sign of the\n permutation that is used for this sorting. Let `\\psi` be the sign\n of the permutation that is used to stably sort the list\n `(1, 2, \\ldots, ns)` in order of (weakly) increasing remainder of\n `i - 1` modulo `n`. (Notice that `\\psi = (-1)^{n(n-1)s(s-1)/4}`.)\n Then, `\\mathbf{V}_n(s_\\lambda) = \\xi \\psi \\prod_{i = 0}^{n - 1}\n s_{\\lambda^{(i)}}`, where\n `(\\lambda^{(0)}, \\lambda^{(1)}, \\ldots, \\lambda^{(n - 1)})`\n is the `n`-quotient of `\\lambda`.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n The result of applying the `n`-th Verschiebung operator (on the ring of\n symmetric functions) to ``self``.\n\n EXAMPLES::\n\n sage: Sym = SymmetricFunctions(ZZ)\n sage: w = Sym.w()\n sage: w[3].verschiebung(2)\n 0\n sage: w[4].verschiebung(4)\n w[1]\n\n TESTS:\n\n Let us check that this method on the Witt basis gives the\n same result as the implementation in sfa.py on the complete\n homogeneous basis::\n\n sage: Sym = SymmetricFunctions(QQ)\n sage: w = Sym.w(); h = Sym.h()\n sage: all( w(h(lam)).verschiebung(3) == w(h(lam).verschiebung(3))\n ....: for lam in Partitions(6) )\n True\n sage: all( h(w(lam)).verschiebung(2) == h(w(lam).verschiebung(2))\n ....: for lam in Partitions(4) )\n True\n '
parent = self.parent()
w_coords_of_self = self.monomial_coefficients().items()
from sage.combinat.partition import Partition
dct = {Partition([(i // n) for i in lam]): coeff for (lam, coeff) in w_coords_of_self if all((((i % n) == 0) for i in lam))}
result_in_w_basis = parent._from_dict(dct)
return result_in_w_basis
|
class ShardPosetElement(tuple):
'\n An element of the shard poset.\n\n This is basically a permutation with extra stored arguments:\n\n - ``p`` -- the permutation itself as a tuple\n - ``runs`` -- the decreasing runs as a tuple of tuples\n - ``run_indices`` -- a list ``integer -> index of the run``\n - ``dpg`` -- the transitive closure of the shard preorder graph\n - ``spg`` -- the transitive reduction of the shard preorder graph\n\n These elements can easily be converted from and to permutations::\n\n sage: from sage.combinat.shard_order import ShardPosetElement\n sage: p0 = Permutation([1,3,4,2])\n sage: e0 = ShardPosetElement(p0); e0\n (1, 3, 4, 2)\n sage: Permutation(list(e0)) == p0\n True\n '
def __new__(cls, p):
'\n Initialization of the underlying tuple\n\n TESTS::\n\n sage: from sage.combinat.shard_order import ShardPosetElement\n sage: ShardPosetElement(Permutation([1,3,4,2]))\n (1, 3, 4, 2)\n '
return tuple.__new__(cls, p)
def __init__(self, p):
'\n INPUT:\n\n - ``p`` - a permutation\n\n EXAMPLES::\n\n sage: from sage.combinat.shard_order import ShardPosetElement\n sage: p0 = Permutation([1,3,4,2])\n sage: e0 = ShardPosetElement(p0); e0\n (1, 3, 4, 2)\n sage: e0.dpg\n Transitive closure of : Digraph on 3 vertices\n sage: e0.spg\n Digraph on 3 vertices\n '
self.runs = p.decreasing_runs(as_tuple=True)
self.run_indices = ([None] * (len(p) + 1))
for (i, bloc) in enumerate(self.runs):
for j in bloc:
self.run_indices[j] = i
G = shard_preorder_graph(self.runs)
self.dpg = G.transitive_closure()
self.spg = G.transitive_reduction()
def __le__(self, other):
'\n Comparison between two elements of the poset.\n\n This is the core function in the implementation of the\n shard intersection order.\n\n One first compares the number of runs, then the set partitions,\n then the pre-orders.\n\n EXAMPLES::\n\n sage: from sage.combinat.shard_order import ShardPosetElement\n sage: p0 = Permutation([1,3,4,2])\n sage: p1 = Permutation([1,4,3,2])\n sage: e0 = ShardPosetElement(p0)\n sage: e1 = ShardPosetElement(p1)\n sage: e0 <= e1\n True\n sage: e1 <= e0\n False\n\n sage: p0 = Permutation([1,2,5,7,3,4,6,8])\n sage: p1 = Permutation([2,5,7,3,4,8,6,1])\n sage: e0 = ShardPosetElement(p0)\n sage: e1 = ShardPosetElement(p1)\n sage: e0 <= e1\n True\n sage: e1 <= e0\n False\n '
if ((type(self) is not type(other)) or (len(self) != len(other))):
raise TypeError('these are not comparable')
if (self.runs == other.runs):
return True
if (len(other.runs) > len(self.runs)):
return False
dico1 = other.run_indices
dico0 = ([None] * len(self.runs))
for (i, bloc) in enumerate(self.runs):
j0 = dico1[bloc[0]]
for k in bloc:
if (dico1[k] != j0):
return False
dico0[i] = j0
dg0 = self.spg
dg1 = other.dpg
for (i, j) in dg0.edge_iterator(labels=False):
if ((dico0[i] != dico0[j]) and (not dg1.has_edge(dico0[i], dico0[j]))):
return False
return True
|
def shard_preorder_graph(runs):
'\n Return the preorder attached to a tuple of decreasing runs.\n\n This is a directed graph, whose vertices correspond to the runs.\n\n There is an edge from a run `R` to a run `S` if `R` is before `S`\n in the list of runs and the two intervals defined by the initial and\n final indices of `R` and `S` overlap.\n\n This only depends on the initial and final indices of the runs.\n For this reason, this input can also be given in that shorten way.\n\n INPUT:\n\n - a tuple of tuples, the runs of a permutation, or\n\n - a tuple of pairs `(i,j)`, each one standing for a run from `i` to `j`.\n\n OUTPUT:\n\n a directed graph, with vertices labelled by integers\n\n EXAMPLES::\n\n sage: from sage.combinat.shard_order import shard_preorder_graph\n sage: s = Permutation([2,8,3,9,6,4,5,1,7])\n sage: def cut(lr):\n ....: return tuple((r[0], r[-1]) for r in lr)\n sage: shard_preorder_graph(cut(s.decreasing_runs()))\n Digraph on 5 vertices\n sage: s = Permutation([9,4,3,2,8,6,5,1,7])\n sage: P = shard_preorder_graph(s.decreasing_runs())\n sage: P.is_isomorphic(digraphs.TransitiveTournament(3))\n True\n '
N = len(runs)
dg = DiGraph(N)
dg.add_edges(((i, j) for i in range((N - 1)) for j in range((i + 1), N) if ((runs[i][(- 1)] < runs[j][0]) and (runs[j][(- 1)] < runs[i][0]))))
return dg
|
def shard_poset(n):
'\n Return the shard intersection order on permutations of size `n`.\n\n This is defined on the set of permutations. To every permutation,\n one can attach a pre-order, using the descending runs and their\n relative positions.\n\n The shard intersection order is given by the implication (or refinement)\n order on the set of pre-orders defined from all permutations.\n\n This can also be seen in a geometrical way. Every pre-order defines\n a cone in a vector space of dimension `n`. The shard poset is given by\n the inclusion of these cones.\n\n .. SEEALSO::\n\n :func:`~sage.combinat.shard_order.shard_preorder_graph`\n\n EXAMPLES::\n\n sage: P = posets.ShardPoset(4); P # indirect doctest\n Finite poset containing 24 elements\n sage: P.chain_polynomial()\n 34*q^4 + 90*q^3 + 79*q^2 + 24*q + 1\n sage: P.characteristic_polynomial()\n q^3 - 11*q^2 + 23*q - 13\n sage: P.zeta_polynomial()\n 17/3*q^3 - 6*q^2 + 4/3*q\n sage: P.is_self_dual()\n False\n '
import operator
Sn = [ShardPosetElement(s) for s in Permutations(n)]
return Poset([Sn, operator.le], cover_relations=False, facade=True)
|
class ShiftedPrimedTableau(ClonableArray, metaclass=InheritComparisonClasscallMetaclass):
'\n A shifted primed tableau.\n\n A primed tableau is a tableau of shifted shape in the alphabet\n `X\' = \\{1\' < 1 < 2\' < 2 < \\cdots < n\' < n\\}` such that\n\n 1. the entries are weakly increasing along rows and columns;\n 2. a row cannot have two repeated primed elements, and a column\n cannot have two repeated non-primed elements;\n\n Skew shape of the shifted primed tableaux is specified either\n with an optional argument ``skew`` or with ``None`` entries.\n\n Primed entries in the main diagonal can be allowed with the optional\n boolean parameter ``primed_diagonal``(default: ``False``).\n\n EXAMPLES::\n\n sage: T = ShiftedPrimedTableaux([4,2])\n sage: T([[1,"2\'","3\'",3],[2,"3\'"]])[1]\n (2, 3\')\n sage: t = ShiftedPrimedTableau([[1,"2p",2.5,3],[2,2.5]])\n sage: t[1]\n (2, 3\')\n sage: ShiftedPrimedTableau([["2p",2,3],["2p","3p"],[2]], skew=[2,1])\n [(None, None, 2\', 2, 3), (None, 2\', 3\'), (2,)]\n sage: ShiftedPrimedTableau([[None,None,"2p"],[None,"2p"]])\n [(None, None, 2\'), (None, 2\')]\n sage: T = ShiftedPrimedTableaux([4,2], primed_diagonal=True)\n sage: T([[1,"2\'","3\'",3],["2\'","3\'"]])[1] # With primed diagonal entry\n (2\', 3\')\n\n TESTS::\n\n sage: t = ShiftedPrimedTableau([[1,2,2.5,3],[2,2.5]])\n Traceback (most recent call last):\n ...\n ValueError: [[1, 2, 2.50000000000000, 3], [2, 2.50000000000000]]\n is not an element of Shifted Primed Tableaux\n\n sage: ShiftedPrimedTableau([[1,1,2.5],[1.5,2.5]])\n Traceback (most recent call last):\n ...\n ValueError: [[1, 1, 2.50000000000000], [1.50000000000000, 2.50000000000000]]\n is not an element of Shifted Primed Tableaux\n\n sage: ShiftedPrimedTableau([[1,1,2.5],[1.5,2.5]], primed_diagonal=True)\n [(1, 1, 3\'), (2\', 3\')]\n '
@staticmethod
def __classcall_private__(cls, T, skew=None, primed_diagonal=False):
'\n Ensure that a shifted tableau is only ever constructed as an\n ``element_class`` call of an appropriate parent.\n\n EXAMPLES::\n\n sage: data = [[1,"2\'","2",3],[2,"3\'"]]\n sage: t = ShiftedPrimedTableau(data)\n sage: T = ShiftedPrimedTableaux(shape=[4,2],weight=(1,3,2))\n sage: t == T(data)\n True\n sage: S = ShiftedPrimedTableaux(shape=[4,2])\n sage: t == S(data)\n True\n sage: t = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n sage: t.parent()\n Shifted Primed Tableaux skewed by [2, 1]\n sage: s = ShiftedPrimedTableau([[None, None,"2p",2,3],[None,"2p"]])\n sage: s.parent()\n Shifted Primed Tableaux skewed by [2, 1]\n\n TESTS::\n\n sage: ShiftedPrimedTableau([])\n []\n sage: ShiftedPrimedTableau([tuple()])\n []\n sage: ShiftedPrimedTableau([], primed_diagonal=True)\n []\n sage: ShiftedPrimedTableau([tuple()], primed_diagonal=True)\n []\n '
if (isinstance(T, ShiftedPrimedTableau) and (T._skew == skew) and (T.parent()._primed_diagonal == primed_diagonal)):
return T
skew_ = Partition([row.count(None) for row in T])
if skew_:
if (skew and (Partition(skew) != skew_)):
raise ValueError('skew shape does not agree with None entries')
skew = skew_
return ShiftedPrimedTableaux(skew=skew, primed_diagonal=primed_diagonal)(T)
def __init__(self, parent, T, skew=None, check=True, preprocessed=False):
'\n Initialize a shifted tableau.\n\n TESTS::\n\n sage: s = ShiftedPrimedTableau([[1,"2\'","3\'",3], [2,"3\'"]])\n sage: t = ShiftedPrimedTableaux([4,2])([[1,"2p","3p",3], [2,"3p"]])\n sage: s == t\n True\n sage: t.parent()\n Shifted Primed Tableaux of shape [4, 2]\n sage: s.parent()\n Shifted Primed Tableaux\n sage: r = ShiftedPrimedTableaux([4, 2])(s); r.parent()\n Shifted Primed Tableaux of shape [4, 2]\n sage: s is t # identical shifted tableaux are distinct objects\n False\n\n A shifted primed tableau is deeply immutable as the rows are\n stored as tuples::\n\n sage: t = ShiftedPrimedTableau([[1,"2p","3p",3],[2,"3p"]])\n sage: t[0][1] = 3\n Traceback (most recent call last):\n ...\n TypeError: \'tuple\' object does not support item assignment\n '
if (not preprocessed):
T = self._preprocess(T, skew=skew)
self._skew = skew
ClonableArray.__init__(self, parent, T, check=check)
@staticmethod
def _preprocess(T, skew=None):
'\n Preprocessing list ``T`` to initialize the tableau.\n\n The output is a list of rows as tuples, with explicit\n ``None`` to indicate the skew shape, and entries being\n ``PrimedEntry`` instances.\n\n Trailing empty rows are removed.\n\n TESTS::\n\n sage: ShiftedPrimedTableau._preprocess([["2\'", "3p", 3.5]],\n ....: skew=[1])\n [(None, 2\', 3\', 4\')]\n sage: ShiftedPrimedTableau._preprocess([[None]], skew=[1])\n [(None,)]\n sage: ShiftedPrimedTableau._preprocess([], skew=[2,1])\n [(None, None), (None,)]\n sage: ShiftedPrimedTableau._preprocess([], skew=[])\n []\n '
if isinstance(T, ShiftedPrimedTableau):
return T
T = [[PrimedEntry(entry) for entry in row if (entry is not None)] for row in T]
while (T and (not T[(- 1)])):
T = T[:(- 1)]
row_min = (min(len(skew), len(T)) if skew else 0)
T_ = [(((None,) * skew[i]) + tuple(T[i])) for i in range(row_min)]
if (row_min < len(T)):
T_ += [tuple(T[i]) for i in range(row_min, len(T))]
elif skew:
T_ += [((None,) * skew[i]) for i in range(row_min, len(skew))]
return T_
def check(self):
'\n Check that ``self`` is a valid primed tableau.\n\n EXAMPLES::\n\n sage: T = ShiftedPrimedTableaux([4,2])\n sage: t = T([[1,\'2p\',2,2],[2,\'3p\']])\n sage: t.check()\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"],[2]],skew=[2,1])\n sage: s.check()\n sage: t = T([[\'1p\',\'2p\',2,2],[2,\'3p\']])\n Traceback (most recent call last):\n ...\n ValueError: [[\'1p\', \'2p\', 2, 2], [2, \'3p\']] is not an element of\n Shifted Primed Tableaux of shape [4, 2]\n\n sage: T = ShiftedPrimedTableaux([4,2], primed_diagonal=True)\n sage: t = T([[\'1p\',\'2p\',2,2],[2,\'3p\']]) # primed_diagonal allowed\n sage: t.check()\n sage: t = T([[\'1p\',\'1p\',2,2],[2,\'3p\']])\n Traceback (most recent call last):\n ...\n ValueError: [[\'1p\', \'1p\', 2, 2], [2, \'3p\']] is not an element of\n Shifted Primed Tableaux of shape [4, 2] and maximum entry 6\n '
if (not self.parent()._contains_tableau(self)):
raise ValueError('{} is not an element of Shifted Primed Tableaux'.format(self))
def is_standard(self):
'\n Return ``True`` if the entries of ``self`` are in bijection with\n positive primed integers `1\', 1, 2\', \\ldots, n`.\n\n EXAMPLES::\n\n sage: ShiftedPrimedTableau([["1\'", 1, "2\'"], [2, "3\'"]],\n ....: primed_diagonal=True).is_standard()\n True\n sage: ShiftedPrimedTableau([["1\'", 1, 2], ["2\'", "3\'"]],\n ....: primed_diagonal=True).is_standard()\n True\n sage: ShiftedPrimedTableau([["1\'", 1, 1], ["2\'", 2]],\n ....: primed_diagonal=True).is_standard()\n False\n sage: ShiftedPrimedTableau([[1, "2\'"], [2]]).is_standard()\n False\n sage: s = ShiftedPrimedTableau([[None, None,"1p","2p",2],[None,"1"]])\n sage: s.is_standard()\n True\n '
flattened = set([i for row in self for i in row if (i is not None)])
if (len(flattened) != sum(((len(row) - row.count(None)) for row in self))):
return False
a = PrimedEntry('1p')
while flattened:
if (a not in flattened):
return False
flattened.remove(a)
a = a.increase_half()
return True
def __eq__(self, other):
'\n Check whether ``self`` is equal to ``other``.\n\n INPUT:\n\n - ``other`` -- the element that ``self`` is compared to\n\n OUTPUT: Boolean\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,"2p"]])\n sage: t == ShiftedPrimedTableaux([2])([[1,3/2]])\n True\n sage: s = ShiftedPrimedTableau([["2p",3]], skew=[1])\n sage: s == [[None, "2p", 3]]\n True\n '
if isinstance(other, ShiftedPrimedTableau):
return ((self._skew == other._skew) and (list(self) == list(other)))
try:
Tab = ShiftedPrimedTableau(other, primed_diagonal=self.parent()._primed_diagonal)
except (ValueError, TypeError):
return False
return ((self._skew == Tab._skew) and (list(self) == list(Tab)))
def __ne__(self, other):
'\n Check whether ``self`` is not equal to ``other``.\n\n INPUT:\n\n - ``other`` -- the element that ``self`` is compared to\n\n OUTPUT: Boolean\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,"2p"]])\n sage: t != ShiftedPrimedTableaux([2])([[1,1]])\n True\n sage: s = ShiftedPrimedTableau([["2p",3]], skew=[1])\n sage: s != [[None, "2p", 3]]\n False\n '
return (not (self == other))
def __hash__(self):
'\n Return the hash of ``self``.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,"2p"]])\n sage: hash(t) == hash(ShiftedPrimedTableaux([2])([[1,3/2]]))\n True\n '
return hash((self._skew, tuple(self)))
def _repr_(self):
'\n Return a string representation of ``self``.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']])\n sage: t\n [(1, 2\', 2, 2), (2, 3\')]\n sage: ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n [(None, None, 2\', 2, 3), (None, 2\')]\n '
return self.parent().options._dispatch(self, '_repr_', 'display')
def _repr_list(self):
'\n Return a string representation of ``self`` as a list of tuples.\n\n EXAMPLES::\n\n sage: ShiftedPrimedTableau([[\'2p\',3],[2,2]], skew=[2])._repr_list()\n "[(None, None, 2\', 3), (2, 2)]"\n '
return repr([row for row in self])
def _repr_tab(self):
'\n Return a nested list of strings representing the elements.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']])\n sage: t._repr_tab()\n [[\' 1 \', " 2\'", \' 2 \', \' 2 \'], [\' 2 \', " 3\'"]]\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n sage: s._repr_tab()\n [[\' . \', \' . \', " 2\'", \' 2 \', \' 3 \'], [\' . \', " 2\'"]]\n '
max_len = (len(str(self.max_entry())) + 2)
repr_tab = []
for row in self:
repr_row = []
for entry in row:
if (entry is None):
repr_row.append('. '.rjust(max_len))
elif entry.is_primed():
repr_row.append(repr(entry).rjust(max_len))
elif entry.is_unprimed():
repr_row.append((repr(entry).rjust((max_len - 1)) + ' '))
repr_tab.append(repr_row)
return repr_tab
def _repr_diagram(self):
'\n Return a string representation of ``self`` as an array.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']])\n sage: print(t._repr_diagram())\n 1 2\' 2 2\n 2 3\'\n sage: t = ShiftedPrimedTableau([[10,\'11p\',11,11],[11,\'12\']])\n sage: print(t._repr_diagram())\n 10 11\' 11 11\n 11 12\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n sage: print(s._repr_diagram())\n . . 2\' 2 3\n . 2\'\n '
max_len = (len(str(self.max_entry())) + 2)
return '\n'.join([(((' ' * max_len) * i) + ''.join(val)) for (i, val) in enumerate(self._repr_tab())])
_repr_compact = _repr_diagram
def _ascii_art_(self):
'\n Return ASCII representation of ``self``.\n\n EXAMPLES::\n\n sage: ascii_art(ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']]))\n +---+---+---+---+\n | 1 | 2\'| 2 | 2 |\n +---+---+---+---+\n | 2 | 3\'|\n +---+---+\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n sage: ascii_art(s)\n +---+---+---+---+---+\n | . | . | 2\'| 2 | 3 |\n +---+---+---+---+---+\n | . | 2\'|\n +---+---+\n\n TESTS::\n\n sage: ascii_art(ShiftedPrimedTableau([]))\n ++\n ++\n\n sage: ascii_art(ShiftedPrimedTableau([], skew=[1]))\n +---+\n | . |\n +---+\n '
from sage.typeset.ascii_art import AsciiArt
return AsciiArt(self._ascii_art_table(unicode=False).splitlines())
def _unicode_art_(self):
'\n Return a Unicode representation of ``self``.\n\n EXAMPLES::\n\n sage: unicode_art(ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']]))\n ┌───┬───┬───┬───┐\n │ 1 │ 2\'│ 2 │ 2 │\n └───┼───┼───┼───┘\n │ 2 │ 3\'│\n └───┴───┘\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n sage: unicode_art(s)\n ┌───┬───┬───┬───┬───┐\n │ . │ . │ 2\'│ 2 │ 3 │\n └───┼───┼───┼───┴───┘\n │ . │ 2\'│\n └───┴───┘\n\n TESTS::\n\n sage: unicode_art(ShiftedPrimedTableau([]))\n ┌┐\n └┘\n sage: unicode_art(ShiftedPrimedTableau([], skew=[1]))\n ┌───┐\n │ . │\n └───┘\n '
from sage.typeset.unicode_art import UnicodeArt
return UnicodeArt(self._ascii_art_table(unicode=True).splitlines())
def _ascii_art_table(self, unicode=False):
'\n TESTS::\n\n sage: t = ShiftedPrimedTableau([[1,\'2p\',2],[2,\'3p\']])\n sage: print(t._ascii_art_table(unicode=True))\n ┌───┬───┬───┐\n │ 1 │ 2\'│ 2 │\n └───┼───┼───┤\n │ 2 │ 3\'│\n └───┴───┘\n sage: print(t._ascii_art_table())\n +---+---+---+\n | 1 | 2\'| 2 |\n +---+---+---+\n | 2 | 3\'|\n +---+---+\n sage: s = ShiftedPrimedTableau([[1,\'2p\',2, 23],[2,\'30p\']])\n sage: print(s._ascii_art_table(unicode=True))\n ┌────┬────┬────┬────┐\n │ 1 │ 2\'│ 2 │ 23 │\n └────┼────┼────┼────┘\n │ 2 │ 30\'│\n └────┴────┘\n sage: print(s._ascii_art_table(unicode=False))\n +----+----+----+----+\n | 1 | 2\'| 2 | 23 |\n +----+----+----+----+\n | 2 | 30\'|\n +----+----+\n sage: s = ShiftedPrimedTableau([["2p",2,10],["2p"]],skew=[2,1])\n sage: print(s._ascii_art_table(unicode=True))\n ┌────┬────┬────┬────┬────┐\n │ . │ . │ 2\'│ 2 │ 10 │\n └────┼────┼────┼────┴────┘\n │ . │ 2\'│\n └────┴────┘\n '
if unicode:
import unicodedata
v = unicodedata.lookup('BOX DRAWINGS LIGHT VERTICAL')
h = unicodedata.lookup('BOX DRAWINGS LIGHT HORIZONTAL')
dl = unicodedata.lookup('BOX DRAWINGS LIGHT DOWN AND LEFT')
dr = unicodedata.lookup('BOX DRAWINGS LIGHT DOWN AND RIGHT')
ul = unicodedata.lookup('BOX DRAWINGS LIGHT UP AND LEFT')
ur = unicodedata.lookup('BOX DRAWINGS LIGHT UP AND RIGHT')
vl = unicodedata.lookup('BOX DRAWINGS LIGHT VERTICAL AND LEFT')
uh = unicodedata.lookup('BOX DRAWINGS LIGHT UP AND HORIZONTAL')
dh = unicodedata.lookup('BOX DRAWINGS LIGHT DOWN AND HORIZONTAL')
vh = unicodedata.lookup('BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL')
else:
v = '|'
h = '-'
dl = dr = ul = ur = vl = uh = dh = vh = '+'
if (not self.shape()):
return ((((dr + dl) + '\n') + ur) + ul)
str_tab = self._repr_tab()
width = len(str_tab[0][0])
str_list = [(((dr + (((h * width) + dh) * (len(str_tab[0]) - 1))) + (h * width)) + dl)]
for (nrow, row) in enumerate(str_tab):
l1 = ((' ' * (width + 1)) * nrow)
l2 = ((' ' * (width + 1)) * nrow)
n = (len(str_tab[(nrow + 1)]) if ((nrow + 1) < len(str_tab)) else (- 1))
for (i, e) in enumerate(row):
if (i == 0):
l1 += (ur + (h * width))
elif (i <= (n + 1)):
l1 += (vh + (h * width))
else:
l1 += (uh + (h * width))
if unicode:
l2 += '{}{:^{width}}'.format(v, e, width=width)
else:
l2 += '{}{:^{width}}'.format(v, e, width=width)
if (i <= n):
l1 += vl
else:
l1 += ul
l2 += v
str_list.append(l2)
str_list.append(l1)
return '\n'.join(str_list)
def pp(self):
"\n Pretty print ``self``.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']])\n sage: t.pp()\n 1 2' 2 2\n 2 3'\n sage: t = ShiftedPrimedTableau([[10,'11p',11,11],[11,'12']])\n sage: t.pp()\n 10 11' 11 11\n 11 12\n sage: s = ShiftedPrimedTableau([['2p',2,3],['2p']],skew=[2,1])\n sage: s.pp()\n . . 2' 2 3\n . 2'\n\n TESTS::\n\n sage: ShiftedPrimedTableau([],skew=[1]).pp()\n .\n sage: ShiftedPrimedTableau([]).pp()\n <BLANKLINE>\n "
print(self._repr_diagram())
def _latex_(self):
'\n Return LaTex code for ``self``.\n\n EXAMPLES::\n\n sage: T = ShiftedPrimedTableaux([4,2])\n sage: latex(T([[1,"2p",2,"3p"],[2,3]]))\n {\\def\\lr#1{\\multicolumn{1}{|@{\\hspace{.6ex}}c@{\\hspace{.6ex}}|}{\\raisebox{-.3ex}{$#1$}}}\n \\raisebox{-.6ex}{$\\begin{array}[b]{*{4}c}\\cline{1-4}\n \\lr{ 1 }&\\lr{ 2\'}&\\lr{ 2 }&\\lr{ 3\'}\\\\\\cline{1-4}\n &\\lr{ 2 }&\\lr{ 3 }\\\\\\cline{2-3}\n \\end{array}$}\n }\n '
from sage.combinat.output import tex_from_array
L = [(([None] * i) + row) for (i, row) in enumerate(self._repr_tab())]
return tex_from_array(L)
def max_entry(self):
'\n Return the minimum unprimed letter `x > y` for all `y` in ``self``.\n\n EXAMPLES::\n\n sage: Tab = ShiftedPrimedTableau([(1,1,\'2p\',\'3p\'),(2,2)])\n sage: Tab.max_entry()\n 3\n\n TESTS::\n\n sage: Tab = ShiftedPrimedTableau([], skew=[2,1])\n sage: Tab.max_entry()\n 0\n sage: Tab = ShiftedPrimedTableau([["1p"]], skew=[2,1])\n sage: Tab.max_entry()\n 1\n '
flat = [entry.unprimed() for row in self for entry in row if (entry is not None)]
if (len(flat) == 0):
return 0
return max(flat)
def shape(self):
'\n Return the shape of the underlying partition of ``self``.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']])\n sage: t.shape()\n [4, 2]\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]],skew=[2,1])\n sage: s.shape()\n [5, 2] / [2, 1]\n '
if (self._skew is None):
return Partition([len(row) for row in self])
return SkewPartition(([len(row) for row in self], self._skew))
def restrict(self, n):
'\n Return the restriction of the shifted tableau to all\n the numbers less than or equal to ``n``.\n\n .. NOTE::\n\n If only the outer shape of the restriction, rather than\n the whole restriction, is needed, then the faster method\n :meth:`restriction_outer_shape` is preferred. Similarly if\n only the skew shape is needed, use :meth:`restriction_shape`.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,\'2p\',2,2],[2,\'3p\']])\n sage: t.restrict(2).pp()\n 1 2\' 2 2\n 2\n\n sage: t.restrict("2p").pp()\n 1 2\'\n\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1])\n sage: s.restrict(2).pp()\n . . 2\' 2\n . 2\'\n sage: s.restrict(1.5).pp()\n . . 2\'\n . 2\'\n '
t = self[:]
n = PrimedEntry(n)
loop = ([y for y in x if ((y is not None) and (y <= n))] for x in t)
return ShiftedPrimedTableau([z for z in loop if z], skew=self._skew)
def restriction_outer_shape(self, n):
'\n Return the outer shape of the restriction of the shifted\n tableau ``self`` to `n`.\n\n If `T` is a (skew) shifted tableau and `n` is a half-integer,\n then the restriction of `T` to `n` is defined as the (skew)\n shifted tableau obtained by removing all cells filled with\n entries greater than `n` from `T`.\n\n This method computes merely the outer shape of the restriction.\n For the restriction itself, use :meth:`restrict`.\n\n EXAMPLES::\n\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1])\n sage: s.pp()\n . . 2\' 2 3\n . 2\'\n sage: s.restriction_outer_shape(2)\n [4, 2]\n sage: s.restriction_outer_shape("2p")\n [3, 2]\n '
n = PrimedEntry(n)
if (self._skew is None):
res = [len([y for y in row if (y <= n)]) for row in self]
else:
res = [len([y for y in row if ((y is None) or (y <= n))]) for (i, row) in enumerate(self)]
return Partition(res)
def restriction_shape(self, n):
'\n Return the skew shape of the restriction of the skew tableau\n ``self`` to ``n``.\n\n If `T` is a shifted tableau and `n` is a half-integer, then\n the restriction of `T` to `n` is defined as the\n (skew) shifted tableau obtained by removing all cells\n filled with entries greater than `n` from `T`.\n\n This method computes merely the skew shape of the restriction.\n For the restriction itself, use :meth:`restrict`.\n\n EXAMPLES::\n\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1])\n sage: s.pp()\n . . 2\' 2 3\n . 2\'\n\n sage: s.restriction_shape(2)\n [4, 2] / [2, 1]\n '
if (self._skew is None):
return Partition(self.restriction_outer_shape(n))
else:
return SkewPartition([self.restriction_outer_shape(n), self._skew])
def to_chain(self):
'\n Return the chain of partitions corresponding to the (skew)\n shifted tableau ``self``, interlaced by one of the colours\n ``1`` is the added cell is on the diagonal, ``2`` if an\n ordinary entry is added and ``3`` if a primed entry is added.\n\n EXAMPLES::\n\n sage: s = ShiftedPrimedTableau([(1, 2, 3.5, 5, 6.5), (3, 5.5)])\n sage: s.pp()\n 1 2 4\' 5 7\'\n 3 6\'\n\n sage: s.to_chain()\n [[], 1, [1], 2, [2], 1, [2, 1], 3, [3, 1], 2, [4, 1], 3, [4, 2], 3, [5, 2]]\n\n\n sage: s = ShiftedPrimedTableau([(1, 3.5), (2.5,), (6,)], skew=[2,1])\n sage: s.pp()\n . . 1 4\'\n . 3\'\n 6\n\n sage: s.to_chain()\n [[2, 1], 2, [3, 1], 0, [3, 1], 3, [3, 2], 3, [4, 2], 0, [4, 2], 1, [4, 2, 1]]\n\n TESTS::\n\n sage: s = ShiftedPrimedTableau([["2p",2,3],["2p"]], skew=[2,1])\n sage: s.pp()\n . . 2\' 2 3\n . 2\'\n sage: s.to_chain()\n Traceback (most recent call last):\n ...\n ValueError: can compute a chain of partitions only for\n skew shifted tableaux without repeated entries\n '
if any(((e not in [0, 1]) for e in self.weight())):
raise ValueError('can compute a chain of partitions only for skew shifted tableaux without repeated entries')
entries = sorted((e for row in self for e in row if (e is not None)))
if (self._skew is None):
mu = Partition([])
m = 0
else:
mu = self._skew
m = len(self._skew)
chain = [mu]
f = 0
for e in entries:
n = e.integer()
chain.extend(([0, mu] * int(((n - f) - 1))))
mu = self.restriction_outer_shape(e)
if (n == e):
if any(((e == row[0]) for (i, row) in enumerate(self) if ((i >= m) or (self._skew[i] == 0)))):
chain.append(1)
else:
chain.append(2)
else:
chain.append(3)
chain.append(mu)
f = n
return chain
def weight(self):
"\n Return the weight of ``self``.\n\n The weight of a shifted primed tableau is defined to be the vector\n with `i`-th component equal to the number of entries `i` and `i'`\n in the tableau.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([['2p',2,2],[2,'3p']], skew=[1])\n sage: t.weight()\n (0, 4, 1)\n "
flat = [entry.integer() for row in self for entry in row if (entry is not None)]
if (not flat):
return ()
weight = tuple([flat.count((i + 1)) for i in range(max(flat))])
return weight
|
class CrystalElementShiftedPrimedTableau(ShiftedPrimedTableau):
'\n Class for elements of ``crystals.ShiftedPrimedTableau``.\n '
def _to_matrix(self):
"\n Return a 2-dimensional array representation of a shifted tableau.\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux([4,2,1])\n sage: t = SPT([[1,'2p',2,2],[2,'3p'],[3]])\n sage: mat = t._to_matrix()\n sage: mat\n [[1, 2', 2, 2], [None, 2, 3', None], [None, None, 3, None]]\n "
m = len(self[0])
return [((([None] * i) + list(row)) + ([None] * ((m - i) - len(row)))) for (i, row) in enumerate(self)]
def _reading_word_with_positions(self):
"\n Iterate over the reading word of ``self`` together with positions\n of the corresponding letters in ``self``.\n\n The reading word of a shifted primed tableau is constructed\n as follows:\n\n 1. List all primed entries in the tableau, column by\n column, in decreasing order within each column, moving\n from the rightmost column to the left, and with all\n the primes removed (i.e. all entries are increased by\n half a unit).\n\n 2. Then list all unprimed entries, row by row, in\n increasing order within each row, moving from the\n bottommost row to the top.\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux([4,2])\n sage: t = SPT([[1,'2p',2,2],[2,'3p']])\n sage: list(t._reading_word_with_positions())\n [((1, 2), 3), ((0, 1), 2), ((1, 1), 2), ((0, 0), 1),\n ((0, 2), 2), ((0, 3), 2)]\n "
mat = self._to_matrix()
(ndim, mdim) = (len(mat), len(mat[0]))
for j in reversed(range(mdim)):
for i in range(ndim):
x = mat[i][j]
if ((x is not None) and x.is_primed()):
(yield ((i, j), x.integer()))
for i in reversed(range(ndim)):
for j in range(mdim):
x = mat[i][j]
if ((x is not None) and x.is_unprimed()):
(yield ((i, j), x.integer()))
def reading_word(self):
"\n Return the reading word of ``self``.\n\n The reading word of a shifted primed tableau is constructed\n as follows:\n\n 1. List all primed entries in the tableau, column by\n column, in decreasing order within each column, moving\n from the rightmost column to the left, and with all\n the primes removed (i.e. all entries are increased by\n half a unit).\n\n 2. Then list all unprimed entries, row by row, in\n increasing order within each row, moving from the\n bottommost row to the top.\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux([4,2])\n sage: t = SPT([[1,'2p',2,2],[2,'3p']])\n sage: t.reading_word()\n [3, 2, 2, 1, 2, 2]\n "
if (self._skew is not None):
raise NotImplementedError('skew tableau must be empty')
return [tup[1] for tup in self._reading_word_with_positions()]
def f(self, ind):
"\n Compute the action of the crystal operator `f_i` on a shifted primed\n tableau using cases from the papers [HPS2017]_ and [AO2018]_.\n\n INPUT:\n\n - ``ind`` -- element in the index set of the crystal\n\n OUTPUT:\n\n Primed tableau or ``None``.\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux([5,4,2])\n sage: t = SPT([[1,1,1,1,'3p'],[2,2,2,'3p'],[3,3]])\n sage: t.pp()\n 1 1 1 1 3'\n 2 2 2 3'\n 3 3\n sage: s = t.f(2)\n sage: s is None\n True\n\n sage: t = SPT([[1,1,1,'2p','3p'],[2,2,3,3],[3,4]])\n sage: t.pp()\n 1 1 1 2' 3'\n 2 2 3 3\n 3 4\n sage: s = t.f(2)\n sage: s.pp()\n 1 1 1 2' 3'\n 2 3' 3 3\n 3 4\n\n sage: SPT = ShiftedPrimedTableaux([2,1])\n sage: t = SPT([[1,1],[2]])\n sage: t.f(-1).pp()\n 1 2'\n 2\n sage: t.f(1).pp()\n 1 2'\n 2\n sage: t.f(2).pp()\n 1 1\n 3\n\n sage: r = SPT([[1,'2p'],[2]])\n sage: r.f(-1) is None\n True\n sage: r.f(1) is None\n True\n sage: r.f(2).pp()\n 1 2'\n 3\n\n sage: r = SPT([[1,1],[3]])\n sage: r.f(-1).pp()\n 1 2'\n 3\n sage: r.f(1).pp()\n 1 2\n 3\n sage: r.f(2) is None\n True\n\n sage: r = SPT([[1,2],[3]])\n sage: r.f(-1).pp()\n 2 2\n 3\n sage: r.f(1).pp()\n 2 2\n 3\n sage: r.f(2) is None\n True\n\n sage: t = SPT([[1,1],[2]])\n sage: t.f(-1).f(2).f(2).f(-1) == t.f(2).f(1).f(-1).f(2)\n True\n sage: t.f(-1).f(2).f(2).f(-1).pp()\n 2 3'\n 3\n sage: all(t.f(-1).f(2).f(2).f(-1).f(i) is None for i in {-1, 1, 2})\n True\n\n sage: SPT = ShiftedPrimedTableaux([4])\n sage: t = SPT([[1,1,1,1]])\n sage: t.f(-1).pp()\n 1 1 1 2'\n sage: t.f(1).pp()\n 1 1 1 2\n sage: t.f(-1).f(-1) is None\n True\n sage: t.f(1).f(-1).pp()\n 1 1 2' 2\n sage: t.f(1).f(1).pp()\n 1 1 2 2\n sage: t.f(1).f(1).f(-1).pp()\n 1 2' 2 2\n sage: t.f(1).f(1).f(1).pp()\n 1 2 2 2\n sage: t.f(1).f(1).f(1).f(-1).pp()\n 2 2 2 2\n sage: t.f(1).f(1).f(1).f(1).pp()\n 2 2 2 2\n sage: t.f(1).f(1).f(1).f(1).f(-1) is None\n True\n "
T = self._to_matrix()
if (ind == (- 1)):
read_word = [num for num in self._reading_word_with_positions() if (num[1] in {1, 2})]
if any((((elt == 2) and T[pos[0]][pos[1]].is_primed()) for (pos, elt) in read_word)):
return None
ones = sorted([pos for (pos, elt) in read_word if (elt == 1)], key=(lambda x: x[1]))
if (len(ones) == 0):
return None
else:
(r, c) = ones[(- 1)]
assert (r == 0)
T[r][c] = (PrimedEntry('2p') if (r != c) else PrimedEntry(2))
T = [tuple((elmt for elmt in row if (elmt is not None))) for row in T]
return type(self)(self.parent(), T, check=False, preprocessed=True)
read_word = [num for num in self._reading_word_with_positions() if ((num[1] == ind) or (num[1] == (ind + 1)))]
element_to_change = None
count = 0
for element in read_word:
if (element[1] == (ind + 1)):
count += 1
elif (count == 0):
element_to_change = element
else:
count -= 1
if (element_to_change is None):
return None
((r, c), elt) = element_to_change
ind_e = PrimedEntry(ind)
ind_plus_one = ind_e.increase_one()
ind_plus_half = ind_e.increase_half()
if T[r][c].is_primed():
T = [[(elmt.increase_half() if (elmt is not None) else elmt) for elmt in row] for row in T]
T = [list(z) for z in zip(*T)]
(r, c) = (c, r)
(h, l) = (len(T), len(T[0]))
if (((c + 1) == l) or (T[r][(c + 1)] is None) or (T[r][(c + 1)] >= ind_plus_one)):
(tp_r, tp_c) = (r, c)
while True:
if (((tp_r + 1) == h) or (T[(tp_r + 1)][tp_c] is None) or (T[(tp_r + 1)][tp_c] > ind_plus_one)):
break
if ((tp_r <= tp_c) and (T[(tp_r + 1)][(tp_r + 1)] == ind_plus_one)):
tp_r += 1
tp_c = tp_r
break
if (ind_plus_half not in T[(tp_r + 1)]):
break
tp_r += 1
tp_c = T[tp_r].index(ind_plus_half)
if (tp_r == r):
T[r][c] = T[r][c].increase_one()
elif (tp_r == tp_c):
T[r][c] = T[r][c].increase_half()
else:
T[r][c] = T[r][c].increase_half()
T[tp_r][tp_c] = T[tp_r][tp_c].increase_half()
elif (T[r][(c + 1)] == ind_plus_half):
T[r][(c + 1)] = T[r][(c + 1)].increase_half()
T[r][c] = T[r][c].increase_half()
if (r > c):
T = [[(elmt.decrease_half() if (elmt is not None) else elmt) for elmt in row] for row in T]
T = [list(z) for z in zip(*T)]
T = [tuple((elmt for elmt in row if (elmt is not None))) for row in T]
return type(self)(self.parent(), T, check=False, preprocessed=True)
def e(self, ind):
"\n Compute the action of the crystal operator `e_i` on a shifted primed\n tableau using cases from the papers [HPS2017]_ and [AO2018]_.\n\n INPUT:\n\n - ``ind`` -- an element in the index set of the crystal\n\n OUTPUT:\n\n Primed tableau or ``None``.\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux([5,4,2])\n sage: t = SPT([[1,1,1,'2p','3p'], [2,'3p',3,3],[3,4]])\n sage: t.pp()\n 1 1 1 2' 3'\n 2 3' 3 3\n 3 4\n sage: s = t.e(2)\n sage: s.pp()\n 1 1 1 2' 3'\n 2 2 3 3\n 3 4\n sage: t == s.f(2)\n True\n\n sage: SPT = ShiftedPrimedTableaux([2,1])\n sage: t = SPT([[2,'3p'],[3]])\n sage: t.e(-1).pp()\n 1 3'\n 3\n sage: t.e(1).pp()\n 1 3'\n 3\n sage: t.e(2).pp()\n 2 2\n 3\n\n sage: r = SPT([[2, 2],[3]])\n sage: r.e(-1).pp()\n 1 2\n 3\n sage: r.e(1).pp()\n 1 2\n 3\n sage: r.e(2) is None\n True\n\n sage: r = SPT([[1,'3p'],[3]])\n sage: r.e(-1) is None\n True\n sage: r.e(1) is None\n True\n sage: r.e(2).pp()\n 1 2'\n 3\n sage: r = SPT([[1,'2p'],[3]])\n sage: r.e(-1).pp()\n 1 1\n 3\n sage: r.e(1) is None\n True\n sage: r.e(2).pp()\n 1 2'\n 2\n sage: t = SPT([[2,'3p'],[3]])\n sage: t.e(-1).e(2).e(2).e(-1) == t.e(2).e(1).e(1).e(2)\n True\n sage: t.e(-1).e(2).e(2).e(-1).pp()\n 1 1\n 2\n sage: all(t.e(-1).e(2).e(2).e(-1).e(i) is None for i in {-1, 1, 2})\n True\n\n sage: SPT = ShiftedPrimedTableaux([4])\n sage: t = SPT([[2,2,2,2]])\n sage: t.e(-1).pp()\n 1 2 2 2\n sage: t.e(1).pp()\n 1 2 2 2\n sage: t.e(-1).e(-1) is None\n True\n sage: t.e(1).e(1).pp()\n 1 1 2 2\n "
T = self._to_matrix()
if (ind == (- 1)):
read_word = [num for num in self._reading_word_with_positions() if (num[1] in {1, 2})]
two_primes = sorted([pos for (pos, elt) in read_word if ((elt == 2) and T[pos[0]][pos[1]].is_primed())], key=(lambda x: x[1]))
if (len(two_primes) == 0):
if (T[0][0] != PrimedEntry(2)):
return None
else:
T[0][0] = PrimedEntry(1)
else:
(r, c) = two_primes[0]
assert (r == 0)
T[r][c] = PrimedEntry(1)
T = [tuple((elmt for elmt in row if (elmt is not None))) for row in T]
return type(self)(self.parent(), T, check=False, preprocessed=True)
read_word = [num for num in self._reading_word_with_positions() if ((num[1] == ind) or (num[1] == (ind + 1)))]
element_to_change = None
count = 0
for element in reversed(read_word):
if (element[1] == ind):
count += 1
elif (count == 0):
element_to_change = element
else:
count -= 1
if (element_to_change is None):
return None
((r, c), elt) = element_to_change
ind_e = PrimedEntry(ind)
ind_plus_half = ind_e.increase_half()
if T[r][c].is_primed():
T = [[(elmt.increase_half() if (elmt is not None) else elmt) for elmt in row] for row in T]
T = [list(z) for z in zip(*T)]
(r, c) = (c, r)
if ((c == 0) or (T[r][(c - 1)] is None) or (T[r][(c - 1)] <= ind_e)):
(tp_r, tp_c) = (r, c)
while True:
if ((tp_r == 0) or (T[(tp_r - 1)][tp_c] is None) or (T[(tp_r - 1)][tp_c] < ind_e)):
break
if (ind_plus_half not in T[(tp_r - 1)]):
break
tp_r -= 1
tp_c = T[tp_r].index(ind_plus_half)
if (tp_r == r):
T[r][c] = T[r][c].decrease_one()
elif (tp_r == tp_c):
T[r][c] = T[r][c].decrease_half()
else:
T[r][c] = T[r][c].decrease_half()
T[tp_r][tp_c] = T[tp_r][tp_c].decrease_half()
elif (T[r][(c - 1)] == ind_plus_half):
T[r][(c - 1)] = T[r][(c - 1)].decrease_half()
T[r][c] = T[r][c].decrease_half()
if (r > c):
T = [[(elmt.decrease_half() if (elmt is not None) else elmt) for elmt in row] for row in T]
T = [list(z) for z in zip(*T)]
T = [tuple((elmt for elmt in row if (elmt is not None))) for row in T]
return type(self)(self.parent(), T, check=False, preprocessed=True)
def is_highest_weight(self, index_set=None):
'\n Return whether ``self`` is a highest weight element of the crystal.\n\n An element is highest weight if it vanishes under all crystal\n operators `e_i`.\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux([5,4,2])\n sage: t = SPT([(1, 1, 1, 1, 1), (2, 2, 2, "3p"), (3, 3)])\n sage: t.is_highest_weight()\n True\n\n sage: SPT = ShiftedPrimedTableaux([5,4])\n sage: s = SPT([(1, 1, 1, 1, 1), (2, 2, "3p", 3)])\n sage: s.is_highest_weight(index_set=[1])\n True\n '
read_w = self.reading_word()
max_entry = max(read_w)
count = {i: 0 for i in range((max_entry + 1))}
if (index_set is None):
index_set = self.parent().index_set()
for l in reversed(read_w):
count[l] += 1
if (((l - 1) in index_set) and (l > 1) and (count[l] > count[(l - 1)])):
return False
return True
def weight(self):
"\n Return the weight of ``self``.\n\n The weight of a shifted primed tableau is defined to be the vector\n with `i`-th component equal to the number of entries `i` and `i'`\n in the tableau.\n\n EXAMPLES::\n\n sage: t = ShiftedPrimedTableau([[1,'2p',2,2],[2,'3p']])\n sage: t.weight()\n (1, 4, 1)\n "
flat = [entry.integer() for row in self for entry in row]
if (flat == []):
max_ind = 0
else:
max_ind = max(flat)
weight = tuple([flat.count((i + 1)) for i in range(max_ind)])
return self.parent().weight_lattice_realization()(weight)
|
class PrimedEntry(SageObject):
"\n The class of entries in shifted primed tableaux.\n\n An entry in a shifted primed tableau is an element in\n the alphabet `\\{1' < 1 < 2' < 2 < \\cdots < n' < n\\}`.\n The difference between two elements `i` and `i-1` counts as a\n whole unit, whereas the difference between `i` and `i'` counts\n as half a unit.\n Internally, we represent an unprimed element `x` as `2x`\n and the primed elements as the corresponding odd integer\n that respects the total order.\n\n INPUT:\n\n - ``entry`` -- a half integer or a string of an integer\n possibly ending in ``p`` or ``'``\n - ``double`` -- the doubled value\n "
def __init__(self, entry=None, double=None):
'\n Normalize the entry.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: PrimedEntry(2)\n 2\n sage: PrimedEntry("2p")\n 2\'\n sage: PrimedEntry("2\'")\n 2\'\n sage: a = PrimedEntry(2.5)\n sage: PrimedEntry(a)\n 3\'\n sage: PrimedEntry(None)\n Traceback (most recent call last):\n ...\n ValueError: primed entry must not be None\n '
if isinstance(entry, self.__class__):
self._entry = entry._entry
return
if (double is not None):
self._entry = Integer(double)
return
if isinstance(entry, str):
if (((entry[(- 1)] == "'") or (entry[(- 1)] == 'p')) and entry[:(- 1)].isdigit()):
self._entry = ((2 * Integer(entry[:(- 1)])) - 1)
else:
self._entry = (2 * Integer(entry))
return
if (entry is None):
raise ValueError('primed entry must not be None')
try:
self._entry = Integer((2 * entry))
except (TypeError, ValueError):
raise ValueError('primed entries must be half-integers')
def __hash__(self):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: b = PrimedEntry("2\'")\n sage: a == b\n True\n '
return hash(self._entry)
def __repr__(self):
'\n Represent ``self`` as primed or unprimed integer.\n\n TESTS::\n\n sage: ShiftedPrimedTableau([[1,"2p"]])[0][1]\n 2\'\n '
if self.is_unprimed():
return repr((self._entry // 2))
else:
return (repr(((self._entry + 1) // 2)) + "'")
def integer(self):
'\n Return the corresponding integer `i` for primed entries\n of the form `i` or `i\'`.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: b = PrimedEntry("2p").integer()\n sage: b\n 2\n sage: b.category()\n Category of elements of Integer Ring\n '
return ((self._entry + 1) // 2)
def __eq__(self, other):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: b = PrimedEntry("2\'")\n sage: a == b\n True\n '
try:
other = PrimedEntry(other)
except ValueError:
return False
return (self._entry == other._entry)
def __ne__(self, other):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("1")\n sage: b = PrimedEntry(1)\n sage: a != b\n False\n '
try:
other = PrimedEntry(other)
except ValueError:
return True
return (self._entry != other._entry)
def __lt__(self, other):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: b = PrimedEntry(2)\n sage: a < b\n True\n '
return (self._entry < PrimedEntry(other)._entry)
def __le__(self, other):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry(2)\n sage: b = PrimedEntry("3p")\n sage: a <= b\n True\n '
return (self._entry <= PrimedEntry(other)._entry)
def __gt__(self, other):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: b = PrimedEntry(2)\n sage: b > a\n True\n '
return (self._entry > PrimedEntry(other)._entry)
def __ge__(self, other):
'\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry(2)\n sage: b = PrimedEntry("3p")\n sage: a >= b\n False\n '
return (self._entry >= PrimedEntry(other)._entry)
def is_unprimed(self):
'\n Checks if ``self`` is an unprimed element.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: a.is_unprimed()\n False\n '
return ((self._entry % 2) == 0)
def is_primed(self):
'\n Checks if ``self`` is a primed element.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("3p")\n sage: a.is_primed()\n True\n '
return ((self._entry % 2) == 1)
def unprimed(self):
'\n Unprime ``self`` if it is a primed element.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: a.unprimed()\n 2\n '
if self.is_unprimed():
return self
else:
return PrimedEntry(double=(self._entry + 1))
def primed(self):
"\n Prime ``self`` if it is an unprimed element.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry(1)\n sage: a.primed()\n 1'\n "
if self.is_unprimed():
return PrimedEntry(double=(self._entry - 1))
else:
return self
def increase_half(self):
"\n Increase ``self`` by half a unit.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry(1)\n sage: a.increase_half()\n 2'\n "
return PrimedEntry(double=(self._entry + 1))
def decrease_half(self):
"\n Decrease ``self`` by half a unit.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry(1)\n sage: a.decrease_half()\n 1'\n "
return PrimedEntry(double=(self._entry - 1))
def increase_one(self):
'\n Increase ``self`` by one unit.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: a.increase_one()\n 3\'\n '
return PrimedEntry(double=(self._entry + 2))
def decrease_one(self):
'\n Decrease ``self`` by one unit.\n\n TESTS::\n\n sage: from sage.combinat.shifted_primed_tableau import PrimedEntry\n sage: a = PrimedEntry("2p")\n sage: a.decrease_one()\n 1\'\n '
return PrimedEntry(double=(self._entry - 2))
|
class ShiftedPrimedTableaux(UniqueRepresentation, Parent):
"\n Returns the combinatorial class of shifted primed tableaux subject\n to the constraints given by the arguments.\n\n A primed tableau is a tableau of shifted shape on the alphabet\n `X' = \\{1' < 1 < 2' < 2 < \\cdots < n' < n\\}` such that\n\n 1. the entries are weakly increasing along rows and columns\n\n 2. a row cannot have two repeated primed entries, and a column\n cannot have two repeated non-primed entries\n\n INPUT:\n\n Valid optional keywords:\n\n - ``shape`` -- the (outer skew) shape of tableaux\n\n - ``weight`` -- the weight of tableaux\n\n - ``max_entry`` -- the maximum entry of tableaux\n\n - ``skew`` -- the inner skew shape of tableaux\n\n - ``primed_diagonal`` -- allow primed entries in main diagonal of tableaux\n\n The weight of a tableau is defined to be the vector with `i`-th\n component equal to the number of entries `i` and `i'` in the tableau.\n The sum of the coordinates in the weight vector must be equal to the\n number of entries in the partition.\n\n The ``shape`` and ``skew`` must be strictly decreasing partitions.\n The ``primed_diagonal`` is a boolean (default: ``False``).\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux(weight=(1,2,2), shape=[3,2]); SPT\n Shifted Primed Tableaux of weight (1, 2, 2) and shape [3, 2]\n sage: SPT.list()\n [[(1, 2, 2), (3, 3)],\n [(1, 2', 3'), (2, 3)],\n [(1, 2', 3'), (2, 3')],\n [(1, 2', 2), (3, 3)]]\n sage: SPT = ShiftedPrimedTableaux(weight=(1,2,2), shape=[3,2],\n ....: primed_diagonal=True); SPT\n Shifted Primed Tableaux of weight (1, 2, 2) and shape [3, 2]\n sage: SPT.list()\n [[(1, 2, 2), (3, 3)],\n [(1, 2, 2), (3', 3)],\n [(1, 2', 3'), (2, 3)],\n [(1, 2', 3'), (2, 3')],\n [(1, 2', 3'), (2', 3)],\n [(1, 2', 3'), (2', 3')],\n [(1, 2', 2), (3, 3)],\n [(1, 2', 2), (3', 3)],\n [(1', 2, 2), (3, 3)],\n [(1', 2, 2), (3', 3)],\n [(1', 2', 3'), (2, 3)],\n [(1', 2', 3'), (2, 3')],\n [(1', 2', 3'), (2', 3)],\n [(1', 2', 3'), (2', 3')],\n [(1', 2', 2), (3, 3)],\n [(1', 2', 2), (3', 3)]]\n sage: SPT = ShiftedPrimedTableaux(weight=(1,2)); SPT\n Shifted Primed Tableaux of weight (1, 2)\n sage: list(SPT)\n [[(1, 2, 2)], [(1, 2', 2)], [(1, 2'), (2,)]]\n sage: SPT = ShiftedPrimedTableaux(weight=(1,2), primed_diagonal=True)\n sage: list(SPT)\n [[(1, 2, 2)],\n [(1, 2', 2)],\n [(1', 2, 2)],\n [(1', 2', 2)],\n [(1, 2'), (2,)],\n [(1, 2'), (2',)],\n [(1', 2'), (2,)],\n [(1', 2'), (2',)]]\n sage: SPT = ShiftedPrimedTableaux([3,2], max_entry=2); SPT\n Shifted Primed Tableaux of shape [3, 2] and maximum entry 2\n sage: list(SPT)\n [[(1, 1, 1), (2, 2)], [(1, 1, 2'), (2, 2)]]\n sage: SPT = ShiftedPrimedTableaux([3,2], max_entry=2,\n ....: primed_diagonal=True)\n sage: list(SPT)\n [[(1, 1, 1), (2, 2)],\n [(1, 1, 1), (2', 2)],\n [(1', 1, 1), (2, 2)],\n [(1', 1, 1), (2', 2)],\n [(1, 1, 2'), (2, 2)],\n [(1, 1, 2'), (2', 2)],\n [(1', 1, 2'), (2, 2)],\n [(1', 1, 2'), (2', 2)]]\n\n TESTS::\n\n sage: [(1,'2p',2,2),(2,'3p')] in ShiftedPrimedTableaux()\n True\n sage: [('1p','2p',2,2),(2,'3p')] in ShiftedPrimedTableaux()\n False\n sage: [(1,1),(2,2)] in ShiftedPrimedTableaux()\n False\n sage: [] in ShiftedPrimedTableaux()\n True\n sage: [('1p','2p',2,2),(2,'3p')] in ShiftedPrimedTableaux(\n ....: primed_diagonal=True)\n True\n sage: [] in ShiftedPrimedTableaux(primed_diagonal=True)\n True\n\n .. SEEALSO::\n\n - :class:`ShiftedPrimedTableau`\n "
Element = ShiftedPrimedTableau
options = Tableaux.options
@staticmethod
def __classcall_private__(cls, shape=None, weight=None, max_entry=None, skew=None, primed_diagonal=False):
'\n Normalize and process input to return the correct parent and\n ensure a unique representation.\n\n TESTS::\n\n sage: ShiftedPrimedTableaux([])\n Shifted Primed Tableaux of shape []\n sage: ShiftedPrimedTableaux(3)\n Traceback (most recent call last):\n ...\n ValueError: invalid shape argument\n sage: ShiftedPrimedTableaux(weight=(2,2,2), shape=[3,2])\n Traceback (most recent call last):\n ...\n ValueError: weight and shape are incompatible\n sage: ShiftedPrimedTableaux([[1]])\n Traceback (most recent call last):\n ...\n ValueError: invalid shape argument\n sage: ShiftedPrimedTableaux(weight=(2,2,2), max_entry=2)\n Traceback (most recent call last):\n ...\n ValueError: maximum entry is incompatible with the weight\n sage: ShiftedPrimedTableaux(shape=[4,1],skew=[3,2])\n Traceback (most recent call last):\n ...\n ValueError: skew shape must be inside the given tableau shape\n\n sage: SPT1 = ShiftedPrimedTableaux(weight=())\n sage: SPT2 = ShiftedPrimedTableaux(weight=(0,0,0))\n sage: SPT1 is SPT2\n True\n '
if (skew is not None):
try:
skew = Partition(skew)
except ValueError:
raise ValueError('invalid skew argument')
if (not all(((skew[i] > skew[(i + 1)]) for i in range((len(skew) - 1))))):
raise ValueError('skew shape must be a strict partition')
if (weight is not None):
weight = tuple(weight)
if (shape is not None):
if isinstance(shape, SkewPartition):
skew = shape.inner()
shape = shape.outer()
try:
shape = Partition(shape)
except (ValueError, TypeError):
raise ValueError('invalid shape argument')
if (not all(((shape[i] > shape[(i + 1)]) for i in range((len(shape) - 1))))):
raise ValueError('shape {} is not a strict partition'.format(shape))
if ((skew is not None) and (not all(((skew[i] <= shape[i]) for i in range(len(skew)))))):
raise ValueError('skew shape must be inside the given tableau shape')
if (weight is not None):
while (weight and (weight[(- 1)] == 0)):
weight = weight[:(- 1)]
if ((max_entry is not None) and (weight is not None)):
if (len(weight) > max_entry):
raise ValueError('maximum entry is incompatible with the weight')
if (shape is None):
if (weight is None):
if (max_entry is not None):
raise ValueError('specify shape or weight argument')
return ShiftedPrimedTableaux_all(skew=skew, primed_diagonal=primed_diagonal)
else:
return ShiftedPrimedTableaux_weight(weight, skew=skew, primed_diagonal=primed_diagonal)
else:
if (weight is None):
return ShiftedPrimedTableaux_shape(shape, max_entry=max_entry, skew=skew, primed_diagonal=primed_diagonal)
if (((skew is not None) and ((sum(shape) - sum(skew)) != sum(weight))) or ((skew is None) and (sum(shape) != sum(weight)))):
raise ValueError('weight and shape are incompatible')
return ShiftedPrimedTableaux_weight_shape(weight, shape, skew=skew, primed_diagonal=primed_diagonal)
def __init__(self, skew=None, primed_diagonal=False):
'\n Initialization of the parent class with given skew shape.\n\n TESTS::\n\n sage: SPT = ShiftedPrimedTableaux(skew=[1])\n sage: TestSuite(SPT).run() # known bug\n '
self._skew = skew
self._primed_diagonal = primed_diagonal
def _element_constructor_(self, T):
'\n Construct an object from ``T`` as an element of shifted primed\n tableaux, if possible.\n\n INPUT:\n\n - ``T`` -- data which can be interpreted as a primed tableau\n\n OUTPUT:\n\n - the corresponding primed tableau object\n\n EXAMPLES::\n\n sage: SPT = ShiftedPrimedTableaux()\n sage: Primed_SPT = ShiftedPrimedTableaux(primed_diagonal=True)\n\n sage: tab = SPT([[1,1,"2p"]]); tab\n [(1, 1, 2\')]\n sage: tab.parent() is SPT\n True\n sage: tab = Primed_SPT([["1p",1,"2p"]]); tab\n [(1\', 1, 2\')]\n sage: tab.parent() is Primed_SPT\n True\n\n sage: tab = SPT([[1,1,2],[2,2]])\n Traceback (most recent call last):\n ...\n ValueError: [[1, 1, 2], [2, 2]] is not an element of Shifted Primed Tableaux\n sage: SPT([[1,"2p","2p"]])\n Traceback (most recent call last):\n ...\n ValueError: [[1, \'2p\', \'2p\']] is not an element of Shifted Primed Tableaux\n\n sage: SPT = ShiftedPrimedTableaux(skew=[1])\n sage: SPT([["2p",2]])\n [(None, 2\', 2)]\n\n sage: SPT = ShiftedPrimedTableaux(weight=(2,1))\n sage: tab = SPT([[1,1,1.5]]); tab\n [(1, 1, 2\')]\n sage: tab.parent() is SPT\n True\n\n sage: SPT = ShiftedPrimedTableaux([3])\n sage: tab = SPT([[1,1,1.5]]); tab\n [(1, 1, 2\')]\n sage: tab.parent() is SPT\n True\n sage: SPT([[1,1]])\n Traceback (most recent call last):\n ...\n ValueError: [[1, 1]] is not an element of Shifted Primed Tableaux\n of shape [3]\n\n sage: SPT = ShiftedPrimedTableaux([3], weight=(2,1))\n sage: tab = SPT([[1,1,1.5]]); tab\n [(1, 1, 2\')]\n sage: tab.parent() is SPT\n True\n sage: SPT([[1,1]])\n Traceback (most recent call last):\n ...\n ValueError: [[1, 1]] is not an element of Shifted Primed Tableaux\n of weight (2, 1) and shape [3]\n '
try:
return self.element_class(self, T, skew=self._skew)
except ValueError:
raise ValueError('{} is not an element of {}'.format(T, self))
def _contains_tableau(self, T):
'\n Check if ``self`` contains preprocessed tableau ``T``.\n\n TESTS::\n\n sage: Tabs = ShiftedPrimedTableaux()\n sage: tab = ShiftedPrimedTableau._preprocess(\n ....: [[1,"2p","3p","3p"]])\n sage: tab\n [(1, 2\', 3\', 3\')]\n sage: Tabs._contains_tableau(tab)\n False\n sage: tab = ShiftedPrimedTableau._preprocess(\n ....: [["1p","2p","3p",3]])\n sage: Tabs._contains_tableau(tab)\n False\n sage: Tabs = ShiftedPrimedTableaux(primed_diagonal=True)\n sage: Tabs._contains_tableau(tab)\n True\n sage: Tabs = ShiftedPrimedTableaux(skew=[1])\n sage: tab = ShiftedPrimedTableau._preprocess(\n ....: [["2p","3p",3]], skew=[1])\n sage: tab\n [(None, 2\', 3\', 3)]\n sage: Tabs._contains_tableau(tab)\n True\n '
if (not all(((len(T[i]) > len(T[(i + 1)])) for i in range((len(T) - 1))))):
return False
if (self._skew is not None):
skew = (self._skew + ([0] * (len(T) - len(self._skew))))
else:
skew = ([0] * len(T))
for (i, row) in enumerate(T):
if (i > 0):
if (not all(((val > T[(i - 1)][(j + 1)]) for (j, val) in enumerate(row) if (((j + 1) >= skew[(i - 1)]) and val.is_unprimed())))):
return False
if (not all(((val >= T[(i - 1)][(j + 1)]) for (j, val) in enumerate(row) if (((j + 1) >= skew[(i - 1)]) and val.is_primed())))):
return False
if (not all(((row[j] <= row[(j + 1)]) for j in range(skew[i], (len(row) - 1)) if row[j].is_unprimed()))):
return False
if (not all(((row[j] < row[(j + 1)]) for j in range(skew[i], (len(row) - 1)) if row[j].is_primed()))):
return False
if (not (self._primed_diagonal or all((row[0].is_unprimed() for (i, row) in enumerate(T) if (skew[i] == 0))))):
return False
return True
|
class ShiftedPrimedTableaux_all(ShiftedPrimedTableaux):
'\n The class of all shifted primed tableaux.\n '
def __init__(self, skew=None, primed_diagonal=False):
'\n Initialize the class of all shifted tableaux.\n\n TESTS::\n\n sage: SPT = ShiftedPrimedTableaux()\n sage: [[1,1.5],[2]] in SPT\n True\n sage: [[1,1.5],[1.5]] in SPT\n False\n sage: [[1,1],[1]] in SPT\n False\n sage: [[1,1],[2,2]] in SPT\n False\n sage: TestSuite(SPT).run() # long time\n\n sage: Primed_SPT = ShiftedPrimedTableaux(primed_diagonal=True)\n sage: [[0.5,1.5],[2]] in Primed_SPT\n True\n sage: [[0.5,1.5],[1.5]] in Primed_SPT\n True\n sage: [[0.5,1],[1]] in Primed_SPT\n False\n sage: TestSuite(Primed_SPT).run() # long time\n '
if (skew is None):
Parent.__init__(self, category=InfiniteEnumeratedSets())
else:
Parent.__init__(self, category=Sets().Infinite())
ShiftedPrimedTableaux.__init__(self, skew=skew, primed_diagonal=primed_diagonal)
def _repr_(self):
'\n Return a string representation of ``self``.\n\n TESTS::\n\n sage: ShiftedPrimedTableaux()\n Shifted Primed Tableaux\n '
if (self._skew is None):
return 'Shifted Primed Tableaux'
return 'Shifted Primed Tableaux skewed by {}'.format(self._skew)
def __iter__(self):
"\n Iterate over ``self``.\n\n EXAMPLES::\n\n sage: Tabs = ShiftedPrimedTableaux()\n sage: Tabs[:5]\n [[], [(1,)], [(2,)], [(1, 2)], [(1, 2')]]\n sage: Tabs = ShiftedPrimedTableaux(primed_diagonal=True)\n sage: Tabs[:5]\n [[], [(1,)], [(1',)], [(2,)], [(2',)]]\n "
if (self._skew is not None):
raise NotImplementedError('skew tableau must be empty')
(yield self.element_class(self, []))
max_entry = 1
while True:
for size in range(1, (max_entry + 1)):
for shape in Partitions(size, max_slope=(- 1)):
for weight in OrderedPartitions(((size + max_entry) - 1), k=max_entry):
weight = [(weight[i] - 1) for i in range(max_entry)]
weight[(- 1)] += 1
for tab in ShiftedPrimedTableaux(shape=shape, weight=weight, primed_diagonal=self._primed_diagonal):
(yield self.element_class(self, tab, check=False, preprocessed=True))
max_entry += 1
|
class ShiftedPrimedTableaux_shape(ShiftedPrimedTableaux):
"\n Shifted primed tableaux of a fixed shape.\n\n Shifted primed tableaux admit a type `A_n` classical crystal structure\n with highest weights corresponding to a given shape.\n\n The list of module generators consists of all elements of the\n crystal with nonincreasing weight entries.\n\n The crystal is constructed following operations described in [HPS2017]_\n and [AO2018]_.\n\n The optional ``primed_diagonal`` allows primed entries in the main diagonal\n of all the Shifted primed tableaux of a fixed shape. If the ``max_entry``\n is ``None`` then ``max_entry`` is set to the total number of entries in the\n tableau if ``primed_diagonal`` is ``True``.\n\n EXAMPLES::\n\n sage: ShiftedPrimedTableaux([4,3,1], max_entry=4)\n Shifted Primed Tableaux of shape [4, 3, 1] and maximum entry 4\n sage: ShiftedPrimedTableaux([4,3,1], max_entry=4).cardinality()\n 384\n\n We compute some of the crystal structure::\n\n sage: SPTC = crystals.ShiftedPrimedTableaux([3,2], 3)\n sage: T = SPTC.module_generators[-1]\n sage: T\n [(1, 1, 2'), (2, 3')]\n sage: T.f(2)\n [(1, 1, 3'), (2, 3')]\n sage: len(SPTC.module_generators)\n 7\n sage: SPTC[0]\n [(1, 1, 1), (2, 2)]\n sage: SPTC.cardinality()\n 24\n\n We compare this implementation with the `q(n)`-crystal\n on (tensor products) of letters::\n\n sage: tableau_crystal = crystals.ShiftedPrimedTableaux([4,1], 3)\n sage: tableau_digraph = tableau_crystal.digraph()\n sage: c = crystals.Letters(['Q', 3])\n sage: tensor_crystal = tensor([c]*5)\n sage: u = tensor_crystal(c(1), c(1), c(1), c(2), c(1))\n sage: subcrystal = tensor_crystal.subcrystal(generators=[u],\n ....: index_set=[1,2,-1])\n sage: tensor_digraph = subcrystal.digraph()\n sage: tensor_digraph.is_isomorphic(tableau_digraph, edge_labels=True)\n True\n\n If we allow primed entries in the main diagonal::\n\n sage: ShiftedPrimedTableaux([4,3,1], max_entry=4,\n ....: primed_diagonal=True)\n Shifted Primed Tableaux of shape [4, 3, 1] and maximum entry 4\n sage: ShiftedPrimedTableaux([4,3,1], max_entry=4,\n ....: primed_diagonal=True).cardinality()\n 3072\n sage: SPTC = ShiftedPrimedTableaux([3,2], max_entry=3,\n ....: primed_diagonal=True)\n sage: T = SPTC[-1]\n sage: T\n [(1', 2', 2), (3', 3)]\n sage: SPTC[0]\n [(1, 1, 1), (2, 2)]\n sage: SPTC.cardinality()\n 96\n "
@staticmethod
def __classcall_private__(cls, shape, max_entry=None, skew=None, primed_diagonal=False):
'\n Normalize the attributes for the class.\n\n TESTS::\n\n sage: SPT = ShiftedPrimedTableaux(shape=[2,1])\n sage: SPT._shape.parent()\n Partitions\n\n sage: SPT1 = ShiftedPrimedTableaux(shape=(2,1), max_entry=3)\n sage: SPT2 = ShiftedPrimedTableaux(shape=[2,1], max_entry=3)\n sage: SPT1 is SPT2\n True\n '
shape = _Partitions(shape)
return super().__classcall__(cls, shape=shape, max_entry=max_entry, skew=skew, primed_diagonal=primed_diagonal)
def __init__(self, shape, max_entry=None, skew=None, primed_diagonal=False):
"\n Initialize the class of shifted primed tableaux of a given shape.\n\n If ``max_elt`` is specified, a finite set with entries smaller\n or equal to ``max_elt``.\n\n TESTS::\n\n sage: SPT = ShiftedPrimedTableaux([4,2,1], max_entry=4)\n sage: TestSuite(SPT).run() # long time\n sage: SPT.cartan_type()\n ['Q', 4]\n\n sage: SPT = ShiftedPrimedTableaux([4,2,1])\n sage: SPT.cartan_type()\n ['A', NN]\n sage: SPT = ShiftedPrimedTableaux([4,2,1], max_entry=4,\n ....: primed_diagonal=True)\n sage: TestSuite(SPT).run() # long time\n "
if (not primed_diagonal):
if (max_entry is None):
if (skew is None):
category = RegularCrystals().Infinite()
self._cartan_type = CartanType(['A+oo'])
self.Element = CrystalElementShiftedPrimedTableau
else:
category = Sets().Infinite()
elif (skew is None):
category = RegularSuperCrystals()
self._cartan_type = CartanType(['Q', max_entry])
self.Element = CrystalElementShiftedPrimedTableau
else:
category = Sets().Finite()
else:
if (max_entry is None):
max_entry = sum(shape)
if (skew is None):
category = FiniteEnumeratedSets()
else:
category = Sets().Finite()
ShiftedPrimedTableaux.__init__(self, skew=skew, primed_diagonal=primed_diagonal)
Parent.__init__(self, category=category)
self._max_entry = max_entry
if (skew is None):
self._shape = Partition(shape)
else:
self._shape = SkewPartition((shape, skew))
def _repr_(self):
'\n Return a string representation of ``self``.\n\n TESTS::\n\n sage: ShiftedPrimedTableaux([3,2,1])\n Shifted Primed Tableaux of shape [3, 2, 1]\n sage: ShiftedPrimedTableaux([3,2,1], primed_diagonal=True)\n Shifted Primed Tableaux of shape [3, 2, 1] and maximum\n entry 6\n '
base = ('Shifted Primed Tableaux of shape ' + self._shape._repr_())
if (self._max_entry is not None):
base += ' and maximum entry {}'.format(self._max_entry)
return base
def _contains_tableau(self, T):
"\n TESTS::\n\n sage: t = ShiftedPrimedTableau._preprocess([[1,'2p',2,2],[2,'3p']])\n sage: ShiftedPrimedTableaux([4,2],max_entry=4)._contains_tableau(t)\n True\n sage: s = ShiftedPrimedTableau._preprocess([[1,'2p',2],[2,'3p']])\n sage: ShiftedPrimedTableaux([4,2])._contains_tableau(s)\n False\n sage: t = ShiftedPrimedTableau._preprocess([['1p','2p',2,2],\n ....: ['2p','3p']])\n sage: ShiftedPrimedTableaux([4,2],max_entry=4,\n ....: primed_diagonal=True)._contains_tableau(t)\n True\n "
if (not super()._contains_tableau(T)):
return False
shape = [len(row) for row in T]
skew = [row.count(None) for row in T]
if (sum(skew) == 0):
shape = Partition(shape)
else:
shape = SkewPartition((shape, skew))
if (self._shape != shape):
return False
if (self._max_entry is not None):
flat = [item.integer() for sublist in T for item in sublist]
if (flat == []):
max_entry = 0
else:
max_entry = int(max(flat))
if (max_entry > self._max_entry):
return False
return True
def __iter__(self):
"\n Iterate over ``self``.\n\n EXAMPLES::\n\n sage: Tabs = ShiftedPrimedTableaux(shape=(3,2), max_entry=5)\n sage: Tabs[:4]\n [[(1, 1, 1), (2, 2)],\n [(1, 1, 1), (2, 3)],\n [(1, 1, 1), (2, 3')],\n [(1, 1, 2), (2, 3)]]\n sage: len(list(Tabs))\n 376\n sage: Tabs = ShiftedPrimedTableaux(shape=(3,2), primed_diagonal=True)\n sage: Tabs[:4]\n [[(1, 1, 1), (2, 2)],\n [(1, 1, 1), (2', 2)],\n [(1', 1, 1), (2, 2)],\n [(1', 1, 1), (2', 2)]]\n sage: len(list(Tabs))\n 1504\n "
if (not self._primed_diagonal):
for T in super().__iter__():
(yield T)
return
from sage.combinat.permutation import Permutations
list_weights = []
for partition in Partitions(sum(self._shape)):
if (len(partition) <= self._max_entry):
for c in Combinations(range(self._max_entry), len(partition)):
for p in Permutations(partition):
weight = ([0] * self._max_entry)
for (i, val) in enumerate(p):
weight[c[i]] = val
list_weights.append(weight)
for weight in list_weights:
for T in ShiftedPrimedTableaux(weight=tuple(weight), shape=self._shape, primed_diagonal=self._primed_diagonal):
(yield self.element_class(self, T, preprocessed=True, check=False))
@lazy_attribute
def module_generators(self):
"\n Return the generators of ``self`` as a crystal.\n\n TESTS::\n\n sage: SPT = ShiftedPrimedTableaux(shape=[2,1])\n sage: SPT.module_generators\n ([(1, 1), (2,)], [(1, 2), (3,)], [(1, 2'), (3,)])\n "
if (self._skew is not None):
raise NotImplementedError('only for non-skew shapes')
list_dw = []
if (self._max_entry is None):
max_entry = sum(self._shape)
else:
max_entry = self._max_entry
for weight in Partition(self._shape).dominated_partitions(rows=max_entry):
list_dw.extend([self.element_class(self, T, check=False, preprocessed=True) for T in ShiftedPrimedTableaux(weight=tuple(weight), shape=self._shape, primed_diagonal=self._primed_diagonal)])
return tuple(list_dw)
def shape(self):
'\n Return the shape of the shifted tableaux ``self``.\n\n TESTS::\n\n sage: ShiftedPrimedTableaux([6,4,3,1]).shape()\n [6, 4, 3, 1]\n '
return self._shape
|
class ShiftedPrimedTableaux_weight(ShiftedPrimedTableaux):
"\n Shifted primed tableaux of fixed weight.\n\n EXAMPLES::\n\n sage: ShiftedPrimedTableaux(weight=(2,3,1))\n Shifted Primed Tableaux of weight (2, 3, 1)\n sage: ShiftedPrimedTableaux(weight=(2,3,1)).cardinality()\n 17\n sage: SPT = ShiftedPrimedTableaux(weight=(2,3,1), primed_diagonal=True)\n sage: SPT.cardinality()\n 64\n sage: T = ShiftedPrimedTableaux(weight=(3,2), primed_diagonal=True)\n sage: T[:5]\n [[(1, 1, 1, 2, 2)],\n [(1, 1, 1, 2', 2)],\n [(1', 1, 1, 2, 2)],\n [(1', 1, 1, 2', 2)],\n [(1, 1, 1, 2), (2,)]]\n sage: T.cardinality()\n 16\n "
def __init__(self, weight, skew=None, primed_diagonal=False):
'\n Initialize the class of shifted primed tableaux of a given weight.\n\n TESTS::\n\n sage: TestSuite( ShiftedPrimedTableaux(weight=(3,2,1)) ).run()\n sage: TestSuite( ShiftedPrimedTableaux(weight=(3,2,1),\n ....: primed_diagonal=True) ).run()\n '
ShiftedPrimedTableaux.__init__(self, skew=skew, primed_diagonal=primed_diagonal)
if (skew is None):
Parent.__init__(self, category=FiniteEnumeratedSets())
else:
Parent.__init__(self, category=Sets().Finite())
self._weight = weight
def _repr_(self):
'\n Return a string representation of ``self``.\n\n TESTS::\n\n sage: ShiftedPrimedTableaux(weight=(3,2,1))\n Shifted Primed Tableaux of weight (3, 2, 1)\n '
if (self._skew is None):
return 'Shifted Primed Tableaux of weight {}'.format(self._weight)
return 'Shifted Primed Tableaux of weight {} skewed by {}'.format(self._weight, self._skew)
def _contains_tableau(self, T):
'\n Check if ``self`` contains preprocessed tableau ``T``.\n\n TESTS::\n\n sage: t = ShiftedPrimedTableau._preprocess([[1,1.5],[2]])\n sage: ShiftedPrimedTableaux(weight=(1,2))._contains_tableau(t)\n True\n sage: t = ShiftedPrimedTableau._preprocess([[0.5,1.5],[2]])\n sage: ShiftedPrimedTableaux(weight=(1,2),\n ....: primed_diagonal=True)._contains_tableau(t)\n True\n sage: s = ShiftedPrimedTableau._preprocess([[1,1.5],[3]])\n sage: ShiftedPrimedTableaux(weight=(1,2))._contains_tableau(s)\n False\n\n sage: u = ShiftedPrimedTableau._preprocess([])\n sage: ShiftedPrimedTableaux(weight=())._contains_tableau(u)\n True\n sage: ShiftedPrimedTableaux(weight=(1,2))._contains_tableau(u)\n False\n '
if (not super()._contains_tableau(T)):
return False
flat = [item.integer() for sublist in T for item in sublist]
if (not flat):
return (not self._weight)
max_ind = max(flat)
weight = tuple([flat.count((i + 1)) for i in range(max_ind)])
return (self._weight == weight)
def __iter__(self):
"\n Iterate over ``self``.\n\n EXAMPLES::\n\n sage: Tabs = ShiftedPrimedTableaux(weight=(2,3))\n sage: Tabs[:4]\n [[(1, 1, 2, 2, 2)],\n [(1, 1, 2', 2, 2)],\n [(1, 1, 2, 2), (2,)],\n [(1, 1, 2', 2), (2,)]]\n sage: len(list(Tabs))\n 5\n sage: Tabs = ShiftedPrimedTableaux(weight=(2,3),\n ....: primed_diagonal=True)\n sage: Tabs[:4]\n [[(1, 1, 2, 2, 2)],\n [(1, 1, 2', 2, 2)],\n [(1', 1, 2, 2, 2)],\n [(1', 1, 2', 2, 2)]]\n sage: len(list(Tabs))\n 16\n "
for shape_ in ZS1_iterator(sum(self._weight)):
if all(((shape_[i] > shape_[(i + 1)]) for i in range((len(shape_) - 1)))):
for tab in ShiftedPrimedTableaux(shape=shape_, weight=self._weight, skew=self._skew, primed_diagonal=self._primed_diagonal):
(yield self.element_class(self, tab, check=False, preprocessed=True))
|
class ShiftedPrimedTableaux_weight_shape(ShiftedPrimedTableaux):
"\n Shifted primed tableaux of the fixed weight and shape.\n\n EXAMPLES::\n\n sage: ShiftedPrimedTableaux([4,2,1], weight=(2,3,2))\n Shifted Primed Tableaux of weight (2, 3, 2) and shape [4, 2, 1]\n sage: ShiftedPrimedTableaux([4,2,1], weight=(2,3,2)).cardinality()\n 4\n sage: T = ShiftedPrimedTableaux([4,2,1], weight=(2,3,2),\n ....: primed_diagonal=True)\n sage: T[:6]\n [[(1, 1, 2, 2), (2, 3'), (3,)],\n [(1, 1, 2, 2), (2, 3'), (3',)],\n [(1, 1, 2, 2), (2', 3'), (3,)],\n [(1, 1, 2, 2), (2', 3'), (3',)],\n [(1, 1, 2', 3), (2, 2), (3,)],\n [(1, 1, 2', 3), (2, 2), (3',)]]\n sage: T.cardinality()\n 32\n "
def __init__(self, weight, shape, skew=None, primed_diagonal=False):
'\n Initialize the class of shifted primed tableaux of the given weight\n and shape.\n\n TESTS::\n\n sage: TestSuite( ShiftedPrimedTableaux([4,2,1],\n ....: weight=(3,2,2)) ).run()\n sage: TestSuite( ShiftedPrimedTableaux([4,2,1],\n ....: weight=(3,2,2), primed_diagonal=True) ).run()\n '
ShiftedPrimedTableaux.__init__(self, skew=skew, primed_diagonal=primed_diagonal)
if (skew is None):
Parent.__init__(self, category=FiniteEnumeratedSets())
else:
Parent.__init__(self, category=Sets().Finite())
self._weight = weight
if (skew is None):
self._shape = _Partitions(shape)
else:
self._shape = SkewPartition((shape, skew))
def _repr_(self):
'\n Return a string representation of ``self``.\n\n TESTS::\n\n sage: ShiftedPrimedTableaux([3,2,1], weight=(4,2))\n Shifted Primed Tableaux of weight (4, 2) and shape [3, 2, 1]\n '
return 'Shifted Primed Tableaux of weight {} and shape {}'.format(self._weight, self._shape)
def _contains_tableau(self, T):
'\n Check if ``self`` contains preprocessed tableau ``T``.\n\n TESTS::\n\n sage: t = ShiftedPrimedTableau._preprocess([[1,1.5],[2]])\n sage: ShiftedPrimedTableaux([2,1],\n ....: weight=(1,2))._contains_tableau(t)\n True\n sage: t = ShiftedPrimedTableau._preprocess([[0.5,1.5],[2]])\n sage: ShiftedPrimedTableaux([2,1],\n ....: weight=(1,2))._contains_tableau(t)\n False\n sage: t = ShiftedPrimedTableau._preprocess([[0.5,1.5],[2]])\n sage: ShiftedPrimedTableaux([2,1], weight=(1,2),\n ....: primed_diagonal=True)._contains_tableau(t)\n True\n sage: ShiftedPrimedTableaux([2,1],\n ....: weight=(2,1))._contains_tableau(t)\n False\n sage: s = ShiftedPrimedTableau._preprocess([[1,1.5,2,3],[3]])\n sage: ShiftedPrimedTableaux([3,2],\n ....: weight=(1,2,2))._contains_tableau(s)\n False\n\n sage: u = ShiftedPrimedTableau._preprocess([])\n sage: ShiftedPrimedTableaux([3,2],\n ....: weight=(1,2,2))._contains_tableau(u)\n False\n sage: ShiftedPrimedTableaux([], weight=())._contains_tableau(u)\n True\n '
if (not super()._contains_tableau(T)):
return False
flat = [item.integer() for sublist in T for item in sublist]
if (not flat):
return (not self._weight)
max_ind = max(flat)
weight = tuple([flat.count((i + 1)) for i in range(max_ind)])
if (self._weight != weight):
return False
shape = [len(row) for row in T]
skew = [row.count(None) for row in T]
if (sum(skew) == 0):
shape = _Partitions(shape)
else:
shape = SkewPartition((shape, skew))
return (self._shape == shape)
def __iter__(self):
"\n Iterate over ``self``.\n\n EXAMPLES::\n\n sage: Tabs = ShiftedPrimedTableaux([3,2], weight=(1,2,2))\n sage: Tabs[:4]\n [[(1, 2, 2), (3, 3)],\n [(1, 2', 3'), (2, 3)],\n [(1, 2', 3'), (2, 3')],\n [(1, 2', 2), (3, 3)]]\n sage: len(list(Tabs))\n 4\n sage: Tabs = ShiftedPrimedTableaux([3,2],weight=(1,2,2),\n ....: primed_diagonal=True)\n sage: Tabs[:4]\n [[(1, 2, 2), (3, 3)],\n [(1, 2, 2), (3', 3)],\n [(1, 2', 3'), (2, 3)],\n [(1, 2', 3'), (2, 3')]]\n sage: len(list(Tabs))\n 16\n\n TESTS::\n\n sage: Tabs = ShiftedPrimedTableaux([3,2], weight=(1,4))\n sage: list(Tabs)\n []\n "
if (self._skew is not None):
raise NotImplementedError('skew tableau must be empty')
if (not self._shape.dominates(sorted(self._weight, reverse=True))):
return
full_shape = self._shape
sub_tab = []
tab_list_new = [[]]
half = (~ QQ(2))
for (i, w) in enumerate(self._weight):
tab_list_old = tab_list_new
tab_list_new = []
for sub_tab in tab_list_old:
sub_shape = [len(row) for row in sub_tab]
for strip in _add_strip(sub_shape, full_shape, w):
l = (len(strip) // 2)
new_tab = []
new_tab1 = None
if (len(sub_shape) < len(full_shape)):
new_tab = [((sub_tab[r] + ([(i + half)] * strip[r])) + ([(i + 1)] * strip[((- r) - 1)])) for r in range((l - 1))]
if (strip[l] != 0):
if self._primed_diagonal:
new_tab1 = new_tab[:]
new_tab1.append(([(i + half)] + ([(i + 1)] * (strip[l] - 1))))
new_tab.append(([(i + 1)] * strip[l]))
else:
new_tab = [((sub_tab[r] + ([(i + half)] * strip[r])) + ([(i + 1)] * strip[((- r) - 1)])) for r in range(l)]
tab_list_new.append(new_tab)
if new_tab1:
tab_list_new.append(new_tab1)
for tab in tab_list_new:
(yield self.element_class(self, tab))
|
def _add_strip(sub_tab, full_tab, length):
"\n Helper function used in the algorithm to generate all shifted primed\n tableaux of the fixed weight and shape.\n\n TESTS::\n\n sage: list(ShiftedPrimedTableaux([3,1], weight=(2,2))) # indirect doctest\n [[(1, 1, 2), (2,)], [(1, 1, 2'), (2,)]]\n sage: list(ShiftedPrimedTableaux([3,1], weight=(2,2), # indirect doctest\n ....: primed_diagonal=True))\n [[(1, 1, 2), (2,)],\n [(1, 1, 2), (2',)],\n [(1, 1, 2'), (2,)],\n [(1, 1, 2'), (2',)],\n [(1', 1, 2), (2,)],\n [(1', 1, 2), (2',)],\n [(1', 1, 2'), (2,)],\n [(1', 1, 2'), (2',)]]\n "
if ((sum(sub_tab) + length) > sum(full_tab)):
raise ValueError('strip does not fit')
if (not sub_tab):
cliff_list = []
else:
cliff_list = [int((sub_tab[0] != full_tab[0]))]
for row in range(1, len(sub_tab)):
if (sub_tab[row] == full_tab[row]):
cliff_list.append(0)
elif ((sub_tab[(row - 1)] - 1) == sub_tab[row]):
cliff_list[(- 1)] += 1
else:
cliff_list.append(1)
if (len(sub_tab) < len(full_tab)):
cliff_list.append(0)
for primes_num in range((min(sum(cliff_list), length) + 1)):
for primed_list in IntegerVectors(n=primes_num, k=len(cliff_list), outer=cliff_list):
row = 0
primed_strip = []
for (i, cliff) in enumerate(cliff_list):
if (cliff == 0):
row += 1
primed_strip.append(0)
primed_strip.extend([int((primed_list[i] > j)) for j in range(cliff)])
row += cliff
plat_list = []
if (sub_tab and (len(sub_tab) < len(full_tab))):
plat_list.append(min(((sub_tab[(- 1)] + primed_strip[(- 2)]) - 1), full_tab[len(sub_tab)]))
for row in reversed(range(1, len(sub_tab))):
plat_list.append(((min(((sub_tab[(row - 1)] + primed_strip[(row - 1)]) - 1), full_tab[row]) - sub_tab[row]) - primed_strip[row]))
if sub_tab:
plat_list.append(((full_tab[0] - sub_tab[0]) - primed_strip[0]))
else:
plat_list.append(full_tab[0])
for non_primed_strip in IntegerVectors(n=(length - primes_num), k=len(plat_list), outer=plat_list):
(yield (list(primed_strip) + list(non_primed_strip)))
|
class ShuffleProduct_abstract(Parent):
'\n Abstract base class for shuffle products.\n '
def __init__(self, l1, l2, element_constructor=None):
'\n Initialize ``self``.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: SP = ShuffleProduct([1,2],[4,5,7,8,9])\n sage: TestSuite(SP).run(skip="_test_an_element")\n '
self._l1 = l1
self._l2 = l2
if (element_constructor is None):
self._element_constructor_ = self._constructor_
else:
self._element_constructor_ = element_constructor
Parent.__init__(self, category=FiniteEnumeratedSets())
def _constructor_(self, x):
'\n This is used by default to produce elements when iterating.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: S = ShuffleProduct([1,2,3],[4,5])\n sage: S._constructor_((1,2,3))\n [1, 2, 3]\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: S = ShuffleProduct_overlapping(w,u)\n sage: S._constructor_((1,2,3))\n [1, 2, 3]\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: S = SetShuffleProduct([[1,2],[3,4]], [[1,4]])\n sage: S._constructor_((1,2,3))\n [1, 2, 3]\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: S = ShuffleProduct_overlapping_r(w,u,1)\n sage: S._constructor_((1,2,3))\n [1, 2, 3]\n '
return list(x)
def __eq__(self, other):
'\n Test for equality.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: SP = ShuffleProduct([1,2],[4,5,7,8,9])\n sage: loads(dumps(SP)) == SP\n True\n sage: SP == ShuffleProduct([1,2],[4,5,7])\n False\n '
if (not isinstance(other, type(self))):
return False
return ((self._l1 == other._l1) and (self._l2 == other._l2))
def __ne__(self, other):
'\n Test for unequality\n\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: A = ShuffleProduct_overlapping_r(w,u,1)\n sage: B = ShuffleProduct_overlapping_r(u,w,2)\n sage: A != A\n False\n sage: A != B\n True\n '
return (not (self == other))
def __contains__(self, x):
'\n Check containment.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: SP = ShuffleProduct([1,2],[4,5,7])\n sage: [1,4,5,2,7] in SP\n True\n sage: (1,4,5,2,7) in SP\n False\n sage: [2,1,4,5,7] in SP\n False\n '
return (x in self.list())
|
class SetShuffleProduct(ShuffleProduct_abstract):
'\n The union of all possible shuffle products of two sets of iterables.\n\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: sorted(SetShuffleProduct({(1,), (2,3)}, {(4,5), (6,)}))\n [[1, 4, 5],\n [1, 6],\n [2, 3, 4, 5],\n [2, 3, 6],\n [2, 4, 3, 5],\n [2, 4, 5, 3],\n [2, 6, 3],\n [4, 1, 5],\n [4, 2, 3, 5],\n [4, 2, 5, 3],\n [4, 5, 1],\n [4, 5, 2, 3],\n [6, 1],\n [6, 2, 3]]\n '
def __init__(self, l1, l2, element_constructor=None):
'\n Construct the set of all possible shuffle products of two sets of iterables.\n\n INPUT:\n\n - ``l1``, ``l2`` -- iterable: the sets to shuffle\n\n - ``element_constructor`` -- constructor for the returned elements\n\n TESTS::\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: X = SetShuffleProduct({(1,2,3), (2,3,4)}, {(5,)})\n sage: X # random\n Shuffle set product of: [(2, 3, 4), (1, 2, 3)] and [(5,)]\n sage: TestSuite(X).run(skip="_test_an_element")\n\n sage: list(SetShuffleProduct({(1,2,3), (2,3,4)}, {(5,)})) # random\n [[2, 3, 4, 5], [2, 5, 3, 4], [5, 2, 3, 4], [2, 3, 5, 4],\n [1, 2, 3, 5], [1, 5, 2, 3], [5, 1, 2, 3], [1, 2, 5, 3]]\n '
assert (isinstance(l1, Iterable) and isinstance(l2, Iterable))
assert all((isinstance(elem, Iterable) for elem in l1))
assert all((isinstance(elem, Iterable) for elem in l2))
if (element_constructor is None):
try:
e = next(iter(l1))
try:
element_constructor = e.parent()._element_constructor_
except AttributeError:
pass
except StopIteration:
pass
ShuffleProduct_abstract.__init__(self, list(l1), list(l2), element_constructor)
def _repr_(self):
'\n TESTS::\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: SetShuffleProduct([[1,2],[3,4]], [[1,4]])\n Shuffle set product of: [[1, 2], [3, 4]] and [[1, 4]]\n sage: SetShuffleProduct([()], [[1,4]])\n Shuffle set product of: [()] and [[1, 4]]\n\n '
return ('Shuffle set product of: %s and %s' % (self._element_constructor_(self._l1), self._element_constructor_(self._l2)))
def _ascii_art_(self):
'\n TESTS::\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: ascii_art(SetShuffleProduct([[BinaryTree()], [BinaryTree([]), BinaryTree([[],[]])]], # needs sage.graphs\n ....: [[1,4]]))\n Set shuffle product of:\n [ [ o, o ] ]\n [ [ / \\ ] ]\n [ [ ], [ o o ] ] and [ [ 1, 4 ] ]\n\n '
from sage.typeset.ascii_art import ascii_art
return (ascii_art('Set shuffle product of:') * ((ascii_art(self._l1) + ascii_art(' and ')) + ascii_art(self._l2)))
def __iter__(self):
'\n TESTS::\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: list(SetShuffleProduct([[],[]], [[]]))\n [[], []]\n sage: list(SetShuffleProduct([[1,2],[3]], [[4]]))\n [[1, 2, 4], [4, 1, 2], [1, 4, 2], [3, 4], [4, 3]]\n sage: list(SetShuffleProduct([[1,2],[3,4]], [[1,4]], element_constructor=set))\n [{1, 2, 4},\n {1, 2, 4},\n {1, 2, 4},\n {1, 2, 4},\n {1, 2, 4},\n {1, 2, 4},\n {1, 3, 4},\n {1, 3, 4},\n {1, 3, 4},\n {1, 3, 4},\n {1, 3, 4},\n {1, 3, 4}]\n '
return itertools.chain.from_iterable((ShuffleProduct(*pair, element_constructor=self._element_constructor_) for pair in itertools.product(self._l1, self._l2)))
def cardinality(self):
'\n The cardinality is defined by the sum of the cardinality of all shuffles.\n That means by a sum of binomials.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import SetShuffleProduct\n sage: SetShuffleProduct([[1,2],[3,4]], [[1,4]], element_constructor=set).cardinality()\n 12\n '
def comp_binom(el1, el2):
ll1 = Integer(len(el1))
ll2 = Integer(len(el2))
return (ll1 + ll2).binomial(ll2)
return sum((comp_binom(el1, el2) for (el1, el2) in itertools.product(self._l1, self._l2)))
|
class ShuffleProduct(ShuffleProduct_abstract):
'\n Shuffle product of two iterables.\n\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: list(ShuffleProduct("abc", "de", element_constructor="".join))\n [\'abcde\',\n \'adbce\',\n \'dabce\',\n \'abdce\',\n \'adebc\',\n \'daebc\',\n \'deabc\',\n \'adbec\',\n \'dabec\',\n \'abdec\']\n sage: list(ShuffleProduct("", "de", element_constructor="".join))\n [\'de\']\n\n '
def __init__(self, l1, l2, element_constructor=None):
'\n Construct the shuffle product of two iterable.\n\n INPUT:\n\n - ``l1``, ``l2`` -- iterable: iterables to shuffle\n\n - ``element_constructor``: constructor for the returned elements\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: SP = ShuffleProduct([1,2,3],[4,5])\n sage: SP\n Shuffle product of: [1, 2, 3] and [4, 5]\n sage: TestSuite(SP).run(skip="_test_an_element")\n\n sage: list(ShuffleProduct(Word("aa"), Word("bbb"), Word))\n [word: aabbb, word: baabb, word: ababb, word: bbaab, word: babab, word: abbab,\n word: bbbaa, word: bbaba, word: babba, word: abbba]\n '
assert (isinstance(l1, Iterable) and isinstance(l2, Iterable))
if (element_constructor is None):
try:
element_constructor = l1.parent()._element_constructor_
except AttributeError:
pass
ShuffleProduct_abstract.__init__(self, list(l1), list(l2), element_constructor)
def _repr_(self):
'\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: ShuffleProduct([1,2,3],[4,5])\n Shuffle product of: [1, 2, 3] and [4, 5]\n sage: B = BinaryTree # needs sage.graphs\n sage: ShuffleProduct([B(), B([[],[]])], []) # needs sage.graphs\n Shuffle product of: [., [[., .], [., .]]] and []\n '
return ('Shuffle product of: %s and %s' % (self._l1, self._l2))
def _ascii_art_(self):
'\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: ascii_art(ShuffleProduct([1,2,3],[4,5]))\n Shuffle product of:\n [ 1, 2, 3 ] and [ 4, 5 ]\n sage: B = BinaryTree # needs sage.graphs\n sage: ascii_art(ShuffleProduct([B([]), B([[],[]])], # needs sage.graphs\n ....: [B([[[],[]],[[],None]])]))\n Shuffle product of:\n [ __o__ ]\n [ / \\ ]\n [ o, o ] [ o o ]\n [ / \\ ] [ / \\ / ]\n [ o o ] and [ o o o ]\n '
from sage.typeset.ascii_art import ascii_art
return (ascii_art('Shuffle product of:') * ((ascii_art(self._l1) + ascii_art(' and ')) + ascii_art(self._l2)))
def __iter__(self):
'\n Efficient iteration from a gray code on binary words in `B(n,k)`.\n\n (with `B(n,k)` the number of binary words of size `n` with `k` one.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: list(ShuffleProduct([1,2,3],[4,5]))\n [[1, 2, 3, 4, 5], [1, 4, 2, 3, 5], [4, 1, 2, 3, 5], [1, 2, 4, 3, 5], [1, 4, 5, 2, 3],\n [4, 1, 5, 2, 3], [4, 5, 1, 2, 3], [1, 4, 2, 5, 3], [4, 1, 2, 5, 3], [1, 2, 4, 5, 3]]\n sage: B = BinaryTree # needs sage.graphs\n sage: ascii_art(list(ShuffleProduct([B([]), B([[],[]])], # needs sage.graphs\n ....: [B([[[],[]],[[],None]])])))\n [ [ o, o , __o__ ] [ __o__ , o, o ]\n [ [ / \\ / \\ ] [ / \\ / \\ ]\n [ [ o o o o ] [ o o o o ]\n [ [ / \\ / ] [ / \\ / ]\n [ [ o o o ], [ o o o ],\n <BLANKLINE>\n [ o, __o__ , o ] ]\n [ / \\ / \\ ] ]\n [ o o o o ] ]\n [ / \\ / ] ]\n [ o o o ] ]\n '
def swap(i, j):
(l[(i - 1)], l[(j - 1)]) = (l[(j - 1)], l[(i - 1)])
def gen(n, k):
if (0 < k < n):
for _ in gen((n - 1), k):
(yield)
if (k == 1):
swap(n, (n - 1))
else:
swap(n, (k - 1))
(yield)
for _ in neg((n - 1), (k - 1)):
(yield)
def neg(n, k):
if (0 < k < n):
for _ in gen((n - 1), (k - 1)):
(yield)
if (k == 1):
swap(n, (n - 1))
else:
swap(n, (k - 1))
(yield)
for _ in neg((n - 1), k):
(yield)
m = len(self._l1)
n = len(self._l2)
mn = (m + n)
l = (([0] * m) + ([1] * n))
EC = self._element_constructor_
(yield EC((self._l1 + self._l2)))
for _ in gen(mn, m):
l1 = iter(self._l1)
l2 = iter(self._l2)
(yield EC([(next(l2) if l[k] else next(l1)) for k in range(mn)]))
def __contains__(self, iterable):
'\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: sh = ShuffleProduct([1,2,3],[4,5])\n sage: list(range(1,6)) in sh\n True\n sage: list(range(1,7)) in sh\n False\n sage: [3,4,5,1,2] in sh\n False\n sage: [1,4,2,5,3] in sh\n True\n sage: [1,4,2,2,5,3] in sh\n False\n '
if (not isinstance(iterable, type(self._element_constructor_([])))):
return False
l1 = self._l1
l2 = self._l2
len_l1 = len(l1)
len_l2 = len(l2)
i_l1 = i_l2 = 0
iterable = list(iterable)
for (i, el) in enumerate(iterable):
if (l1[i_l1] == el):
i_l1 += 1
elif (l2[i_l2] == el):
i_l2 += 1
else:
return False
if (i_l1 == len_l1):
return (iterable[(i + 1):] == l2[i_l2:])
if (i_l2 == len_l2):
return (iterable[(i + 1):] == l1[i_l1:])
return (((i_l1 + 1) == len_l1) and ((i_l2 + 1) == len_l2))
def cardinality(self):
'\n Return the number of shuffles of `l_1` and `l_2`, respectively of\n lengths `m` and `n`, which is `\\binom{m+n}{n}`.\n\n TESTS::\n\n sage: from sage.combinat.shuffle import ShuffleProduct\n sage: ShuffleProduct([3,1,2], [4,2,1,3]).cardinality()\n 35\n sage: ShuffleProduct([3,1,2,5,6,4], [4,2,1,3]).cardinality() == binomial(10,4)\n True\n '
ll1 = Integer(len(self._l1))
ll2 = Integer(len(self._l2))
return (ll1 + ll2).binomial(ll1)
|
class ShuffleProduct_overlapping_r(ShuffleProduct_abstract):
'\n The overlapping shuffle product of the two words ``w1`` and ``w2``\n with precisely ``r`` overlaps.\n\n See :class:`ShuffleProduct_overlapping` for a definition.\n\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: S = ShuffleProduct_overlapping_r(w,u,1)\n sage: list(S)\n [word: 11,9,1,\n word: 2,18,1,\n word: 11,1,9,\n word: 2,9,10,\n word: 939,\n word: 9,2,10]\n '
def __init__(self, w1, w2, r, element_constructor=None, add=operator.add):
'\n Initialize ``self``.\n\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: S = ShuffleProduct_overlapping_r(w,u,1)\n sage: TestSuite(S).run(skip="_test_an_element")\n '
self.r = r
self.add = add
if (element_constructor is None):
if isinstance(w1, Word_class):
element_constructor = w1.parent()
else:
try:
element_constructor = w1.parent()._element_constructor_
except AttributeError:
pass
ShuffleProduct_abstract.__init__(self, w1, w2, element_constructor)
def _repr_(self):
"\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: ShuffleProduct_overlapping_r(w,u,1).__repr__()\n 'Overlapping shuffle product of word: 29 and word: 91 with 1 overlaps'\n "
return ('Overlapping shuffle product of %s and %s with %s overlaps' % (repr(self._l1), repr(self._l2), self.r))
def __eq__(self, other):
'\n Check equality.\n\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = map(Words(range(20)), [[2, 9], [9, 1]])\n sage: A = ShuffleProduct_overlapping_r(w,u,1)\n sage: B = ShuffleProduct_overlapping_r(u,w,2)\n sage: A == A\n True\n sage: A == B\n False\n '
return (ShuffleProduct_abstract.__eq__(self, other) and (self.r == other.r))
def __iter__(self):
'\n EXAMPLES::\n\n sage: from sage.combinat.shuffle import ShuffleProduct_overlapping_r\n sage: w, u = Word([1,2]), Word([3,4])\n sage: ShuffleProduct_overlapping_r(w,u,1).list()\n [word: 424, word: 154, word: 442, word: 136, word: 352, word: 316]\n sage: w, u = map(Words(range(1,7)), [[1,2], [3,4]])\n sage: W = Words(range(1,7))\n sage: w, u = W([1,2]), W([3,4])\n sage: ShuffleProduct_overlapping_r(w, u, 1).list() #indirect doctest\n [word: 424, word: 154, word: 442, word: 136, word: 352, word: 316]\n\n sage: I, J = Composition([2, 2]), Composition([1, 1])\n sage: S = ShuffleProduct_overlapping_r(I, J, 1)\n sage: S.list()\n [[3, 2, 1], [2, 3, 1], [3, 1, 2], [2, 1, 3], [1, 3, 2], [1, 2, 3]]\n\n TESTS:\n\n We need to be explicitly more generic about the resulting parent\n when shuffling two compositions `I` and `J` (:trac:`15131`)::\n\n sage: I, J = Compositions(4)([2, 2]), Composition([1, 1])\n sage: S = ShuffleProduct_overlapping_r(I, J, 1, Compositions())\n sage: S.list()\n [[3, 2, 1], [2, 3, 1], [3, 1, 2], [2, 1, 3], [1, 3, 2], [1, 2, 3]]\n '
EC = self._element_constructor_
m = len(self._l1)
n = len(self._l2)
r = self.r
add = self.add
(wc1, wc2) = (self._l1, self._l2)
blank = ([None] * ((m + n) - r))
for iv in IntegerVectors(m, ((m + n) - r), max_part=1):
w = blank[:]
filled_places = []
unfilled_places = []
i = 0
for j in range(len(iv)):
if (iv[j] == 1):
w[j] = wc1[i]
i += 1
filled_places.append(j)
else:
unfilled_places.append(j)
for subset in itertools.combinations(filled_places, r):
places_to_fill = sorted((unfilled_places + list(subset)))
i = 0
res = w[:]
for j in places_to_fill:
if (res[j] is not None):
res[j] = add(res[j], wc2[i])
else:
res[j] = wc2[i]
i += 1
(yield EC(res))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.