-
-
Notifications
You must be signed in to change notification settings - Fork 654
Completion of polynomial rings and their fraction fields #40635
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
base: develop
Are you sure you want to change the base?
Changes from all commits
2368519
573dae0
ce72980
d990b8f
eff3e22
2f06fbc
e6a8942
5f008e6
7468d4a
779cb91
aa9e296
5388244
a5d3d7d
6791145
dede4c3
e31740c
d0bf69c
1177266
b2ee24f
4dea431
0f8b78d
c84ffe6
ee59022
d816dc5
973dffa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2466,12 +2466,12 @@ class CompletionFunctor(ConstructionFunctor): | |
True | ||
|
||
sage: P.<x> = ZZ[] | ||
sage: Px = P.completion(x) # currently the only implemented completion of P | ||
sage: Px = P.completion(x) | ||
sage: Px | ||
Power Series Ring in x over Integer Ring | ||
Completion of Univariate Polynomial Ring in x over Integer Ring at x | ||
sage: F3 = Px.construction()[0] | ||
sage: F3(GF(3)['x']) | ||
Power Series Ring in x over Finite Field of size 3 | ||
Completion of Univariate Polynomial Ring in x over Finite Field of size 3 at x | ||
|
||
TESTS:: | ||
|
||
|
@@ -2484,7 +2484,7 @@ class CompletionFunctor(ConstructionFunctor): | |
(1 + O(5^20))*a + 3 + 2*5 + 2*5^2 + 2*5^3 + 2*5^4 + 2*5^5 + 2*5^6 + 2*5^7 + 2*5^8 + 2*5^9 + 2*5^10 + 2*5^11 + 2*5^12 + 2*5^13 + 2*5^14 + 2*5^15 + 2*5^16 + 2*5^17 + 2*5^18 + 2*5^19 + O(5^20) | ||
""" | ||
rank = 4 | ||
_real_types = ['Interval', 'Ball', 'MPFR', 'RDF', 'RLF', 'RR'] | ||
_real_types = [None, 'Interval', 'Ball', 'MPFR', 'RDF', 'RLF', 'RR'] | ||
_dvr_types = [None, 'fixed-mod', 'floating-point', 'capped-abs', 'capped-rel', 'lattice-cap', 'lattice-float', 'relaxed'] | ||
|
||
def __init__(self, p, prec, extras=None): | ||
|
@@ -2541,7 +2541,7 @@ def __init__(self, p, prec, extras=None): | |
from sage.rings.infinity import Infinity | ||
if self.p == Infinity: | ||
if self.type not in self._real_types: | ||
raise ValueError("completion type must be one of %s" % (", ".join(self._real_types))) | ||
raise ValueError("completion type must be one of %s" % (", ".join(self._real_types[1:]))) | ||
elif self.type not in self._dvr_types: | ||
raise ValueError("completion type must be one of %s" % (", ".join(self._dvr_types[1:]))) | ||
|
||
|
@@ -2777,9 +2777,9 @@ def commutes(self, other): | |
functors in opposite order works. It does:: | ||
|
||
sage: P.<x> = ZZ[] | ||
sage: C = P.completion(x).construction()[0] | ||
sage: C = P.completion('x').construction()[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
sage: R = FractionField(P) | ||
sage: hasattr(R,'completion') | ||
sage: hasattr(R, 'completion') | ||
False | ||
sage: C(R) is Frac(C(P)) | ||
True | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ | |
|
||
lazy_import('sage.rings.padics.factory', ['Qp', 'Zp']) | ||
from sage.rings.polynomial.polynomial_element import Polynomial | ||
from sage.rings.fraction_field_element import FractionFieldElement | ||
from sage.rings.fraction_field_FpT import FpTElement | ||
|
||
try: | ||
from .puiseux_series_ring_element import PuiseuxSeries | ||
|
@@ -47,6 +49,16 @@ def O(*x, **kwds): | |
O(x^100) | ||
sage: 1/(1+x+O(x^5)) | ||
1 - x + x^2 - x^3 + x^4 + O(x^5) | ||
|
||
Completion at other places also works:: | ||
|
||
sage: x^3 + O((x^2 + 1)^10) | ||
-x + x*(x^2 + 1) + O((x^2 + 1)^10) | ||
sage: x^3 + O(1/x^10) # completion at infinity | ||
x^3 + O(x^-10) | ||
|
||
An example with several variables:: | ||
|
||
sage: R.<u,v> = QQ[[]] | ||
sage: 1 + u + v^2 + O(u, v)^5 | ||
1 + u + v^2 + O(u, v)^5 | ||
|
@@ -126,11 +138,6 @@ def O(*x, **kwds): | |
|
||
:: | ||
|
||
sage: R.<x> = QQ[] | ||
sage: O(2*x) | ||
Traceback (most recent call last): | ||
... | ||
NotImplementedError: completion only currently defined for the maximal ideal (x) | ||
sage: R.<x> = LazyPowerSeriesRing(QQ) | ||
sage: O(x^5) | ||
O(x^5) | ||
|
@@ -169,13 +176,29 @@ def O(*x, **kwds): | |
if isinstance(x, power_series_ring_element.PowerSeries): | ||
return x.parent()(0, x.degree(), **kwds) | ||
|
||
if isinstance(x, (FractionFieldElement, FpTElement)): | ||
if x.denominator().is_one(): | ||
x = x.numerator() | ||
elif x.numerator().is_one(): | ||
x = x.denominator() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels fishy, what if the element is like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, the numerator is |
||
if isinstance(x, Polynomial) and x.is_monomial(): | ||
from sage.rings.infinity import infinity | ||
C = x.parent().completion(infinity) | ||
n = x.degree() | ||
return C.zero().add_bigoh(n) | ||
|
||
if isinstance(x, Polynomial): | ||
if x.parent().ngens() != 1: | ||
A = x.parent() | ||
if A.ngens() != 1: | ||
raise NotImplementedError("completion only currently defined " | ||
"for univariate polynomials") | ||
if x.is_monomial(): | ||
C = A.completion(A.variable_name()) | ||
n = x.degree() | ||
if not x.is_monomial(): | ||
raise NotImplementedError("completion only currently defined " | ||
"for the maximal ideal (x)") | ||
p, n = x.perfect_power() | ||
C = A.completion(p) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a test where Maybe also add a test where elements from two different parents are added, make sure they are not implicitly coercible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, for functoriality, it is nice to have completion at nonmaximal ideals. |
||
return C.zero().add_bigoh(n) | ||
|
||
if isinstance(x, (int, Integer, Rational)): | ||
# p-adic number | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When can the type be
None
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When called with a polynomial ring and
Infinity
(which was not implemented beforehand).