-
-
Notifications
You must be signed in to change notification settings - Fork 528
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
Improve random_element for number field orders and ideals #6273
Comments
comment:1
I have implemented this. using the random_element() function for ZZ and integral bases. It works for absolute and relative orders and ideals. I started out using the random_element() function for the module class, but that did not work in the relative situation. It is a little strange that the classes for orders and ideals do not derive from free ZZ-modules. |
Changed keywords from none to number field ideal order |
comment:3
REVIEW: I think it would be better to do
then in the docstring say that the inputs are identical to ZZ.random_element, whatever those are. This will if ZZ.random_element is ever improved, changed, or extended in any way (and let's hope it is), then this docstring won't have to change. Then in the call to ZZ.random_element, just do ZZ.random_element(*args, **kwds). This shorter and more robust. -- William |
comment:4
Replying to @williamstein:
OK, I'll do that. John |
comment:5
Attachment: trac_6273.patch.gz The revised patch does what was asked for in the review! |
Reviewer: Nick Alexander |
Author: John Cremona |
comment:6
In the relative case, the parents are wrong. I am fixing this right now. |
comment:7
Sorry about that. I'll review your fix as soon as I can. John |
comment:8
Attachment: trac_6273-replacement.patch.gz The new patch sorts out the parent problem ok, with suitable new doctests. I note that you now delegate the random function for orders to that of ideals -- this means that the new code is not used for non-maximal order, unfortunately. But then the same was true for my version. So I would have given this a positive review, while noting that at some point non-maximal orders will need to be dealt with too. Unfortunately:
so it's still "needs work" |
comment:9
Replying to @JohnCremona:
Let's just comment out both basis lines (since basis works, and it's essentially random). Can you make non-maximal orders work with the previous code? If so, do it and I will review. |
Attachment: trac_6273_new.patch.gz Replaces both previous |
comment:10
I removed the lines showing the bases (which were not part of the test exactly, just there for illustration). I reinstated my original for orders, since it works for non-maximal orders, and added a new doctest to show that; but I kept in the additional doctests from the review patch to show that theparent are now correct (which I also borrowed from the review patch). This one tests ok on both 32- and 64-bit, and I hope contains the best of both earlier patches with none of the problems! And in view of the trouble this took to get right, I removed the "(easy)" from the ticket's title! |
comment:11
I'm a fan! |
Merged: sage-4.1.alpha0 |
At the moment, random_element for number field orders returns a random integer coerced into the order, which isn't very useful. A much better solution would be to use the random_element method of the underlying free ZZ-module.
More generally, one could ask for the same functionality for fractional ideals (and the above would be the special case for the ideal (1).)
Component: number theory
Keywords: number field ideal order
Author: John Cremona
Reviewer: Nick Alexander
Merged: sage-4.1.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/6273
The text was updated successfully, but these errors were encountered: