From 1ce6553ff8bef59f6ab4e5b1eee710e0c70a1e07 Mon Sep 17 00:00:00 2001 From: Kim Walisch Date: Sat, 9 Nov 2024 10:08:00 +0100 Subject: [PATCH] Update to latest libprimesieve --- .../include/primesieve/PreSieve_Tables.hpp | 6 +++--- lib/primesieve/src/README.md | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/primesieve/include/primesieve/PreSieve_Tables.hpp b/lib/primesieve/include/primesieve/PreSieve_Tables.hpp index de6eaf96a..cfd035df6 100644 --- a/lib/primesieve/include/primesieve/PreSieve_Tables.hpp +++ b/lib/primesieve/include/primesieve/PreSieve_Tables.hpp @@ -1,5 +1,5 @@ /// -/// @file PreSieve_Table.hpp +/// @file PreSieve_Tables.hpp /// @brief Pre-sieve multiples of small primes < 100 to speed up the /// sieve of Eratosthenes. The idea is to allocate several /// arrays (buffers_) and remove the multiples of small primes @@ -104,7 +104,7 @@ int main() if (j + 1 < buffers[i].size()) std::cout << (((j+1) % 20 == 0) ? "," : ", "); } - std::cout << " }," << std::endl; + std::cout << (i + 1 < buffers.size() ? " }," : " }") << std::endl; } std::cout << "}};" << std::endl; @@ -10860,7 +10860,7 @@ const primesieve::Array, 8> buffers = 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xf7, 0xff, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff }, + 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff } }}; } // namespace diff --git a/lib/primesieve/src/README.md b/lib/primesieve/src/README.md index 7bf036b52..72720be33 100644 --- a/lib/primesieve/src/README.md +++ b/lib/primesieve/src/README.md @@ -52,12 +52,14 @@ buckets and only when there are no more buckets in the stock the MemoryPool will allocate new buckets. -* **PreSieve** is used to pre-sieve multiples of small primes < 100 - to speed up the sieve of Eratosthenes. Upon creation the - multiples of small primes are removed from multiple buffers. Then - whilst sieving, we perform a bitwise AND on the buffer arrays - and store the result in the sieve array. Pre-sieving provides a - speedup of up to 30% when sieving the primes < 10^10. +* **PreSieve** is used to pre-sieve multiples of small primes < 100 to speed + up the sieve of Eratosthenes. The ```PreSieve_Tables.hpp``` header contains + 8 static lookup tables which have been sieved using the primes < 100. Each + of these lookup tables has a size of about 32 kilobytes and the total size + of all pre-sieve lookup tables is about 200 kilobytes. Whilst sieving, we + perform a bitwise AND of the pre-sieve lookup tables and store the result in + the sieve array. Pre-sieving provides a speedup of up to 30% when sieving + the primes < 10^10. * **SievingPrimes** is used to generate the sieving primes ≤ sqrt(stop). SievingPrimes is used by the CountPrintPrimes and PrimeGenerator classes.