Commit d45ae478 authored by Peter Bruin's avatar Peter Bruin

avoid infinite loop in random_torsion_point

parent 8abfafa9
......@@ -121,7 +121,7 @@ find_extension(GEN group, unsigned long l, unsigned long p,
/* Naïve algorithm for finding a random l-torsion point. */
static GEN
random_torsion_point(GEN J, unsigned long l) {
random_torsion_point(GEN J, unsigned long l, int *tries) {
GEN n, m;
long v;
GEN P, Q;
......@@ -132,7 +132,7 @@ random_torsion_point(GEN J, unsigned long l) {
if(v == 0)
pari_err(e_MISC, "no point of order %li", l);
m = gdiv(n, powuu(l, v));
while(1) {
while((*tries)-- > 0) {
err_printf("finding random point\n");
P = jacobian_random_point(J);
err_printf("multiplying by %Ps\n", m);
......@@ -186,8 +186,8 @@ find_bases(GEN J, unsigned long l, GEN f, GEN proj, int tries,
*matrices = cgetg(n + 1, t_VEC);
for (i = 1; i <= n; i++)
gel(*bases, i) = cgetg(1, t_VEC);
while (tries-- > 0 && found < 2*n) {
P = random_torsion_point(J, l);
while (tries > 0 && found < 2*n) {
P = random_torsion_point(J, l, &tries);
for(i = 1; i <= n; i++) {
j = lg(gel(*bases, i)) - 1;
if (j == 2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment