@@ -54,14 +54,17 @@ def ZZ_points_of_bounded_height(dim, bound):
54
54
55
55
sage: from sage.schemes.projective.proj_bdd_height import ZZ_points_of_bounded_height
56
56
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)]
58
58
sage: len(list(ZZ_points_of_bounded_height(1, 5)))
59
- 80
59
+ 40
60
60
sage: sorted(list(ZZ_points_of_bounded_height(1, 2)))
61
61
[(-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)]
65
68
66
69
There are no points of negative height::
67
70
@@ -73,11 +76,16 @@ def ZZ_points_of_bounded_height(dim, bound):
73
76
return iter (set ([]))
74
77
75
78
PN = ProjectiveSpace (ZZ , dim )
79
+ points_of_bounded_height = set ([])
80
+
81
+ all_tuples = itertools .product (range (- bound , bound + 1 ), repeat = dim + 1 )
76
82
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
81
89
82
90
83
91
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):
267
275
sage: P.<z,w> = ProjectiveSpace(O, 1)
268
276
sage: len(list(P.points_of_bounded_height(bound=2)))
269
277
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)]
270
288
"""
271
289
if bound < 1 :
272
290
return iter ([])
@@ -431,10 +449,7 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
431
449
432
450
if point not in points_in_class_a :
433
451
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 ()
438
453
point .scale_by (denom )
439
454
440
455
points_in_class_a .add (point )
0 commit comments