def _to_s(self, part): """ Returns a function which gives the coefficient of a partition in the Schur expansion of self(part). EXAMPLES:: sage: Ht = MacdonaldPolynomialsHt(QQ) sage: f21 = Ht._to_s(Partition([2,1])) sage: [f21(part) for part in Partitions(3)] [1, q + t, q*t] sage: f22 = Ht._to_s(Partition([2,2])) sage: [f22(part) for part in Partitions(4)] [1, q*t + q + t, q^2 + t^2, q^2*t + q*t^2 + q*t, q^2*t^2] """ q, t = QQqt.gens() s = sfa.SFASchur(QQqt) J = MacdonaldPolynomialsJ(QQ) res = 0 for p in sage.combinat.partition.Partitions(sum(part)): res += (J(part).scalar_t(s(p), t)) * s(p) res = res.map_coefficients(lambda c: c.subs(t=1 / t)) res *= t**part.weighted_size() f = lambda part2: res.coefficient(part2) return f
def scalar(self, x): """ Returns standard scalar product between self and s. This is the default implementation that converts both self and x into Schur functions and performs the scalar product that basis. EXAMPLES:: sage: HLP = HallLittlewoodP(QQ) sage: HLQ = HallLittlewoodQ(QQ) sage: HLQp = HallLittlewoodQp(QQ) sage: HLP([2]).scalar(HLQp([2])) 1 sage: HLP([2]).scalar(HLQp([1,1])) 0 """ sp = self.parent() xp = x.parent() BR = sp.base_ring() s = sfa.SFASchur(BR) s_self = s(self) s_x = s(x) return s_self.scalar(s_x)
def __init__(self, R, t=None): """ TESTS:: sage: HallLittlewoodP(QQ) Hall-Littlewood polynomials in the P basis over Fraction Field of Univariate Polynomial Ring in t over Rational Field sage: HallLittlewoodP(QQ,t=2) Hall-Littlewood polynomials in the P basis with t=2 over Rational Field """ if t is None: R = R['t'].fraction_field() self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) else: self.t = R(t) self._name += " with t=%s" % self.t sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # print self, self._s # This coercion is broken: HLP = HallLittlewoodP(QQ); HLP(HLP._s[1]) # Bases defined by orthotriangularity should inherit from some # common category BasesByOrthotriangularity (shared with Jack, HL, orthotriang, Mcdo) if hasattr(self, "_s_cache"): self._s = sfa.SFASchur(R) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.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 __init__(self, R, q=None, t=None): """ EXAMPLES:: sage: MacdonaldPolynomialsP(QQ) Macdonald polynomials in the P basis over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field sage: MacdonaldPolynomialsP(QQ,t=2) Macdonald polynomials in the P basis with t=2 over Fraction Field of Univariate Polynomial Ring in q over Rational Field sage: MacdonaldPolynomialsP(QQ,q=2) Macdonald polynomials in the P basis with q=2 over Fraction Field of Univariate Polynomial Ring in t over Rational Field sage: MacdonaldPolynomialsP(QQ,q=2,t=2) Macdonald polynomials in the P basis with q=2 and t=2 over Rational Field """ #Neither q nor t are specified if t is None and q is None: R = R['q,t'].fraction_field() self.q, self.t = R.gens() elif t is not None and q is None: if t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) self.t = R(t) self._name += " with t=%s" % self.t R = R['q'].fraction_field() self.q = R.gen() elif t is None and q is not None: if q not in R: raise ValueError, "q (=%s) must be in R (=%s)" % (q, R) self.q = R(q) self._name += " with q=%s" % self.q R = R['t'].fraction_field() self.t = R.gen() else: if t not in R or q not in R: raise ValueError self.q = R(q) self.t = R(t) self._name += " with q=%s and t=%s" % (self.q, self.t) sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # Bases defined by orthotriangularity should inherit from some # common category BasesByOrthotriangularity (shared with Jack, HL, orthotriang, Mcdo) if hasattr(self, "_s_cache"): self._s = sfa.SFASchur(R) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.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 qt_kostka(lam, mu): """ Returns the `K_{\lambda\mu}(q,t)` by computing the change of basis from the Macdonald H basis to the Schurs. EXAMPLES:: sage: from sage.combinat.sf.macdonald import qt_kostka sage: qt_kostka([2,1,1],[1,1,1,1]) t^3 + t^2 + t sage: qt_kostka([1,1,1,1],[2,1,1]) q sage: qt_kostka([1,1,1,1],[3,1]) q^3 sage: qt_kostka([1,1,1,1],[1,1,1,1]) 1 sage: qt_kostka([2,1,1],[2,2]) q^2*t + q*t + q sage: qt_kostka([2,2],[2,2]) q^2*t^2 + 1 sage: qt_kostka([4],[3,1]) t sage: qt_kostka([2,2],[3,1]) q^2*t + q sage: qt_kostka([3,1],[2,1,1]) q*t^3 + t^2 + t sage: qt_kostka([2,1,1],[2,1,1]) q*t^2 + q*t + 1 sage: qt_kostka([2,1],[1,1,1,1]) 0 """ lam = sage.combinat.partition.Partition(lam) mu = sage.combinat.partition.Partition(mu) R = QQ['q,t'] if lam.size() != mu.size(): return R(0) if (lam, mu) in _qt_kostka_cache: return _qt_kostka_cache[(lam, mu)] H = MacdonaldPolynomialsH(QQ) s = sfa.SFASchur(H.base_ring()) parts = sage.combinat.partition.Partitions(mu.size()) for p2 in parts: res = s(H(p2)) for p1 in parts: _qt_kostka_cache[(p1, p2)] = R(res.coefficient(p1).numerator()) return _qt_kostka_cache[(lam, mu)]
def __init__(self, R, q=None, t=None): """ TESTS:: sage: S = MacdonaldPolynomialsS(QQ) sage: S == loads(dumps(S)) True """ self._name = "Macdonald polynomials in the S basis" self._prefix = "McdS" MacdonaldPolynomials_generic.__init__(self, R, q, t) self._s = sfa.SFASchur(self.base_ring()) self._self_to_s_cache = S_to_s_cache self._s_to_self_cache = s_to_S_cache _set_cache(cache_s, self)
def __init__(self, R, q=None, t=None): """ TESTS:: sage: Ht = MacdonaldPolynomialsHt(QQ) sage: Ht == loads(dumps(Ht)) True """ self._name = "Macdonald polynomials in the Ht basis" self._prefix = "McdHt" MacdonaldPolynomials_generic.__init__(self, R, q, t) self._s = sfa.SFASchur(self.base_ring()) self._self_to_s_cache = ht_to_s_cache self._s_to_self_cache = s_to_ht_cache self._J = MacdonaldPolynomialsJ(self.base_ring(), self.q, self.t) _set_cache(cache_ht, self)
def _to_s(self, part): """ Returns a function which gives the coefficient of a partition in the Schur expansion of self(part). EXAMPLES:: sage: H = MacdonaldPolynomialsH(QQ) sage: f21 = H._to_s(Partition([2,1])) sage: [f21(part) for part in Partitions(3)] [t, q*t + 1, q] """ q, t = QQqt.gens() s = sfa.SFASchur(QQqt) res = s(self._Ht(part)).map_coefficients(lambda c: c.subs(t=1 / t)) res *= t**part.weighted_size() f = lambda part2: res.coefficient(part2) return f
def __init__(self, R, k, t=None): """ EXAMPLES:: sage: kSchurFunctions(QQ, 3).base_ring() Univariate Polynomial Ring in t over Rational Field sage: kSchurFunctions(QQ, 3, t=1).base_ring() Rational Field sage: ks3 = kSchurFunctions(QQ, 3) sage: ks3 == loads(dumps(ks3)) True """ self.k = k self._name = "k-Schur Functions at level %s"%k self._prefix = "ks%s"%k self._element_class = kSchurFunctions_t.Element if t is None: R = R['t'] self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)"%(t,R) else: self.t = R(t) if str(t) != 't': self._name += " with t=%s"%self.t self._s_to_self_cache = s_to_k_cache.get(k, {}) self._self_to_s_cache = k_to_s_cache.get(k, {}) # This is an abuse, since kschur functions do not form a basis of Sym sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # so we need to take some counter measures self._basis_keys = sage.combinat.partition.Partitions(NonNegativeIntegers(), max_part=k) self._s = sfa.SFASchur(self.base_ring()) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) # This really should be a conversion, not a coercion (it can fail) 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 expand(self, n, alphabet='x'): """ Expands the symmetric function as a symmetric polynomial in `n` variables. EXAMPLES:: sage: HLP = HallLittlewoodP(QQ) sage: HLQ = HallLittlewoodQ(QQ) sage: HLQp = HallLittlewoodQp(QQ) sage: HLP([2]).expand(2) x0^2 + (-t + 1)*x0*x1 + x1^2 sage: HLQ([2]).expand(2) (-t + 1)*x0^2 + (t^2 - 2*t + 1)*x0*x1 + (-t + 1)*x1^2 sage: HLQp([2]).expand(2) x0^2 + x0*x1 + x1^2 """ sp = self.parent() BR = sp.base_ring() s = sfa.SFASchur(BR) return s(self).expand(n, alphabet=alphabet)
def _to_s(self, part): """ Returns a function which gives the coefficient of a partition in the Schur expansion of self(part). EXAMPLES:: sage: S = MacdonaldPolynomialsS(QQ) sage: S2 = S._to_s(Partition([2])) sage: S2(Partition([2])) -t + 1 sage: S2(Partition([1,1])) t^2 - t """ #Covert to the power sum p = sfa.SFAPower(QQqt) s = sfa.SFASchur(QQqt) p_x = p(s(part)) t = self.t f = lambda m, c: (m, c * prod([(1 - t**k) for k in m])) res = s(p_x.map_item(f)) f = lambda part2: res.coefficient(part2) return f