pock: Set the sieve vector size correctly.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 7 Feb 2019 11:28:33 +0000 (11:28 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 7 Feb 2019 11:43:18 +0000 (11:43 +0000)
Having calculated `sievesz' so carefully, it seems a shame not to use it
-- especially when that results in the sieve vector being thirty times
larger than it should be.

More seriously, this causes the `smallprimes' iterator to continue way
past its proper end-point.  Fortunately, all of the uses in this program
are safe.

pock

diff --git a/pock b/pock
index 3d9f66b..cb49996 100644 (file)
--- a/pock
+++ b/pock
@@ -239,7 +239,7 @@ class Sieve (object):
     n = (limit - 2)/2
     sievesz = (n + me._NBIT - 1)/me._NBIT
     me._sievemax = sievesz*me._NBIT
-    me._bits = n*[0]
+    me._bits = sievesz*[0]
 
     ## This is standard Sieve of Eratosthenes.  For each index i: if
     ## bit i is clear, then p = 2 i + 3 is prime, so set the bits