Skip to content

Commit 7168b4a

Browse files
committed
using python-style for-loops in modular folder
1 parent 0fd5967 commit 7168b4a

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

src/sage/modular/arithgroup/congroup.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t):
132132
dd = dd / g
133133
# Test if we've found a new coset representative.
134134
is_new = 1
135-
for i from 0 <= i < k:
135+
for i in range(k):
136136
j = 4*i
137137
if (R[j+1]*aa - R[j]*bb) % t == 0 and \
138138
(R[j+3]*cc - R[j+2]*dd) % Ndivt == 0:
@@ -237,7 +237,7 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t):
237237
continue
238238
# Test if we've found a new coset representative.
239239
is_new = 1
240-
for i from 0 <= i < k:
240+
for i in range(k):
241241
j = 4*i
242242
if (R[j] - aa) % t == 0 and \
243243
(R[j+1] - bb) % t == 0 and \
@@ -258,7 +258,7 @@ def degeneracy_coset_representatives_gamma1(int N, int M, int t):
258258

259259
# Return the list left multiplied by T.
260260
S = []
261-
for i from 0 <= i < k:
261+
for i in range(k):
262262
j = 4*i
263263
S.append([R[j], R[j+1], R[j+2]*t, R[j+3]*t])
264264
sig_free(R)

src/sage/modular/modform/eis_series_cython.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ cpdef Ek_ZZ(int k, int prec=10):
9393
while True:
9494
continue_flag = 0
9595
# do the first p-1
96-
for i from 0 < i < p:
96+
for i in range(1, p):
9797
ind += p
9898
if (ind >= prec):
9999
continue_flag = 1
@@ -215,7 +215,7 @@ cpdef eisenstein_series_poly(int k, int prec = 10) :
215215
mpz_clear(last_m1)
216216

217217
fmpz_poly_set_coeff_mpz(res.poly, prec-1, val[prec-1])
218-
for i from 1 <= i < prec - 1 :
218+
for i in range(1, prec - 1):
219219
fmpz_poly_set_coeff_mpz(res.poly, i, val[i])
220220

221221
fmpz_poly_scalar_mul_mpz(res.poly, res.poly, (<Integer>(a0.denominator())).value)

src/sage/modular/modform/l_series_gross_zagier_coeffs.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def bqf_theta_series(Q, long bound, var=None):
6868
cdef long a, b, c
6969
a, b, c = Q
7070
cdef long* terms = bqf_theta_series_c(NULL, bound, a, b, c)
71-
L = [terms[i] for i from 0 <= i <= bound]
71+
L = [terms[i] for i in range(bound + 1)]
7272
sig_free(terms)
7373
return to_series(L, var)
7474

@@ -85,13 +85,13 @@ cdef long* bqf_theta_series_c(long* terms, long bound, long a, long b, long c) e
8585
terms = <long*>check_calloc(1 + bound, sizeof(long))
8686

8787
sig_on()
88-
for x from -xmax <= x <= xmax:
88+
for x in range(-xmax, xmax + 1):
8989
yD = b * b * x * x - 4 * c * (a * x * x - bound)
9090
if yD > 0:
9191
sqrt_yD = sqrt(yD)
9292
ymin = <long>ceil((-b * x - sqrt_yD) / (2 * c))
9393
ymax = <long>floor((-b * x + sqrt_yD) / (2 * c))
94-
for y from ymin <= y <= ymax:
94+
for y in range(ymin, ymax + 1):
9595
terms[a * x * x + b * x * y + c * y * y] += 1
9696
sig_off()
9797
return terms
@@ -161,7 +161,7 @@ def gross_zagier_L_series(an_list, Q, long N, long u, var=None):
161161
i += 1
162162
sig_on()
163163
memcpy(terms, con_terms, sizeof(long) * bound) # m = 1
164-
for m from 2 <= m <= <long>sqrt(bound):
164+
for m in range(2, <long>sqrt(bound) + 1):
165165
if arith.c_gcd_longlong(D * N, m) == 1:
166166
me = m * kronecker_symbol(D, m)
167167
j = 0

src/sage/modular/modsym/apply.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def apply_to_monomial(int i, int j, int a, int b, int c, int d):
103103

104104
cdef Integer res
105105
v = []
106-
for k from 0 <= k <= j:
106+
for k in range(j + 1):
107107
res = <Integer>PY_NEW(Integer)
108108
fmpz_poly_get_coeff_mpz(res.value, pr, k)
109109
v.append(int(res))

src/sage/modular/modsym/p1list.pyx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ cdef int c_p1_normalize_int(int N, int u, int v,
108108
Ng = N/g
109109
vNg = (v*Ng) % N
110110
t = 1
111-
for k from 2 <= k <= g:
111+
for k in range(2, g + 1):
112112
v = (v + vNg) % N
113113
t = (t + Ng) % N
114114
if v<min_v and arith_int.c_gcd_int(t,N)==1:
@@ -220,8 +220,8 @@ def p1list_int(int N):
220220

221221
lst = [(0,1)]
222222
c = 1
223-
for d from 0 <= d < N:
224-
lst.append((c,d))
223+
for d in range(N):
224+
lst.append((c, d))
225225

226226
cmax = N // 2
227227
if N % 2: # N odd, max divisor is <= N/3
@@ -230,11 +230,11 @@ def p1list_int(int N):
230230
else:
231231
cmax = N // 3
232232

233-
for c from 2 <= c <= cmax:
233+
for c in range(2, cmax + 1):
234234
if N % c == 0: # c is a proper divisor
235235
h = N // c
236236
g = arith_int.c_gcd_int(c, h)
237-
for d from 1 <= d <= h:
237+
for d in range(1, h + 1):
238238
sig_check()
239239
if arith_int.c_gcd_int(d, g) == 1:
240240
d1 = d
@@ -373,10 +373,10 @@ cdef int c_p1_normalize_llong(int N, int u, int v,
373373
Ng = N/g
374374
vNg = <int> ((<llong>v * <llong> Ng) % ll_N)
375375
t = 1
376-
for k from 2 <= k <= g:
376+
for k in range(2, g + 1):
377377
v = (v + vNg) % N
378378
t = (t + Ng) % N
379-
if v<min_v and arith_int.c_gcd_int(t,N)==1:
379+
if v < min_v and arith_int.c_gcd_int(t, N) == 1:
380380
min_v = v
381381
min_t = t
382382
v = min_v
@@ -472,8 +472,8 @@ def p1list_llong(int N):
472472

473473
lst = [(0,1)]
474474
c = 1
475-
for d from 0 <= d < N:
476-
lst.append((c,d))
475+
for d in range(N):
476+
lst.append((c, d))
477477

478478
cmax = N // 2
479479
if N % 2: # N odd, max divisor is <= N/3
@@ -482,18 +482,18 @@ def p1list_llong(int N):
482482
else:
483483
cmax = N // 3
484484

485-
for c from 2 <= c <= cmax:
485+
for c in range(2, cmax + 1):
486486
if N % c == 0: # c is a proper divisor
487487
h = N // c
488488
g = arith_int.c_gcd_int(c, h)
489-
for d from 1 <= d <= h:
489+
for d in range(1, h + 1):
490490
if arith_int.c_gcd_int(d, g) == 1:
491491
sig_check()
492492
d1 = d
493493
while arith_int.c_gcd_int(d1, c) != 1:
494494
d1 += h
495495
c_p1_normalize_llong(N, c, d1, &u, &v, &s, 0)
496-
lst.append((u,v))
496+
lst.append((u, v))
497497
lst.sort()
498498
return lst
499499

@@ -663,7 +663,7 @@ cdef int p1_normalize_xgcdtable(int N, int u, int v,
663663
Ng = N/g
664664
vNg = (v*Ng) % N
665665
t = 1
666-
for k from 2 <= k <= g:
666+
for k in range(2, g + 1):
667667
v = (v + vNg) % N
668668
t = (t + Ng) % N
669669
if v < min_v and t_g[t] == 1: # arith_int.c_gcd_int(t,N)==1:
@@ -744,10 +744,10 @@ cdef class P1List():
744744
cdef llong ll_s, ll_t, ll_N = N
745745

746746
if N <= 46340:
747-
for i from 0 <= i < N:
747+
for i in range(N):
748748
self.g[i] = arith_int.c_xgcd_int(i, N, &self.s[i], &self.t[i])
749749
else:
750-
for i from 0 <= i < N:
750+
for i in range(N):
751751
self.g[i] = arith_llong.c_xgcd_longlong(i, N, &ll_s, &ll_t)
752752
self.s[i] = <int>(ll_s % ll_N)
753753
self.t[i] = <int>(ll_t % ll_N)

0 commit comments

Comments
 (0)