Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/rings/field.py
8817 views
1
r"""
2
Abstract base class for fields
3
"""
4
5
#*****************************************************************************
6
# Copyright (C) 2005 William Stein <[email protected]>
7
#
8
# Distributed under the terms of the GNU General Public License (GPL)
9
#
10
# This code is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# General Public License for more details.
14
#
15
# The full text of the GPL is available at:
16
#
17
# http://www.gnu.org/licenses/
18
#*****************************************************************************
19
20
from sage.rings.ring import Field
21
22
def is_PrimeField(R):
23
r"""
24
Determine if ``R`` is a field that is equal to its own prime subfield.
25
26
INPUT:
27
28
- ``R`` -- a ring or field
29
30
OUTPUT:
31
32
- ``True`` if R is `\QQ` or a finite field `\GF{p}` for `p` prime,
33
``False`` otherwise.
34
35
EXAMPLES::
36
37
sage: sage.rings.field.is_PrimeField(QQ)
38
True
39
sage: sage.rings.field.is_PrimeField(GF(7))
40
True
41
sage: sage.rings.field.is_PrimeField(GF(7^2,'t'))
42
False
43
"""
44
from finite_rings.constructor import is_FiniteField
45
from rational_field import is_RationalField
46
47
if is_RationalField(R):
48
return True
49
if is_FiniteField(R):
50
return R.degree() == 1
51
return False
52
53
54