Ticket #13399: trac_13399-sf-as.3.patch

File trac_13399-sf-as.3.patch, 38.2 KB (added by Jeroen Demeyer, 10 years ago)

same patch with minor doc changes

  • sage/combinat/sf/jack.py

    # HG changeset patch
    # User Anne Schilling <anne@math.ucdavis.edu>
    # Date 1345872756 25200
    # Node ID 2ef52b39a638c141bcdec41f7182d6f1aed69895
    # Parent  0452690e4d618e75f2eaa859e09056bc59cd28fc
    #13399: Some fixes in symmetric functions.
    
    This patch implements the following fixes to symmetric functions:
    - HL creation operator for k-Schur functions
    - it fixes omega for k-Schur functions for generic t
    - it changes the multiplication for k-Schur functions for generic t, so that
      the result stays in the k-bounded subspace if possible and lifts to symmetric functions otherwise
    - it moves coproduct_by_coercion to SymmetricFunctionAlgebra_generic and
      inserts a coproduct function in KBoundedSubspaceBases, ElementMethods
    - it fixes the coersion between the Jack P and Pq basis; this was previously extremely slow,
      for example for
      {{{
          sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
          sage: Qp = Sym.jack().Qp()
          sage: P = Sym.jack().P()
          sage: P(Qp[2,1])
          ((-192*t^3+192*t^2-192*t+192)/(-64*t^3-224*t^2-224*t-64))*JackP[1, 1, 1]
          + ((128*t^2-64*t+80)/(64*t^2+64*t+16))*JackP[2, 1] + ((8*t-8)/(8*t+4))*JackP[3]
       }}}
    - it fixes the coproduct for Jack symmetric functions
    
    diff --git a/sage/combinat/sf/jack.py b/sage/combinat/sf/jack.py
    a b  
    5959        - ``Sym`` -- a ring of symmetric functions
    6060        - ``t`` -- an optional parameter (default : 't')
    6161
    62         EXAMPLES ::
     62        EXAMPLES::
    6363
    6464            sage: SymmetricFunctions(FractionField(QQ['t'])).jack()
    6565            Jack polynomials over Fraction Field of Univariate Polynomial Ring in t over Rational Field
     
    8787
    8888        - returns the name of the family of bases
    8989
    90         EXAMPLES ::
     90        EXAMPLES::
    9191
    9292            sage: SymmetricFunctions(QQ).jack(1)
    9393            Jack polynomials with t=1 over Rational Field
     
    107107
    108108        - the base ring of the symmetric functions ring of ``self``
    109109
    110         EXAMPLES ::
     110        EXAMPLES::
    111111
    112112            sage: J2 = SymmetricFunctions(QQ).jack(t=2)
    113113            sage: J2.base_ring()
     
    128128
    129129        - the symmetric functions ring of ``self``
    130130
    131         EXAMPLES ::
     131        EXAMPLES::
    132132
    133133            sage: Jacks = SymmetricFunctions(FractionField(QQ['t'])).jack()
    134134            sage: Jacks.symmetric_function_ring()
     
    148148
    149149        - the `P` basis of the Jack symmetric functions
    150150
    151         EXAMPLES ::
     151        EXAMPLES::
    152152
    153153            sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
    154154            sage: JP = Sym.jack().P(); JP
     
    251251
    252252        - the `Q` basis of the Jack symmetric functions
    253253
    254         EXAMPLES ::
     254        EXAMPLES::
    255255
    256256            sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
    257257            sage: JQ = Sym.jack().Q(); JQ
     
    290290
    291291        OUTPUT: the `J` basis of the Jack symmetric functions
    292292
    293         EXAMPLES ::
     293        EXAMPLES::
    294294
    295295            sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
    296296            sage: JJ = Sym.jack().J(); JJ
     
    356356
    357357        - the `Q'` basis of the Jack symmetric functions
    358358
    359         EXAMPLES ::
     359        EXAMPLES::
    360360
    361361            sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
    362362            sage: JP = Sym.jack().P()
     
    368368            sage: a.scalar(JP([1,1]))
    369369            0
    370370            sage: JP(JQp([2]))                        # todo: missing auto normalization
    371             ((2*t-2)/(2*t+2))*JackP[1, 1] + JackP[2]
     371            ((-t+1)/(-t-1))*JackP[1, 1] + JackP[2]
    372372            sage: JP._normalize(JP(JQp([2])))
    373             ((t-1)/(t+1))*JackP[1, 1] + JackP[2]
     373            ((-t+1)/(-t-1))*JackP[1, 1] + JackP[2]
    374374        """
    375         return self.P().dual_basis(prefix="JackQp", basis_name = "Jack Qp"+ self._name_suffix)
     375        return JackPolynomials_qp(self)
    376376
    377377#############################
    378378# to be deprecated
     
    573573        0
    574574        sage: s = P.realization_of().s()
    575575        sage: P(Qp([2]))                        # todo: missing auto normalization
    576         ((2*t-2)/(2*t+2))*JackP[1, 1] + JackP[2]
     576        ((-t+1)/(-t-1))*JackP[1, 1] + JackP[2]
    577577        sage: P._normalize(P(Qp([2])))
    578         ((t-1)/(t+1))*JackP[1, 1] + JackP[2]
     578        ((-t+1)/(-t-1))*JackP[1, 1] + JackP[2]
    579579    """
    580580    (R, t) = NoneConvention(R, t)
    581581    sage.misc.superseded.deprecation(5457, "Deprecation warning: In the future use SymmetricFunctions(R).jack(t=%s).Qp()"%(t))
     
    621621    - a polynomial in the parameter ``t`` which is equal to the scalar
    622622      product of ``J(part)`` and ``P(part)``
    623623
    624     EXAMPLES ::
     624    EXAMPLES::
    625625
    626626        sage: from sage.combinat.sf.jack import c1
    627627        sage: t = QQ['t'].gen()
     
    647647    - a polynomial in the parameter ``t`` which is equal to the scalar
    648648      product of ``J(part)`` and ``Q(part)``
    649649
    650     EXAMPLES ::
     650    EXAMPLES::
    651651
    652652        sage: from sage.combinat.sf.jack import c2
    653653        sage: t = QQ['t'].gen()
     
    657657    return prod([t+t*part.arm_lengths(flat=True)[i]+part.leg_lengths(flat=True)[i] for i in range(sum(part))],
    658658                t.parent().one())
    659659
     660def normalize_coefficients(self, c):
     661    r"""
     662    If our coefficient ring is the field of fractions over a univariate
     663    polynomial ring over the rationals, then we should clear both the
     664    numerator and denominator of the denominators of their
     665    coefficients.
     666
     667    INPUT:
     668
     669    - ``self`` -- a Jack basis of the symmetric functions
     670    - ``c`` -- a coefficient in the base ring of ``self``
     671
     672    OUTPUT:
     673
     674    - divide numerator and denominator by the greatest common divisor
     675
     676    EXAMPLES::
     677
     678        sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
     679        sage: t = JP.base_ring().gen()
     680        sage: a = 2/(1/2*t+1/2)
     681        sage: JP._normalize_coefficients(a)
     682        4/(t + 1)
     683        sage: a = 1/(1/3+1/6*t)
     684        sage: JP._normalize_coefficients(a)
     685        6/(t + 2)
     686        sage: a = 24/(4*t^2 + 12*t + 8)
     687        sage: JP._normalize_coefficients(a)
     688        6/(t^2 + 3*t + 2)
     689    """
     690    BR = self.base_ring()
     691    if is_FractionField(BR) and BR.base_ring() == QQ:
     692        denom = c.denominator()
     693        numer = c.numerator()
     694
     695        #Clear the denominators
     696        a = lcm([i.denominator() for i in denom.coeffs()])
     697        b = lcm([i.denominator() for i in numer.coeffs()])
     698        l = Integer(a).lcm(Integer(b))
     699        denom *= l
     700        numer *= l
     701
     702        #Divide through by the gcd of the numerators
     703        a = gcd([i.numerator() for i in denom.coeffs()])
     704        b = gcd([i.numerator() for i in numer.coeffs()])
     705        l = Integer(a).gcd(Integer(b))
     706
     707        denom = denom / l
     708        numer = numer / l
     709
     710        return c.parent()(numer, denom)
     711    else:
     712        return c
     713
    660714####################################################################
    661715
    662716class JackPolynomials_generic(sfa.SymmetricFunctionAlgebra_generic):
     
    695749            self._m = self._sym.monomial()
    696750            self   .register_coercion(SetMorphism(Hom(self._m, self, category), self._m_to_self))
    697751            self._m.register_coercion(SetMorphism(Hom(self, self._m, category), self._self_to_m))
     752        if hasattr(self, "_h_cache"):
     753            # temporary until Hom(GradedHopfAlgebrasWithBasis work better)
     754            category = sage.categories.all.ModulesWithBasis(self._sym.base_ring())
     755            self._h = self._sym.homogeneous()
     756            self   .register_coercion(SetMorphism(Hom(self._h, self, category), self._h_to_self))
     757            self._h.register_coercion(SetMorphism(Hom(self, self._h, category), self._self_to_h))
    698758
    699759    def _m_to_self(self, x):
    700760        r"""
     
    792852        - a polynomial in the parameter ``t`` which is equal to the scalar
    793853          product of ``J(part)`` and ``Q(part)``
    794854
    795         EXAMPLES ::
     855        EXAMPLES::
    796856
    797857            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    798858            sage: JP.c2(Partition([2,1]))
     
    800860        """
    801861        return c2(part, self.t)
    802862
    803     def _normalize_coefficients(self, c):
    804         r"""
    805         If our coefficient ring is the field of fractions over a univariate
    806         polynomial ring over the rationals, then we should clear both the
    807         numerator and denominator of the denominators of their
    808         coefficients.
    809 
    810         INPUT:
    811 
    812         - ``self`` -- a Jack basis of the symmetric functions
    813         - ``c`` -- a coefficient in the base ring of ``self``
    814 
    815         OUTPUT:
    816 
    817         - divide numerator and denominator by the greatest common divisor
    818 
    819         EXAMPLES ::
    820 
    821             sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    822             sage: t = JP.base_ring().gen()
    823             sage: a = 2/(1/2*t+1/2)
    824             sage: JP._normalize_coefficients(a)
    825             4/(t + 1)
    826             sage: a = 1/(1/3+1/6*t)
    827             sage: JP._normalize_coefficients(a)
    828             6/(t + 2)
    829             sage: a = 24/(4*t^2 + 12*t + 8)
    830             sage: JP._normalize_coefficients(a)
    831             6/(t^2 + 3*t + 2)
    832         """
    833         BR = self.base_ring()
    834         if is_FractionField(BR) and BR.base_ring() == QQ:
    835             denom = c.denominator()
    836             numer = c.numerator()
    837 
    838             #Clear the denominators
    839             a = lcm([i.denominator() for i in denom.coeffs()])
    840             b = lcm([i.denominator() for i in numer.coeffs()])
    841             l = Integer(a).lcm(Integer(b))
    842             denom *= l
    843             numer *= l
    844 
    845             #Divide through by the gcd of the numerators
    846             a = gcd([i.numerator() for i in denom.coeffs()])
    847             b = gcd([i.numerator() for i in numer.coeffs()])
    848             l = Integer(a).gcd(Integer(b))
    849 
    850             denom = denom / l
    851             numer = numer / l
    852 
    853             return c.parent()(numer, denom)
    854         else:
    855             return c
     863    _normalize_coefficients = normalize_coefficients
    856864
    857865    def _normalize(self, x):
    858866        r"""
     
    867875
    868876        - returns ``x`` with _normalize_coefficient applied to each of the coefficients
    869877
    870         EXAMPLES ::
     878        EXAMPLES::
    871879
    872880            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    873881            sage: t = JP.base_ring().gen()
     
    894902
    895903        - the normalized morphism
    896904
    897         EXAMPLES ::
     905        EXAMPLES::
    898906
    899907            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    900908            sage: normal = JP._normalize_morphism(AlgebrasWithBasis(JP.base_ring()))
     
    930938
    931939        - returns the product of ``left`` and ``right`` expanded in the basis ``self``
    932940
    933         EXAMPLES ::
     941        EXAMPLES::
    934942
    935943            sage: JJ = SymmetricFunctions(FractionField(QQ['t'])).jack().J()
    936944            sage: JJ([1])^2              # indirect doctest
     
    957965
    958966        - the family of Jack symmetric functions associated to ``self``
    959967
    960         EXAMPLES ::
     968        EXAMPLES::
    961969
    962970            sage: JackP = SymmetricFunctions(QQ).jack(t=2).P()
    963971            sage: JackP.jack_family()
     
    965973        """
    966974        return self._jack
    967975
     976    def coproduct_by_coercion(self, elt):
     977        r"""
     978        Returns the coproduct of the element ``elt`` by coercion to the Schur basis.
     979
     980        INPUT:
     981
     982        - ``self`` -- a Jack symmetric function basis
     983        - ``elt`` -- an instance of this basis
     984
     985        OUTPUT:
     986
     987        - The coproduct acting on ``elt``, the result is an element of the
     988          tensor squared of the Jack symmetric function basis
     989
     990        EXAMPLES::
     991
     992            sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())
     993            sage: Sym.jack().P()[2,2].coproduct() #indirect doctest
     994            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[]
     995        """
     996        from sage.categories.tensor import tensor
     997        s = self.realization_of().schur()
     998        g = self.tensor_square().sum(coeff*tensor([self(s[x]), self(s[y])])
     999                                        for ((x,y), coeff) in s(elt).coproduct())
     1000        normalize = self._normalize_coefficients
     1001        return self.tensor_square().sum(normalize(coeff)*tensor([self(x), self(y)])
     1002                    for ((x,y), coeff) in g)
     1003
     1004
    9681005    class Element(sfa.SymmetricFunctionAlgebra_generic.Element):
    969         pass
    9701006        def scalar_jack(self, x, t=None):
    9711007            r"""
    9721008            A scalar product where the power sums are orthogonal and
     
    9831019
    9841020            - returns the Jack scalar product between ``x`` and ``self``
    9851021
    986             EXAMPLES ::
     1022            EXAMPLES::
    9871023
    9881024                sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
    9891025                sage: JP = Sym.jack().P()
     
    10151051
    10161052    - returns the scalar product between the power sum indexed by ``part1`` and ``part2``
    10171053
    1018     EXAMPLES ::
     1054    EXAMPLES::
    10191055
    10201056        sage: Q.<t> = QQ[]
    10211057        sage: from sage.combinat.sf.jack import part_scalar_jack
     
    10451081        - ``self`` -- an instance of the Jack `P` basis of the symmetric functions
    10461082        - ``jack`` -- a family of Jack symmetric function bases
    10471083
    1048         EXAMPLES ::
     1084        EXAMPLES::
    10491085
    10501086            sage: P = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    10511087            sage: TestSuite(P).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive
     
    10691105        - ``self`` -- an instance of the Jack `P` basis of the symmetric functions
    10701106        - ``n`` -- a positive integer indicating the degree
    10711107
    1072         EXAMPLES ::
     1108        EXAMPLES::
    10731109
    10741110            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    10751111            sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]
     
    11201156        - returns a function that accepts a partition and returns the coefficients
    11211157          of the expansion of the element of ``P(part)`` in the monomial basis
    11221158
    1123         EXAMPLES ::
     1159        EXAMPLES::
    11241160
    11251161            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    11261162            sage: JP._m_cache(3)
     
    11481184
    11491185        - returns the product of ``left`` and ``right`` expanded in the basis ``self``
    11501186
    1151         EXAMPLES ::
     1187        EXAMPLES::
    11521188
    11531189            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    11541190            sage: m = JP.symmetric_function_ring().m()
     
    11871223               The Clarendon Press, Oxford University Press, New York, 1995, With contributions
    11881224               by A. Zelevinsky, Oxford Science Publications.
    11891225
    1190         EXAMPLES ::
     1226        EXAMPLES::
    11911227
    11921228            sage: JP = SymmetricFunctions(FractionField(QQ['t'])).jack().P()
    11931229            sage: JJ = SymmetricFunctions(FractionField(QQ['t'])).jack().J()
     
    12431279
    12441280    def __init__(self, jack):
    12451281        r"""
    1246         The J basis is a defined as a normalized form of the P basis
     1282        The `J` basis is a defined as a normalized form of the `P` basis
    12471283
    12481284        INPUT:
    12491285
    12501286        - ``self`` -- an instance of the Jack `P` basis of the symmetric functions
    12511287        - ``jack`` -- a family of Jack symmetric function bases
    12521288
    1253         EXAMPLES ::
     1289        EXAMPLES::
    12541290
    12551291            sage: J = SymmetricFunctions(FractionField(QQ['t'])).jack().J()
    12561292            sage: TestSuite(J).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive
     
    12791315
    12801316    def __init__(self, jack):
    12811317        r"""
    1282         The `Q` basis is defined as a normalized form of the P basis
     1318        The `Q` basis is defined as a normalized form of the `P` basis
    12831319
    12841320        INPUT:
    12851321
    1286         - ``self`` -- an instance of the Jack `P` basis of the symmetric functions
     1322        - ``self`` -- an instance of the Jack `Q` basis of the symmetric functions
    12871323        - ``jack`` -- a family of Jack symmetric function bases
    12881324
    1289         EXAMPLES ::
     1325        EXAMPLES::
    12901326
    1291             sage: Q = SymmetricFunctions(FractionField(QQ['t'])).jack().J()
     1327            sage: Q = SymmetricFunctions(FractionField(QQ['t'])).jack().Q()
    12921328            sage: TestSuite(Q).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive
    12931329            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)
    12941330        """
     
    13071343    class Element(JackPolynomials_generic.Element):
    13081344        pass
    13091345
     1346qp_to_h_cache = {}
     1347h_to_qp_cache = {}
     1348class JackPolynomials_qp(JackPolynomials_generic):
     1349    def __init__(self, jack):
     1350        r"""
     1351        The `Qp` basis is the dual basis to the `P` basis with respect to the
     1352        standard scalar product
     1353
     1354        INPUT:
     1355
     1356        - ``self`` -- an instance of the Jack `Qp` basis of the symmetric functions
     1357        - ``jack`` -- a family of Jack symmetric function bases
     1358
     1359        EXAMPLES::
     1360
     1361            sage: Qp = SymmetricFunctions(FractionField(QQ['t'])).jack().Qp()
     1362            sage: TestSuite(Qp).run(skip=['_test_associativity', '_test_distributivity', '_test_prod']) # products are too expensive
     1363            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)
     1364        """
     1365        self._name = "Jack polynomials in the Qp basis"
     1366        self._prefix = "JackQp"
     1367        JackPolynomials_generic.__init__(self, jack)
     1368        self._P = self._jack.P()
     1369        self._self_to_h_cache = qp_to_h_cache
     1370        self._h_to_self_cache = h_to_qp_cache
     1371
     1372    def _multiply(self, left, right):
     1373        r"""
     1374        The product of two Jack symmetric functions is done by multiplying the
     1375        elements in the monomial basis and then expressing the elements
     1376        the basis ``self``.
     1377
     1378        INPUT:
     1379
     1380        - ``self`` -- an instance of the Jack `Qp` basis of the symmetric functions
     1381        - ``left``, ``right`` -- symmetric function elements
     1382
     1383        OUTPUT:
     1384
     1385        - returns the product of ``left`` and ``right`` expanded in the basis ``self``
     1386
     1387        EXAMPLES::
     1388
     1389            sage: JQp = SymmetricFunctions(FractionField(QQ['t'])).jack().Qp()
     1390            sage: h = JQp.symmetric_function_ring().h()
     1391            sage: JQp([1])^2 # indirect doctest
     1392            JackQp[1, 1] + (-2/(-t-1))*JackQp[2]
     1393            sage: h(_)
     1394            h[1, 1]
     1395            sage: JQp = SymmetricFunctions(QQ).jack(t=2).Qp()
     1396            sage: h = SymmetricFunctions(QQ).h()
     1397            sage: JQp([2,1])^2
     1398            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]
     1399            sage: h(_)
     1400            h[2, 2, 1, 1] - 6/5*h[3, 2, 1] + 9/25*h[3, 3]
     1401        """
     1402        return self( self._h(left)*self._h(right) )
     1403
     1404    def _h_cache(self, n):
     1405        r"""
     1406        Computes the change of basis between the Jack polynomials in the `Qp`
     1407        basis and the homogeneous symmetric functions. This uses the coefficients
     1408        in the change of basis between the Jack `P` basis and the monomial basis.
     1409
     1410        INPUT:
     1411
     1412        - ``self`` -- an instance of the Jack `Qp` basis of the symmetric functions
     1413        - ``n`` -- a positive integer indicating the degree
     1414
     1415        EXAMPLES::
     1416
     1417            sage: JQp = SymmetricFunctions(FractionField(QQ['t'])).jack().Qp()
     1418            sage: l = lambda c: [ (i[0],[j for j in sorted(i[1].items())]) for i in sorted(c.items())]
     1419            sage: JQp._h_cache(2)
     1420            sage: l(JQp._self_to_h_cache[2])
     1421            [([1, 1], [([1, 1], 1), ([2], 2/(-t - 1))]), ([2], [([2], 1)])]
     1422            sage: l(JQp._h_to_self_cache[2])
     1423            [([1, 1], [([1, 1], 1), ([2], -2/(-t - 1))]), ([2], [([2], 1)])]
     1424            sage: JQp._h_cache(3)
     1425            sage: l(JQp._h_to_self_cache[3])
     1426            [([1, 1, 1], [([1, 1, 1], 1), ([2, 1], 6/(t + 2)), ([3], -6/(-2*t^2 - 3*t - 1))]), ([2, 1], [([2, 1], 1), ([3], 3/(2*t + 1))]), ([3], [([3], 1)])]
     1427            sage: l(JQp._self_to_h_cache[3])
     1428            [([1, 1, 1], [([1, 1, 1], 1), ([2, 1], -6/(t + 2)), ([3], -6/(-t^2 - 3*t - 2))]), ([2, 1], [([2, 1], 1), ([3], -3/(2*t + 1))]), ([3], [([3], 1)])]
     1429        """
     1430        if n in self._self_to_h_cache:
     1431            return
     1432        else:
     1433            self._self_to_h_cache[n] = {}
     1434            self._h_to_self_cache[n] = {}
     1435        self._P._m_cache(n)
     1436        from_cache_1 = self._P._self_to_m_cache[n]
     1437        to_cache_1 = self._self_to_h_cache[n]
     1438        from_cache_2 = self._P._m_to_self_cache[n]
     1439        to_cache_2 = self._h_to_self_cache[n]
     1440        for mu in from_cache_1.keys():
     1441            for la in from_cache_1[mu].keys():
     1442                if not la in to_cache_1:
     1443                    to_cache_1[la] = {}
     1444                    to_cache_2[la] = {}
     1445                to_cache_2[la][mu] = from_cache_1[mu][la]
     1446                to_cache_1[la][mu] = from_cache_2[mu][la]
     1447
     1448    def _self_to_h( self, x ):
     1449        r"""
     1450        Isomorphism from self to the homogeneous basis
     1451
     1452        INPUT:
     1453
     1454        - ``self`` -- a Jack `Qp` basis of the symmetric functions
     1455        - ``x`` -- an element of the Jack `Qp` basis
     1456
     1457        OUTPUT:
     1458
     1459        - an element of the homogeneous basis equivalent to ``x``
     1460
     1461        EXAMPLES ::
     1462
     1463            sage: Sym = SymmetricFunctions(QQ)
     1464            sage: JQp = Sym.jack(t=2).Qp()
     1465            sage: h = Sym.homogeneous()
     1466            sage: JQp._self_to_h(JQp[2,1])
     1467            h[2, 1] - 3/5*h[3]
     1468
     1469        This is for internal use only. Please use instead::
     1470
     1471            sage: h(JQp[2,1])
     1472            h[2, 1] - 3/5*h[3]
     1473        """
     1474        return self._h._from_cache(x, self._h_cache, self._self_to_h_cache, t = self.t)
     1475
     1476    def _h_to_self( self, x ):
     1477        r"""
     1478        Isomorphism from the homogeneous basis into ``self``
     1479
     1480        INPUT:
     1481
     1482        - ``self`` -- a Jack `Qp` basis of the symmetric functions
     1483        - ``x`` -- element of the homogeneous basis
     1484
     1485        OUTPUT:
     1486
     1487        - an element of the Jack `Qp` basis equivalent to ``x``
     1488
     1489        EXAMPLES ::
     1490
     1491            sage: Sym = SymmetricFunctions(QQ)
     1492            sage: JQp = Sym.jack(t=2).Qp()
     1493            sage: h = Sym.homogeneous()
     1494            sage: JQp._h_to_self(h[2,1])
     1495            JackQp[2, 1] + 3/5*JackQp[3]
     1496
     1497        This is for internal use only. Please use instead::
     1498
     1499            sage: JQp(h[2,1])
     1500            JackQp[2, 1] + 3/5*JackQp[3]
     1501        """
     1502        return self._from_cache(x, self._h_cache, self._h_to_self_cache, t = self.t)
     1503
     1504    def coproduct_by_coercion( self, elt ):
     1505        r"""
     1506        Returns the coproduct of the element ``elt`` by coercion to the Schur basis.
     1507
     1508        INPUT:
     1509
     1510        - ``elt`` -- an instance of the ``Qp`` basis
     1511
     1512        OUTPUT:
     1513
     1514        - The coproduct acting on ``elt``, the result is an element of the
     1515          tensor squared of the ``Qp`` symmetric function basis
     1516
     1517        EXAMPLES::
     1518
     1519            sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())
     1520            sage: JQp = Sym.jack().Qp()
     1521            sage: JQp[2,2].coproduct()   #indirect doctest
     1522            JackQp[] # JackQp[2, 2] + (2*t/(t+1))*JackQp[1] # JackQp[2, 1] + JackQp[1, 1] # JackQp[1, 1] + ((-4*t^3-8*t^2)/(-2*t^3-5*t^2-4*t-1))*JackQp[2] # JackQp[2] + (2*t/(t+1))*JackQp[2, 1] # JackQp[1] + JackQp[2, 2] # JackQp[]
     1523        """
     1524        h = elt.parent().realization_of().h()
     1525        parent = elt.parent()
     1526        from sage.categories.tensor import tensor
     1527        cfunc = lambda x, y: tensor([parent(x), parent(y)])
     1528        cprod = h(elt).coproduct().apply_multilinear_morphism( cfunc )
     1529        normalize = lambda c: normalize_coefficients( parent, c )
     1530        return cprod.parent().sum(normalize(coeff)*tensor([parent(x), parent(y)])
     1531                        for ((x,y), coeff) in cprod)
     1532
     1533    class Element(JackPolynomials_generic.Element):
     1534        pass
     1535
    13101536#Zonal polynomials ( =P(at t=2) )
    13111537class SymmetricFunctionAlgebra_zonal(sfa.SymmetricFunctionAlgebra_generic):
    13121538    def __init__(self, Sym):
     
    14141640
    14151641# Backward compatibility for unpickling
    14161642from sage.structure.sage_object import register_unpickle_override
     1643register_unpickle_override('sage.combinat.sf.jack', 'JackPolynomial_qp', JackPolynomials_qp.Element)
    14171644register_unpickle_override('sage.combinat.sf.jack', 'JackPolynomial_j', JackPolynomials_j.Element)
    14181645register_unpickle_override('sage.combinat.sf.jack', 'JackPolynomial_p', JackPolynomials_p.Element)
    14191646register_unpickle_override('sage.combinat.sf.jack', 'JackPolynomial_q', JackPolynomials_q.Element)
  • sage/combinat/sf/monomial.py

    diff --git a/sage/combinat/sf/monomial.py b/sage/combinat/sf/monomial.py
    a b  
    222222        return self.sum_of_terms((Partition(exp=monomial), coeff)
    223223                                 for (monomial, coeff) in p.dict().iteritems())
    224224
    225     def coproduct_by_coercion(self, elt):
    226         r"""
    227         Returns the coproduct of the element ``elt`` by coercion to the Schur basis.
    228 
    229         INPUT:
    230 
    231         - ``self`` -- a monomial symmetric function basis
    232         - ``elt`` -- an instance of monomial basis
    233 
    234         OUTPUT:
    235 
    236         - The coproduct acting on ``elt``, the result is an element of the
    237           tensor squared of the monomial symmetric function basis
    238 
    239 
    240         EXAMPLES::
    241 
    242             sage: m = SymmetricFunctions(QQ).m()
    243             sage: m[3,1,1].coproduct()
    244             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[]
    245             sage: m.coproduct_by_coercion(m[2,1])
    246             m[] # m[2, 1] + m[1] # m[2] + m[2] # m[1] + m[2, 1] # m[]
    247             sage: m.coproduct_by_coercion(m[2,1]) == m([2,1]).coproduct()
    248             True
    249         """
    250         from sage.categories.tensor import tensor
    251         s = self.realization_of().schur()
    252         return self.tensor_square().sum(coeff * tensor([self(s[x]), self(s[y])])
    253                                         for ((x,y), coeff) in s(elt).coproduct())
    254 
    255225
    256226    class Element(classical.SymmetricFunctionAlgebra_classical.Element):
    257227        def expand(self, n, alphabet='x'):
  • sage/combinat/sf/new_kschur.py

    diff --git a/sage/combinat/sf/new_kschur.py b/sage/combinat/sf/new_kschur.py
    a b  
    2626from sage.categories.graded_coalgebras_with_basis import GradedCoalgebrasWithBasis
    2727from sage.categories.magmas import Magmas
    2828from sage.categories.examples.infinite_enumerated_sets import NonNegativeIntegers
     29from sage.categories.tensor import tensor
    2930from sage.combinat.partition import Partition, Partitions, Partition_class
    3031from sage.combinat.sf.sf import SymmetricFunctions
    3132from sage.categories.morphism import SetMorphism
     
    413414            Method for multiplying two elements.
    414415
    415416            When `t=1`, the `k`-bounded subspace is an algebra, so the product of two elements
    416             is always in the space. For generic `t`, the result is returned in the ring
    417             of symmetric functions since the `k`-bounded subspace is not closed under multiplication.
     417            is always in the space. For generic `t`, the `k`-bounded subspace is not closed under
     418            multiplication, so the result is returned in the `k`-bounded subspace if possible and
     419            else in the ring of symmetric functions.
    418420
    419421            EXAMPLES::
    420422
     
    439441                ks3[3, 2, 1] + ks3[3, 3]
    440442                sage: f.parent()
    441443                3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis also with t=1
     444
     445            TESTS::
     446
     447                sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
     448                sage: ks2 = Sym.kschur(2)
     449                sage: ks3 = Sym.kschur(3)
     450                sage: ks5 = Sym.kschur(5)
     451                sage: ks5(ks3[2]) * ks5(ks2[2,1])
     452                ks5[2, 2, 1] + ks5[3, 1, 1] + (t+1)*ks5[3, 2] + (t+1)*ks5[4, 1] + t*ks5[5]
    442453            """
    443454            if self.parent().realization_of().t == 1:
    444455                return self.parent()(self.lift()*other.lift())
    445             return self.lift()*other.lift()
     456            result = self.lift()*other.lift()
     457            try:
     458                result = self.parent()(result)
     459            except ValueError:
     460                pass
     461            return result
     462
     463        def hl_creation_operator(self, nu, t = None):
     464            r"""
     465            This is the vertex operator that generalizes Jing's operator.
     466
     467            It is a linear operator that raises the degree by
     468            `|\nu|`. This creation operator is a t-analogue of
     469            multiplication by ``s(nu)`` .
     470
     471            .. SEEALSO:: Proposition 5 in [SZ.2001]_.
     472
     473            INPUT:
     474
     475            -  ``nu`` -- a partition
     476
     477            - ``t`` -- a parameter (default: None, in this case `t` is used)
     478
     479            REFERENCES:
     480
     481            .. [SZ.2001] M. Shimozono, M. Zabrocki,
     482               Hall-Littlewood vertex operators and generalized Kostka polynomials.
     483               Adv. Math. 158 (2001), no. 1, 66-85.
     484
     485            EXAMPLES::
     486
     487                sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
     488                sage: ks = Sym.kschur(4)
     489                sage: s = Sym.schur()
     490                sage: s(ks([3,1,1]).hl_creation_operator([1]))
     491                (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]
     492                sage: ks([3,1,1]).hl_creation_operator([1])
     493                (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]
     494
     495                sage: Sym = SymmetricFunctions(QQ)
     496                sage: ks = Sym.kschur(4,t=1)
     497                sage: ks([3,1,1]).hl_creation_operator([1])
     498                ks4[3, 1, 1, 1] + ks4[3, 2, 1] + ks4[4, 1, 1]
     499            """
     500            if t is None:
     501                t = self.parent().realization_of().t
     502            return self.parent()(self.lift().hl_creation_operator(nu,t=t))
     503
     504        def coproduct(self):
     505            r"""
     506            Returns the coproduct operation on ``self``.
     507
     508            The coproduct is first computed on the homogeneous basis if `t=1` and
     509            on the Hall-Littlewood ``Qp`` basis otherwise.  The result is computed
     510            then converted to the tensor squared of ``self.parent()``
     511
     512            EXAMPLES::
     513
     514                sage: Sym = SymmetricFunctions(QQ)
     515                sage: ks3 = Sym.kschur(3,1)
     516                sage: ks3[2,1].coproduct()
     517                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[]
     518                sage: h3 = Sym.khomogeneous(3)
     519                sage: h3[2,1].coproduct()
     520                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[]
     521                sage: ks3t = SymmetricFunctions(FractionField(QQ['t'])).kschur(3)
     522                sage: ks3t[2,1].coproduct()
     523                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[]
     524                sage: ks3t[3,1].coproduct()
     525                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]
     526                + (t+1)*ks3[2] # ks3[2] + ks3[2, 1] # ks3[1] + (t+1)*ks3[3] # ks3[1] + ks3[3, 1] # ks3[]
     527            """
     528            lifted = self.lift()
     529            target_basis = self.parent()
     530            ambient = self.parent().realization_of().ambient()
     531            t = self.parent().realization_of().t
     532            if t==1:
     533                source_basis = ambient.h()
     534            else:
     535                source_basis = ambient.hall_littlewood(t=t).Qp()
     536            cpfunc = lambda x,y: tensor([ target_basis(x), target_basis(y) ])
     537            return source_basis(lifted).coproduct().apply_multilinear_morphism( cpfunc )
     538
    446539
    447540        def omega(self):
    448541            r"""
    449542            Returns the `\omega` operator on ``self``.
    450543           
    451             `\omega` maps the `k`-Schur function `s_\lambda` to `s_{\lambda^{(k)}}`, where
     544            At `t=1`, `\omega` maps the `k`-Schur function `s^{(k)}_\lambda` to `s^{(k)}_{\lambda^{(k)}}`, where
    452545            `\lambda^{(k)}` is the `k`-conjugate of the partition `\lambda`.
    453            
     546
    454547            .. SEEALSO:: :meth:`~sage.combinat.partition.Partition_class.k_conjugate`.
     548
     549            For generic `t`, `\omega` sends `s^{(k)}_\lambda[X;t]` to `t^d s^{(k)}_{\lambda^{(k)}}[X;1/t]`,
     550            where `d` is the size of the core of `\lambda` minus the size of `\lambda`. Most of the time,
     551            this result is not in the `k`-bounded subspace.
     552
     553            .. SEEALSO:: :meth:`omega_t_inverse`.
    455554           
    456555            EXAMPLES::
    457556
     
    463562                sage: kh[3].omega()
    464563                h3[1, 1, 1] - 2*h3[2, 1] + h3[3]
    465564
    466                 sage: Sym = SymmetricFunctions(QQ['t'])
    467                 sage: ks = Sym.kschur(4)
    468                 sage: ks[2,2,1,1].omega()
    469                 ks4[3, 2, 1]
     565                sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
     566                sage: ks = Sym.kschur(3)
     567                sage: ks[3,1,1].omega()
     568                Traceback (most recent call last):
     569                ...
     570                ValueError: t*s[2, 1, 1, 1] + s[3, 1, 1] is not in the image of Generic morphism:
     571                From: 3-bounded Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the 3-Schur basis
     572                To:   Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Schur basis
    470573            """
    471             ks = kSchur(self.parent().realization_of())
    472             f = ks(self)
    473             return self.parent()(f.map_support( lambda p: p.k_conjugate(self.parent().k) ))
     574            return self.parent()(self.lift().omega())
     575
     576        def omega_t_inverse(self):
     577            r"""
     578            Returns the map `t\to 1/t` composed with `\omega` on ``self``.
     579
     580            Unlike the map :meth:`omega`, the result of :meth:`omega_t_inverse` lives in the
     581            `k`-bounded subspace and hence will return an element even for generic `t`. For `t=1`,
     582            :meth:`omega` and :meth:`omega_t_inverse` return the same result.
     583
     584            EXAMPLES::
     585
     586                sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
     587                sage: ks = Sym.kschur(3)
     588                sage: ks[3,1,1].omega_t_inverse()
     589                1/t*ks3[2, 1, 1, 1]
     590                sage: ks[3,2].omega_t_inverse()
     591                1/t^2*ks3[1, 1, 1, 1, 1]
     592            """
     593            s = self.parent().realization_of().ambient()
     594            t = s.base_ring().gen()
     595            invert = lambda x: s.base_ring()(x.subs(t=1/t))
     596            return self.parent()(s(self).map_coefficients(invert).omega())
    474597
    475598        def is_schur_positive(self, *args, **kwargs):
    476599            r"""
  • sage/combinat/sf/sfa.py

    diff --git a/sage/combinat/sf/sfa.py b/sage/combinat/sf/sfa.py
    a b  
    17401740        m = sage.combinat.sf.sf.SymmetricFunctions(self.base_ring()).m()
    17411741        return self(m.from_polynomial(poly, check=check))
    17421742
     1743    def coproduct_by_coercion(self, elt):
     1744        r"""
     1745        Returns the coproduct of the element ``elt`` by coercion to the Schur basis.
     1746
     1747        INPUT:
     1748
     1749        - ``self`` -- a symmetric function basis
     1750        - ``elt`` -- an instance of this basis
     1751
     1752        OUTPUT:
     1753
     1754        - The coproduct acting on ``elt``, the result is an element of the
     1755          tensor squared of the basis ``self``
     1756
     1757        EXAMPLES::
     1758
     1759            sage: m = SymmetricFunctions(QQ).m()
     1760            sage: m[3,1,1].coproduct()
     1761            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[]
     1762            sage: m.coproduct_by_coercion(m[2,1])
     1763            m[] # m[2, 1] + m[1] # m[2] + m[2] # m[1] + m[2, 1] # m[]
     1764            sage: m.coproduct_by_coercion(m[2,1]) == m([2,1]).coproduct()
     1765            True
     1766            sage: McdH = SymmetricFunctions(QQ['q','t'].fraction_field()).macdonald().H()
     1767            sage: McdH[2,1].coproduct()
     1768            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[]
     1769            sage: HLQp = SymmetricFunctions(QQ['t'].fraction_field()).hall_littlewood().Qp()
     1770            sage: HLQp[2,1].coproduct()                                                       
     1771            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[]
     1772            sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
     1773            sage: LLT = Sym.llt(3)
     1774            sage: LLT.cospin([3,2,1]).coproduct()
     1775            (t+1)*m[] # m[1, 1] + m[] # m[2] + (t+1)*m[1] # m[1] + (t+1)*m[1, 1] # m[] + m[2] # m[]
     1776        """
     1777        from sage.categories.tensor import tensor
     1778        s = self.realization_of().schur()
     1779        return self.tensor_square().sum(coeff * tensor([self(s[x]), self(s[y])])
     1780                                        for ((x,y), coeff) in s(elt).coproduct())
     1781
     1782
    17431783class SymmetricFunctionAlgebra_generic_Element(CombinatorialFreeModule.Element):
    17441784    r"""
    17451785    Class of generic elements for the symmetric function algebra.
     
    28512891        This is the vertex operator that generalizes Jing's operator.
    28522892
    28532893        It is a linear operator that raises the degree by
    2854         sum(nu). This creation operator is a t-analogue of
    2855         multiplication by s(nu)
     2894        `|\nu|`. This creation operator is a t-analogue of
     2895        multiplication by ``s(nu)`` .
    28562896
    28572897        .. SEEALSO:: Proposition 5 in [SZ2001]_.
    28582898
     
    28902930
    28912931        TESTS::
    28922932
    2893             sage: Sym = SymmetricFunctions(FractionField(QQ['t']))
    2894             sage: ks = Sym.kschur(4)
    2895             sage: ks([3,1,1]).lift().hl_creation_operator([1])
    2896             (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]
    2897             sage: ks(ks([3,1,1]).lift().hl_creation_operator([1]))
    2898             (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]
    28992933            sage: s(0).hl_creation_operator([1])
    29002934            0
    29012935        """
     
    29142948                        for mu in Partitions(d+1, max_length=len(nu)) )
    29152949                )
    29162950
     2951
    29172952SymmetricFunctionAlgebra_generic.Element = SymmetricFunctionAlgebra_generic_Element
    29182953
    29192954