Path: blob/master/src/sage/rings/function_field/constructor.py
8820 views
r"""1Factories to construct Function Fields23AUTHORS:45- William Stein (2010): initial version67- Maarten Derickx (2011-09-11): added ``FunctionField_polymod_Constructor``,8use ``@cached_function``910- Julian Rueth (2011-09-14): replaced ``@cached_function`` with11``UniqueFactory``1213EXAMPLES::1415sage: K.<x> = FunctionField(QQ); K16Rational function field in x over Rational Field17sage: L.<x> = FunctionField(QQ); L18Rational function field in x over Rational Field19sage: K is L20True21"""22#*****************************************************************************23# Copyright (C) 2010 William Stein <[email protected]>24# Copyright (C) 2011 Maarten Derickx <[email protected]>25# Copyright (C) 2011 Julian Rueth <[email protected]>26#27# Distributed under the terms of the GNU General Public License (GPL)28# as published by the Free Software Foundation; either version 2 of29# the License, or (at your option) any later version.30# http://www.gnu.org/licenses/31#*****************************************************************************3233from sage.structure.factory import UniqueFactory3435class FunctionFieldFactory(UniqueFactory):36"""37Return the function field in one variable with constant field ``F``. The38function field returned is unique in the sense that if you call this39function twice with the same base field and name then you get the same40python object back.4142INPUT:4344- ``F`` -- a field4546- ``names`` -- name of variable as a string or a tuple containing a string4748EXAMPLES::4950sage: K.<x> = FunctionField(QQ); K51Rational function field in x over Rational Field52sage: L.<y> = FunctionField(GF(7)); L53Rational function field in y over Finite Field of size 754sage: R.<z> = L[]55sage: M.<z> = L.extension(z^7-z-y); M56Function field in z defined by z^7 + 6*z + 6*y5758TESTS::5960sage: K.<x> = FunctionField(QQ)61sage: L.<x> = FunctionField(QQ)62sage: K is L63True64sage: M.<x> = FunctionField(GF(7))65sage: K is M66False67sage: N.<y> = FunctionField(QQ)68sage: K is N69False70"""71def create_key(self,F,names):72"""73Given the arguments and keywords, create a key that uniquely74determines this object.7576EXAMPLES::7778sage: K.<x> = FunctionField(QQ) # indirect doctest79"""80if not isinstance(names,tuple):81names=(names,)82return (F,names)8384def create_object(self,version,key,**extra_args):85"""86Create the object from the key and extra arguments. This is only87called if the object was not found in the cache.8889EXAMPLES::9091sage: K.<x> = FunctionField(QQ)92sage: L.<x> = FunctionField(QQ)93sage: K is L94True95"""96from function_field import RationalFunctionField97return RationalFunctionField(key[0],names=key[1])9899FunctionField=FunctionFieldFactory("sage.rings.function_field.constructor.FunctionField")100101class FunctionFieldPolymodFactory(UniqueFactory):102"""103Create a function field defined as an extension of another104function field by adjoining a root of a univariate polynomial.105The returned function field is unique in the sense that if you106call this function twice with an equal ``polynomial`` and ``names``107it returns the same python object in both calls.108109INPUT:110111- ``polynomial`` -- a univariate polynomial over a function field112113- ``names`` -- variable names (as a tuple of length 1 or string)114115- ``category`` -- a category (defaults to category of function fields)116117EXAMPLES::118119sage: K.<x> = FunctionField(QQ)120sage: R.<y>=K[]121sage: y2 = y*1122sage: y2 is y123False124sage: L.<w>=K.extension(x-y^2)125sage: M.<w>=K.extension(x-y2^2)126sage: L is M127True128"""129def create_key(self,polynomial,names):130"""131Given the arguments and keywords, create a key that uniquely132determines this object.133134EXAMPLES::135136sage: K.<x> = FunctionField(QQ)137sage: R.<y>=K[]138sage: L.<w> = K.extension(x-y^2) # indirect doctest139"""140if names is None:141names=polynomial.variable_name()142if not isinstance(names,tuple):143names=(names,)144return (polynomial,names)145146def create_object(self,version,key,**extra_args):147"""148Create the object from the key and extra arguments. This is only149called if the object was not found in the cache.150151EXAMPLES::152153sage: K.<x> = FunctionField(QQ)154sage: R.<y>=K[]155sage: L.<w> = K.extension(x-y^2) # indirect doctest156sage: y2 = y*1157sage: M.<w> = K.extension(x-y2^2) # indirect doctest158sage: L is M159True160"""161from function_field import FunctionField_polymod162return FunctionField_polymod(key[0],names=key[1])163164FunctionField_polymod=FunctionFieldPolymodFactory("sage.rings.function_field.constructor.FunctionField_polymod")165166167