Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/rings/function_field/constructor.py
8820 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``,
9
use ``@cached_function``
10
11
- Julian Rueth (2011-09-14): replaced ``@cached_function`` with
12
``UniqueFactory``
13
14
EXAMPLES::
15
16
sage: K.<x> = FunctionField(QQ); K
17
Rational function field in x over Rational Field
18
sage: L.<x> = FunctionField(QQ); L
19
Rational function field in x over Rational Field
20
sage: K is L
21
True
22
"""
23
#*****************************************************************************
24
# Copyright (C) 2010 William Stein <[email protected]>
25
# Copyright (C) 2011 Maarten Derickx <[email protected]>
26
# Copyright (C) 2011 Julian Rueth <[email protected]>
27
#
28
# Distributed under the terms of the GNU General Public License (GPL)
29
# as published by the Free Software Foundation; either version 2 of
30
# the License, or (at your option) any later version.
31
# http://www.gnu.org/licenses/
32
#*****************************************************************************
33
34
from sage.structure.factory import UniqueFactory
35
36
class FunctionFieldFactory(UniqueFactory):
37
"""
38
Return the function field in one variable with constant field ``F``. The
39
function field returned is unique in the sense that if you call this
40
function twice with the same base field and name then you get the same
41
python object back.
42
43
INPUT:
44
45
- ``F`` -- a field
46
47
- ``names`` -- name of variable as a string or a tuple containing a string
48
49
EXAMPLES::
50
51
sage: K.<x> = FunctionField(QQ); K
52
Rational function field in x over Rational Field
53
sage: L.<y> = FunctionField(GF(7)); L
54
Rational function field in y over Finite Field of size 7
55
sage: R.<z> = L[]
56
sage: M.<z> = L.extension(z^7-z-y); M
57
Function field in z defined by z^7 + 6*z + 6*y
58
59
TESTS::
60
61
sage: K.<x> = FunctionField(QQ)
62
sage: L.<x> = FunctionField(QQ)
63
sage: K is L
64
True
65
sage: M.<x> = FunctionField(GF(7))
66
sage: K is M
67
False
68
sage: N.<y> = FunctionField(QQ)
69
sage: K is N
70
False
71
"""
72
def create_key(self,F,names):
73
"""
74
Given the arguments and keywords, create a key that uniquely
75
determines this object.
76
77
EXAMPLES::
78
79
sage: K.<x> = FunctionField(QQ) # indirect doctest
80
"""
81
if not isinstance(names,tuple):
82
names=(names,)
83
return (F,names)
84
85
def create_object(self,version,key,**extra_args):
86
"""
87
Create the object from the key and extra arguments. This is only
88
called if the object was not found in the cache.
89
90
EXAMPLES::
91
92
sage: K.<x> = FunctionField(QQ)
93
sage: L.<x> = FunctionField(QQ)
94
sage: K is L
95
True
96
"""
97
from function_field import RationalFunctionField
98
return RationalFunctionField(key[0],names=key[1])
99
100
FunctionField=FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField")
101
102
class FunctionFieldPolymodFactory(UniqueFactory):
103
"""
104
Create a function field defined as an extension of another
105
function field by adjoining a root of a univariate polynomial.
106
The returned function field is unique in the sense that if you
107
call this function twice with an equal ``polynomial`` and ``names``
108
it returns the same python object in both calls.
109
110
INPUT:
111
112
- ``polynomial`` -- a univariate polynomial over a function field
113
114
- ``names`` -- variable names (as a tuple of length 1 or string)
115
116
- ``category`` -- a category (defaults to category of function fields)
117
118
EXAMPLES::
119
120
sage: K.<x> = FunctionField(QQ)
121
sage: R.<y>=K[]
122
sage: y2 = y*1
123
sage: y2 is y
124
False
125
sage: L.<w>=K.extension(x-y^2)
126
sage: M.<w>=K.extension(x-y2^2)
127
sage: L is M
128
True
129
"""
130
def create_key(self,polynomial,names):
131
"""
132
Given the arguments and keywords, create a key that uniquely
133
determines this object.
134
135
EXAMPLES::
136
137
sage: K.<x> = FunctionField(QQ)
138
sage: R.<y>=K[]
139
sage: L.<w> = K.extension(x-y^2) # indirect doctest
140
"""
141
if names is None:
142
names=polynomial.variable_name()
143
if not isinstance(names,tuple):
144
names=(names,)
145
return (polynomial,names)
146
147
def create_object(self,version,key,**extra_args):
148
"""
149
Create the object from the key and extra arguments. This is only
150
called if the object was not found in the cache.
151
152
EXAMPLES::
153
154
sage: K.<x> = FunctionField(QQ)
155
sage: R.<y>=K[]
156
sage: L.<w> = K.extension(x-y^2) # indirect doctest
157
sage: y2 = y*1
158
sage: M.<w> = K.extension(x-y2^2) # indirect doctest
159
sage: L is M
160
True
161
"""
162
from function_field import FunctionField_polymod
163
return FunctionField_polymod(key[0],names=key[1])
164
165
FunctionField_polymod=FunctionFieldPolymodFactory("sage.rings.function_field.constructor.FunctionField_polymod")
166
167