Dear all, in https://github.com/sagemath/sage/pull/38108, which provides a solver for functional equations in lazy completions of graded algebras with basis, I (want to) use generic methods, so that I do not have to write special code for every other algebra. Here is an example which I find a bit depressing:
sage: s = SymmetricFunctions(QQ).s() sage: f = (s[1,1] + s[2])^2 sage: f.monomial_coefficients() {[2, 1, 1]: 3, [2, 2]: 2, [1, 1, 1, 1]: 1, [3, 1]: 3, [4]: 1} sage: list(f) [([2, 1, 1], 3), ([2, 2], 2), ([1, 1, 1, 1], 1), ([3, 1], 3), ([4], 1)] sage: s.monomial(Partition([2,1,1])) s[2, 1, 1] This works for algebras subclassing CombinatorialFreeModule, for example symmetric functions and the free algebra. However, it will not work for polynomials: sage: R.<x,y> = QQ[] sage: f = (x+2*y)^2 sage: list(f) [(1, x^2), (4, x*y), (4, y^2)] sage: R.monomial(0,2) y^2 sage: T.<x> = QQ[] sage: t = (x+1)^2 sage: list(t) [1, 2, 1] Note that * coefficient_monomials does not exist * list gives pairs in the multivariate case, but the coefficient comes first, and a flat list in the univariate case * monomial takes one argument for each variable, and does not accept tuples. My question is: do we want to keep this discrepancy forever, or should we work on resolving it. I see the following first steps: * slightly generalize MPolynomialRing_base.monomial and to accept also a single tuple of the correct length. * introduce a method `monomial_coefficients` which produces a dict from exponents to coefficients. Any opinions? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/494619c7-0d23-4d6e-aed8-1e44797b71b0n%40googlegroups.com.