Skip to content

Commit 0889ab4

Browse files
author
Release Manager
committed
sagemathgh-39387: minor changes about faster binomial in modular just using the faster binomial method ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39387 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 4aa862e + bf358ee commit 0889ab4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/sage/modular/dirichlet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
import sage.rings.abc
6363

6464
from sage.arith.functions import lcm
65-
from sage.arith.misc import bernoulli, binomial, factorial, kronecker, factor, gcd, fundamental_discriminant, euler_phi, valuation
65+
from sage.arith.misc import bernoulli, factorial, kronecker, factor, gcd, fundamental_discriminant, euler_phi, valuation
6666
from sage.categories.map import Map
6767
from sage.categories.objects import Objects
6868
from sage.categories.rings import Rings
@@ -724,7 +724,7 @@ def bernoulli(self, k, algorithm='recurrence', cache=True, **opts):
724724
def S(n):
725725
return sum(v[r] * r**n for r in range(1, N))
726726

727-
ber = sum(binomial(k, j) * bernoulli(j, **opts) *
727+
ber = sum(ZZ(k).binomial(j) * bernoulli(j, **opts) *
728728
N**(j - 1) * S(k - j) for j in range(k + 1))
729729
elif algorithm == "definition":
730730
# This is better since it computes the same thing, but requires

src/sage/modular/pollack_stevens/dist.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ REFERENCES:
2727
# ****************************************************************************
2828
import operator
2929

30-
from sage.arith.misc import binomial, bernoulli
30+
from sage.arith.misc import bernoulli
3131
from sage.categories.fields import Fields
3232
from sage.matrix.constructor import matrix
3333
from sage.matrix.matrix cimport Matrix
@@ -1129,7 +1129,7 @@ cdef class Dist_vector(Dist):
11291129
"""
11301130
# assert self._moments[0][0]==0, "not total measure zero"
11311131
# print("result accurate modulo p^",self.moment(0).valuation(self.p) )
1132-
# v=[0 for j in range(0,i)]+[binomial(j,i)*bernoulli(j-i) for j in range(i,M)]
1132+
# v=[0 for j in range(i)]+[binomial(j,i)*bernoulli(j-i) for j in range(i,M)]
11331133
M = self.precision_relative()
11341134
R = self.parent().base_ring()
11351135
K = R.fraction_field()
@@ -1142,7 +1142,7 @@ cdef class Dist_vector(Dist):
11421142
# bernoulli(1) = -1/2; the only nonzero odd Bernoulli number
11431143
v[m] += m * minhalf * scalar
11441144
for j in range(m - 1, M, 2):
1145-
v[j] += binomial(j, m - 1) * bern[(j - m + 1) // 2] * scalar
1145+
v[j] += ZZ(j).binomial(m - 1) * bern[(j - m + 1) // 2] * scalar
11461146
p = self.parent().prime()
11471147
cdef Dist_vector ans
11481148
if p == 0:

src/sage/modular/pollack_stevens/padic_lseries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(self, symb, gamma=None, quadratic_twist=1, precision=None):
121121
self._gamma = gamma
122122
self._quadratic_twist = quadratic_twist
123123
self._precision = precision
124-
self._cinf = ZZ(1) # is set when called for an elliptic curve
124+
self._cinf = ZZ.one() # is set when called for an elliptic curve
125125

126126
def __getitem__(self, n):
127127
r"""
@@ -373,7 +373,7 @@ def _basic_integral(self, a, j):
373373
ap = ap * kronecker(D, p)
374374
K = pAdicField(p, M)
375375
symb_twisted = symb.evaluate_twisted(a, D)
376-
return sum(binomial(j, r) *
376+
return sum(ZZ(j).binomial(r) *
377377
((a - ZZ(K.teichmuller(a))) ** (j - r)) *
378378
(p ** r) *
379379
symb_twisted.moment(r) for r in range(j + 1)) / ap

0 commit comments

Comments
 (0)