Ticket #11666: trac_11666_remove_random_hack.patch

File trac_11666_remove_random_hack.patch, 1.4 KB (added by vbraun, 7 years ago)

Initial patch

  • sage/rings/real_mpfr.pyx

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1329868056 28800
    # Node ID a202ee88c02e9765b6b8e4f4b34e4b6ea59944c0
    # Parent  65c70eeebf8baba98019b8a8c03c0d4001f636a4
    Trac #11666: Upgrade MPFR to 3.1.0
    
    This patch removes the ugly hack that is no longer
    necessary to have the same random numbers on 32 and 64 bit
    
    diff --git a/sage/rings/real_mpfr.pyx b/sage/rings/real_mpfr.pyx
    a b  
    928928        """
    929929        cdef RealNumber x = self._new()
    930930        cdef randstate rstate = current_randstate()
    931         if sizeof(long) == 4:
    932             # This is a gross hack that depends on the internals of
    933             # MPFR... but that's OK, because if MPFR changes it will
    934             # be instantly caught by the doctests above.
    935             # MPFR rounds up the precision to a multiple of the
    936             # current word size, then requests that many bits from
    937             # .gmp_state .  So if (1 <= precision mod 64 <= 32),
    938             # a 64-bit machine will request 32 more bits than a 32-bit
    939             # machine, and the random numbers will get out of sync.
    940             # We work around this problem by requesting an extra
    941             # 32 bits on a 32-bit machine.
    942             if 1 <= self.__prec % 64 <= 32:
    943                 rstate.c_random()           
    944931        mpfr_urandomb(x.value, rstate.gmp_state)
    945932        if min == 0 and max == 1:
    946933            return x