-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
wrong type for denominator #9063
Comments
comment:1
If the element of the ring is zero or the base_ring does not have a denominator function, the code returned the "wrong 1", either int 1 or polynomial 1. The patch correct this. |
comment:2
Attachment: trac_9063.patch.gz Corrected a typo in documentation |
Author: Luis Felipe Tabera Alonso |
Reviewer: John Cremona |
comment:4
This looks good to me. It applied ok to 4.5.3.alpha1, and all (long) tests pass, except for one:
The problem is in the function weak_popov_form() in sage/rings/matrix/matrix_misc.py (which was only merged into Sage receontly -- and I was, by chance, its reviewer). There one has matrices of polynomials over fields and the code tries to clear denominators, by forming the LCM of the denominators; and that now fails when those denominators are all equal to 1 in a finite field! Rather than mess with the weakpopov form code, this could be solved if there was an lcm function for finite field elements which always returned 1 (except lcm(0,0)=0, perhaps). |
comment:5
Well, The issue of adding a lcm function for finite fields has some problems associated:
So this approach will add a backwards incompatibility at least. |
comment:6
Replying to @lftabera:
Well spotted! I think that this current behavour is a bug:
since it makes no mathematical sense at all. It's the same for gcd:
Both of these would not happen if finite field elements have gcd and lcm methods, and in my opinion that would be better. Someone should try to implement this and do a full test to see if any existing code (tests) is broken. I hope not -- I cannot imagine anyone relying on this rather crazy behaviour. |
comment:7
I have added a new bug dealing with the issue of lcm. So this bug now depends on #9819 |
comment:9
Replying to @JohnCremona:
What do you exactly mean? I think this is the correct wayy to go. The problem may be solved by a workaround on weak_popov_form, but surely will appear on other instances of fields or other methods that may be added in the future. |
comment:10
Attachment: weak-popof-form.patch.gz I have attached another patch that solves the problem in weak_popov_form. I follow the python mantra of 'explicit better than implicit'. The algorithm expects as entries a matrix with rational functions as entries. If the entries are polynomials, then the algorithm may fail because the denominators will be elements in a field and currently sage does not consider this case for all fields. Now, the algorithm first transforms the input matrix to a matrix with rational functions as entries which is the domain the algorithm is expected to work. The denominators will then be polynomials and the algorithm will work as expected. I have added a doctest to check that the output is the same in the polynomial and rational function case. As a side effect, I correct a typo in the documentation of weak_popov_form. The documentation asserts that the output is (W, N, t) where W and N are matrices of rational functions. In fact, N is a matrix of polynomials. Both patches can be applied in any order. With this patch bug #9819 does not apply. |
comment:11
AFAICT, the Can't we just avoid clearing the denominators if |
comment:12
Attachment: weak-popof-form.2.patch.gz I have added a new patch to weak_popov_form so it does not perform any cleaning of denominadors when the matrix has polynomial entries. Apply: trac_9063.patch weak-popof-form.2.patch In any order |
comment:14
failed on coverage for both files ./sage -coverage sage/rings/polynomial/multi_polynomial.pyx sage/rings/polynomial/multi_polynomial.pyx Missing documentation:
Missing doctests:
./sage -coverage sage/matrix/matrix2.pyx ---------------------------------------------------------------------- Missing documentation:
Missing doctests:
|
comment:15
Sorry, I was following developers guide, which stated if coverage is less than 100% than it needs work. However, given the functions that you changed are not the ones where coverage failed, I put it back to needs_review. I will be running other test now |
Changed reviewer from John Cremona to John Cremona, Aly Deines |
comment:16
Looks good to me. |
Changed reviewer from John Cremona, Aly Deines to John Cremona, Alyson Deines |
Changed reviewer from John Cremona, Alyson Deines to John Cremona, Aly Deines |
Merged: sage-4.6.2.alpha1 |
If you create a polynomial in one variable over a finite field and ask for the denominator, then the answer you get has the wrong type when the polynomial is the zero polynomial. Here's an example:
Component: algebra
Author: Luis Felipe Tabera Alonso
Reviewer: John Cremona, Aly Deines
Merged: sage-4.6.2.alpha1
Issue created by migration from https://trac.sagemath.org/ticket/9063
The text was updated successfully, but these errors were encountered: