Ticket #9054: trac_9054_codomain.patch

File trac_9054_codomain.patch, 1.8 KB (added by saraedum, 6 years ago)

set the correct codomain for function fields

  • sage/rings/function_field/function_field.py

    exporting patch:
    # HG changeset patch
    # User Julian Rüth <julian.rueth@gmail.com>
    # Date 1311351537 -7200
    # Node ID 6be45617d3fd77916a605eb8c28966f5b47fe201
    # Parent  58c4d3f474221e7cdd8c5eab1d2fda05febcbdcf
    Trac 9054: correct codomain of morphisms
    
    diff -r 58c4d3f47422 -r 6be45617d3fd sage/rings/function_field/function_field.py
    a b  
    305305            4*w + t + 1
    306306            sage: f(x*y + x/(x^2+1))
    307307            (4*t + 4)*w + (t + 1)/(t^2 + 2*t + 2)
     308
     309        We make another extension of a rational function field::
     310
     311            sage: R3.<yy> = FunctionField(QQ); S3.<xx> = R3[]
     312            sage: L3.<xx> = R3.extension(yy^2 - xx^3 - 1)
     313
     314        This is the function field L with the generators exchanged. We define a morphism to L::
     315
     316            sage: g = L3.hom([x,y]); g
     317            Morphism of function fields defined by xx |--> x, yy |--> y
    308318        """
    309319        if not isinstance(im_gens, (list,tuple)):
    310320            im_gens = [im_gens]
     321        if len(im_gens) == 0:
     322            raise ValueError, "no images specified"
     323   
    311324        if len(im_gens) > 1:
    312325            base_morphism = self.base_field().hom(im_gens[1:], base_morphism)
    313         return maps.FunctionFieldMorphism(self.Hom(im_gens[0].parent()), im_gens[0], base_morphism)
     326
     327        # the codomain of this morphism is the field containing all the im_gens
     328        codomain = im_gens[0].parent();
     329        if base_morphism is not None:
     330            if base_morphism.codomain().has_coerce_map_from(codomain):
     331                codomain = base_morphism.codomain();
     332
     333        return maps.FunctionFieldMorphism(self.Hom(codomain), im_gens[0], base_morphism)
    314334
    315335class FunctionField_polymod(FunctionField):
    316336    """