-
-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a method divides
to Polynomial
#19171
Comments
Dependencies: 16649 |
Changed dependencies from 16649 to #16649 |
Branch: u/bruno/t19171_divides_poly |
Commit: |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:8
I added some noise with two forced pushes (due to some mistake I made), but there is really only one commit! Now the ticket passes the tests (as far as I can tell) and is very ready for review! |
comment:9
You would better use Why is this code specific to polynomials? |
Reviewer: Vincent Delecroix |
comment:12
Replying to @videlec:
Done.
I tried to explain the reasons in the description: For polynomials over (say) I could have changed the generic method instead to catch an ¹ "We know" is maybe a too strong assumption. In #16649, I did changes that ensure that the assumption holds for all current implementations of polynomials in Sage. (This was not the case before.) Yet, future implementations may break this rule. This may imply that we shouldn't simply rely on |
comment:37
The difficulties with rings such as If we decide this, the problem with |
comment:38
Replying to @bgrenet:
There is #25277 for that (it is merged in beta3 already). So you can test for division... but you can not divide yet.
It is fine to catch an exception, but it should be clear what it means. |
comment:39
Replying to @videlec:
I meant testing divisibility of polynomials over |
comment:40
Replying to @bgrenet:
A far from efficient method consist in
But for that, you need a method that return all quotients. Hence my remark. |
comment:41
So do you agree with me that we should better abandon non-integral rings (at least for now)? |
comment:42
Replying to @bgrenet:
yes |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:45
Is the proposed solution ok for you? |
comment:46
You are not doing the right thing on non-integral domains. You should test
(testing divisibility of leading coefficient is not even valid... I was wrong) You need a line break after It should be documented that this method only works for integral domains. And the examples with Zmod(6) (raising error) should be in the |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:48
I've followed your advice, and changed my mind: My idea was to give an answer (for non-integral domains) as long as I am able to do so. The problem with the divisibility of leading coefficients made me adopt the opposite viewpoint: Divisibility is not implemented for non-integral domains, that's it. I am not sure that an implementation which only works in some uninteresting cases would be helpful to anyone! |
comment:49
update milestone 8.3 -> 8.4 |
comment:50
ok |
Changed branch from u/bruno/t19171_divides_poly to |
The generic method
divides
that can be found insrc/sage/structure/element.pyx
usesquo_rem
(via%
) to test if an element divides another one:return (x % self) == 0
.For polynomials, depending on the implementations, the method
quo_rem
may raise an error if the divisor is not monic (see #16649 for more on this).This ticket aims at implementing a method
divides
for the classPolynomial
, so that it catches the errors inquo_rem
to returnFalse
when it is needed.Example of a problematic behavior:
Depends on #16649
Depends on #25277
Component: commutative algebra
Keywords: polynomial, division
Author: Bruno Grenet
Branch/Commit:
94c0390
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/19171
The text was updated successfully, but these errors were encountered: