def _cis(self, series_ring, base_ring):
        r"""
        The cycle index series for the species of partitions is given by

        .. math::

             exp \sum_{n \ge 1} \frac{1}{n} \left( exp \left( \sum_{k \ge 1} \frac{x_{kn}}{k} \right) -1 \right).



        EXAMPLES::

            sage: P = species.PartitionSpecies()
            sage: g = P.cycle_index_series()
            sage: g.coefficients(5)
            [p[],
             p[1],
             p[1, 1] + p[2],
             5/6*p[1, 1, 1] + 3/2*p[2, 1] + 2/3*p[3],
             5/8*p[1, 1, 1, 1] + 7/4*p[2, 1, 1] + 7/8*p[2, 2] + p[3, 1] + 3/4*p[4]]
        """
        ciset = SetSpecies().cycle_index_series(base_ring)
        CIS = ciset.parent()
        res = CIS.sum_generator(((1 / n) * ciset).stretch(n)
                                for n in _integers_from(ZZ(1))).exponential()
        if self.is_weighted():
            res *= self._weight
        return res
Exemplo n.º 2
0
 def _cis(self, series_ring, base_ring):
     r"""
     The cycle index series for the species of partitions is given by
     
     .. math::
     
          exp \sum_{n \ge 1} \frac{1}{n} \left( exp \left( \sum_{k \ge 1} \frac{x_{kn}}{k} \right) -1 \right).
     
     
     
     EXAMPLES::
     
         sage: P = species.PartitionSpecies()
         sage: g = P.cycle_index_series()
         sage: g.coefficients(5)
         [p[],
          p[1],
          p[1, 1] + p[2],
          5/6*p[1, 1, 1] + 3/2*p[2, 1] + 2/3*p[3],
          5/8*p[1, 1, 1, 1] + 7/4*p[2, 1, 1] + 7/8*p[2, 2] + p[3, 1] + 3/4*p[4]]
     """
     ciset = SetSpecies().cycle_index_series(base_ring)
     CIS = ciset.parent()
     res = CIS.sum_generator(((1/n)*ciset).stretch(n) for n in _integers_from(ZZ(1))).exponential()
     if self.is_weighted():
         res *= self._weight
     return res
Exemplo n.º 3
0
 def _gs_iterator(self, base_ring):
     r"""
     EXAMPLES::
     
         sage: P = species.PartitionSpecies()
         sage: g = P.generating_series()
         sage: g.coefficients(5)
         [1, 1, 1, 5/6, 5/8]
     """
     from sage.combinat.combinat import bell_number
     for n in _integers_from(0):
         yield self._weight*base_ring(bell_number(n)/factorial_stream[n])
Exemplo n.º 4
0
    def _gs_iterator(self, base_ring):
        r"""
        EXAMPLES::

            sage: P = species.PartitionSpecies()
            sage: g = P.generating_series()
            sage: g.coefficients(5)
            [1, 1, 1, 5/6, 5/8]
        """
        from sage.combinat.combinat import bell_number
        for n in _integers_from(0):
            yield self._weight*base_ring(bell_number(n)/factorial_stream[n])
Exemplo n.º 5
0
    def _itgs_iterator(self, base_ring):
        """
        The generating series for the species of subsets is
        `e^{2x}`.

        EXAMPLES::

            sage: S = species.SubsetSpecies()
            sage: S.isotype_generating_series().coefficients(5)
            [1, 2, 3, 4, 5]
        """
        for n in _integers_from(1):
            yield base_ring(n)
Exemplo n.º 6
0
 def _cis_iterator(self, base_ring):
     """
     EXAMPLES::
     
         sage: L = species.LinearOrderSpecies()
         sage: g = L.cycle_index_series()
         sage: g.coefficients(5)
         [p[], p[1], p[1, 1], p[1, 1, 1], p[1, 1, 1, 1]]
     """
     from sage.combinat.sf.sf import SymmetricFunctions
     p = SymmetricFunctions(base_ring).power()
     for n in _integers_from(0):
         yield p([1]*n) 
Exemplo n.º 7
0
    def _gs_iterator(self, base_ring):
        """
        The generating series for the species of subsets is
        `e^{2x}`.

        EXAMPLES::

            sage: S = species.SubsetSpecies()
            sage: S.generating_series().coefficients(5)
            [1, 2, 2, 4/3, 2/3]
        """
        for n in _integers_from(0):
            yield base_ring(2) ** n / base_ring(factorial_stream[n])
Exemplo n.º 8
0
 def _itgs_iterator(self, base_ring):
     """
     The generating series for the species of subsets is
     `e^{2x}`.
     
     EXAMPLES::
     
         sage: S = species.SubsetSpecies()
         sage: S.isotype_generating_series().coefficients(5)
         [1, 2, 3, 4, 5]
     """
     for n in _integers_from(1):
         yield base_ring(n)
Exemplo n.º 9
0
 def _gs_iterator(self, base_ring):
     """
     The generating series for the species of subsets is
     `e^{2x}`.
     
     EXAMPLES::
     
         sage: S = species.SubsetSpecies()
         sage: S.generating_series().coefficients(5)
         [1, 2, 2, 4/3, 2/3]
     """
     for n in _integers_from(0):
         yield base_ring(2)**n / base_ring(factorial_stream[n])
Exemplo n.º 10
0
    def _cis_gen(self, base_ring):
        """
        EXAMPLES::

            sage: S = species.SetSpecies()
            sage: g = S._cis_gen(QQ)
            sage: [next(g) for i in range(5)]
            [0, p[1], 1/2*p[2], 1/3*p[3], 1/4*p[4]]
        """
        from sage.combinat.sf.sf import SymmetricFunctions
        p = SymmetricFunctions(base_ring).power()
        yield p(0)
        for n in _integers_from(1):
            yield p([n])/n
Exemplo n.º 11
0
 def _cis_gen(self, base_ring):
     """
     EXAMPLES::
     
         sage: S = species.SubsetSpecies()
         sage: g = S._cis_gen(QQ)
         sage: [g.next() for i in range(5)]
         [0, 2*p[1], p[2], 2/3*p[3], 1/2*p[4]]
     """
     from sage.combinat.sf.all import SFAPower
     p = SFAPower(base_ring)
     yield base_ring(0)
     for n in _integers_from(ZZ(1)):
         yield 2*p([n])/n
Exemplo n.º 12
0
 def _cis_gen(self, base_ring):
     """
     EXAMPLES::
     
         sage: S = species.SubsetSpecies()
         sage: g = S._cis_gen(QQ)
         sage: [g.next() for i in range(5)]
         [0, 2*p[1], p[2], 2/3*p[3], 1/2*p[4]]
     """
     from sage.combinat.sf.all import SFAPower
     p = SFAPower(base_ring)
     yield base_ring(0)
     for n in _integers_from(ZZ(1)):
         yield 2 * p([n]) / n
Exemplo n.º 13
0
    def _itgs_iterator(self, base_ring):
        r"""
        The isomorphism type generating series is given by
        `\frac{1}{1-x}`.

        EXAMPLES::

            sage: P = species.PermutationSpecies()
            sage: g = P.isotype_generating_series()
            sage: g.coefficients(10)
            [1, 1, 2, 3, 5, 7, 11, 15, 22, 30]
        """
        from sage.combinat.partitions import number_of_partitions
        for n in _integers_from(0):
            yield base_ring(number_of_partitions(n))
Exemplo n.º 14
0
    def _gs_iterator(self, base_ring):
        r"""
        The generating series for the species of sets is given by
        `e^x`.

        EXAMPLES::

            sage: S = species.SetSpecies()
            sage: g = S.generating_series()
            sage: g.coefficients(10)
            [1, 1, 1/2, 1/6, 1/24, 1/120, 1/720, 1/5040, 1/40320, 1/362880]
            sage: [g.count(i) for i in range(10)]
            [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        """
        for n in _integers_from(0):
            yield base_ring(self._weight/factorial_stream[n])
Exemplo n.º 15
0
    def _cis_iterator(self, base_ring):
        r"""
        The cycle index series of the species of cyclic permutations is
        given by
        
        .. math::
        
             -\sum_{k=1}^\infty \phi(k)/k * log(1 - x_k) 
        
        
        which is equal to
        
        .. math::
        
             \sum_{n=1}^\infty \frac{1}{n} * \sum_{k|n} \phi(k) * x_k^{n/k} 
        
        .
        
        EXAMPLES::
        
            sage: P = species.CycleSpecies()
            sage: cis = P.cycle_index_series()
            sage: cis.coefficients(7)
            [0,
             p[1],
             1/2*p[1, 1] + 1/2*p[2],
             1/3*p[1, 1, 1] + 2/3*p[3],
             1/4*p[1, 1, 1, 1] + 1/4*p[2, 2] + 1/2*p[4],
             1/5*p[1, 1, 1, 1, 1] + 4/5*p[5],
             1/6*p[1, 1, 1, 1, 1, 1] + 1/6*p[2, 2, 2] + 1/3*p[3, 3] + 1/3*p[6]]
        """
        from sage.combinat.sf.sf import SymmetricFunctions

        p = SymmetricFunctions(base_ring).power()

        zero = base_ring(0)

        yield zero
        for n in _integers_from(1):
            res = zero
            for k in divisors(n):
                res += euler_phi(k) * p([k]) ** (n // k)
            res /= n
            yield self._weight * res
Exemplo n.º 16
0
    def _cis_iterator(self, base_ring):
        r"""
        The cycle index series of the species of cyclic permutations is
        given by
        
        .. math::
        
             -\sum_{k=1}^\infty \phi(k)/k * log(1 - x_k) 
        
        
        which is equal to
        
        .. math::
        
             \sum_{n=1}^\infty \frac{1}{n} * \sum_{k|n} \phi(k) * x_k^{n/k} 
        
        .
        
        EXAMPLES::
        
            sage: P = species.CycleSpecies()
            sage: cis = P.cycle_index_series()
            sage: cis.coefficients(7)
            [0,
             p[1],
             1/2*p[1, 1] + 1/2*p[2],
             1/3*p[1, 1, 1] + 2/3*p[3],
             1/4*p[1, 1, 1, 1] + 1/4*p[2, 2] + 1/2*p[4],
             1/5*p[1, 1, 1, 1, 1] + 4/5*p[5],
             1/6*p[1, 1, 1, 1, 1, 1] + 1/6*p[2, 2, 2] + 1/3*p[3, 3] + 1/3*p[6]]
        """
        from sage.combinat.sf.all import SFAPower
        p = SFAPower(base_ring)

        zero = base_ring(0)

        yield zero
        for n in _integers_from(1):
            res = zero
            for k in divisors(n):
                res += euler_phi(k)*p([k])**(n//k)
            res /= n
            yield self._weight*res
Exemplo n.º 17
0
    def _cis_gen(self, base_ring, n):
        """
        EXAMPLES::

            sage: P = species.PermutationSpecies()
            sage: g = P._cis_gen(QQ, 2)
            sage: [g.next() for i in range(10)]
            [p[], 0, p[2], 0, p[2, 2], 0, p[2, 2, 2], 0, p[2, 2, 2, 2], 0]
        """
        from sage.combinat.sf.sf import SymmetricFunctions
        p = SymmetricFunctions(base_ring).power()

        pn = p([n])

        n = n - 1
        yield p(1)

        for k in _integers_from(1):
            for i in range(n):
                yield base_ring(0)
            yield pn**k
Exemplo n.º 18
0
    def _cis(self, series_ring, base_ring):
        r"""
        The cycle index series for the species of permutations is given by

        .. math::

             \prod{n=1}^\infty \frac{1}{1-x_n}.

        EXAMPLES::

            sage: P = species.PermutationSpecies()
            sage: g = P.cycle_index_series()
            sage: g.coefficients(5)
            [p[],
             p[1],
             p[1, 1] + p[2],
             p[1, 1, 1] + p[2, 1] + p[3],
             p[1, 1, 1, 1] + p[2, 1, 1] + p[2, 2] + p[3, 1] + p[4]]
        """
        CIS = series_ring
        return CIS.product_generator( CIS(self._cis_gen(base_ring, i)) for i in _integers_from(ZZ(1)) )
Exemplo n.º 19
0
    def _gs_iterator(self, base_ring):
        r"""
        The generating series for cyclic permutations is
        `-\log(1-x) = \sum_{n=1}^\infty x^n/n`.

        EXAMPLES::

            sage: P = species.CycleSpecies()
            sage: g = P.generating_series()
            sage: g.coefficients(10)
            [0, 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9]

        TESTS::

            sage: P = species.CycleSpecies()
            sage: g = P.generating_series(RR)
            sage: g.coefficients(3)
            [0.000000000000000, 1.00000000000000, 0.500000000000000]
        """
        one = base_ring(1)
        yield base_ring(0)
        for n in _integers_from(ZZ(1)):
            yield self._weight * one / n
Exemplo n.º 20
0
 def _gs_iterator(self, base_ring):
     r"""
     The generating series for cyclic permutations is
     `-\log(1-x) = \sum_{n=1}^\infty x^n/n`.
     
     EXAMPLES::
     
         sage: P = species.CycleSpecies()
         sage: g = P.generating_series()
         sage: g.coefficients(10)
         [0, 1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9]
     
     TESTS::
     
         sage: P = species.CycleSpecies()
         sage: g = P.generating_series(RR)
         sage: g.coefficients(3)
         [0.000000000000000, 1.00000000000000, 0.500000000000000]
     """
     one = base_ring(1)
     yield base_ring(0)
     for n in _integers_from(ZZ(1)):
         yield self._weight * one / n