-
-
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
Make _floordiv_() return the Euclidean quotient for power series over fields #20062
Comments
Commit: |
comment:2
I don't fully agree with your proposal: In (generic) implementations for elements of rings, one may need to have a |
comment:3
Replying to @bgrenet:
Why would this be necessary? If the user calls
Well, power series rings are not fields. There is also an implementation of
Then we should do this in general for ring elements; I don't really see the advantage of this... In my opinion, it would make more sense to make sure that power series rings |
comment:4
Replying to @pjbruin:
One case I very often encounter is the need of an "exact division", that is a division when you know in advance that the result is exact.
Right. But this behavior for
That's right, it is probably a bad idea to make
You're perfectly right. My two-cent on this would be as follows:
sage: R.<x> = QQ[[]]
sage: (1/(1+x)).parent()
Power Series Ring in x over Rational Field
sage: (1/x).parent()
Laurent Series Ring in x over Rational Field while for instance for sage: (1/1).parent() is (1/2).parent()
True
|
comment:5
I tried to (1) add a method Jeroen, do you (as the author of e.g. #2034) perhaps know a way around this? Edit: (2) was done in #20283. |
comment:6
Replying to @pjbruin:
I think that such category stuff should probably not be used for Cython methods, I'm not entirely surprised that it doesn't work. In any case, I think there is not much point in implementing stuff if we haven't agreed on the semantics of |
comment:7
After thinking about this a bit more, it still seems meaningful to me to have an operator However, both to warn users and because the "correct" |
comment:8
Replying to @pjbruin:
Note that there exists a method sage: R.<x> = QQ[[]]
sage: R(1).quo_rem(1+t)
(1 - t + t^2 - t^3 + t^4 - t^5 + t^6 - t^7 + t^8 - t^9 + t^10 - t^11 + t^12 - t^13 + t^14 - t^15 + t^16 - t^17 + t^18 - t^19 + O(t^20),
0) |
comment:9
Replying to @bgrenet:
Yes, I added that in #20283.
Yes, absolutely. There are two problems: (1) due to the problem mentioned in comment:5, it seems that we cannot easily implement a generic |
comment:10
Replying to @pjbruin:
I did not notice that, so you probably knew this
Again, I simply trust you for the technical part about
Btw, I think that this change should also go with a change of behavior in the |
comment:11
A proposal along the line of my previous comment would be as follows: cpdef RingElement _floordiv_(self, RingElement denom):
"""
...
"""
from sage.misc.superseded import deprecation
try:
deprecation(20062, "the operator // now performs a euclidean division for power series over fields, use / instead to perform a (true) division")
return self.quo_rem(denom)[0]
except AttributeError, NotImplementedError:
deprecation(20062, "the operator // is deprecated for power series over non-fields, use / instead")
return self._div_(denom) Testing this code, I get a deprecation warning about deprecation warnings so it is probably not the right way to write this: /opt/sage/local/lib/python2.7/site-packages/IPython/core/formatters.py:92: DeprecationWarning: DisplayFormatter._ipython_display_formatter_default is deprecated: use @default decorator instead. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
The new comment implements a variant of your suggestion; I think the message in the case of fields should be a normal warning (since the behaviour changed), not a deprecation. |
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
Reviewer: Bruno Grenet |
comment:15
This looks good to me! |
Changed branch from u/pbruin/20062-PowerSeries_floordiv to |
There exists a method
PowerSeries_poly.__floordiv__()
, but it is not clear how it differs from ordinary division (see #15601 comment:43), or how it should differ mathematically.We replace this method by a new method
PowerSeries._floordiv_()
, which returns the Euclidean quotient over fields and is a deprecated alias for_div_()
over other rings.CC: @jdemeyer
Component: algebra
Author: Peter Bruin
Branch/Commit:
b7cd5cb
Reviewer: Bruno Grenet
Issue created by migration from https://trac.sagemath.org/ticket/20062
The text was updated successfully, but these errors were encountered: