Ticket #4260: trac_4260_bugfix.patch

File trac_4260_bugfix.patch, 1.3 KB (added by malb, 9 years ago)
  • sage/matrix/matrix_modn_dense_double.pyx

    # HG changeset patch
    # User Martin Albrecht <martinralbrecht@googlemail.com>
    # Date 1320842339 -3600
    # Node ID 6455aae40beeb8fa68ee13bbb716d69661ef6746
    # Parent  c2599038f933514e7797c5cd3306315d61876b0e
    #4260 bugfix for 32-bit systems
    
    diff --git a/sage/matrix/matrix_modn_dense_double.pyx b/sage/matrix/matrix_modn_dense_double.pyx
    a b  
    9898    cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, x):
    9999        r"""
    100100        Set the (i,j) entry with no bounds-checking, or any other checks.
    101        
     101
    102102        Assumes that `x` is in the base ring.
    103103
    104104        EXAMPLE::
     
    131131            sage: a*a
    132132            4337773
    133133        """
    134         self._matrix[i][j] = <double>(<IntegerMod_int>x).ivalue
     134        # note that INTEGER_MOD_INT32_LIMIT is ceil(sqrt(2^31-1)) < 2^23
     135        if (<Matrix_modn_dense_template>self).p <= INTEGER_MOD_INT32_LIMIT:
     136            self._matrix[i][j] = <double>(<IntegerMod_int>x).ivalue
     137        else:
     138            self._matrix[i][j] = <double>(<IntegerMod_int64>x).ivalue
    135139
    136140    cdef IntegerMod_abstract get_unsafe(self, Py_ssize_t i, Py_ssize_t j):
    137141        r"""
    138142        Return the (i,j) entry with no bounds-checking.
    139        
     143
    140144        EXAMPLE::
    141145
    142146            sage: A = random_matrix(GF(3016963), 4, 4); A