Path: blob/master/sage/rings/function_field/constructor.py
4036 views
r"""1Factories to construct Function Fields23AUTHORS:45- William Stein (2010): initial version67- Maarten Derickx (2011-09-11): added FunctionField_polymod_Constructor, use @cached_function89- Julian Rueth (2011-09-14): replaced @cached_function with UniqueFactory1011EXAMPLES::1213sage: K.<x> = FunctionField(QQ); K14Rational function field in x over Rational Field15sage: L.<x> = FunctionField(QQ); L16Rational function field in x over Rational Field17sage: K is L18True19"""20#*****************************************************************************21# Copyright (C) 2010 William Stein <[email protected]>22# Copyright (C) 2011 Maarten Derickx <[email protected]>23# Copyright (C) 2011 Julian Rueth <[email protected]>24#25# Distributed under the terms of the GNU General Public License (GPL)26# as published by the Free Software Foundation; either version 2 of27# the License, or (at your option) any later version.28# http://www.gnu.org/licenses/29#*****************************************************************************3031from sage.structure.factory import UniqueFactory3233class FunctionFieldFactory(UniqueFactory):34"""35Return the function field in one variable with constant field ``F``. The function36field returned is unique in the sense that if you call this function twice37with the same base field and name then you get the same python object back.3839INPUT:4041- ``F`` -- a field42- ``names`` -- name of variable as a string or a tuple containg a string4344EXAMPLES::4546sage: K.<x> = FunctionField(QQ); K47Rational function field in x over Rational Field48sage: L.<y> = FunctionField(GF(7)); L49Rational function field in y over Finite Field of size 750sage: R.<z> = L[]51sage: M.<z> = L.extension(z^7-z-y); M52Function field in z defined by z^7 + 6*z + 6*y5354TESTS::5556sage: K.<x> = FunctionField(QQ)57sage: L.<x> = FunctionField(QQ)58sage: K is L59True60sage: M.<x> = FunctionField(GF(7))61sage: K is M62False63sage: N.<y> = FunctionField(QQ)64sage: K is N65False66"""67def create_key(self, F, names):68if not isinstance(names,tuple):69names = (names,)70return (F,names)7172def create_object(self, version, key, **extra_args):73from function_field import RationalFunctionField74return RationalFunctionField(key[0], names=key[1])7576FunctionField = FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField")7778class FunctionFieldPolymodFactory(UniqueFactory):79"""80Create a function field defined as an extension of another81function field by adjoining a root of a univariate polynomial.82The returned function field is unique in the sense that if you83call this function twice with an equal ``polynomial`` and ``names``84it returns the same python object in both calls.8586INPUT:8788- ``polynomial`` -- a univariate polynomial over a function field89- ``names`` -- variable names (as a tuple of length 1 or string)90- ``category`` -- a category (defaults to category of function fields)9192EXAMPLES::9394sage: K.<x> = FunctionField(QQ)95sage: R.<y>=K[]96sage: y2 = y*197sage: y2 is y98False99sage: L.<w>=K.extension(x-y^2) #indirect doctest100sage: M.<w>=K.extension(x-y2^2) #indirect doctest101sage: L is M102True103"""104def create_key(self, polynomial, names):105if names is None:106names = polynomial.variable_name()107if not isinstance(names,tuple):108names = (names,)109return (polynomial,names)110111def create_object(self, version, key, **extra_args):112from function_field import FunctionField_polymod113return FunctionField_polymod(key[0], names=key[1])114115FunctionField_polymod = FunctionFieldPolymodFactory("sage.rings.function_field.constructor.FunctionField_polymod")116117118