Ticket #14906: trac_14906-cycle_index_expand_as_sf.patch

File trac_14906-cycle_index_expand_as_sf.patch, 2.0 KB (added by agd, 6 years ago)
  • sage/combinat/species/generating_series.py

    # HG changeset patch
    # User Andrew Gainer-Dewar <andrew (dot) gainer (dot) dewar (at) gmail (dot) com>
    # Date 1374855228 18000
    # Node ID 4de972e00afeaa1c18bde01d5b24f1d5554ca9f9
    # Parent  5d8c13e7b81a1e152855073f97a4d48ee97255d1
    14906: Implement expand_as_sf method for CycleIndexSeries
    
    diff --git a/sage/combinat/species/generating_series.py b/sage/combinat/species/generating_series.py
    a b class CycleIndexSeries(LazyPowerSeries): 
    450450        R = self.base_ring().base_ring()
    451451        OGS = OrdinaryGeneratingSeriesRing(R)()
    452452        return OGS._new(self._ogs_gen, lambda ao: ao, self)
     453
     454    def expand_as_sf(self, n, alphabet='x'):
     455        """
     456        Returns the expansion of a cycle index series as a symmetric function in
     457        ``n`` variables.
     458
     459        Specifically, this returns a :class:`~sage.combinat.species.series.LazyPowerSeries` whose
     460        ith term is obtained by calling :meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.expand`
     461        on the ith term of ``self``.
     462       
     463        This relies on the (standard) interpretation of a cycle index series as a symmetric function
     464        in the power sum basis.
     465
     466        INPUT:
     467
     468        - ``self`` -- a cycle index series
     469
     470        - ``n`` -- a positive integer
     471
     472        - ``alphabet`` -- a variable for the expansion (default: `x`)
     473
     474        EXAMPLES::
     475
     476            sage: from sage.combinat.species.set_species import SetSpecies
     477            sage: SetSpecies().cycle_index_series().expand_as_sf(2).coefficients(4)
     478            [1, x0 + x1, x0^2 + x0*x1 + x1^2, x0^3 + x0^2*x1 + x0*x1^2 + x1^3]
     479
     480        """
     481        expanded_poly_ring = self.coefficient(0).expand(n, alphabet).parent()
     482        LPSR = LazyPowerSeriesRing(expanded_poly_ring)
     483
     484        expander_gen = (LPSR.term(self.coefficient(i).expand(n, alphabet), i) for i in _integers_from(0))
     485
     486        return LPSR.sum_generator(expander_gen)
    453487   
    454488    def _ogs_gen(self, ao):
    455489        """