Exemple #1
0
    def _o_to_s_on_basis(self, lam):
        r"""
        Return the orthogonal symmetric function ``o[lam]`` expanded in
        the Schur basis, where ``lam`` is a partition.

        TESTS:

        Check that this is the inverse::

            sage: o = SymmetricFunctions(QQ).o()
            sage: s = SymmetricFunctions(QQ).s()
            sage: all(o(s(o[la])) == o[la] for i in range(5) for la in Partitions(i))
            True
            sage: all(s(o(s[la])) == s[la] for i in range(5) for la in Partitions(i))
            True
        """
        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)  # // 2 for horizontal dominoes
            for mu in Partitions(n - 2 * j)
        })
Exemple #2
0
    def _s_to_o_on_basis(self, lam):
        r"""
        Return the Schur symmetric function ``s[lam]`` expanded in
        the orthogonal basis, where ``lam`` is a partition.

        INPUT:

        - ``lam`` -- a partition

        OUTPUT:

        - the expansion of ``s[lam]`` in the orthogonal basis ``self``

        EXAMPLES::

            sage: Sym = SymmetricFunctions(QQ)
            sage: s = Sym.schur()
            sage: o = Sym.orthogonal()
            sage: o._s_to_o_on_basis(Partition([]))
            o[]
            sage: o._s_to_o_on_basis(Partition([4,2,1]))
            o[1] + 2*o[2, 1] + o[2, 2, 1] + o[3]
             + o[3, 1, 1] + o[3, 2] + o[4, 1] + o[4, 2, 1]
            sage: s(o._s_to_o_on_basis(Partition([3,1]))) == s[3,1]
            True
        """
        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)  # // 2 for horizontal dominoes
            for mu in Partitions(n - 2 * j)
        })
Exemple #3
0
    def _s_to_sp_on_basis(self, lam):
        r"""
        Return the Schur symmetric function ``s[lam]`` expanded in
        the symplectic basis, where ``lam`` is a partition.

        INPUT:

        - ``lam`` -- a partition

        OUTPUT:

        - the expansion of ``s[lam]`` in the symplectic basis ``self``

        EXAMPLES::

            sage: Sym = SymmetricFunctions(QQ)
            sage: s = Sym.schur()
            sage: sp = Sym.symplectic()
            sage: sp._s_to_sp_on_basis(Partition([]))
            sp[]
            sage: sp._s_to_sp_on_basis(Partition([4,2,1]))
            sp[2, 1] + sp[3] + sp[3, 1, 1] + sp[3, 2] + sp[4, 1] + sp[4, 2, 1]
            sage: s(sp._s_to_sp_on_basis(Partition([3,1]))) == s[3,1]
            True
        """
        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)  # // 2 for vertical dominoes
            for mu in Partitions(n - 2 * j)
        })
Exemple #4
0
    def _llt_generic(self, skp, stat):
        r"""
        Takes in partition, list of partitions, or a list of skew
        partitions as well as a function which takes in two partitions and
        a level and returns a coefficient.

        INPUT:

        - ``self`` -- a family of LLT symmetric functions bases
        - ``skp`` -- a partition or a list of partitions or a list of skew partitions
        - ``stat`` -- a function which accepts two partitions and a value
          for the level and returns a coefficient which is a polynomial
          in a parameter `t`.  The first partition is the index of the
          LLT function, the second partition is the index of the monomial
          basis element.

        OUTPUT:

        - returns the monomial expansion of the LLT symmetric function
          indexed by ``skp``

        EXAMPLES::

            sage: L3 = SymmetricFunctions(FractionField(QQ['t'])).llt(3)
            sage: f = lambda skp,mu,level: QQ(1)
            sage: L3._llt_generic([3,2,1],f)
            m[1, 1] + m[2]
            sage: L3._llt_generic([[2,1],[1],[2]],f)
            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]
            sage: L3._llt_generic([[[2,2],[1]],[[2,1],[]]],f)
            m[1, 1, 1, 1] + m[2, 1, 1] + m[2, 2] + m[3, 1] + m[4]
        """
        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():
            #skp is a list of skew partitions
            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 is a list of 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])
Exemple #5
0
    def antipode_on_basis(self, a):
        """
        Return the antipode of the basis element indexed by ``a``.

        EXAMPLES::

            sage: R = PolynomialRing(ZZ, 'q').fraction_field()
            sage: q = R.gen()
            sage: I = HallAlgebra(R, q).monomial_basis()
            sage: I.antipode_on_basis(Partition([1]))
            -I[1]
            sage: I.antipode_on_basis(Partition([2]))
            1/q*I[1, 1] - I[2]
            sage: I.antipode_on_basis(Partition([2,1]))
            -1/q*I[1, 1, 1] + I[2, 1]

            sage: R.<q> = LaurentPolynomialRing(ZZ)
            sage: I = HallAlgebra(R, q).monomial_basis()
            sage: I.antipode_on_basis(Partition([2,1]))
            -(q^-1)*I[1, 1, 1] + I[2, 1]
        """
        H = HallAlgebra(self.base_ring(), self._q)
        cur = self.one()
        for r in a:
            q = (-1) ** r * self._q ** (-(r * (r - 1)) // 2)
            cur *= self(H._from_dict({p: q for p in Partitions(r)}))
        return cur
    def _repr_(self):
        """
        Return a string representation of ``self``.

        EXAMPLES::

            sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]])
            sage: elt =  RC(partition_list=[[2],[2,2],[2,1],[2]])[2]
            sage: elt # indirect doctest
            0[ ][ ]0
            -1[ ]-1
            <BLANKLINE>
            sage: Partitions.global_options(convention="french")
            sage: elt # indirect doctest
            -1[ ]-1
            0[ ][ ]0
            <BLANKLINE>
            sage: Partitions.global_options.reset()
        """
        # If it is empty, return saying so
        if len(self._list) == 0:
            return("(/)\n")

        from sage.combinat.partition import Partitions
        if Partitions.global_options("convention") == "french":
            itr = reversed(list(enumerate(self._list)))
        else:
            itr = enumerate(self._list)
        retStr = ""
        for i, val in itr:
            retStr += str(self.vacancy_numbers[i])
            retStr += "[ ]"*val
            retStr += str(self.rigging[i])
            retStr += "\n"
        return(retStr)
Exemple #7
0
    def __init__(self, t, domain, codomain):
        """
        Initialization of ``self``.

        INPUT:

        - ``t`` -- a function taking a monomial in CombinatorialFreeModule(QQ, Partitions()),
           and returning a (partition, coefficient) list.

        - ``domain``, ``codomain`` -- parents

        Construct a function mapping a partition to an element of ``codomain``.

        This is a temporary quick hack to wrap around the existing
        symmetrica conversions, without changing their specs.

        EXAMPLES::

            sage: Sym = SymmetricFunctions(QQ[x])
            sage: p = Sym.p(); s = Sym.s()
            sage: def t(x) : [(p,c)] = x; return [ (p,2*c), (p.conjugate(), c) ]
            sage: f = sage.combinat.sf.sf.SymmetricaConversionOnBasis(t, p, s)
            sage: f(Partition([3,1]))
            s[2, 1, 1] + 2*s[3, 1]
        """
        self._domain = domain
        self.fake_sym = CombinatorialFreeModule(QQ, Partitions())
        self._codomain = codomain
        self._t = t
Exemple #8
0
    def __iter__(self):
        """
        An iterator for ``self``.

        This generates the rooted trees of given size. The algorithm
        first picks a partition for the sizes of subtrees, then picks
        appropriate tuples of smaller trees.

        EXAMPLES::

            sage: from sage.combinat.rooted_tree import *
            sage: RootedTrees(1).list()
            [[]]
            sage: RootedTrees(2).list()
            [[[]]]
            sage: RootedTrees(3).list()
            [[[[]]], [[], []]]
            sage: RootedTrees(4).list()
            [[[[[]]]], [[[], []]], [[], [[]]], [[], [], []]]
        """
        if self._n == 1:
            yield self._element_constructor_([])
            return

        from sage.combinat.partition import Partitions
        from itertools import combinations_with_replacement, product
        for part in Partitions(self._n - 1):
            mults = part.to_exp_dict()
            choices = []
            for p, mp in mults.items():
                lp = self.__class__(p).list()
                new_choice = [list(z) for z in combinations_with_replacement(lp, mp)]
                choices.append(new_choice)
            for c in product(*choices):
                yield self.element_class(self._parent_for, sum(c, []))
Exemple #9
0
    def _qbar_to_p_on_generator(self, n):
        r"""
        Convert a generator of the basis indexed by ``n`` to the
        power sum basis.

        INPUT:

        - ``n`` -- a non-negative integer

        EXAMPLES::

            sage: qbar = SymmetricFunctions(QQ['q'].fraction_field()).qbar('q')
            sage: qbar._qbar_to_p_on_generator(3)
            (1/6*q^2-1/3*q+1/6)*p[1, 1, 1]
             + (1/2*q^2-1/2)*p[2, 1]
             + (1/3*q^2+1/3*q+1/3)*p[3]
            sage: qbar = SymmetricFunctions(QQ).qbar(-1)
            sage: qbar._qbar_to_p_on_generator(3)
            2/3*p[1, 1, 1] + 1/3*p[3]
        """
        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:]))
Exemple #10
0
    def antipode_on_basis(self, la):
        """
        Return the antipode of the basis element indexed by ``la``.

        EXAMPLES::

            sage: R = PolynomialRing(ZZ, 'q').fraction_field()
            sage: q = R.gen()
            sage: H = HallAlgebra(R, q)
            sage: H.antipode_on_basis(Partition([1,1]))
            1/q*H[2] + 1/q*H[1, 1]
            sage: H.antipode_on_basis(Partition([2]))
            -1/q*H[2] + ((q^2-1)/q)*H[1, 1]

            sage: R.<q> = LaurentPolynomialRing(ZZ)
            sage: H = HallAlgebra(R, q)
            sage: H.antipode_on_basis(Partition([1,1]))
            (q^-1)*H[2] + (q^-1)*H[1, 1]
            sage: H.antipode_on_basis(Partition([2]))
            -(q^-1)*H[2] - (q^-1-q)*H[1, 1]
        """
        if all(x == 1 for x in la):
            r = len(la)
            q = (-1) ** r * self._q ** (-(r * (r - 1)) // 2)
            return self._from_dict({p: q for p in Partitions(r)})

        I = HallAlgebraMonomials(self.base_ring(), self._q)
        return self(I(self.monomial(la)).antipode())
Exemple #11
0
    def __classcall_private__(cls, s, part=None):
        """
        Normalize input to ensure a unique representation.

        EXAMPLES::

            sage: S = SetPartitions(4)
            sage: T = SetPartitions([1,2,3,4])
            sage: S is T
            True
        """
        if isinstance(s, (int, Integer)):
            s = frozenset(range(1, s + 1))
        else:
            try:
                if s.cardinality() == infinity:
                    raise ValueError("The set must be finite")
            except AttributeError:
                pass
            s = frozenset(s)

        if part is not None:
            if isinstance(part, (int, Integer)):
                if len(s) < part:
                    raise ValueError("part must be <= len(set)")
                else:
                    return SetPartitions_setn(s, part)
            else:
                if part not in Partitions(len(s)):
                    raise ValueError("part must be a partition of %s" % len(s))
                else:
                    return SetPartitions_setparts(s, Partition(part))
        else:
            return SetPartitions_set(s)
Exemple #12
0
    def _repr_(self):
        """
        Return a string representation of ``self``.

        EXAMPLES::

            sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]])
            sage: elt =  RC(partition_list=[[2],[2,2],[2,1],[2]])[2]
            sage: elt # indirect doctest
            0[ ][ ]0
            -1[ ]-1
            <BLANKLINE>
            sage: Partitions.global_options(convention="french")
            sage: elt # indirect doctest
            -1[ ]-1
            0[ ][ ]0
            <BLANKLINE>
            sage: Partitions.global_options.reset()
        """
        # If it is empty, return saying so
        if len(self._list) == 0:
            return ("(/)\n")

        from sage.combinat.partition import Partitions
        if Partitions.global_options("convention") == "french":
            itr = reversed(list(enumerate(self._list)))
        else:
            itr = enumerate(self._list)
        retStr = ""
        for i, val in itr:
            retStr += str(self.vacancy_numbers[i])
            retStr += "[ ]" * val
            retStr += str(self.rigging[i])
            retStr += "\n"
        return (retStr)
Exemple #13
0
    def YoungsLattice(n):
        """
        Return Young's Lattice up to rank `n`.

        In other words, the poset of partitions
        of size less than or equal to `n` ordered by inclusion.

        INPUT:

        - ``n`` -- a positive integer

        EXAMPLES::

            sage: P = Posets.YoungsLattice(3); P
            Finite meet-semilattice containing 7 elements
            sage: P.cover_relations()
            [[[], [1]],
             [[1], [1, 1]],
             [[1], [2]],
             [[1, 1], [1, 1, 1]],
             [[1, 1], [2, 1]],
             [[2], [2, 1]],
             [[2], [3]]]
        """
        from sage.combinat.partition import Partitions, Partition
        from sage.misc.flatten import flatten
        partitions = flatten([list(Partitions(i)) for i in range(n + 1)])
        return JoinSemilattice((partitions, Partition.contains)).dual()
    def _functorial_compose_gen(self, g, ao):
        """
        Return a generator for the coefficients of the functorial
        composition of ``self`` with ``g``.

        EXAMPLES::

            sage: E = species.SetSpecies()
            sage: E2 = species.SetSpecies(size=2)
            sage: WP = species.SubsetSpecies()
            sage: P2 = E2*E
            sage: P2_cis = P2.cycle_index_series()
            sage: WP_cis = WP.cycle_index_series()
            sage: g = WP_cis._functorial_compose_gen(P2_cis,0)
            sage: [next(g) for i in range(5)]
            [p[],
             p[1],
             p[1, 1] + p[2],
             4/3*p[1, 1, 1] + 2*p[2, 1] + 2/3*p[3],
             8/3*p[1, 1, 1, 1] + 4*p[2, 1, 1] + 2*p[2, 2] + 4/3*p[3, 1] + p[4]]
        """
        p = self.parent().base_ring()
        n = 0
        while True:
            res = p(0)
            for s in Partitions(n):
                t = g._cycle_type(s)
                q = self.count(t) / s.aut()
                res += q * p(s)
            yield res
            n += 1
def bulgarian_solitaire(n):
    r"""
    Return the finite discrete dynamical system defined
    by Bulgarian solitaire on partitions of size `n`.

    Let `n` be a nonnegative integer.
    Let `P` be the set of all integer partitions of
    size `n`.
    Let `B : P \to P` be the map that sends each
    partition
    `\lambda = (\lambda_1, \lambda_2, \ldots, \lambda_k)`
    of `n` (with all the `\lambda_i` positive) to
    `(\lambda_1 - 1, \lambda_2 - 1, \ldots, \lambda_k - 1, k)`,
    where zero entries have been removed and the remaining
    entries sorted into decreasing order.
    (For example,
    `B(5, 4, 2, 2, 1, 1) = (6, 4, 3, 1, 1)`.)
    This method yields the finite DDS whose ground set
    is `P` and whose evolution is `B`.

    EXAMPLES::

        sage: BS = finite_dynamical_systems.bulgarian_solitaire
        sage: BS(3).evolution()(Partition([3]))
        [2, 1]
        sage: BS(3).evolution()(Partition([2, 1]))
        [2, 1]
        sage: BS(3).evolution()(Partition([1, 1, 1]))
        [3]
        sage: BS(4).evolution()(Partition([4]))
        [3, 1]
        sage: BS(4).orbit(Partition([4]))
        [[4], [3, 1], [2, 2], [2, 1, 1]]
        sage: BS(4).orbit(Partition([3, 1]))
        [[3, 1], [2, 2], [2, 1, 1]]
        sage: BS(7).orbit(Partition([6, 1]), preperiod=True)
        ([[6, 1], [5, 2], [4, 2, 1], [3, 3, 1], [3, 2, 2], [3, 2, 1, 1]], 2)
        sage: BS(6).is_homomesic(lambda lam: len(lam))
        True
        sage: BS(6).is_homomesic(lambda lam: lam[0])
        True
        sage: BS(6).is_homomesic(lambda lam: lam[-1])
        True
        sage: BS(8).is_homomesic(lambda lam: len(lam))
        True
        sage: BS(8).is_homomesic(lambda lam: lam[0])
        True
        sage: BS(8).is_homomesic(lambda lam: lam[-1])
        False
    """
    from sage.combinat.partition import Partition, Partitions
    X = Partitions(n)

    def phi(lam):
        mu = [p - 1 for p in lam if p > 0]
        nu = sorted(mu + [len(lam)], reverse=True)
        return Partition(nu)

    return FiniteDynamicalSystem(X, phi)
Exemple #16
0
    def __iter__(self):
        r"""
        Iterate over ``self``.

        EXAMPLES::

            sage: PTC = PrimarySimilarityClassTypes(2)
            sage: PTC.cardinality()
            3
        """
        n = self._n
        if self._min[0].divides(n):
            for par in Partitions(ZZ(n / self._min[0]), starting=self._min[1]):
                yield self.element_class(self, self._min[0], par)
        for d in filter(lambda d: d > self._min[0], divisors(n)):
            for par in Partitions(ZZ(n / d)):
                yield self.element_class(self, d, par)
Exemple #17
0
    def k_schur_noncommutative_variables(self, la):
        r"""
        In type `A^{(1)}` this is the `k`-Schur function in noncommutative variables defined by Thomas Lam.

        REFERENCES:

           .. [Lam2005] T. Lam, Affine Stanley symmetric functions, Amer. J. Math.  128  (2006),  no. 6, 1553--1586.

        This function is currently only defined in type `A^{(1)}`.

        INPUT:

        - ``la`` -- a partition with first part bounded by the rank of the Weyl group

        EXAMPLES::

            sage: A = NilCoxeterAlgebra(WeylGroup(['A',3,1]))
            sage: A.k_schur_noncommutative_variables([2,2])
            u[0,3,1,0] + u[3,1,2,0] + u[1,2,0,1] + u[3,2,0,3] + u[2,0,3,1] + u[2,3,1,2]

        TESTS::

            sage: A = NilCoxeterAlgebra(WeylGroup(['A',3,1]))
            sage: A.k_schur_noncommutative_variables([])
            1

            sage: A.k_schur_noncommutative_variables([1,2])
            Traceback (most recent call last):
            ...
            AssertionError: [1, 2] is not a partition.

            sage: A.k_schur_noncommutative_variables([4,2])
            Traceback (most recent call last):
            ...
            AssertionError: [4, 2] is not a 3-bounded partition.

            sage: C = NilCoxeterAlgebra(WeylGroup(['C',3,1]))
            sage: C.k_schur_noncommutative_variables([2,2])
            Traceback (most recent call last):
            ...
            AssertionError: Weyl Group of type ['C', 3, 1] (as a matrix group acting on the root space) is not affine type A.


        """
        assert self._cartan_type[0] == 'A' and len(
            self._cartan_type) == 3 and self._cartan_type[
                2] == 1, "%s is not affine type A." % (self._W)
        assert la in Partitions(), "%s is not a partition." % (la)
        assert (len(la) == 0 or la[0] < self._W.n
                ), "%s is not a %s-bounded partition." % (la, self._W.n - 1)
        Sym = SymmetricFunctions(self._base_ring)
        h = Sym.homogeneous()
        ks = Sym.kschur(self._n - 1, 1)
        f = h(ks[la])
        return sum(
            f.coefficient(x) * self.homogeneous_noncommutative_variables(x)
            for x in f.support())
Exemple #18
0
    def __iter__(self):
        r"""
        An iterator for super partitions of degree ``n`` and sector ``m``.

        EXAMPLES::

            sage: SuperPartitions(6,2).cardinality()
            28
            sage: SuperPartitions(6,4).first()
            [3, 2, 1, 0; ]
        """
        for r in range(self.n + 1):
            for p1 in Partitions(r):
                for p0 in Partitions(self.n - r, max_slope=-1, length=self.m):
                    yield self.element_class(self, [list(p0), list(p1)])
                for p0 in Partitions(self.n - r,
                                     max_slope=-1,
                                     length=self.m - 1):
                    yield self.element_class(self, [list(p0) + [0], list(p1)])
Exemple #19
0
    def __init__(self, base_ring):
        """
        EXAMPLES::

            sage: A = GradedModulesWithBasis(QQ).example(); A
            An example of a graded module with basis: the free module on partitions over Rational Field
            sage: TestSuite(A).run()
        """
        CombinatorialFreeModule.__init__(self, base_ring, Partitions(),
                                         category=GradedModulesWithBasis(base_ring))
Exemple #20
0
    def _DualGrothendieck(self,la):
        r"""
        Returns the expansion of the K-`k`-Schur function in the homogeneous basis. This
        method is here for caching purposes.

        INPUT:

        - ``la`` -- A `k`-bounded partition.

        OUTPUT:

        - A symmetric function in the homogeneous basis.

        EXAMPLES::

            sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()
            sage: g._DualGrothendieck(Partition([2,1]))
            h[2] + h[2, 1] - h[3]
            sage: g._DualGrothendieck(Partition([]))
            h[]
            sage: g._DualGrothendieck(Partition([4,1]))
            0
        """
        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 __init__(self, R):
        """
        TESTS::

            sage: s = sage.combinat.combinatorial_algebra.TestAlgebra(QQ)
            sage: TestSuite(s).run()
        """
        from sage.combinat.partition import Partition, Partitions
        self._one = Partition([])
        CombinatorialAlgebra.__init__(self, R, cc=Partitions())
Exemple #22
0
    def _DualGrothMatrix(self, m):
        r"""
        Returns the change of basis matrix between the K_kschur basis and the `k`-bounded
        homogeneous basis.

        INPUT:

        - ``m`` -- An integer

        OUTPUT:

        - A matrix.

        EXAMPLES::

            sage: g = SymmetricFunctions(QQ).kBoundedSubspace(3,1).K_kschur()
            sage: g._DualGrothMatrix(3)
            [ 1  1  1  0  0  0  0]
            [ 0  1  2  0  0  0  0]
            [ 0  0  1  0  0  0  0]
            [ 0 -1 -2  1  1  0  0]
            [ 0  0 -2  0  1  0  0]
            [ 0  0  1  0 -1  1  0]
            [ 0  0  0  0  0  0  1]
            sage: g._DualGrothMatrix(0)
            [1]
        """
        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)
    def cardinality(self):
        """
        Return the cardinality of ``self``.

        EXAMPLES::

            sage: sp = SymmetricGroupRepresentations(4, "specht")
            sage: sp.cardinality()
            5
        """
        return Partitions(self._n).cardinality()
Exemple #24
0
    def list(self):
        r"""
        Returns the list of all `k`-cores of length `n`.

        EXAMPLES::

            sage: C = Cores(3,4)
            sage: C.list()
            [[4, 2], [3, 1, 1], [2, 2, 1, 1]]
        """
        return [la.to_core(self.k-1) for la in Partitions(self.n, max_part=self.k-1)]
Exemple #25
0
        def transition_matrix(self, other, n):
            """
            Return the degree ``n`` transition matrix between ``self`` and ``other``.

            INPUT:

            - ``other`` -- a basis in the ring of symmetric functions
            - ``n`` -- a positive integer

            The entry in the `i^{th}` row and `j^{th}` column is the
            coefficient obtained by writing the `i^{th}` element of the
            basis of ``self`` in terms of the basis ``other``, and extracting the
            `j^{th}` coefficient.

            EXAMPLES::

                sage: Sym = SymmetricFunctions(QQ); s = Sym.schur()
                sage: ks3 = Sym.kschur(3,1)
                sage: ks3.transition_matrix(s,5)
                [1 1 1 0 0 0 0]
                [0 1 0 1 0 0 0]
                [0 0 1 0 1 0 0]
                [0 0 0 1 0 1 0]
                [0 0 0 0 1 1 1]

                sage: Sym = SymmetricFunctions(QQ['t'])
                sage: s = Sym.schur()
                sage: ks = Sym.kschur(3)
                sage: ks.transition_matrix(s,5)
                [t^2   t   1   0   0   0   0]
                [  0   t   0   1   0   0   0]
                [  0   0   t   0   1   0   0]
                [  0   0   0   t   0   1   0]
                [  0   0   0   0 t^2   t   1]
            """
            P = Partitions(n, max_part=self.k)
            # todo: Q should be set by getting the degree n index set for
            # `other`.
            Q = Partitions(n)
            return matrix( [[other(self[row]).coefficient(col) for col in Q]
                            for row in P] )
Exemple #26
0
    def __iter__(self):
        """
        Iterate over ``self``.

        EXAMPLES::

            sage: SetPartitions(3).list()
            [{{1, 2, 3}}, {{1}, {2, 3}}, {{1, 3}, {2}}, {{1, 2}, {3}}, {{1}, {2}, {3}}]
        """
        for p in Partitions(len(self._set)):
            for sp in self._iterator_part(p):
                yield self.element_class(self, sp)
Exemple #27
0
    def list(self):
        r"""
        Returns the list of all `k`-cores of size `n`.

        EXAMPLES::

            sage: C = Cores(3, size = 4)
            sage: C.list()
            [[3, 1], [2, 1, 1]]
        """
        k_cores = filter(lambda x: x.is_core(self.k), Partitions(self.n))
        return [Core(x, self.k) for x in k_cores]
Exemple #28
0
def _exp_term(n, R = RationalField()):
    """
    Compute the order-n term of the cycle index series of the species `E` of sets.

    EXAMPLES::

        sage: from sage.combinat.species.generating_series import _exp_term
        sage: [_exp_term(i) for i in range(4)]
        [p[], p[1], 1/2*p[1, 1] + 1/2*p[2], 1/6*p[1, 1, 1] + 1/2*p[2, 1] + 1/3*p[3]]
    """
    p = SymmetricFunctions(R).power()
    return sum(p(part) / part.aut() for part in Partitions(n))
Exemple #29
0
def create_power_values(r, s, poly_degree):
    list_of_power_values = []
    for partition_set in Partitions(poly_degree, max_length=r + s).list():
        partition_set = list(partition_set)
        if max(partition_set) < max(r, s):
            if len(partition_set) == r + s:
                list_of_power_values.append(partition_set)
            else:
                while len(partition_set) < r + s:
                    partition_set.append(0)
                list_of_power_values.append(partition_set)
    return list_of_power_values
Exemple #30
0
    def __iter__(self):
        r"""
        TESTS::

            sage: list(AbelianStrata(genus=1))
            [H(0)]
        """
        if self._genus == 0:
            pass
        elif self._genus == 1:
            yield AbelianStratum(0, marked_separatrix=self._marked_separatrix)
        else:
            if self._marked_separatrix == 'no':
                for p in Partitions(2*self._genus-2):
                    yield AbelianStratum(p)
            else:
                for p in Partitions(2*self._genus-2):
                    l = list(p)
                    for t in set(l):
                        i = l.index(t)
                        yield AbelianStratum([t] + l[:i] + l[i+1:],
                                             marked_separatrix=self._marked_separatrix)
Exemple #31
0
    def list(self):
        r"""
        Returns the list of all `k`-cores of size `n`.

        EXAMPLES::

            sage: C = Cores(3, size = 4)
            sage: C.list()
            [[3, 1], [2, 1, 1]]
        """
        return [
            Core(x, self.k) for x in Partitions(self.n) if x.is_core(self.k)
        ]
Exemple #32
0
    def _repr_(self):
        """
        Return a string representation of ``self``.

        INPUT:

        - ``half_width_boxes`` -- (Default: ``True``) Display the partition
          using half width boxes

        EXAMPLES::

            sage: RC = RiggedConfigurations(['B', 2, 1], [[2, 2]])
            sage: elt = RC(partition_list=[[2],[2,1]])[1]
            sage: elt
            -2[][]-2
            -2[]-2
            <BLANKLINE>
            sage: RiggedConfigurations.use_half_width_boxes_type_B = False
            sage: elt
            -2[ ][ ]-2
            -2[ ]-2
            <BLANKLINE>
            sage: RiggedConfigurations.use_half_width_boxes_type_B = True
        """
        # If it is empty, return saying so
        if len(self._list) == 0:
            return "(/)\n"

        from sage.combinat.partition import Partitions

        if Partitions.global_options("convention") == "french":
            itr = reversed(list(enumerate(self._list)))
        else:
            itr = enumerate(self._list)
        ret_str = ""

        from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations

        if RiggedConfigurations.use_half_width_boxes_type_B:
            box_str = "[]"
        else:
            box_str = "[ ]"

        vac_num_width = max(len(str(vac_num)) for vac_num in self.vacancy_numbers)
        for i, val in itr:
            ret_str += ("{:>" + str(vac_num_width) + "}").format(self.vacancy_numbers[i])
            ret_str += box_str * val
            ret_str += str(self.rigging[i])
            ret_str += "\n"
        return ret_str
Exemple #33
0
    def _repr_(self):
        """
        Return a string representation of ``self``.

        EXAMPLES::

            sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]])
            sage: elt =  RC(partition_list=[[2],[2,2],[2,1],[2]])[2]
            sage: elt
             0[ ][ ]0
            -1[ ]-1
            <BLANKLINE>
            sage: Partitions.global_options(convention="french")
            sage: elt
            -1[ ]-1
             0[ ][ ]0
            <BLANKLINE>
            sage: Partitions.global_options.reset()
        """
        # If it is empty, return saying so
        if len(self._list) == 0:
            return "(/)\n"

        from sage.combinat.partition import Partitions

        if Partitions.global_options("convention") == "French":
            itr = reversed(list(enumerate(self._list)))
        else:
            itr = enumerate(self._list)
        ret_str = ""
        vac_num_width = max(len(str(vac_num)) for vac_num in self.vacancy_numbers)
        for i, val in itr:
            ret_str += ("{:>" + str(vac_num_width) + "}").format(self.vacancy_numbers[i])
            ret_str += "[ ]" * val
            ret_str += str(self.rigging[i])
            ret_str += "\n"
        return ret_str
Exemple #34
0
def GL_irreducible_character(n, mu, KK):
    r"""
    Return the character of the irreducible module indexed by ``mu``
    of `GL(n)` over the field ``KK``.

    INPUT:

    - ``n`` -- a positive integer
    - ``mu`` -- a partition of at most ``n`` parts
    - ``KK`` -- a field

    OUTPUT:

    a symmetric function which should be interpreted in ``n``
    variables to be meaningful as a character

    EXAMPLES:

    Over `\QQ`, the irreducible character for `\mu` is the Schur
    function associated to `\mu`, plus garbage terms (Schur
    functions associated to partitions with more than `n` parts)::

        sage: from sage.algebras.schur_algebra import GL_irreducible_character
        sage: sbasis = SymmetricFunctions(QQ).s()
        sage: z = GL_irreducible_character(2, [2], QQ)
        sage: sbasis(z)
        s[2]

        sage: z = GL_irreducible_character(4, [3, 2], QQ)
        sage: sbasis(z)
        -5*s[1, 1, 1, 1, 1] + s[3, 2]

    Over a Galois field, the irreducible character for `\mu` will
    in general be smaller.

    In characteristic `p`, for a one-part partition `(r)`, where
    `r = a_0 + p a_1 + p^2 a_2 + \dots`, the result is (see [GreenPoly]_,
    after 5.5d) the product of `h[a_0], h[a_1]( pbasis[p]), h[a_2]
    ( pbasis[p^2]), \dots,` which is consistent with the following ::

        sage: from sage.algebras.schur_algebra import GL_irreducible_character
        sage: GL_irreducible_character(2, [7], GF(3))
        m[4, 3] + m[6, 1] + m[7]
    """
    mbasis = SymmetricFunctions(QQ).m()
    r = sum(mu)
    M = SchurTensorModule(KK, n, r)
    A = M._schur
    SGA = M._sga

    # make ST the superstandard tableau of shape mu
    from sage.combinat.tableau import from_shape_and_word

    ST = from_shape_and_word(mu, range(1, r + 1), convention="English")

    # make ell the reading word of the highest weight tableau of shape mu
    ell = [i + 1 for i, l in enumerate(mu) for dummy in range(l)]

    e = M.basis()[tuple(ell)]  # the element e_l

    # This is the notation `\{X\}` from just before (5.3a) of [GreenPoly]_.
    S = SGA._indices
    BracC = SGA._from_dict({S(x.tuple()): x.sign() for x in ST.column_stabilizer()}, remove_zeros=False)
    f = e * BracC  # M.action_by_symmetric_group_algebra(e, BracC)

    # [Green, Theorem 5.3b] says that a basis of the Carter-Lusztig
    # module V_\mu is given by taking this f, and multiplying by all
    # xi_{i,ell} with ell as above and i semistandard.

    carter_lusztig = []
    for T in SemistandardTableaux(mu, max_entry=n):
        i = tuple(flatten(T))
        schur_rep = schur_representative_from_index(i, tuple(ell))
        y = A.basis()[schur_rep] * e  # M.action_by_Schur_alg(A.basis()[schur_rep], e)
        carter_lusztig.append(y.to_vector())

    # Therefore, we now have carter_lusztig as a list giving the basis
    # of `V_\mu`

    # We want to think of expressing this character as a sum of monomial
    # symmetric functions.

    # We will determine a basis element for each m_\lambda in the
    # character, and we want to keep track of them by \lambda.

    # That means that we only want to pick out the basis elements above for
    # those semistandard words whose content is a partition.

    contents = Partitions(r, max_length=n).list()
    # all partitions of r, length at most n

    # JJ will consist of a list for each element of `contents`,
    # recording the list
    # of semistandard tableaux words with that content

    # graded_basis will consist of the a corresponding basis element
    graded_basis = []
    JJ = []
    for i in range(len(contents)):
        graded_basis.append([])
        JJ.append([])
    for T in SemistandardTableaux(mu, max_entry=n):
        i = tuple(flatten(T))
        # Get the content of T
        con = [0] * n
        for a in i:
            con[a - 1] += 1
        try:
            P = Partition(con)
            P_index = contents.index(P)
            JJ[P_index].append(i)
            schur_rep = schur_representative_from_index(i, tuple(ell))
            x = A.basis()[schur_rep] * f  # M.action_by_Schur_alg(A.basis()[schur_rep], f)
            graded_basis[P_index].append(x.to_vector())
        except ValueError:
            pass

    # There is an inner product on the Carter-Lusztig module V_\mu; its
    # maximal submodule is exactly the kernel of the inner product.

    # Now, for each possible partition content, we look at the graded piece of
    # that degree, and we record how these elements pair with each of the
    # elements of carter_lusztig.

    # The kernel of this pairing is the part of this graded piece which is
    # not in the irreducible module for \mu.

    length = len(carter_lusztig)

    phi = mbasis.zero()
    for aa in range(len(contents)):
        mat = []
        for kk in range(len(JJ[aa])):
            temp = []
            for j in range(length):
                temp.append(graded_basis[aa][kk].inner_product(carter_lusztig[j]))
            mat.append(temp)
        angle = Matrix(mat)
        phi += (len(JJ[aa]) - angle.nullity()) * mbasis(contents[aa])
    return phi