Ticket #8721: trac_8721-residue_field_lifting_bug.patch

File trac_8721-residue_field_lifting_bug.patch, 1.9 KB (added by David Loeffler, 12 years ago)
  • sage/rings/number_field/number_field_ideal.py

    # HG changeset patch
    # User David Loeffler <d.loeffler.01@cantab.net>
    # Date 1295975834 0
    # Node ID 039c566589b663700f313ab0cecac96289334b8e
    # Parent  063ffd2a1aa7c0aaf2f7548513dc8ee546a0a108
    #8721: Residue fields for relative number fields broken (again)
    
    diff -r 063ffd2a1aa7 -r 039c566589b6 sage/rings/number_field/number_field_ideal.py
    a b  
    27602760            sage: R(1/b)
    27612761            2*abar
    27622762
     2763        We verify that #8721 is fixed::
     2764
     2765            sage: L.<a, b> = NumberField([x^2 - 3, x^2 - 5])
     2766            sage: L.ideal(a).residue_field()
     2767            Residue field in abar of Fractional ideal (a)
    27632768        """
    27642769        if not self.is_prime():
    27652770            raise ValueError, "The ideal must be prime"
     
    28872892        self.__OK = OK
    28882893        self.__Q = Q
    28892894        self.__M_OK_map = M_OK_map
     2895        self.__Kgen = OK.number_field().absolute_generator()
    28902896   
    28912897    def __call__(self, x):
    28922898        """
     
    28992905            sage: f = R.lift_map()
    29002906            sage: f(R(a/17))
    29012907            1
     2908
     2909        A relative example, which used to fail but is fixed by #8721::
     2910
     2911            sage: L.<a, b> = NumberField([x^2 + 1, x^2 - 5])
     2912            sage: p = L.ideal(2*a + 3)
     2913            sage: V, to_V, from_V = p._p_quotient(13)
     2914            sage: from_V(V.0)
     2915            (-1/2*b + 7/2)*a - 1/2*b + 3/2
    29022916        """
    29032917        # This lifts to OK tensor F_p
    29042918        v = self.__Q.lift(x)
    29052919        # This lifts to ZZ^n (= OK)
    29062920        w = v.lift()
    29072921        # Write back in terms of K
    2908         z = w * self.__M_OK_map
    2909         return self.__OK(z.list())
     2922        z = (w * self.__M_OK_map).list()
     2923        return self.__OK(sum([z[i] * self.__Kgen**i for i in xrange(len(z))]))
    29102924
    29112925    def __repr__(self):
    29122926        """