Opened 12 years ago
Last modified 11 years ago
#9944 closed defect
categories for polynomial rings — at Version 12
Reported by: | robertwb | Owned by: | nthiery |
---|---|---|---|
Priority: | major | Milestone: | sage-4.7.1 |
Component: | categories | Keywords: | |
Cc: | sage-combinat | Merged in: | |
Authors: | Robert Bradshaw | Reviewers: | Nicolas M. Thiéry, Mike Hansen |
Report Upstream: | N/A | Work issues: | Fix one test |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
Currently, they're always just commutative rings.
Apply:
Change History (16)
Changed 12 years ago by
comment:1 Changed 12 years ago by
- Status changed from new to needs_review
comment:2 Changed 12 years ago by
Changed 12 years ago by
comment:3 Changed 12 years ago by
- Reviewers set to Nicolas M. Thiéry, Mike Hansen
I went ahead and moved the functionality to it's own category since we want the mathematical information at the category level. Could someone look over these changes?
comment:4 follow-up: ↓ 8 Changed 12 years ago by
The first patch only concerned univarite polynomial rings, the logic is not all correct for multivariate polynomial rings (though on an orthogonal note, that could use some fixing up as well). It seems odd to have a category of univariate polynomial rings over a fixed basering, which is why I put the logic into the concrete object. I suppose the category should a be declared as a graded R-algebra as well (do we have join categories yet?).
I don't know if PolynomialRing? asserts its basering is commutative, but IIRC it's been assumed for a long time.
comment:5 Changed 12 years ago by
Apply only 9944-poly-cat.patch
Changed 12 years ago by
comment:6 Changed 12 years ago by
Apply 9944-poly-cat.patch and 9944-poly-cat-doctests.patch .
Changed 11 years ago by
comment:7 Changed 11 years ago by
- Description modified (diff)
I would give this a positive review for Robert's idea and I would open a new ticket for the multivariate rings. I'll just send a mail to Mike whether he is ok with that or no.
comment:8 in reply to: ↑ 4 ; follow-up: ↓ 9 Changed 11 years ago by
Replying to robertwb:
The first patch only concerned univarite polynomial rings, the logic is not all correct for multivariate polynomial rings (though on an orthogonal note, that could use some fixing up as well). It seems odd to have a category of univariate polynomial rings over a fixed basering, which is why I put the logic into the concrete object. I suppose the category should a be declared as a graded R-algebra as well (do we have join categories yet?).
Sorry for the very late answer. In MuPAD, we had a category for univariate polynomial rings: there are several possible implementations of such, and it's natural to factor out the generic code, together with the category inheritance logic, in a category.
And yes, we have join categories. See Category.join.
I let you see whether to create the UnivariatePolynomialRing? category in this ticket or in a later ticket.
comment:9 in reply to: ↑ 8 ; follow-up: ↓ 12 Changed 11 years ago by
Replying to nthiery:
Sorry for the very late answer. In MuPAD, we had a category for univariate polynomial rings: there are several possible implementations of such, and it's natural to factor out the generic code, together with the category inheritance logic, in a category.
Aparently there is a doctest failure. I fixed it, but unfortunately it went into my patch submitted for #9138. Therefore, "needs work".
Question: Do we really want a category of polynomial rings? Or do we want that (1) polynomial rings use the category framework (that's the purpose of my patch for #9138) and (2) the category to which a given polynomial ring belongs is a bit narrower than simply "category of rings"? I hope it is the latter.
My suggestion is that I submit a small patch fixing the doctests. Please tell whether my patch for #9138 improves the multivariate case. Then, perhaps it would be possible to give Roberts patches (+ doctest fix) a positive review, so that we can focus on #9138.
comment:10 Changed 11 years ago by
- Status changed from needs_review to needs_work
- Work issues set to Fix one test
comment:11 Changed 11 years ago by
At #9138, Jason Bandlow reported a slow-down, that is at least partially caused by the patches here. Do you have any idea what could be the reason?
comment:12 in reply to: ↑ 9 Changed 11 years ago by
- Description modified (diff)
Replying to SimonKing:
Aparently there is a doctest failure. I fixed it, but unfortunately it went into my patch submitted for #9138. Therefore, "needs work".
Strange: Although the patch bot did see that error in one run, I can not reproduce it (but I had to change that test in my patch for #9138, because it turns QQ['x'].category()
into the join of the category of euclidean domains and commutative algebras over QQ
.
The other issue, namely the performance loss, was studied on sage-devel.
Florent Hivert found that a long mro does not matter for Python, but it does matter if the classes inherit from a cdef class. That is the case for most classes in Sage (inheriting from SageObject
), so, we should address the problem of a long mro.
Eventually, that should be fixed in Cython (and I think Florent reported it upstream). But for now, it seems to me we should think of a work-around.
Would it be acceptable coding practice to explicitly state in a derived class (say, MPolynomialRing_generic
), that frequently used methods such as base or base_ring are the same as Parent.base
or Parent.base_ring
? David Roe stated that it might be dangerous to do so, at least if cpdef
methods are involved.
I have been through the patch, and it sounds good! I won't have the time to actually test it before some time, so please anyone beat me to it!
Just one micro question: does PolynomialRing? actually check that the ring is commutative?
Cheers