Skip to content
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
14 changes: 5 additions & 9 deletions src/sage/schemes/curves/affine_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,14 +1744,13 @@ def tangent_line(self, p):
Tp = self.tangent_space(p)

if Tp.dimension() > 1:
raise ValueError("the curve is not smooth at {}".format(p))
raise ValueError(f"the curve is not smooth at {p}")

from sage.schemes.curves.constructor import Curve

# translate to p
I0 = []
for poly in Tp.defining_polynomials():
I0.append(poly.subs({x: x - c for x, c in zip(gens, p)}))
I0 = [poly.subs({x: x - c for x, c in zip(gens, p)})
for poly in Tp.defining_polynomials()]

return Curve(I0, A)

Expand Down Expand Up @@ -2744,11 +2743,8 @@ def places_on(self, point):
gs = [phi(g) for g in point.prime_ideal().gens()]
fs = [g for g in gs if not g.is_zero()]
f = fs.pop()
places = []
for p in f.zeros():
if all(f.valuation(p) > 0 for f in fs):
places.append(p)
return places
return [p for p in f.zeros()
if all(f.valuation(p) > 0 for f in fs)]

def parametric_representation(self, place, name=None):
"""
Expand Down
9 changes: 3 additions & 6 deletions src/sage/schemes/curves/projective_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@
sage: set_verbose(-1)
sage: P.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: C = Curve([(x^2 + y^2 - y*z - 2*z^2)*(y*z - x^2 + 2*z^2)*z + y^5], P)
sage: C.ordinary_model() # long time (5 seconds)

Check warning on line 1402 in src/sage/schemes/curves/projective_curve.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Warning: slow doctest:

slow doctest:: Test ran for 124.70s cpu, 126.26s wall Check ran for 0.00s cpu, 0.00s wall
Scheme morphism:
From: Projective Plane Curve over Number Field in a
with defining polynomial y^2 - 2 defined
Expand Down Expand Up @@ -2862,14 +2862,11 @@

phi = self._map_to_function_field
denom = self._coordinate_functions[i]
gs = [phi(f)/denom**f.degree() for f in prime.gens()]
gs = [phi(f) / denom**f.degree() for f in prime.gens()]
fs = [g for g in gs if not g.is_zero()]
f = fs.pop()
places = []
for p in f.zeros():
if all(f.valuation(p) > 0 for f in fs):
places.append(p)
return places
return [p for p in f.zeros()
if all(f.valuation(p) > 0 for f in fs)]

def jacobian(self, model, base_div=None):
"""
Expand Down
10 changes: 6 additions & 4 deletions src/sage/schemes/elliptic_curves/BSD.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,12 @@ def prove_BSD(E, verbosity=0, two_desc='mwrank', proof=None, secs_hi=5,
if p >= 5 and D_K % p and len(K.factor(p)) == 1:
# p is inert in K
BSD.primes.append(p)
for p in heegner_primes:
if p >= 5 and D_E % p and D_K % p and len(K.factor(p)) == 1:
# p is good for E and inert in K
kolyvagin_primes.append(p)

kolyvagin_primes.extend(p for p in heegner_primes
# p is good for E and inert in K
if p >= 5 and D_E % p and D_K % p
and len(K.factor(p)) == 1)

for p in prime_divisors(BSD.sha_an):
if p >= 5 and D_K % p and len(K.factor(p)) == 1:
if BSD.curve.is_good(p):
Expand Down
9 changes: 4 additions & 5 deletions src/sage/schemes/elliptic_curves/ell_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3207,16 +3207,15 @@ def montgomery_model(self, twisted=False, morphism=False):
R = self.base_ring()
P = PolynomialRing(R, 'v')

sols = []
for r in P([b, a, 0, 1]).roots(multiplicities=False):
for s in P([3 * r**2 + a, 0, -1]).roots(multiplicities=False):
sols.append((r,s))
sols = [(r, s)
for r in P([b, a, 0, 1]).roots(multiplicities=False)
for s in P([3 * r**2 + a, 0, -1]).roots(multiplicities=False)]

if not sols:
raise ValueError(f'{self} has no Montgomery model')

# square s allows us to take B=1
r,s = max(sols, key=lambda t: t[1].is_square())
r, s = max(sols, key=lambda t: t[1].is_square())

A = 3 * r / s
B = R.one() if s.is_square() else ~s
Expand Down
3 changes: 1 addition & 2 deletions src/sage/schemes/generic/divisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ def CurvePointToIdeal(C, P):
polys.append(x[i])
else:
polys.append(x[i]-ai)
for i in range(m+1,n):
polys.append(x[i])
polys.extend(x[i] for i in range(m + 1, n))
return R.ideal(polys)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,16 +1054,15 @@ def count_points_exhaustive(self, n=1, naive=False):
[9, 27, 108, 675, 3069, 16302]
"""
g = self.genus()
a = []
for i in range(1, min(n, g) + 1):
a.append(self.cardinality_exhaustive(extension_degree=i))
a = [self.cardinality_exhaustive(extension_degree=i)
for i in range(1, min(n, g) + 1)]

if n <= g:
return a

if naive:
for i in range(g + 1, n + 1):
a.append(self.cardinality_exhaustive(extension_degree=i))
a.extend(self.cardinality_exhaustive(extension_degree=i)
for i in range(g + 1, n + 1))

# let's not be too naive and compute the frobenius polynomial
f = self._frobenius_polynomial_cardinalities(a=a)
Expand Down
10 changes: 1 addition & 9 deletions src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,8 @@ def transpose_list(input) -> list[list]:
sage: transpose_list(L)
[[1, 3, 5], [2, 4, 6]]
"""
h = len(input)
w = len(input[0])

output = []
for i in range(w):
row = []
for j in range(h):
row.append(input[j][i])
output.append(row)
return output
return [[input_j[i] for input_j in input] for i in range(w)]


def helper_matrix(Q):
Expand Down
25 changes: 8 additions & 17 deletions src/sage/schemes/product_projective/rational_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,20 @@ def enum_product_projective_rational_field(X, B):

R = X.codomain().ambient_space()
m = R.num_components()
iters = [ R[i].points_of_bounded_height(bound=B) for i in range(m) ]
iters = [R[i].points_of_bounded_height(bound=B) for i in range(m)]
dim = [R[i].dimension_relative() + 1 for i in range(m)]

dim_prefix = [0, dim[0]] # prefixes dim list
dim_prefix = [0, dim[0]] # prefixes dim list
for i in range(1, len(dim)):
dim_prefix.append(dim_prefix[i] + dim[i])

pts = []
P = []
for i in range(m):
pt = next(iters[i])
for j in range(dim[i]):
P.append(pt[j]) # initial value of P
P.extend(pt[j] for j in range(dim[i])) # initial value of P

try: # add the initial point
try: # add the initial point
pts.append(X(P))
except TypeError:
pass
Expand Down Expand Up @@ -450,18 +449,12 @@ def points_modulo_primes(X, primes):
Return a list of rational points modulo all `p` in primes,
computed parallelly.
"""
normalized_input = []
for p in primes_list:
normalized_input.append(((X, p, ), {}))
normalized_input = [((X, p, ), {}) for p in primes_list]
p_iter = p_iter_fork(ncpus())

points_pair = list(p_iter(parallel_function, normalized_input))
points_pair.sort()
modulo_points = []
for pair in points_pair:
modulo_points.append(pair[1])

return modulo_points
return [pair[1] for pair in points_pair]

def parallel_function_combination(point_p_max):
r"""
Expand Down Expand Up @@ -511,12 +504,10 @@ def lift_all_points():
r"""
Return list of all rational points lifted parallelly.
"""
normalized_input = []
points = modulo_points.pop() # remove the list of points corresponding to largest prime
points = modulo_points.pop() # remove the list of points corresponding to largest prime
len_modulo_points.pop()

for point in points:
normalized_input.append(( (point, ), {}))
normalized_input = [((point, ), {}) for point in points]
p_iter = p_iter_fork(ncpus())
points_satisfying = list(p_iter(parallel_function_combination, normalized_input))

Expand Down
31 changes: 13 additions & 18 deletions src/sage/schemes/projective/proj_bdd_height.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def IQ_points_of_bounded_height(PS, K, dim, bound):
possible_norm_set = set()
for i in range(class_number):
for k in range(1, floor(bound + 1)):
possible_norm_set.add(k*class_group_ideal_norms[i])
possible_norm_set.add(k * class_group_ideal_norms[i])

coordinate_space = {}
coordinate_space[0] = [K(0)]
Expand All @@ -199,11 +199,9 @@ def IQ_points_of_bounded_height(PS, K, dim, bound):
a_norm_bound = bound * a_norm
a_coordinates = []

for m in coordinate_space:
for m, coord_m in coordinate_space.items():
if m <= a_norm_bound:
for x in coordinate_space[m]:
if x in a:
a_coordinates.append(x)
a_coordinates.extend(x for x in coord_m if x in a)

points_in_class_a = set()
t = len(a_coordinates) - 1
Expand All @@ -213,7 +211,7 @@ def IQ_points_of_bounded_height(PS, K, dim, bound):
if a == K.ideal(point_coordinates):
for p in itertools.permutations(point_coordinates):
for u in unit_tuples:
point = PS([i*j for i, j in zip(u, p)] + [p[dim]])
point = PS([i * j for i, j in zip(u, p)] + [p[dim]])

if point not in points_in_class_a:
points_in_class_a.add(point)
Expand Down Expand Up @@ -360,21 +358,18 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53):
vertex = sum([coefficient_tuple[i]*fund_unit_logs[i] for i in range(r)])
fund_parallelotope_vertices.append(vertex)

D_numbers = []
for v in range(r + 1):
D_numbers.append(max([vertex[v] for vertex in fund_parallelotope_vertices]))
D_numbers = [max(vertex[v] for vertex in fund_parallelotope_vertices)
for v in range(r + 1)]

A_numbers = []
for v in range(r + 1):
A_numbers.append(min([pr_ideal_gen_logs[y][v] for y in pr_ideal_gen_logs]))
A_numbers = [min(pr_ideal_gen_logs[y][v] for y in pr_ideal_gen_logs)
for v in range(r + 1)]

aux_constant = (1/K_degree) * Reals(norm_bound).log()
aux_constant = (1 / K_degree) * Reals(norm_bound).log()

L_numbers = []
for v in range(r1):
L_numbers.append(aux_constant + D_numbers[v] - A_numbers[v])
for v in range(r1, r + 1):
L_numbers.append(2*aux_constant + D_numbers[v] - A_numbers[v])
L_numbers = [aux_constant + D_numbers[v] - A_numbers[v]
for v in range(r1)]
L_numbers.extend(2 * aux_constant + D_numbers[v] - A_numbers[v]
for v in range(r1, r + 1))
L_numbers = vector(L_numbers).change_ring(QQ)

T = column_matrix(fund_unit_logs).delete_rows([r]).change_ring(QQ)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/schemes/projective/projective_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,14 @@ def dehomogenize(self, n):
...
ValueError: can...t dehomogenize at 0 coordinate
"""
if self[n].is_zero():
sn = self[n]
if sn.is_zero():
raise ValueError("can't dehomogenize at 0 coordinate")
PS = self.codomain()
A = PS.affine_patch(n)
Q = []
for i in range(PS.ambient_space().dimension_relative() + 1):
if i != n:
Q.append(self[i] / self[n])
Q = [self[i] / sn
for i in range(PS.ambient_space().dimension_relative() + 1)
if i != n]
return A.point(Q)

def global_height(self, prec=None):
Expand Down
15 changes: 5 additions & 10 deletions src/sage/schemes/projective/projective_rational_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,14 @@ def parallel_function(X, p):
all rational points in modulo ring.
"""
Xp = X.change_ring(GF(p))
L = Xp.rational_points()

return [list(_) for _ in L]
return [list(p) for p in Xp.rational_points()]

def points_modulo_primes(X, primes):
r"""
Return a list of rational points modulo all `p` in primes,
computed parallelly.
"""
normalized_input = []
for p in primes_list:
normalized_input.append(((X, p, ), {}))
normalized_input = [((X, p, ), {}) for p in primes_list]
p_iter = p_iter_fork(ncpus())

points_pair = list(p_iter(parallel_function, normalized_input))
Expand Down Expand Up @@ -528,12 +524,11 @@ def lift_all_points():
r"""
Return list of all rational points lifted parallelly.
"""
normalized_input = []
points = modulo_points.pop() # remove the list of points corresponding to largest prime
points = modulo_points.pop() # remove the list of points corresponding to largest prime
len_modulo_points.pop()

for point in points:
normalized_input.append(( (point, ), {}))
normalized_input = [((point, ), {}) for point in points]

p_iter = p_iter_fork(ncpus())
points_satisfying = list(p_iter(parallel_function_combination, normalized_input))

Expand Down
21 changes: 6 additions & 15 deletions src/sage/schemes/projective/projective_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -2034,10 +2034,7 @@ def is_linearly_independent(self, points, n=None):
all_subsets = Subsets(range(len(points)), n)
linearly_independent = True
for subset in all_subsets:
point_list = []
for index in subset:
point_list.append(list(points[index]))
M = matrix(point_list)
M = matrix([list(points[index]) for index in subset])
if M.rank() != n:
linearly_independent = False
break
Expand Down Expand Up @@ -2165,18 +2162,13 @@ def subscheme_from_Chow_form(self, Ch, dim):
if binomial(n + 1, n - dim) != R.ngens():
raise ValueError("for given dimension, there should be %d variables in the Chow form" % binomial(n + 1, n - dim))
# create the brackets associated to variables
L1 = []
for t in UnorderedTuples(list(range(n + 1)), dim + 1):
if all(t[i] < t[i + 1] for i in range(dim)):
L1.append(list(t))
L1 = [list(t) for t in UnorderedTuples(range(n + 1), dim + 1)
if all(t[i] < t[i + 1] for i in range(dim))]
# create the dual brackets
L2 = []
signs = []
for l in L1:
s = []
for v in range(n + 1):
if v not in l:
s.append(v)
s = [v for v in range(n + 1) if v not in l]
t1 = [b + 1 for b in l]
t2 = [b + 1 for b in s]
perm = Permutation(t1 + t2)
Expand All @@ -2190,9 +2182,8 @@ def subscheme_from_Chow_form(self, Ch, dim):
else:
T = PolynomialRing(R.base_ring(), n + 1, 'z')
M = matrix(T, n - dim, n + 1, list(T.gens()))
coords = []
for i in range(len(L2)):
coords.append(signs[i] * M.matrix_from_columns(L2[i]).det())
coords = [si * M.matrix_from_columns(L2i).det()
for si, L2i in zip(signs, L2)]
# substitute in dual brackets to chow form
phi = R.hom(coords, T)
ch = phi(Ch)
Expand Down
Loading