Esempio n. 1
0
        def __init__(self, alg, prefix="D"):
            r"""
            Initialize ``self``.

            EXAMPLES::

                sage: TestSuite(DescentAlgebra(QQ, 4).D()).run()
            """
            self._prefix = prefix
            self._basis_name = "standard"
            p_set = subsets(range(1, alg._n))
            CombinatorialFreeModule.__init__(self, alg.base_ring(),
                                             map(tuple, p_set),
                                             category=DescentAlgebraBases(alg),
                                             bracket="", prefix=prefix)

            # Change of basis:
            B = alg.B()
            self.module_morphism(self.to_B_basis,
                                 codomain=B, category=self.category()
                                 ).register_as_coercion()

            B.module_morphism(B.to_D_basis,
                              codomain=self, category=self.category()
                              ).register_as_coercion()

            # Coercion to symmetric group algebra
            SGA = SymmetricGroupAlgebra(alg.base_ring(), alg._n)
            self.module_morphism(self.to_symmetric_group_algebra,
                                 codomain=SGA, category=Algebras(alg.base_ring())
                                 ).register_as_coercion()
Esempio n. 2
0
        def __init__(self, alg, prefix="D"):
            r"""
            Initialize ``self``.

            EXAMPLES::

                sage: TestSuite(DescentAlgebra(QQ, 4).D()).run()
            """
            self._prefix = prefix
            self._basis_name = "standard"
            p_set = subsets(range(1, alg._n))
            CombinatorialFreeModule.__init__(self,
                                             alg.base_ring(),
                                             map(tuple, p_set),
                                             category=DescentAlgebraBases(alg),
                                             bracket="",
                                             prefix=prefix)

            # Change of basis:
            B = alg.B()
            self.module_morphism(
                self.to_B_basis, codomain=B,
                category=self.category()).register_as_coercion()

            B.module_morphism(B.to_D_basis,
                              codomain=self,
                              category=self.category()).register_as_coercion()
Esempio n. 3
0
        def to_B_basis(self, S):
            r"""
            Return `D_S` as a linear combination of `B_p`-basis elements.

            EXAMPLES::

                sage: DA = DescentAlgebra(QQ, 4)
                sage: D = DA.D()
                sage: B = DA.B()
                sage: map(B, D.basis()) # indirect doctest
                [B[4],
                 B[1, 3] - B[4],
                 B[2, 2] - B[4],
                 B[1, 1, 2] - B[1, 3] - B[2, 2] + B[4],
                 B[3, 1] - B[4],
                 B[1, 2, 1] - B[1, 3] - B[3, 1] + B[4],
                 B[2, 1, 1] - B[2, 2] - B[3, 1] + B[4],
                 B[1, 1, 1, 1] - B[1, 1, 2] - B[1, 2, 1] + B[1, 3]
                  - B[2, 1, 1] + B[2, 2] + B[3, 1] - B[4]]
            """
            B = self.realization_of().B()

            if not S:
                return B.one()

            n = self.realization_of()._n
            C = Compositions(n)
            return B.sum_of_terms([(C.from_subset(T,
                                                  n), (-1)**(len(S) - len(T)))
                                   for T in subsets(S)])
Esempio n. 4
0
        def to_B_basis(self, S):
            r"""
            Return `D_S` as a linear combination of `B_p`-basis elements.

            EXAMPLES::

                sage: DA = DescentAlgebra(QQ, 4)
                sage: D = DA.D()
                sage: B = DA.B()
                sage: map(B, D.basis()) # indirect doctest
                [B[4],
                 B[1, 3] - B[4],
                 B[2, 2] - B[4],
                 B[1, 1, 2] - B[1, 3] - B[2, 2] + B[4],
                 B[3, 1] - B[4],
                 B[1, 2, 1] - B[1, 3] - B[3, 1] + B[4],
                 B[2, 1, 1] - B[2, 2] - B[3, 1] + B[4],
                 B[1, 1, 1, 1] - B[1, 1, 2] - B[1, 2, 1] + B[1, 3]
                  - B[2, 1, 1] + B[2, 2] + B[3, 1] - B[4]]
            """
            B = self.realization_of().B()

            if not S:
                return B.one()

            n = self.realization_of()._n
            C = Compositions(n)
            return B.sum_of_terms([(C.from_subset(T, n), (-1)**(len(S)-len(T)))
                                   for T in subsets(S)])
Esempio n. 5
0
    def nonempty_subsets(self):
        r"""
        EXAMPLES::

            sage: from partitioner import ClassificationStrategy
            sage: cs2 = ClassificationStrategy(2, make_disjoint=True)
            sage: for cs in cs2.nonempty_subsets():
            ....:     print(cs)
            ====================================
            classification strategy with 1 trees
            ------------------------------------
            classification tree 1 () (2 () ())
            s2 >= 0
            s1 >= 0
            s0 >= 0
            ====================================
            classification strategy with 1 trees
            ------------------------------------
            classification tree 2 (1 () ()) ()
            s2 >= 0
            s1 >= 0
            s0 >= 0
            ====================================
            classification strategy with 2 trees
            ------------------------------------
            classification tree 1 () (2 () ())
            s2 >= 0
            s1 >= 0
            s0 >= s2
            ------------------------------------
            classification tree 2 (1 () ()) ()
            s2 > s0
            s1 >= 0
            s0 >= 0
        """
        from sage.misc.misc import subsets
        d = self.dimension()
        return iter(ClassificationStrategy(d,
                                           make_disjoint=self.is_disjoint(),
                                           trees=srees)
                    for srees in subsets(self.trees)
                    if srees)