Skip to content

Commit 8709112

Browse files
committed
proj_bdd_height.py: Correct impl of ZZ_points_of_bounded_height and one maximal order test
1 parent 1402be4 commit 8709112

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

src/sage/schemes/projective/proj_bdd_height.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,17 @@ def ZZ_points_of_bounded_height(dim, bound):
5454
5555
sage: from sage.schemes.projective.proj_bdd_height import ZZ_points_of_bounded_height
5656
sage: sorted(list(ZZ_points_of_bounded_height(1, 1)))
57-
[(-1 : -1), (-1 : 0), (-1 : 1), (0 : -1), (0 : 1), (1 : -1), (1 : 0), (1 : 1)]
57+
[(-1 : -1), (-1 : 0), (-1 : 1), (0 : -1)]
5858
sage: len(list(ZZ_points_of_bounded_height(1, 5)))
59-
80
59+
40
6060
sage: sorted(list(ZZ_points_of_bounded_height(1, 2)))
6161
[(-2 : -1), (-2 : 1), (-1 : -2), (-1 : -1),
62-
(-1 : 0), (-1 : 1), (-1 : 2), (0 : -1),
63-
(0 : 1), (1 : -2), (1 : -1), (1 : 0),
64-
(1 : 1), (1 : 2), (2 : -1), (2 : 1)]
62+
(-1 : 0), (-1 : 1), (-1 : 2), (0 : -1)]
63+
sage: sorted(list(ZZ_points_of_bounded_height(2, 1)))
64+
[(-1 : -1 : -1), (-1 : -1 : 0), (-1 : -1 : 1), (-1 : 0 : -1),
65+
(-1 : 0 : 0), (-1 : 0 : 1), (-1 : 1 : -1), (-1 : 1 : 0),
66+
(-1 : 1 : 1), (0 : -1 : -1), (0 : -1 : 0), (0 : -1 : 1),
67+
(0 : 0 : -1)]
6568
6669
There are no points of negative height::
6770
@@ -73,11 +76,16 @@ def ZZ_points_of_bounded_height(dim, bound):
7376
return iter(set([]))
7477

7578
PN = ProjectiveSpace(ZZ, dim)
79+
points_of_bounded_height = set([])
80+
81+
all_tuples = itertools.product(range(-bound, bound+1), repeat=dim+1)
7682

77-
for i in range(-bound, bound + 1):
78-
for j in range(-bound, bound + 1):
79-
if gcd(i, j) == 1:
80-
yield PN((i, j))
83+
for t in all_tuples:
84+
if gcd(t) == 1:
85+
point = PN(t)
86+
if point not in points_of_bounded_height:
87+
points_of_bounded_height.add(point)
88+
yield point
8189

8290

8391
def QQ_points_of_bounded_height(dim, bound, normalize=False):
@@ -267,6 +275,16 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
267275
sage: P.<z,w> = ProjectiveSpace(O, 1)
268276
sage: len(list(P.points_of_bounded_height(bound=2)))
269277
44
278+
279+
::
280+
281+
sage: R.<x> = QQ[]
282+
sage: K.<a> = NumberField(3*x^2 + 1)
283+
sage: O = K.maximal_order()
284+
sage: P.<z,w> = ProjectiveSpace(O, 1)
285+
sage: sorted(list(P.points_of_bounded_height(bound=1, normalize=True)))
286+
[(-1 : 1), (-3/2*a - 1/2 : 1), (3/2*a - 1/2 : 1), (0 : 1),
287+
(-3/2*a + 1/2 : 0), (-3/2*a + 1/2 : 1), (3/2*a + 1/2 : 1), (1 : 1)]
270288
"""
271289
if bound < 1:
272290
return iter([])
@@ -431,10 +449,7 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
431449

432450
if point not in points_in_class_a:
433451
if normalize:
434-
if O is ZZ:
435-
denom = lcm([point[i].denominator() for i in range(len(point))])
436-
else:
437-
denom = K.ideal(list(point)).absolute_norm().denominator()
452+
denom = K.ideal(list(point)).absolute_norm().denominator()
438453
point.scale_by(denom)
439454

440455
points_in_class_a.add(point)

0 commit comments

Comments
 (0)