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

File trac_13433-review-mh-darijs_mod.patch, 2.9 KB (added by Darij Grinberg, 9 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 class CycleIndexSeries(LazyPowerSeries): return self.parent().sum_generator(multinv_builder(i) for i in _integers_from(0)) def _div_(self, y): def __div__(self, y): """ TESTS::
• ## sage/combinat/species/series.py

diff --git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
 a class LazyPowerSeriesRing(UniqueRepresen def _sum_gen(self, series_list): """ Returns a generator for the coefficients of the sum the the lazy power series in series_list. Return a generator for the coefficients of the sum of the lazy power series in series_list. INPUT: class LazyPowerSeriesRing(UniqueRepresen n += 1 def sum_generator(self, g): """ r""" Given a stream of lazy power series $F^i$ for $i = 0 \ldots \infty$, return the lazy power series $f$ whose coefficient of $x^n$ is given by .. MATH:: f_n = \sum_{j=0}^{n} F^j_n . In particular, when each $F^j$ is divisible by $x^j$, this is the sum of the $F^j$. EXAMPLES:: sage: L = LazyPowerSeriesRing(QQ) class LazyPowerSeriesRing(UniqueRepresen sage: t = L.sum_generator(g()) sage: t.coefficients(9) [1, 2, 3, 4, 5, 6, 7, 8, 9] Let us check by example a classical identity from enumerative combinatorics: We have .. MATH:: \prod_{k > 0} \frac{1}{1-x^k} = \sum_{i \geq 0} x^i \prod_{0 < k\leq i} \frac{1}{1-x^k}. Note that both sides of this identity are the generating function of the partition numbers. We will check the identity on its first 10 coefficients, so we cut power series at x^{10} and discard the factors with k \geq 10 on the left hand side:: sage: rhs_addends = [L.one()] sage: pro = L.one() sage: for i in range(1, 10): ....:     pro *= L([1 if m % i == 0 else 0 for m in range(10)]) ....:     # pro is now \prod_{0 < k\leq i} \frac{1}{1-x^k}. ....:     rhs_addends.append(pro * (L.gen() ** i)) sage: rhs = L.sum_generator(rhs_addends) sage: pro.coefficients(10) == rhs.coefficients(10) True """ return self(self._sum_generator_gen(g))