Ticket #11319: trac_11319_prime_field_coercion.patch

File trac_11319_prime_field_coercion.patch, 2.0 KB (added by johanbosman, 10 years ago)
  • sage/rings/finite_rings/finite_field_prime_modn.py

    # HG changeset patch
    # User Johan Bosman <johan.g.bosman@gmail.com>
    # Date 1305044964 -3600
    # Node ID 62712000f0a2b17b20e4e9c59092ddef239a2c03
    # Parent  847a0615a3a8feefa364145a3a6ac147d7ce19ef
    Trac 11319: allow coercion from prime residue field into prime finite field
    
    diff -r 847a0615a3a8 -r 62712000f0a2 sage/rings/finite_rings/finite_field_prime_modn.py
    a b  
    136136            5
    137137            sage: 12 % 7
    138138            5
     139            sage: ZZ.residue_field(7).hom(GF(7))(1)  # See trac 11319
     140            1
    139141        """
    140142        from sage.rings.integer_ring import ZZ
    141143        from sage.rings.finite_rings.integer_mod_ring import IntegerModRing_generic
     
    145147            return integer_mod.Integer_to_IntegerMod(self)
    146148        elif isinstance(S, IntegerModRing_generic):
    147149            from sage.rings.residue_field import ResidueField_generic
    148             if S.characteristic() == self.characteristic() and not isinstance(S, ResidueField_generic):
     150            if S.characteristic() == self.characteristic() and \
     151               (not isinstance(S, ResidueField_generic) or S.degree() == 1):
    149152                try:
    150153                    return integer_mod.IntegerMod_to_IntegerMod(S, self)
    151154                except TypeError:
  • sage/rings/residue_field.pyx

    diff -r 847a0615a3a8 -r 62712000f0a2 sage/rings/residue_field.pyx
    a b  
    508508            sage: F = OK.residue_field(P)
    509509            sage: F.has_coerce_map_from(GF(13)) # indirect doctest
    510510            True
    511             sage: GF(13).has_coerce_map_from(F)
    512             False
     511            sage: GF(13).has_coerce_map_from(F)  # See trac 11319
     512            True
    513513           
    514514            #sage: R.<t> = GF(17)[]; P = R.ideal(t^3 + t^2 + 7)
    515515            #sage: k.<a> = P.residue_field()