Ticket #13433: trac_13433-review-mh-darijs_mod.patch

File trac_13433-review-mh-darijs_mod.patch, 2.9 KB (added by darij, 8 years ago)
  • sage/combinat/species/generating_series.py

    # HG changeset patch
    # User Mike Hansen <mhansen@gmail.com>
    # Date 1374443237 -3600
    # Node ID cdbb2986fc54830c5203fc1ef5ce0af4df6a216d
    # Parent  fa658c53d32c07db906e12255cdae79949849b74
    #13443: Review patch
    
    diff --git a/sage/combinat/species/generating_series.py b/sage/combinat/species/generating_series.py
    a b class CycleIndexSeries(LazyPowerSeries): 
    535535       
    536536        return self.parent().sum_generator(multinv_builder(i) for i in _integers_from(0))
    537537
    538     def _div_(self, y):
     538    def __div__(self, y):
    539539        """
    540540        TESTS::
    541541
  • sage/combinat/species/series.py

    diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
    a b class LazyPowerSeriesRing(UniqueRepresen 
    359359
    360360    def _sum_gen(self, series_list):
    361361        """
    362         Returns a generator for the coefficients of the sum the the lazy
    363         power series in series_list.
     362        Return a generator for the coefficients of the sum of the lazy
     363        power series in ``series_list``.
    364364
    365365        INPUT:
    366366
    class LazyPowerSeriesRing(UniqueRepresen 
    419419            n += 1
    420420
    421421    def sum_generator(self, g):
    422         """
     422        r"""
     423        Given a stream of lazy power series $F^i$ for
     424        $i = 0 \ldots \infty$, return the lazy power series $f$ whose coefficient
     425        of $x^n$ is given by
     426
     427        .. MATH::
     428
     429            f_n = \sum_{j=0}^{n} F^j_n .
     430       
     431        In particular, when each $F^j$ is divisible by $x^j$, this is the sum of
     432        the $F^j$.
     433       
    423434        EXAMPLES::
    424435
    425436            sage: L = LazyPowerSeriesRing(QQ)
    class LazyPowerSeriesRing(UniqueRepresen 
    437448            sage: t = L.sum_generator(g())
    438449            sage: t.coefficients(9)
    439450            [1, 2, 3, 4, 5, 6, 7, 8, 9]
     451
     452        Let us check by example a classical identity from enumerative
     453        combinatorics: We have
     454
     455        .. MATH::
     456
     457            \prod_{k > 0} \frac{1}{1-x^k} = \sum_{i \geq 0} x^i \prod_{0 < k\leq i} \frac{1}{1-x^k}.
     458
     459        Note that both sides of this identity are the generating function of the
     460        partition numbers. We will check the identity on its first `10`
     461        coefficients, so we cut power series at `x^{10}` and discard the factors
     462        with `k \geq 10` on the left hand side::
     463
     464            sage: rhs_addends = [L.one()]
     465            sage: pro = L.one()
     466            sage: for i in range(1, 10):
     467            ....:     pro *= L([1 if m % i == 0 else 0 for m in range(10)])
     468            ....:     # pro is now \prod_{0 < k\leq i} \frac{1}{1-x^k}.
     469            ....:     rhs_addends.append(pro * (L.gen() ** i))
     470            sage: rhs = L.sum_generator(rhs_addends)
     471            sage: pro.coefficients(10) == rhs.coefficients(10)
     472            True
    440473        """
    441474        return self(self._sum_generator_gen(g))
    442475