Conversation
|
Documentation preview for this PR (built with commit b9947d2; changes) is ready! 🎉 |
f3f2bf8 to
b9947d2
Compare
|
You might want to be careful with a change like that. Mathematically, for instance, a ZZ-algebra with unity is a ZZ-module with extra structure, so the action of ZZ on the algebra is more fundamental than the multiplication structure on the algebra itself. So mathematically, it makes sense to prefer the ZZ-action over coercion from ZZ into the algebra followed by multiplication. For performance, this can also be a difference: multiplying by an integer (i.e., a scalar multiplication) is really quite a bit cheaper than using full algebra multiplication with an element that happens to be a coerced scalar. Thank about the situation where you have the full n x n matrix algebra over a field k. Then k coerces into the algebra as diagonal matrices. Would your change prefer that coercion over the scalar multiplication action? Multiplying two n x n matrices is significantly more expensive than a scalar multiplication of a matrix. Note that the matrix algebra is simply an example. Perhaps there things are arranged in such a way that scalar multiplication gets recognized early or in a different way. But the principle applies in many cases. It may well be that your change is fine, but you should carefully review that it is, certainly for the reason above. |
|
Martin’s description is oversimplified and missing a key component. We do not prefer coercion over already defined actions for the reasons you stated (performance and being natural). However, we instead prefer doing coercion over doing a pushout of the base ring. |
|
The situation at hand is this. Suppose there is a coercion |
|
Oh thanks. If you put it that way it sounds quite natural to do. |
tscrim
left a comment
There was a problem hiding this comment.
Thank you. Than I will approve this.
sagemathgh-37916: structure/coerce actions We modify `ModuleAction` to prefer coercion of the base ring over creating an action. More precisely, before this branch, we have ``` sage: G = PolynomialRing(QQ, "x") sage: S = PolynomialRing(MatrixSpace(QQ, 2), "x") sage: G.gen() * S.gen() [x 0] [0 x]*x ``` instead of ``` [1 0] [0 1]*x^2 ``` and ``` sage: G = PolynomialRing(QQ, "x") sage: S = PolynomialRing(InfinitePolynomialRing(QQ, "a"), "x") sage: G.gen() * S.an_element() x*x ``` instead of ``` x^2 ``` which is at least surprising. In the end, this is needed to make sagemath#37033 work. Authors: @tscrim and @mantepse. URL: sagemath#37916 Reported by: Martin Rubey Reviewer(s): Travis Scrimshaw
sagemathgh-37916: structure/coerce actions We modify `ModuleAction` to prefer coercion of the base ring over creating an action. More precisely, before this branch, we have ``` sage: G = PolynomialRing(QQ, "x") sage: S = PolynomialRing(MatrixSpace(QQ, 2), "x") sage: G.gen() * S.gen() [x 0] [0 x]*x ``` instead of ``` [1 0] [0 1]*x^2 ``` and ``` sage: G = PolynomialRing(QQ, "x") sage: S = PolynomialRing(InfinitePolynomialRing(QQ, "a"), "x") sage: G.gen() * S.an_element() x*x ``` instead of ``` x^2 ``` which is at least surprising. In the end, this is needed to make sagemath#37033 work. Authors: @tscrim and @mantepse. URL: sagemath#37916 Reported by: Martin Rubey Reviewer(s): Travis Scrimshaw
sagemathgh-37916: structure/coerce actions We modify `ModuleAction` to prefer coercion of the base ring over creating an action. More precisely, before this branch, we have ``` sage: G = PolynomialRing(QQ, "x") sage: S = PolynomialRing(MatrixSpace(QQ, 2), "x") sage: G.gen() * S.gen() [x 0] [0 x]*x ``` instead of ``` [1 0] [0 1]*x^2 ``` and ``` sage: G = PolynomialRing(QQ, "x") sage: S = PolynomialRing(InfinitePolynomialRing(QQ, "a"), "x") sage: G.gen() * S.an_element() x*x ``` instead of ``` x^2 ``` which is at least surprising. In the end, this is needed to make sagemath#37033 work. Authors: @tscrim and @mantepse. URL: sagemath#37916 Reported by: Martin Rubey Reviewer(s): Travis Scrimshaw
We modify
ModuleActionto prefer coercion of the base ring over creating an action. More precisely, before this branch, we haveinstead of
and
instead of
which is at least surprising.
In the end, this is needed to make #37033 work.
Authors: @tscrim and @mantepse.