Ticket #6832: inverse_mod.patch

File inverse_mod.patch, 1.1 KB (added by mtaranes, 12 years ago)
  • sage/rings/number_field/number_field_element.pyx

    # HG changeset patch
    # User Maite Aranes <M.T.Aranes@warwick.ac.uk>
    # Date 1251376341 -3600
    # Node ID 9fef68d6d829092182a614bfe8f986728f9c87c2
    # Parent  684eea91ff224e5bc6259ca19f1576c4c082b9d3
    Fix bug in inverse_mod for integral elements of number fields
    
    diff -r 684eea91ff22 -r 9fef68d6d829 sage/rings/number_field/number_field_element.pyx
    a b  
    28782878            sage: d = 3*a + 1
    28792879            sage: d.inverse_mod(N)
    28802880            1
     2881
     2882        ::
     2883
     2884            sage: k.<a> = NumberField(x^3 + 11)
     2885            sage: d = a + 13
     2886            sage: d.inverse_mod(a^2) * d - 1 in k.ideal(a^2)
     2887            True
     2888            sage: d.inverse_mod((5, a + 1))*d - 1 in k.ideal(5, a + 1)
     2889            True
     2890
    28812891        """
    2882         R = I.number_field().ring_of_integers()
     2892        k = self.number_field()
     2893        R = k.ring_of_integers()
     2894        I = k.ideal(I)
     2895
    28832896        try:
    28842897            return I.small_residue(_inverse_mod_generic(R(self), I))
    28852898        except TypeError: