Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Clean up multi_modular.pyx
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Apr 25, 2016
1 parent 950f0f5 commit 54d3cf8
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 181 deletions.
10 changes: 6 additions & 4 deletions src/sage/ext/mod_int.h
Expand Up @@ -14,13 +14,15 @@
* Hence, we use signed 64-bit ints. This gives us fast conversion
* to/from Python on 64-bit Linux and OSX, and a large number of
* available (but not quite as fast) primes on 64-bit Windows and all
* 32-bit platforms (see Trac ##10281)
* 32-bit platforms (see Trac #10281)
*/
#define mod_int int_fast64_t

typedef int64_t mod_int;

/* The largest value we can do arithmetic on without risking overflowing.
* That is, you can multiply two MOD_INT_MAX in a mod_int.
*/
#define MOD_INT_OVERFLOW ((((mod_int)1) << (sizeof(mod_int)*8 - 1)) - 1)
#define MOD_INT_MAX ((mod_int)sqrt(MOD_INT_OVERFLOW) - 1)
#define MOD_INT_OVERFLOW_UNSIGNED ((((uint64_t)1) << (sizeof(mod_int)*8 - 1)) - 1)
#define MOD_INT_OVERFLOW ((mod_int)MOD_INT_OVERFLOW_UNSIGNED)
#define MOD_INT_MAX ((mod_int)sqrt(MOD_INT_OVERFLOW_UNSIGNED) - 1)

6 changes: 4 additions & 2 deletions src/sage/ext/mod_int.pxd
Expand Up @@ -9,8 +9,10 @@ The `mod_int` Data Type
# Copyright (C) 2013 Volker Braun <vbraun.name@gmail.com>
# Copyright (C) 2013 William Stein <wstein@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

Expand Down
8 changes: 3 additions & 5 deletions src/sage/ext/multi_modular.pxd
Expand Up @@ -2,9 +2,8 @@

from sage.ext.mod_int cimport *
from sage.libs.gmp.types cimport mpz_t
from sage.rings.integer cimport Integer

cdef class MultiModularBasis_base:
cdef class MultiModularBasis_base(object):
cdef int n
cdef mod_int* moduli
cdef mpz_t* partial_products
Expand Down Expand Up @@ -37,6 +36,5 @@ cdef class MultiModularBasis(MultiModularBasis_base):

cdef class MutableMultiModularBasis(MultiModularBasis):
cdef mod_int __last_prime
cdef mod_int next_prime_c(self) except -1
cdef mod_int replace_prime_c(self, int i) except -1

cpdef mod_int next_prime(self) except -1
cpdef mod_int replace_prime(self, int ix) except -1

0 comments on commit 54d3cf8

Please sign in to comment.