35
35
from sage .geometry .polyhedron .constructor import Polyhedron
36
36
37
37
38
- def ZZ_points_of_bounded_height (dim , bound ):
38
+ def ZZ_points_of_bounded_height (PS , dim , bound ):
39
39
r"""
40
40
Return an iterator of the points in ``self`` of absolute multiplicative
41
41
height of at most ``bound`` in the rational field.
42
42
43
43
INPUT:
44
44
45
+ - ``PS`` -- a projective space
46
+
45
47
- ``dim`` -- a positive integer
46
48
47
49
- ``bound`` -- a positive integer
@@ -53,14 +55,16 @@ def ZZ_points_of_bounded_height(dim, bound):
53
55
EXAMPLES:
54
56
55
57
sage: from sage.schemes.projective.proj_bdd_height import ZZ_points_of_bounded_height
56
- sage: sorted(list(ZZ_points_of_bounded_height(1, 1)))
58
+ sage: PS = ProjectiveSpace(ZZ, 1)
59
+ sage: sorted(list(ZZ_points_of_bounded_height(PS, 1, 1)))
57
60
[(-1 : -1), (-1 : 0), (-1 : 1), (0 : -1)]
58
- sage: len(list(ZZ_points_of_bounded_height(1, 5)))
61
+ sage: len(list(ZZ_points_of_bounded_height(PS, 1, 5)))
59
62
40
60
- sage: sorted(list(ZZ_points_of_bounded_height(1, 2)))
63
+ sage: sorted(list(ZZ_points_of_bounded_height(PS, 1, 2)))
61
64
[(-2 : -1), (-2 : 1), (-1 : -2), (-1 : -1),
62
65
(-1 : 0), (-1 : 1), (-1 : 2), (0 : -1)]
63
- sage: sorted(list(ZZ_points_of_bounded_height(2, 1)))
66
+ sage: PS = ProjectiveSpace(ZZ, 2)
67
+ sage: sorted(list(ZZ_points_of_bounded_height(PS, 2, 1)))
64
68
[(-1 : -1 : -1), (-1 : -1 : 0), (-1 : -1 : 1), (-1 : 0 : -1),
65
69
(-1 : 0 : 0), (-1 : 0 : 1), (-1 : 1 : -1), (-1 : 1 : 0),
66
70
(-1 : 1 : 1), (0 : -1 : -1), (0 : -1 : 0), (0 : -1 : 1),
@@ -69,32 +73,32 @@ def ZZ_points_of_bounded_height(dim, bound):
69
73
There are no points of negative height::
70
74
71
75
sage: from sage.schemes.projective.proj_bdd_height import ZZ_points_of_bounded_height
72
- sage: list(ZZ_points_of_bounded_height(1, -3))
76
+ sage: PS = ProjectiveSpace(ZZ, 1)
77
+ sage: list(ZZ_points_of_bounded_height(PS, 1, -3))
73
78
[]
74
79
"""
75
80
if bound < 1 :
76
81
return iter (set ([]))
77
82
78
- PN = ProjectiveSpace (ZZ , dim )
79
83
points_of_bounded_height = set ([])
80
84
81
- all_tuples = itertools .product (range (- bound , bound + 1 ), repeat = dim + 1 )
82
-
83
- for t in all_tuples :
85
+ for t in itertools .product (range (- bound , bound + 1 ), repeat = dim + 1 ):
84
86
if gcd (t ) == 1 :
85
- point = PN (t )
87
+ point = PS (t )
86
88
if point not in points_of_bounded_height :
87
89
points_of_bounded_height .add (point )
88
90
yield point
89
91
90
92
91
- def QQ_points_of_bounded_height (dim , bound , normalize = False ):
93
+ def QQ_points_of_bounded_height (PS , dim , bound , normalize = False ):
92
94
r"""
93
95
Return an iterator of the points in ``self`` of absolute multiplicative
94
96
height of at most ``bound`` in the rational field.
95
97
96
98
INPUT:
97
99
100
+ - ``PS`` -- a projective space
101
+
98
102
- ``dim`` -- a positive integer
99
103
100
104
- ``bound`` -- a real number
@@ -109,35 +113,36 @@ def QQ_points_of_bounded_height(dim, bound, normalize=False):
109
113
EXAMPLES:
110
114
111
115
sage: from sage.schemes.projective.proj_bdd_height import QQ_points_of_bounded_height
112
- sage: sorted(list(QQ_points_of_bounded_height(1, 1)))
116
+ sage: PS = ProjectiveSpace(QQ, 1)
117
+ sage: sorted(list(QQ_points_of_bounded_height(PS, 1, 1)))
113
118
[(-1 : 1), (0 : 1), (1 : 0), (1 : 1)]
114
- sage: len(list(QQ_points_of_bounded_height(1, 5)))
119
+ sage: len(list(QQ_points_of_bounded_height(PS, 1, 5)))
115
120
40
116
- sage: sorted(list(QQ_points_of_bounded_height(1, 2)))
121
+ sage: sorted(list(QQ_points_of_bounded_height(PS, 1, 2)))
117
122
[(-2 : 1), (-1 : 1), (-1/2 : 1), (0 : 1),
118
123
(1/2 : 1), (1 : 0), (1 : 1), (2 : 1)]
119
- sage: sorted(list(QQ_points_of_bounded_height(1, 2, normalize=True)))
124
+ sage: sorted(list(QQ_points_of_bounded_height(PS, 1, 2, normalize=True)))
120
125
[(-2 : 1), (-1 : 1), (-1 : 2), (0 : 1),
121
126
(1 : 0), (1 : 1), (1 : 2), (2 : 1)]
122
127
123
128
There are no points of negative height::
124
129
125
130
sage: from sage.schemes.projective.proj_bdd_height import QQ_points_of_bounded_height
126
- sage: list(QQ_points_of_bounded_height(1, -3))
131
+ sage: PS = ProjectiveSpace(QQ, 1)
132
+ sage: list(QQ_points_of_bounded_height(PS, 1, -3))
127
133
[]
128
134
"""
129
135
if bound < 1 :
130
136
return iter (set ([]))
131
137
132
- PN = ProjectiveSpace (QQ , dim )
133
138
unit_tuples = list (itertools .product ([- 1 , 1 ], repeat = dim ))
134
139
points_of_bounded_height = set ([])
135
140
increasing_tuples = itertools .combinations_with_replacement (range (floor (bound + 1 )), dim + 1 )
136
141
for t in increasing_tuples :
137
142
if gcd (t ) == 1 :
138
143
for p in itertools .permutations (t ):
139
144
for u in unit_tuples :
140
- point = PN ([a * b for a , b in zip (u , p )] + [p [dim ]])
145
+ point = PS ([a * b for a , b in zip (u , p )] + [p [dim ]])
141
146
if point not in points_of_bounded_height :
142
147
if normalize :
143
148
point .scale_by (lcm ([point [i ].denominator () for i in range (dim + 1 )]))
@@ -146,24 +151,21 @@ def QQ_points_of_bounded_height(dim, bound, normalize=False):
146
151
yield point
147
152
148
153
149
- def IQ_points_of_bounded_height (PN , K , dim , bound , normalize = False ):
154
+ def IQ_points_of_bounded_height (PS , K , dim , bound ):
150
155
r"""
151
156
Return an iterator of the points in ``self`` of absolute multiplicative
152
157
height of at most ``bound`` in the imaginary quadratic field ``K``.
153
158
154
159
INPUT:
155
160
156
- - ``PN `` -- a projective space
161
+ - ``PS `` -- a projective space
157
162
158
163
- ``K`` -- a number field
159
164
160
165
- ``dim`` -- a positive interger
161
166
162
167
- ``bound`` -- a real number
163
168
164
- - ``normalize`` -- boolean (optional, default: ``False``); whether to
165
- normalize the coordinates of returned points
166
-
167
169
OUTPUT:
168
170
169
171
- an iterator of points of bounded height
@@ -217,18 +219,14 @@ def IQ_points_of_bounded_height(PN, K, dim, bound, normalize=False):
217
219
if a == K .ideal (point_coordinates ):
218
220
for p in itertools .permutations (point_coordinates ):
219
221
for u in unit_tuples :
220
- point = PN ([i * j for i , j in zip (u , p )] + [p [dim ]])
222
+ point = PS ([i * j for i , j in zip (u , p )] + [p [dim ]])
221
223
222
224
if point not in points_in_class_a :
223
- if normalize :
224
- denom = K .ideal (list (point )).absolute_norm ().denominator ()
225
- point .scale_by (denom )
226
-
227
225
points_in_class_a .add (point )
228
226
yield point
229
227
230
228
231
- def points_of_bounded_height (PN , K , dim , bound , prec = 53 , normalize = False ):
229
+ def points_of_bounded_height (PS , K , dim , bound , prec = 53 ):
232
230
r"""
233
231
Return an iterator of the points in ``K`` with dimension ``dim`` of
234
232
absolute multiplicative height of at most ``bound``.
@@ -239,7 +237,7 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
239
237
240
238
INPUT:
241
239
242
- - ``PN `` -- a projective space
240
+ - ``PS `` -- a projective space
243
241
244
242
- ``K`` -- a number field
245
243
@@ -249,9 +247,6 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
249
247
250
248
- ``prec`` -- (default: 53) a positive integer
251
249
252
- - ``normalize`` -- boolean (optional, default: ``False``); whether to
253
- normalize the coordinates of returned points
254
-
255
250
OUTPUT:
256
251
257
252
- an iterator of points of bounded height
@@ -275,16 +270,14 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
275
270
sage: P.<z,w> = ProjectiveSpace(O, 1)
276
271
sage: len(list(P.points_of_bounded_height(bound=2)))
277
272
44
278
- sage: len(list(P.points_of_bounded_height(bound=2, normalize=True)))
279
- 44
280
273
281
274
::
282
275
283
276
sage: R.<x> = QQ[]
284
277
sage: K.<a> = NumberField(3*x^2 + 1)
285
278
sage: O = K.maximal_order()
286
279
sage: P.<z,w> = ProjectiveSpace(O, 1)
287
- sage: sorted(list(P.points_of_bounded_height(bound=1, normalize=True )))
280
+ sage: sorted(list(P.points_of_bounded_height(bound=1)))
288
281
[(-1 : 1), (-3/2*a - 1/2 : 1), (3/2*a - 1/2 : 1), (0 : 1),
289
282
(-3/2*a + 1/2 : 0), (-3/2*a + 1/2 : 1), (3/2*a + 1/2 : 1), (1 : 1)]
290
283
@@ -309,8 +302,6 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
309
302
else :
310
303
K_degree = K .degree ()
311
304
312
- O = K .maximal_order ()
313
-
314
305
roots_of_unity = K .roots_of_unity ()
315
306
unit_tuples = list (itertools .product (roots_of_unity , repeat = dim ))
316
307
@@ -457,12 +448,8 @@ def points_of_bounded_height(PN, K, dim, bound, prec=53, normalize=False):
457
448
if log_arch_height <= log_arch_height_bound and a == K .ideal (point_coordinates ):
458
449
for p in itertools .permutations (point_coordinates ):
459
450
for u in unit_tuples :
460
- point = PN ([i * j for i , j in zip (u , p )] + [p [dim ]])
451
+ point = PS ([i * j for i , j in zip (u , p )] + [p [dim ]])
461
452
462
453
if point not in points_in_class_a :
463
- if normalize :
464
- denom = K .ideal (list (point )).absolute_norm ().denominator ()
465
- point .scale_by (denom )
466
-
467
454
points_in_class_a .add (point )
468
455
yield point
0 commit comments