-
-
Notifications
You must be signed in to change notification settings - Fork 568
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
is_square and sqrt for polynomials and fraction fields #9094
Comments
Attachment: 9094-sqrt.patch.gz |
comment:2
Looks good (and useful). Patch applies fine to 4.4.3. I tested all sage/rings and had one failure (in a new doctest, on 64-bit ubuntu):
I have never been happy about doctests using random elements, however deterministic they are supposed to be. I would have tested for self==0 at the start of the sqrt function, but that case will be caught quickly anyway, so no problem. I have been working on a patch to add both all= and extend= parameters to the sqrt function for AA and QQbar, having found how awkward it is when the parameters are not uniform across types. Would it be worth adding an extend= parameter here, even if a NotImplementedError is raised when it is needed (i.e. for sqrt of a non-square when extend=True)? So: needs work because of the doctest failure; up to you whether to do the extend= thing. |
Work Issues: doctest failure |
Reviewer: John Cremona |
Author: Robert Bradshaw |
comment:5
is_square and sqrt can be done generally for fraction fields, given the corresponding functions for the base ring:
|
comment:7
On sage days 23 we discussed how to make this faster by avoiding factoring in polynomial rings. We are currently implementing this together with the remark of pbruin. When finnished the patch will be added to 9054 because it also fixes some other bugs on that ticket. |
This comment has been minimized.
This comment has been minimized.
comment:9
This patch also leaks memory, probably because of bug #9129
executing the above gives:
Ps. if you want to check this, please don't let the loop run as long as I did ;). It might make your computer on the edge of crashing |
comment:10
I just added a patch which should fix this also. It does it in a slightly different way. The sqrt() functions just are using the is_square(root=True) functionality (one should not have two square root finding algorithms in parralel). Also the sqrt() function has now the optional parameter extend. The is_square() function now also uses the trick mentioned by Peter the Bruin which is very general as it should be in this general base class. The patch should be installed aplied to 4.4.4 instead of the other patch. |
This comment has been minimized.
This comment has been minimized.
Changed work issues from doctest failure to improve documentation, add more tests |
Changed reviewer from John Cremona to mstreng |
Changed author from Robert Bradshaw to mderickx |
comment:11
Looks good. No time for a complete review right now, but here are some remarks:
|
comment:23
Only apply: trac_9094-sqrt-mderickx.2.patch |
This comment has been minimized.
This comment has been minimized.
comment:25
Since you told me you're going to rewrite the patch, I'm holding off on doctesting. Three short comments: in structure/element.pyx
|
comment:27
|
comment:28
Replying to @robertwb:
Indeed, it should use
Hi Robert, I can answer this question. This was a discussion on sage-devel. 4 options were discussed for dealing with these unitary operators for lazy numbers. A) leaving them as they were B) hard-coding them (as Maarten just did) C) "fixing LazyNamedUnop to preserve documentation" D) "populating these methods at class creation time Option A was discarded: it lacks tab completion, and (as we saw in this ticket) leads to a big mess and a lot of confusion when a base class such as RingElement gets a default implementation for one of these unitary operators. Options C and D were suggested by you, but you seemed to be the only one in the discussion who knew how to do them. Maarten said he was interested in them, and then nothing happened for months. So I guess that in the end Maarten implemented the only remaining option, which leads to stable, transparent, understandable code that is unfortunately a bit long. I think the extra time that Sage developers will need when extending or changing Maarten's long list of similar methods is not too bad if you compare it to the time that Sage developers will need when trying to understand more complicated code and having to debug it if something unforeseen happens. But that's just my opinion. +1 from me for the way Maarten implemented it.
Are there general guidelines for this? I can imagine |
comment:29
New file added Only apply: trac_9094-sqrt-mderickx.patch It's RLF is now boiler plate code free, works with tab completion and works with inheritance thanks to Thomas Kluiver here at sage days since he told me how to do it :). Also added the other suggestions. Hopefully finally a final version?? |
This comment has been minimized.
This comment has been minimized.
comment:30
Hi Maarten, could you add a doctest to
|
A patch instead of the other one, which I ofcourse think is better ;) |
comment:31
Attachment: trac_9094-sqrt-mderickx.patch.gz Done :) |
comment:32
Looks good. |
Changed reviewer from John Cremona, Marco Streng to John Cremona, Marco Streng, Robert Bradshaw |
This comment has been minimized.
This comment has been minimized.
Changed work issues from make general sqrt compatible with lazy reals, or go back to double code to none |
Merged: sage-4.7.alpha5 |
Implement is_square and sqrt for polynomials and fraction fields.
Only apply: attachment: trac_9094-sqrt-mderickx.patch
CC: @koffie @pjbruin @mstreng @mminzlaff
Component: algebra
Author: Robert Bradshaw, Maarten Derickx
Reviewer: John Cremona, Marco Streng, Robert Bradshaw
Merged: sage-4.7.alpha5
Issue created by migration from https://trac.sagemath.org/ticket/9094
The text was updated successfully, but these errors were encountered: