# 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): 
535  535  
536  536  return self.parent().sum_generator(multinv_builder(i) for i in _integers_from(0)) 
537  537  
538   def _div_(self, y): 
 538  def __div__(self, y): 
539  539  """ 
540  540  TESTS:: 
541  541  
diff git a/sage/combinat/species/series.py b/sage/combinat/species/series.py
a

b

class LazyPowerSeriesRing(UniqueRepresen 
359  359  
360  360  def _sum_gen(self, series_list): 
361  361  """ 
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``. 
364  364  
365  365  INPUT: 
366  366  
… 
… 
class LazyPowerSeriesRing(UniqueRepresen 
419  419  n += 1 
420  420  
421  421  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  
423  434  EXAMPLES:: 
424  435  
425  436  sage: L = LazyPowerSeriesRing(QQ) 
… 
… 
class LazyPowerSeriesRing(UniqueRepresen 
437  448  sage: t = L.sum_generator(g()) 
438  449  sage: t.coefficients(9) 
439  450  [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}{1x^k} = \sum_{i \geq 0} x^i \prod_{0 < k\leq i} \frac{1}{1x^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}{1x^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 
440  473  """ 
441  474  return self(self._sum_generator_gen(g)) 
442  475  