|
97 | 97 | from sage.rings.integer_ring import ZZ
|
98 | 98 | from sage.rings.infinity import infinity
|
99 | 99 | from sage.arith.misc import divisors
|
| 100 | +from sage.misc.misc_c import prod |
100 | 101 | from sage.combinat.integer_vector_weighted import iterator_fast as wt_int_vec_iter
|
101 | 102 | from sage.combinat.sf.sfa import _variables_recursive, _raise_variables
|
102 | 103 | from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis
|
@@ -1814,21 +1815,21 @@ def get_coefficient(self, n):
|
1814 | 1815 | if self._right[0]:
|
1815 | 1816 | assert self._degree_f is not None, "the plethysm with a lazy symmetric function of valuation 0 is defined only for symmetric functions of finite support"
|
1816 | 1817 |
|
1817 |
| - return sum((c * self._compute_product(n, la) |
| 1818 | + return sum((c * self.compute_product(n, la) |
1818 | 1819 | for k in range(self._left._approximate_order, self._degree_f)
|
1819 | 1820 | for la, c in self._left[k]),
|
1820 | 1821 | self._basis.zero())
|
1821 | 1822 |
|
1822 |
| - return sum((c * self._compute_product(n, la) |
| 1823 | + return sum((c * self.compute_product(n, la) |
1823 | 1824 | for k in range(self._left._approximate_order, n+1)
|
1824 | 1825 | for la, c in self._left[k]),
|
1825 | 1826 | self._basis.zero())
|
1826 | 1827 |
|
1827 |
| - def _compute_product(self, n, la): |
1828 |
| - """ |
| 1828 | + def compute_product(self, n, la): |
| 1829 | + r""" |
1829 | 1830 | Compute the product ``c * p[la](self._right)`` in degree ``n``.
|
1830 | 1831 |
|
1831 |
| - TESTS:: |
| 1832 | + EXAMPLES:: |
1832 | 1833 |
|
1833 | 1834 | sage: from sage.data_structures.stream import Stream_plethysm, Stream_exact, Stream_function, Stream_zero
|
1834 | 1835 | sage: s = SymmetricFunctions(QQ).s()
|
@@ -1859,27 +1860,34 @@ def _compute_product(self, n, la):
|
1859 | 1860 | sage: all(h._compute_product(k, Partition([2, 2, 1])) == B.restrict_degree(k) for k in range(7))
|
1860 | 1861 | True
|
1861 | 1862 | """
|
| 1863 | + # This is the approximate order of the result |
| 1864 | + rao = self._right._approximate_order |
| 1865 | + ret_approx_order = rao * sum(la) |
1862 | 1866 | ret = self._basis.zero()
|
| 1867 | + if n < ret_approx_order: |
| 1868 | + return ret |
| 1869 | + |
1863 | 1870 | la_exp = la.to_exp()
|
1864 | 1871 | wgt = [i for i, m in enumerate(la_exp, 1) if m]
|
1865 | 1872 | exp = [m for m in la_exp if m]
|
1866 |
| - for k in wt_int_vec_iter(n, wgt): |
| 1873 | + wgt.reverse() |
| 1874 | + exp.reverse() |
| 1875 | + for k in wt_int_vec_iter(n - ret_approx_order, wgt): |
1867 | 1876 | # TODO: it may make a big difference here if the
|
1868 |
| - # approximate order would be updated |
1869 |
| - if any(d < self._right._approximate_order * m |
1870 |
| - for m, d in zip(exp, k)): |
1871 |
| - continue |
1872 |
| - prod = self._basis.one() |
1873 |
| - for i, m, d in zip(wgt, exp, k): |
1874 |
| - prod *= self._stretched_power_restrict_degree(i, m, d) |
1875 |
| - ret += prod |
| 1877 | + # approximate order would be updated. |
| 1878 | + # The test below is based off not removing the flxed block |
| 1879 | + #if any(d < self._right._approximate_order * m |
| 1880 | + # for m, d in zip(exp, k)): |
| 1881 | + # continue |
| 1882 | + ret += prod(self.stretched_power_restrict_degree(i, m, rao * m + d) |
| 1883 | + for i, m, d in zip(wgt, exp, k)) |
1876 | 1884 | return ret
|
1877 | 1885 |
|
1878 |
| - def _stretched_power_restrict_degree(self, i, m, d): |
1879 |
| - """ |
| 1886 | + def stretched_power_restrict_degree(self, i, m, d): |
| 1887 | + r""" |
1880 | 1888 | Return the degree ``d*i`` part of ``p([i]*m)(g)``.
|
1881 | 1889 |
|
1882 |
| - TESTS:: |
| 1890 | + EXAMPLES:: |
1883 | 1891 |
|
1884 | 1892 | sage: from sage.data_structures.stream import Stream_plethysm, Stream_exact, Stream_function, Stream_zero
|
1885 | 1893 | sage: s = SymmetricFunctions(QQ).s()
|
@@ -1908,11 +1916,11 @@ def _stretched_power_restrict_degree(self, i, m, d):
|
1908 | 1916 | # integer and not a symmetric function
|
1909 | 1917 | if power_d:
|
1910 | 1918 | if self._tensor_power is None:
|
1911 |
| - terms = {m.stretch(i): raised_c for m, c in power_d |
| 1919 | + terms = {mon.stretch(i): raised_c for mon, c in power_d |
1912 | 1920 | if (raised_c := _raise_variables(c, i, self._degree_one))}
|
1913 | 1921 | else:
|
1914 |
| - terms = {tuple((mu.stretch(i) for mu in m)): raised_c |
1915 |
| - for m, c in power_d |
| 1922 | + terms = {tuple((mu.stretch(i) for mu in mon)): raised_c |
| 1923 | + for mon, c in power_d |
1916 | 1924 | if (raised_c := _raise_variables(c, i, self._degree_one))}
|
1917 | 1925 | return self._p.element_class(self._p, terms)
|
1918 | 1926 |
|
|
0 commit comments