Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes in pyx files #38542

Merged
merged 5 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/sage/combinat/designs/evenly_distributed_sets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,24 @@ cdef class EvenlyDistributedSetsBacktracker:
raise ValueError(f"{K} is not a field")
cdef unsigned int q = K.cardinality()
cdef unsigned int e = k*(k-1)/2
if (q-1) % (2*e) != 0:
if (q-1) % (2*e):
raise ValueError("k(k-1)={} does not divide q-1={}".format(k*(k-1),q-1))
cdef unsigned int m = (q-1)/e
cdef unsigned int m = (q - 1) // e

self.q = q
self.e = e
self.k = k
self.m = (q-1) / e
self.m = (q - 1) // e
self.K = K

self.diff = <unsigned int **> check_calloc(q, sizeof(unsigned int *))
self.diff[0] = <unsigned int *> check_malloc(q*q*sizeof(unsigned int))
for i in range(1,self.q):
for i in range(1, self.q):
self.diff[i] = self.diff[i-1] + q

self.ratio = <unsigned int **> check_calloc(q, sizeof(unsigned int *))
self.ratio[0] = <unsigned int *> check_malloc(q*q*sizeof(unsigned int))
for i in range(1,self.q):
for i in range(1, self.q):
self.ratio[i] = self.ratio[i-1] + q

self.B = <unsigned int *> check_malloc(k*sizeof(unsigned int))
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/designs/subhypergraph_search.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ cdef inline int bs_get(uint64_t * bitset, int index) noexcept:
r"""
Return a bit of a bitset
"""
return (bitset[index/64]>>(index%64))&1
return (bitset[index//64]>>(index%64))&1

cdef inline void bs_set(uint64_t * bitset, int index, int bit) noexcept:
r"""
Expand All @@ -142,8 +142,8 @@ cdef inline void bs_set(uint64_t * bitset, int index, int bit) noexcept:
"bit" *MUST* be equal to either 0 or to 1. The code does not involve any
"if".
"""
bitset[index/64] &= ~((<uint64_t> 1)<<index%64)
bitset[index/64] |= (<uint64_t> bit)<<index%64
bitset[index//64] &= ~((<uint64_t> 1)<<index%64)
bitset[index//64] |= (<uint64_t> bit)<<index%64

cdef inline int bs_issubset64(uint64_t * b1, uint64_t b2, int limbs) noexcept:
r"""
Expand Down Expand Up @@ -180,7 +180,7 @@ cdef hypergraph h_init(int n,list H) noexcept:
cdef hypergraph h
h.n = n
h.m = len(H)
h.limbs = (n+63)/64 # =ceil(n/64)
h.limbs = (n+63) // 64 # =ceil(n/64)
h.names = <int *> sig_malloc(sizeof(int)*n)
h.sets = <uint64_t **> sig_malloc(h.m*sizeof(uint64_t *))
h.set_space = <uint64_t *> sig_calloc(h.m*(h.limbs+1),sizeof(uint64_t))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5394,7 +5394,7 @@ cdef class Matroid(SageObject):
E = set(self.groundset())
Q = set(list(E)[:m])
E = E-Q
for r in range(len(Q)/2 + 1):
for r in range(len(Q) // 2 + 1):
R = set(list(E)[:r])
for Q1 in map(set, combinations(Q, r)):
Q2 = Q-Q1
Expand Down
12 changes: 6 additions & 6 deletions src/sage/modular/arithgroup/congroup.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t):
# total number of coset representatives that we'll find
n = Gamma0(N).index() / Gamma0(M).index()
k = 0 # number found so far
Ndivt = N / t
Ndivt = N // t
R = <int*>check_allocarray(4 * n, sizeof(int))
halfmax = 2*(n+10)
while k < n:
Expand All @@ -126,10 +126,10 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t):
g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa)
if g == 0:
continue
cc = cc / g
cc = cc // g
if cc % M != 0:
continue
dd = dd / g
dd = dd // g
# Test if we've found a new coset representative.
is_new = 1
for i in range(k):
Expand Down Expand Up @@ -217,7 +217,7 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t):
# total number of coset representatives that we'll find
n = Gamma1(N).index() / Gamma1(M).index()
d = arith_int.c_gcd_int(t, N // t)
n = n / d
n = n // d
k = 0 # number found so far
Ndivt = N // t
R = <int*>check_allocarray(4 * n, sizeof(int))
Expand All @@ -229,10 +229,10 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t):
g = arith_int.c_xgcd_int(-cc, dd, &bb, &aa)
if g == 0:
continue
cc = cc / g
cc = cc // g
if cc % M != 0:
continue
dd = dd / g
dd = dd // g
if M != 1 and dd % M != 1:
continue
# Test if we've found a new coset representative.
Expand Down
3 changes: 2 additions & 1 deletion src/sage/modular/hypergeometric_misc.pxd
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D,
cpdef hgm_coeffs(long long p, unsigned int f,
int prec, gamma, m, int D,
gtable, int gtable_prec, bint use_longs)
7 changes: 4 additions & 3 deletions src/sage/modular/hypergeometric_misc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ from cpython cimport array
from cysignals.signals cimport sig_check
from sage.rings.integer cimport Integer

cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D,
cpdef hgm_coeffs(long long p, unsigned int f,
int prec, gamma, m, int D,
gtable, int gtable_prec, bint use_longs):
r"""
Compute coefficients for the hypergeometric trace formula.
Expand Down Expand Up @@ -35,8 +36,8 @@ cpdef hgm_coeffs(long long p, int f, int prec, gamma, m, int D,
"""
from sage.rings.padics.factory import Zp

cdef int gl, j, k, l, v, gv
cdef long long i, q1, w, w1, w2, q2, r, r1
cdef int gl, j, k, v, gv
cdef long long i, l, q1, w, w1, w2, q2, r, r1
cdef bint flip, use_longlongs

q1 = p ** f - 1
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/modform/eis_series_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ cpdef Ek_ZZ(int k, int prec=10):

# compute the valuation of n at p
additional_p_powers = 0
temp_index = ind / p
temp_index = ind // p
remainder = 0
while not remainder:
additional_p_powers += 1
prev_index = temp_index
temp_index = temp_index / p
temp_index = temp_index // p
remainder = prev_index - p*temp_index

# if we need a new sum, it has to be the next uncomputed one.
Expand Down
16 changes: 8 additions & 8 deletions src/sage/modular/modsym/heilbronn.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ cdef class HeilbronnCremona(Heilbronn):
# NOTE: In C, -p/2 means "round toward 0", but in Python it
# means "round down."
sig_on()
for r in range(-p/2, p/2+1):
for r in range(-p // 2, p // 2 + 1):
x1 = p
x2 = -r
y1 = 0
Expand All @@ -394,7 +394,7 @@ cdef class HeilbronnCremona(Heilbronn):
x3 = 0
y3 = 0
q = 0
list_append4(L, x1,x2,y1,y2)
list_append4(L, x1, x2, y1, y2)
while b:
q = <int>roundf(<float>a / <float> b)
c = a - b*q
Expand All @@ -406,8 +406,8 @@ cdef class HeilbronnCremona(Heilbronn):
y3 = q*y2 - y1
y1 = y2
y2 = y3
list_append4(L, x1,x2, y1,y2)
self.length = L.i/4
list_append4(L, x1, x2, y1, y2)
self.length = L.i // 4
sig_off()


Expand Down Expand Up @@ -491,7 +491,7 @@ cdef class HeilbronnMerel(Heilbronn):
for a in range(1, n+1):
## We have ad-bc=n so c=0 and ad=n, or b=(ad-n)/c
## Must have ad - n >= 0, so d must be >= Ceiling(n/a).
q = n/a
q = n // a
if q*a == n:
d = q
for b in range(a):
Expand All @@ -503,10 +503,10 @@ cdef class HeilbronnMerel(Heilbronn):
## Divisor c of bc must satisfy Floor(bc/c) lt a and c lt d.
## c ge (bc div a + 1) <=> Floor(bc/c) lt a (for integers)
## c le d - 1 <=> c lt d
for c in range(bc/a + 1, d):
for c in range(bc // a + 1, d):
if bc % c == 0:
list_append4(L,a,bc/c,c,d)
self.length = L.i/4
list_append4(L, a, bc // c, c, d)
self.length = L.i // 4
sig_off()


Expand Down
42 changes: 21 additions & 21 deletions src/sage/modular/modsym/p1list.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ cdef int c_p1_normalize_int(int N, int u, int v,

# Now g = s*u + t*N, so s is a "pseudo-inverse" of u mod N
# Adjust s modulo N/g so it is coprime to N.
if g!=1:
d = N/g
if g != 1:
d = N // g
while arith_int.c_gcd_int(s,N) != 1:
s = (s+d) % N

Expand All @@ -105,8 +105,8 @@ cdef int c_p1_normalize_int(int N, int u, int v,

min_v = v
min_t = 1
if g!=1:
Ng = N/g
if g != 1:
Ng = N // g
vNg = (v*Ng) % N
t = 1
for k in range(2, g + 1):
Expand Down Expand Up @@ -355,8 +355,8 @@ cdef int c_p1_normalize_llong(int N, int u, int v,

# Now g = s*u + t*N, so s is a "pseudo-inverse" of u mod N
# Adjust s modulo N/g so it is coprime to N.
if g!=1:
d = N/g
if g != 1:
d = N // g
while arith_int.c_gcd_int(s,N) != 1:
s = (s+d) % N

Expand All @@ -367,8 +367,8 @@ cdef int c_p1_normalize_llong(int N, int u, int v,

min_v = v
min_t = 1
if g!=1:
Ng = N/g
if g != 1:
Ng = N // g
vNg = <int> ((<llong>v * <llong> Ng) % ll_N)
t = 1
for k in range(2, g + 1):
Expand Down Expand Up @@ -640,8 +640,8 @@ cdef int p1_normalize_xgcdtable(int N, int u, int v,

# Now g = s*u + t*N, so s is a "pseudo-inverse" of u mod N
# Adjust s modulo N/g so it is coprime to N.
if g!=1:
d = N/g
if g != 1:
d = N // g
while t_g[s] != 1: # while arith_int.c_gcd_int(s,N) != 1:
s = (s+d) % N

Expand All @@ -651,8 +651,8 @@ cdef int p1_normalize_xgcdtable(int N, int u, int v,

min_v = v
min_t = 1
if g!=1:
Ng = N/g
if g != 1:
Ng = N // g
vNg = (v*Ng) % N
t = 1
for k in range(2, g + 1):
Expand Down Expand Up @@ -1237,17 +1237,17 @@ def lift_to_sl2z_int(int c, int d, int N):

# compute prime-to-d part of m.
while True:
g = arith_int.c_gcd_int(m,d)
g = arith_int.c_gcd_int(m, d)
if g == 1:
break
m = m / g
m = m // g

# compute prime-to-N part of m.
while True:
g = arith_int.c_gcd_int(m,N)
g = arith_int.c_gcd_int(m, N)
if g == 1:
break
m = m / g
m = m // g
d += N * m
g = arith_int.c_xgcd_int(c, d, &z1, &z2)

Expand Down Expand Up @@ -1299,25 +1299,25 @@ def lift_to_sl2z_llong(llong c, llong d, int N):
g = arith_llong.c_xgcd_longlong(c, d, &z1, &z2)

# We're lucky: z1*c + z2*d = 1.
if g==1:
if g == 1:
return [z2, -z1, c, d]

# Have to try harder.
m = c

# compute prime-to-d part of m.
while True:
g = arith_llong.c_gcd_longlong(m,d)
g = arith_llong.c_gcd_longlong(m, d)
if g == 1:
break
m = m / g
m = m // g

# compute prime-to-N part of m.
while True:
g = arith_llong.c_gcd_longlong(m,N)
g = arith_llong.c_gcd_longlong(m, N)
if g == 1:
break
m = m / g
m = m // g
d += N * m
g = arith_llong.c_xgcd_longlong(c, d, &z1, &z2)

Expand Down
Loading
Loading