Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/rings/function_field/constructor.py
4036 views
1
r"""
2
Factories to construct Function Fields
3
4
AUTHORS:
5
6
- William Stein (2010): initial version
7
8
- Maarten Derickx (2011-09-11): added FunctionField_polymod_Constructor, use @cached_function
9
10
- Julian Rueth (2011-09-14): replaced @cached_function with UniqueFactory
11
12
EXAMPLES::
13
14
sage: K.<x> = FunctionField(QQ); K
15
Rational function field in x over Rational Field
16
sage: L.<x> = FunctionField(QQ); L
17
Rational function field in x over Rational Field
18
sage: K is L
19
True
20
"""
21
#*****************************************************************************
22
# Copyright (C) 2010 William Stein <[email protected]>
23
# Copyright (C) 2011 Maarten Derickx <[email protected]>
24
# Copyright (C) 2011 Julian Rueth <[email protected]>
25
#
26
# Distributed under the terms of the GNU General Public License (GPL)
27
# as published by the Free Software Foundation; either version 2 of
28
# the License, or (at your option) any later version.
29
# http://www.gnu.org/licenses/
30
#*****************************************************************************
31
32
from sage.structure.factory import UniqueFactory
33
34
class FunctionFieldFactory(UniqueFactory):
35
"""
36
Return the function field in one variable with constant field ``F``. The function
37
field returned is unique in the sense that if you call this function twice
38
with the same base field and name then you get the same python object back.
39
40
INPUT:
41
42
- ``F`` -- a field
43
- ``names`` -- name of variable as a string or a tuple containg a string
44
45
EXAMPLES::
46
47
sage: K.<x> = FunctionField(QQ); K
48
Rational function field in x over Rational Field
49
sage: L.<y> = FunctionField(GF(7)); L
50
Rational function field in y over Finite Field of size 7
51
sage: R.<z> = L[]
52
sage: M.<z> = L.extension(z^7-z-y); M
53
Function field in z defined by z^7 + 6*z + 6*y
54
55
TESTS::
56
57
sage: K.<x> = FunctionField(QQ)
58
sage: L.<x> = FunctionField(QQ)
59
sage: K is L
60
True
61
sage: M.<x> = FunctionField(GF(7))
62
sage: K is M
63
False
64
sage: N.<y> = FunctionField(QQ)
65
sage: K is N
66
False
67
"""
68
def create_key(self, F, names):
69
if not isinstance(names,tuple):
70
names = (names,)
71
return (F,names)
72
73
def create_object(self, version, key, **extra_args):
74
from function_field import RationalFunctionField
75
return RationalFunctionField(key[0], names=key[1])
76
77
FunctionField = FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField")
78
79
class FunctionFieldPolymodFactory(UniqueFactory):
80
"""
81
Create a function field defined as an extension of another
82
function field by adjoining a root of a univariate polynomial.
83
The returned function field is unique in the sense that if you
84
call this function twice with an equal ``polynomial`` and ``names``
85
it returns the same python object in both calls.
86
87
INPUT:
88
89
- ``polynomial`` -- a univariate polynomial over a function field
90
- ``names`` -- variable names (as a tuple of length 1 or string)
91
- ``category`` -- a category (defaults to category of function fields)
92
93
EXAMPLES::
94
95
sage: K.<x> = FunctionField(QQ)
96
sage: R.<y>=K[]
97
sage: y2 = y*1
98
sage: y2 is y
99
False
100
sage: L.<w>=K.extension(x-y^2) #indirect doctest
101
sage: M.<w>=K.extension(x-y2^2) #indirect doctest
102
sage: L is M
103
True
104
"""
105
def create_key(self, polynomial, names):
106
if names is None:
107
names = polynomial.variable_name()
108
if not isinstance(names,tuple):
109
names = (names,)
110
return (polynomial,names)
111
112
def create_object(self, version, key, **extra_args):
113
from function_field import FunctionField_polymod
114
return FunctionField_polymod(key[0], names=key[1])
115
116
FunctionField_polymod = FunctionFieldPolymodFactory("sage.rings.function_field.constructor.FunctionField_polymod")
117
118