Ticket #10484: trac_10484-crt_bug.2.patch

File trac_10484-crt_bug.2.patch, 950 bytes (added by davidloeffler, 11 years ago)

new version

  • sage/rings/arith.py

    # HG changeset patch
    # User David Loeffler <d.loeffler.01@cantab.net>
    # Date 1292529962 0
    # Node ID f13cd7f506238cea116cc5d3c4fbf81b7c58916d
    # Parent  207cbed9fdf2e71be645cd4531077a8718c5ff64
    #10484: Chinese remainder code raises an error when called with Python ints
    
    diff -r 207cbed9fdf2 -r f13cd7f50623 sage/rings/arith.py
    a b  
    27352735        Traceback (most recent call last):
    27362736        ...
    27372737        ValueError: No solution to crt problem since gcd(x^2 - 1,x^3 - 1) does not divide 2-x
     2738
     2739        sage: crt(int(2), int(3), int(7), int(11))
     2740        58
    27382741    """
    27392742    if isinstance(a, list):
    27402743        return CRT_list(a, b)
     2744    if isinstance(a, (int, long)):
     2745        a = integer.Integer(a) # otherwise we get an error at (b-a).quo_rem(g)
    27412746    g, alpha, beta = XGCD(m, n)
    27422747    q, r = (b - a).quo_rem(g)
    27432748    if r != 0: