Skip to content

Commit e254eb0

Browse files
committed
sort torsion points to avoid differences in low precision, and adjust test output
1 parent 080c78a commit e254eb0

File tree

5 files changed

+137
-113
lines changed

5 files changed

+137
-113
lines changed

libsrc/points.cc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,27 @@ vector<Point> points_from_x(Curvedata &E, const bigrational& x)
300300
return ans;
301301
}
302302

303+
// comparison function for sorting torsion points (on the same curve)
304+
// We sort by (1) order of point, (2) denominator, (3) X-coordinate,
305+
// (4) y-coordinate
306+
307+
struct Point_cmp : public binary_function<Point, Point, bool> {
308+
bool operator()(Point& P, Point& Q)
309+
{
310+
int s = order(P)-order(Q);
311+
if(s) return (s<0); // true if P has smaller order
312+
bigint t = P.getZ()-Q.getZ();
313+
if(!is_zero(t)) return (t<0); // true if P has smaller Z (denominator)
314+
t = P.getX()-Q.getX();
315+
if(!is_zero(t)) return (t<0); // true if P has smaller X
316+
t = P.getY()-Q.getY();
317+
return (t<0); // true if P has smaller Y
318+
}
319+
};
320+
321+
// Now to sort a list Plist of points in place, do
322+
// ::sort(Plist.begin(), Plist.end(), Point_cmp());
323+
303324
long Curvedata::get_ntorsion()
304325
{
305326
if(ntorsion==0)
@@ -379,6 +400,7 @@ vector<Point> two_torsion(Curvedata& E)
379400
else
380401
two_tors.push_back(Point(E,ei,BIGINT(0),BIGINT(1)));
381402
}
403+
::sort(two_tors.begin(), two_tors.end(), Point_cmp());
382404
#ifdef DEBUG_TORSION
383405
cout<<"\ntwo_torsion() returning "<<two_tors<<"\n";
384406
#endif
@@ -441,6 +463,7 @@ vector<Point> three_torsion(Curvedata& E)
441463
}
442464
}
443465
}
466+
::sort(three_tors.begin(), three_tors.end(), Point_cmp());
444467
#ifdef DEBUG_TORSION
445468
cout<<"\nthree_torsion() returning "<<three_tors<<"\n";
446469
#endif
@@ -573,7 +596,8 @@ vector<Point> torsion_points(Curvedata& E) // After Darrin Doud, adapted by JC
573596
#endif
574597
}
575598
}
576-
return points;
599+
::sort(points.begin(), points.end(), Point_cmp());
600+
return points;
577601
}
578602

579603
//#define DEBUG_DIVISION_POINTS 1

tests/out_no_ntl/allisog.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Verbose? (0/1) [ [0,-1,1,-10,-20] [0,-1,1,-7820,-263580] [0,-1,1,0,0] ]
44
[ [1,0,1,4,-6] [1,0,1,-36,-70] [1,0,1,-1,0] [1,0,1,-171,-874] [1,0,1,-11,12] [1,0,1,-2731,-55146] ]
55
[0,2,3,3,0,0;2,0,0,0,3,3;3,0,0,0,2,0;3,0,0,0,0,2;0,3,2,0,0,0;0,3,0,2,0,0]
66

7-
[ [1,1,1,-10,-10] [1,1,1,-5,2] [1,1,1,35,-28] [1,1,1,-135,-660] [1,1,1,-80,242] [1,1,1,0,0] [1,1,1,-110,-880] [1,1,1,-2160,-39540] ]
8-
[0,2,2,2,0,0,0,0;2,0,0,0,2,2,0,0;2,0,0,0,0,0,0,0;2,0,0,0,0,0,2,2;0,2,0,0,0,0,0,0;0,2,0,0,0,0,0,0;0,0,0,2,0,0,0,0;0,0,0,2,0,0,0,0]
7+
[ [1,1,1,-10,-10] [1,1,1,35,-28] [1,1,1,-135,-660] [1,1,1,-5,2] [1,1,1,-110,-880] [1,1,1,-2160,-39540] [1,1,1,-80,242] [1,1,1,0,0] ]
8+
[0,2,2,2,0,0,0,0;2,0,0,0,0,0,0,0;2,0,0,0,2,2,0,0;2,0,0,0,0,0,2,2;0,0,2,0,0,0,0,0;0,0,2,0,0,0,0,0;0,0,0,2,0,0,0,0;0,0,0,2,0,0,0,0]
99

10-
[ [1,-1,1,-1,-14] [1,-1,1,-6,-4] [1,-1,1,-1,0] [1,-1,1,-91,-310] ]
10+
[ [1,-1,1,-1,-14] [1,-1,1,-6,-4] [1,-1,1,-91,-310] [1,-1,1,-1,0] ]
1111
[0,2,0,0;2,0,2,2;0,2,0,0;0,2,0,0]
1212

1313
[ [0,1,1,-9,-15] [0,1,1,1,0] [0,1,1,-769,-8470] ]
@@ -16,8 +16,8 @@ Verbose? (0/1) [ [0,-1,1,-10,-20] [0,-1,1,-7820,-263580] [0,-1,1,0,0] ]
1616
[ [0,1,0,4,4] [0,1,0,-1,0] [0,1,0,-36,-140] [0,1,0,-41,-116] ]
1717
[0,2,3,0;2,0,0,3;3,0,0,2;0,3,2,0]
1818

19-
[ [1,0,0,-4,-1] [1,0,0,-39,90] [1,0,0,1,0] [1,0,0,-49,-136] [1,0,0,-34,-217] [1,0,0,-784,-8515] ]
20-
[0,2,2,2,0,0;2,0,0,0,0,0;2,0,0,0,0,0;2,0,0,0,2,2;0,0,0,2,0,0;0,0,0,2,0,0]
19+
[ [1,0,0,-4,-1] [1,0,0,-39,90] [1,0,0,-49,-136] [1,0,0,1,0] [1,0,0,-34,-217] [1,0,0,-784,-8515] ]
20+
[0,2,2,2,0,0;2,0,0,0,0,0;2,0,0,0,2,2;2,0,0,0,0,0;0,0,2,0,0,0;0,0,2,0,0,0]
2121

2222
[ [0,-1,0,-4,4] [0,-1,0,-64,220] [0,-1,0,1,0] [0,-1,0,-24,-36] [0,-1,0,16,-180] [0,-1,0,-384,-2772] ]
2323
[0,2,2,2,0,0;2,0,0,0,0,0;2,0,0,0,0,0;2,0,0,0,2,2;0,0,0,2,0,0;0,0,0,2,0,0]

tests/out_no_ntl/torsion.out

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Curve [0,0,0,1,0] has 2 torsion point(s)
1010
Cyclic: C2
1111
Curve [0,0,0,0,100] has 3 torsion point(s)
1212
[0:1:0] (order 1)
13-
[0:10:1] (order 3)
1413
[0:-10:1] (order 3)
14+
[0:10:1] (order 3)
1515
Cyclic: C3
1616
Curve [0,0,0,1,2] has 4 torsion point(s)
1717
[0:1:0] (order 1)
18-
[1:-2:1] (order 4)
1918
[-1:0:1] (order 2)
19+
[1:-2:1] (order 4)
2020
[1:2:1] (order 4)
2121
Cyclic: C4
2222
Curve [0,0,0,-1,0] has 4 torsion point(s)
@@ -27,120 +27,120 @@ Curve [0,0,0,-1,0] has 4 torsion point(s)
2727
Non-cyclic: C2 x C2
2828
Curve [0,-1,1,0,0] has 5 torsion point(s)
2929
[0:1:0] (order 1)
30-
[1:-1:1] (order 5)
3130
[0:-1:1] (order 5)
3231
[0:0:1] (order 5)
32+
[1:-1:1] (order 5)
3333
[1:0:1] (order 5)
3434
Cyclic: C5
3535
Curve [0,0,0,0,1] has 6 torsion point(s)
3636
[0:1:0] (order 1)
37-
[2:-3:1] (order 6)
38-
[0:-1:1] (order 3)
3937
[-1:0:1] (order 2)
38+
[0:-1:1] (order 3)
4039
[0:1:1] (order 3)
40+
[2:-3:1] (order 6)
4141
[2:3:1] (order 6)
4242
Cyclic: C6
4343
Curve [1,-1,1,-3,3] has 7 torsion point(s)
4444
[0:1:0] (order 1)
45-
[3:-6:1] (order 7)
46-
[1:-2:1] (order 7)
4745
[-1:-2:1] (order 7)
4846
[-1:2:1] (order 7)
47+
[1:-2:1] (order 7)
4948
[1:0:1] (order 7)
49+
[3:-6:1] (order 7)
5050
[3:2:1] (order 7)
5151
Cyclic: C7
5252
Curve [0,1,0,-14624,669300] has 8 torsion point(s)
5353
[0:1:0] (order 1)
54-
[418:-8232:1] (order 8)
54+
[75:0:1] (order 2)
5555
[124:-882:1] (order 4)
56+
[124:882:1] (order 4)
5657
[82:-168:1] (order 8)
57-
[75:0:1] (order 2)
5858
[82:168:1] (order 8)
59-
[124:882:1] (order 4)
59+
[418:-8232:1] (order 8)
6060
[418:8232:1] (order 8)
6161
Cyclic: C8
6262
Curve [0,1,0,-160,308] has 8 torsion point(s)
6363
[0:1:0] (order 1)
64-
[26:-120:1] (order 4)
65-
[11:0:1] (order 2)
66-
[26:120:1] (order 4)
6764
[-14:0:1] (order 2)
68-
[-4:30:1] (order 4)
6965
[2:0:1] (order 2)
66+
[11:0:1] (order 2)
7067
[-4:-30:1] (order 4)
68+
[-4:30:1] (order 4)
69+
[26:-120:1] (order 4)
70+
[26:120:1] (order 4)
7171
Non-cyclic: C2 x C4
7272
Curve [1,-1,1,-14,29] has 9 torsion point(s)
7373
[0:1:0] (order 1)
74-
[9:-29:1] (order 9)
75-
[3:-5:1] (order 9)
7674
[1:-5:1] (order 3)
75+
[1:3:1] (order 3)
7776
[-3:-5:1] (order 9)
7877
[-3:7:1] (order 9)
79-
[1:3:1] (order 3)
78+
[3:-5:1] (order 9)
8079
[3:1:1] (order 9)
80+
[9:-29:1] (order 9)
8181
[9:19:1] (order 9)
8282
Cyclic: C9
8383
Curve [1,0,0,115,561] has 10 torsion point(s)
8484
[0:1:0] (order 1)
85-
[70:-629:1] (order 10)
86-
[16:-89:1] (order 5)
87-
[4:-35:1] (order 10)
88-
[-2:-17:1] (order 5)
8985
[-34:17:8] (order 2)
86+
[-2:-17:1] (order 5)
9087
[-2:19:1] (order 5)
91-
[4:31:1] (order 10)
88+
[16:-89:1] (order 5)
9289
[16:73:1] (order 5)
90+
[4:-35:1] (order 10)
91+
[4:31:1] (order 10)
92+
[70:-629:1] (order 10)
9393
[70:559:1] (order 10)
9494
Cyclic: C10
9595
Curve [1,0,1,-19,26] has 12 torsion point(s)
9696
[0:1:0] (order 1)
97-
[13:-52:1] (order 6)
98-
[4:-7:1] (order 3)
97+
[-5:2:1] (order 2)
9998
[3:-2:1] (order 2)
99+
[14:-11:8] (order 2)
100+
[4:-7:1] (order 3)
100101
[4:2:1] (order 3)
101-
[13:38:1] (order 6)
102-
[-5:2:1] (order 2)
102+
[-2:-7:1] (order 6)
103103
[-2:8:1] (order 6)
104-
[1:2:1] (order 6)
105-
[14:-11:8] (order 2)
106104
[1:-4:1] (order 6)
107-
[-2:-7:1] (order 6)
105+
[1:2:1] (order 6)
106+
[13:-52:1] (order 6)
107+
[13:38:1] (order 6)
108108
Non-cyclic: C2 x C6
109109
Curve [1,0,0,-1070,7812] has 16 torsion point(s)
110110
[0:1:0] (order 1)
111-
[244:-3902:1] (order 8)
112-
[64:-482:1] (order 4)
113-
[34:-122:1] (order 8)
114-
[28:-14:1] (order 2)
115-
[34:88:1] (order 8)
116-
[64:418:1] (order 4)
117-
[244:3658:1] (order 8)
118111
[-36:18:1] (order 2)
119-
[-26:148:1] (order 8)
120-
[-8:130:1] (order 4)
121-
[4:58:1] (order 8)
112+
[28:-14:1] (order 2)
122113
[62:-31:8] (order 2)
123-
[4:-62:1] (order 8)
124114
[-8:-122:1] (order 4)
115+
[-8:130:1] (order 4)
116+
[64:-482:1] (order 4)
117+
[64:418:1] (order 4)
125118
[-26:-122:1] (order 8)
119+
[-26:148:1] (order 8)
120+
[4:-62:1] (order 8)
121+
[4:58:1] (order 8)
122+
[34:-122:1] (order 8)
123+
[34:88:1] (order 8)
124+
[244:-3902:1] (order 8)
125+
[244:3658:1] (order 8)
126126
Non-cyclic: C2 x C8
127127
Curve [1,0,0,-372368141774940800,87459461608665181808640000] has 16 torsion point(s)
128128
[0:1:0] (order 1)
129-
[654296320:-11132578294400:1] (order 8)
130-
[369088000:-549923580800:1] (order 4)
131-
[353359600:-34032060800:1] (order 8)
129+
[352179456:-176089728:1] (order 2)
132130
[352441600:-176220800:1] (order 2)
133-
[353359600:33678701200:1] (order 8)
134-
[369088000:549554492800:1] (order 4)
135-
[654296320:11131923998080:1] (order 8)
136131
[-5636968450:2818484225:8] (order 2)
137-
[117433600:6734213027200:1] (order 8)
138-
[335795200:532525225600:1] (order 4)
139-
[351262480:33612641920:1] (order 8)
140-
[352179456:-176089728:1] (order 2)
141-
[351262480:-33963904400:1] (order 8)
142132
[335795200:-532861020800:1] (order 4)
133+
[335795200:532525225600:1] (order 4)
134+
[369088000:-549923580800:1] (order 4)
135+
[369088000:549554492800:1] (order 4)
143136
[117433600:-6734330460800:1] (order 8)
137+
[117433600:6734213027200:1] (order 8)
138+
[351262480:-33963904400:1] (order 8)
139+
[351262480:33612641920:1] (order 8)
140+
[353359600:-34032060800:1] (order 8)
141+
[353359600:33678701200:1] (order 8)
142+
[654296320:-11132578294400:1] (order 8)
143+
[654296320:11131923998080:1] (order 8)
144144
Non-cyclic: C2 x C8
145145
Curve [0,0,0,-4/9,0] has 4 torsion point(s)
146146
[0:1:0] (order 1)

tests/out_ntl/allisog.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Verbose? (0/1) [ [0,-1,1,-10,-20] [0,-1,1,-7820,-263580] [0,-1,1,0,0] ]
44
[ [1,0,1,4,-6] [1,0,1,-36,-70] [1,0,1,-1,0] [1,0,1,-171,-874] [1,0,1,-11,12] [1,0,1,-2731,-55146] ]
55
[0,2,3,3,0,0;2,0,0,0,3,3;3,0,0,0,2,0;3,0,0,0,0,2;0,3,2,0,0,0;0,3,0,2,0,0]
66

7-
[ [1,1,1,-10,-10] [1,1,1,-5,2] [1,1,1,35,-28] [1,1,1,-135,-660] [1,1,1,-80,242] [1,1,1,0,0] [1,1,1,-110,-880] [1,1,1,-2160,-39540] ]
8-
[0,2,2,2,0,0,0,0;2,0,0,0,2,2,0,0;2,0,0,0,0,0,0,0;2,0,0,0,0,0,2,2;0,2,0,0,0,0,0,0;0,2,0,0,0,0,0,0;0,0,0,2,0,0,0,0;0,0,0,2,0,0,0,0]
7+
[ [1,1,1,-10,-10] [1,1,1,35,-28] [1,1,1,-135,-660] [1,1,1,-5,2] [1,1,1,-110,-880] [1,1,1,-2160,-39540] [1,1,1,-80,242] [1,1,1,0,0] ]
8+
[0,2,2,2,0,0,0,0;2,0,0,0,0,0,0,0;2,0,0,0,2,2,0,0;2,0,0,0,0,0,2,2;0,0,2,0,0,0,0,0;0,0,2,0,0,0,0,0;0,0,0,2,0,0,0,0;0,0,0,2,0,0,0,0]
99

10-
[ [1,-1,1,-1,-14] [1,-1,1,-6,-4] [1,-1,1,-1,0] [1,-1,1,-91,-310] ]
10+
[ [1,-1,1,-1,-14] [1,-1,1,-6,-4] [1,-1,1,-91,-310] [1,-1,1,-1,0] ]
1111
[0,2,0,0;2,0,2,2;0,2,0,0;0,2,0,0]
1212

1313
[ [0,1,1,-9,-15] [0,1,1,1,0] [0,1,1,-769,-8470] ]
@@ -16,8 +16,8 @@ Verbose? (0/1) [ [0,-1,1,-10,-20] [0,-1,1,-7820,-263580] [0,-1,1,0,0] ]
1616
[ [0,1,0,4,4] [0,1,0,-1,0] [0,1,0,-36,-140] [0,1,0,-41,-116] ]
1717
[0,2,3,0;2,0,0,3;3,0,0,2;0,3,2,0]
1818

19-
[ [1,0,0,-4,-1] [1,0,0,-39,90] [1,0,0,1,0] [1,0,0,-49,-136] [1,0,0,-34,-217] [1,0,0,-784,-8515] ]
20-
[0,2,2,2,0,0;2,0,0,0,0,0;2,0,0,0,0,0;2,0,0,0,2,2;0,0,0,2,0,0;0,0,0,2,0,0]
19+
[ [1,0,0,-4,-1] [1,0,0,-39,90] [1,0,0,-49,-136] [1,0,0,1,0] [1,0,0,-34,-217] [1,0,0,-784,-8515] ]
20+
[0,2,2,2,0,0;2,0,0,0,0,0;2,0,0,0,2,2;2,0,0,0,0,0;0,0,2,0,0,0;0,0,2,0,0,0]
2121

2222
[ [0,-1,0,-4,4] [0,-1,0,-64,220] [0,-1,0,1,0] [0,-1,0,-24,-36] [0,-1,0,16,-180] [0,-1,0,-384,-2772] ]
2323
[0,2,2,2,0,0;2,0,0,0,0,0;2,0,0,0,0,0;2,0,0,0,2,2;0,0,0,2,0,0;0,0,0,2,0,0]

0 commit comments

Comments
 (0)