Ticket #7931: 7931_crt.patch

File 7931_crt.patch, 1.1 KB (added by roed, 9 years ago)

This is now #10047.

  • sage/rings/finite_rings/integer_mod.pyx

    # HG changeset patch
    # User David Roe <roed@math.harvard.edu>
    # Date 1285948365 14400
    # Node ID c125f6da818ad57e4d44eb25ed901a1ac6591e0b
    # Parent  5eb432d59dc6f2cf6296a8729b25ee895e0d8ded
    [mq]: 7931_crt.patch
    
    diff -r 5eb432d59dc6 -r c125f6da818a sage/rings/finite_rings/integer_mod.pyx
    a b  
    12871287            True
    12881288            sage: a.crt(b).modulus()
    12891289            100000000
     1290
     1291        TESTS::
     1292
     1293            sage: mod(0,1).crt(mod(4,2^127))
     1294            4
    12901295       
    12911296        AUTHORS:
    12921297
    12931298        - Robert Bradshaw
    12941299        """
    12951300        cdef int_fast64_t new_modulus
     1301        if other.__modulus.int64 == 1: return self
     1302        if self.__modulus.int64 == 1: return other
    12961303        if not PY_TYPE_CHECK(self, IntegerMod_gmp) and not PY_TYPE_CHECK(other, IntegerMod_gmp):
    12971304           
    1298             if other.__modulus.int64 == 1: return self
    12991305            new_modulus = self.__modulus.int64 * other.__modulus.int64
    13001306            if new_modulus < INTEGER_MOD_INT32_LIMIT:
    13011307                return self.__crt(other)