Skip to content

Commit 2b7b7d1

Browse files
committed
move methods into category of fields
1 parent dc99dc8 commit 2b7b7d1

File tree

2 files changed

+55
-51
lines changed

2 files changed

+55
-51
lines changed

src/sage/categories/fields.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,61 @@ def is_integrally_closed(self) -> bool:
240240
"""
241241
return True
242242

243+
def integral_closure(self):
244+
"""
245+
Return this field, since fields are integrally closed in their
246+
fraction field.
247+
248+
EXAMPLES::
249+
250+
sage: QQ.integral_closure()
251+
Rational Field
252+
sage: Frac(ZZ['x,y']).integral_closure()
253+
Fraction Field of Multivariate Polynomial Ring in x, y
254+
over Integer Ring
255+
"""
256+
return self
257+
258+
def prime_subfield(self):
259+
"""
260+
Return the prime subfield of ``self``.
261+
262+
EXAMPLES::
263+
264+
sage: k = GF(9, 'a') # needs sage.rings.finite_rings
265+
sage: k.prime_subfield() # needs sage.rings.finite_rings
266+
Finite Field of size 3
267+
"""
268+
if self.characteristic() == 0:
269+
import sage.rings.rational_field
270+
return sage.rings.rational_field.RationalField()
271+
272+
from sage.rings.finite_rings.finite_field_constructor import GF
273+
return GF(self.characteristic())
274+
275+
def divides(self, x, y, coerce=True):
276+
"""
277+
Return ``True`` if ``x`` divides ``y`` in this field.
278+
279+
This is usually ``True`` in a field!.
280+
281+
If ``coerce`` is ``True`` (the default), first coerce
282+
``x`` and ``y`` into ``self``.
283+
284+
EXAMPLES::
285+
286+
sage: QQ.divides(2, 3/4)
287+
True
288+
sage: QQ.divides(0, 5)
289+
False
290+
"""
291+
if coerce:
292+
x = self(x)
293+
y = self(y)
294+
if x.is_zero():
295+
return y.is_zero()
296+
return True
297+
243298
def _gcd_univariate_polynomial(self, a, b):
244299
"""
245300
Return the gcd of ``a`` and ``b`` as a monic polynomial.

src/sage/rings/ring.pyx

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,40 +1002,6 @@ cdef class Field(CommutativeRing):
10021002
"""
10031003
return self
10041004

1005-
def divides(self, x, y, coerce=True):
1006-
"""
1007-
Return ``True`` if ``x`` divides ``y`` in this field (usually ``True``
1008-
in a field!). If ``coerce`` is ``True`` (the default), first coerce
1009-
``x`` and ``y`` into ``self``.
1010-
1011-
EXAMPLES::
1012-
1013-
sage: QQ.divides(2, 3/4)
1014-
True
1015-
sage: QQ.divides(0, 5)
1016-
False
1017-
"""
1018-
if coerce:
1019-
x = self(x)
1020-
y = self(y)
1021-
if x.is_zero():
1022-
return y.is_zero()
1023-
return True
1024-
1025-
def integral_closure(self):
1026-
"""
1027-
Return this field, since fields are integrally closed in their
1028-
fraction field.
1029-
1030-
EXAMPLES::
1031-
1032-
sage: QQ.integral_closure()
1033-
Rational Field
1034-
sage: Frac(ZZ['x,y']).integral_closure()
1035-
Fraction Field of Multivariate Polynomial Ring in x, y over Integer Ring
1036-
"""
1037-
return self
1038-
10391005
def is_field(self, proof=True):
10401006
"""
10411007
Return ``True`` since this is a field.
@@ -1047,23 +1013,6 @@ cdef class Field(CommutativeRing):
10471013
"""
10481014
return True
10491015

1050-
def prime_subfield(self):
1051-
"""
1052-
Return the prime subfield of ``self``.
1053-
1054-
EXAMPLES::
1055-
1056-
sage: k = GF(9, 'a') # needs sage.rings.finite_rings
1057-
sage: k.prime_subfield() # needs sage.rings.finite_rings
1058-
Finite Field of size 3
1059-
"""
1060-
if self.characteristic() == 0:
1061-
import sage.rings.rational_field
1062-
return sage.rings.rational_field.RationalField()
1063-
else:
1064-
from sage.rings.finite_rings.finite_field_constructor import GF
1065-
return GF(self.characteristic())
1066-
10671016
def algebraic_closure(self):
10681017
"""
10691018
Return the algebraic closure of ``self``.

0 commit comments

Comments
 (0)