chiark / gitweb /
rho.cc: Fix the cycle-finding table initialization.
[rhodes] / rho.cc
diff --git a/rho.cc b/rho.cc
index d41a8870573a1947ed245227705332561f9b2a57..7033258ec3ceeca822e8a8e2d7490924bf9a189e 100644 (file)
--- a/rho.cc
+++ b/rho.cc
@@ -198,20 +198,6 @@ int main(int argc, char *argv[])
     tab[i].m = power(a, rep(tab[i].du))*power(b, rep(tab[i].dv));
   }
 
-  // Now we start the random walk...
-  seed();
-  niter = 8ull << (dpbits ? dpbits : (NumBits(l) + 1)/2);
-again:
-  NTL::ZZ_p u{NTL::random_ZZ_p()}, v{NTL::random_ZZ_p()};
-  NTL::GF2E t = power(a, rep(u))*power(b, rep(v));
-
-  hist h[NHIST];
-  unsigned o = 0;
-  unsigned long long k = 0;
-
-  if (!dpbits)
-    for (i = 0; i < NHIST; i++) h[i].k = 0;
-
   stdin_fdflags = fcntl(0, F_GETFL);
   if (stdin_fdflags < 0) barf("fcntl stdin", errno);
   sa.sa_handler = cleanup;
@@ -230,6 +216,21 @@ again:
   if (fcntl(0, F_SETFL, stdin_fdflags | O_NONBLOCK))
     barf("fcntl stdin", errno);
 
+  // Now we start the random walk...
+  seed();
+  niter = 8ull << (dpbits ? dpbits : (NumBits(l) + 1)/2);
+again:
+  NTL::ZZ_p u{NTL::random_ZZ_p()}, v{NTL::random_ZZ_p()};
+  NTL::GF2E t = power(a, rep(u))*power(b, rep(v));
+
+  hist h[NHIST];
+  unsigned o = 0;
+  unsigned long long k = 0;
+
+  if (!dpbits)
+    for (i = 0; i < NHIST; i++)
+      { h[i].k = 0; h[i].y = a; h[i].u = 1; h[i].v = 0; }
+
   for (;;) {
     if (k >= niter) goto again;
     if (!(k%CHECK_NITER)) {