Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package primecount for openSUSE:Factory 
checked in at 2023-05-23 14:54:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/primecount (Old)
 and      /work/SRC/openSUSE:Factory/.primecount.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "primecount"

Tue May 23 14:54:08 2023 rev:11 rq:1088399 version:7.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/primecount/primecount.changes    2023-05-13 
17:18:10.626566097 +0200
+++ /work/SRC/openSUSE:Factory/.primecount.new.1533/primecount.changes  
2023-05-23 14:54:38.666519000 +0200
@@ -1,0 +2,6 @@
+Mon May 22 12:25:00 UTC 2023 - Kim Walisch <kim.wali...@gmail.com>
+
+- Update to primecount-7.8 (API & ABI are backwards compatible).
+- Fix pi(-n) issue for 128-bit integers.
+
+-------------------------------------------------------------------

Old:
----
  primecount-7.7.tar.gz

New:
----
  primecount-7.8.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ primecount.spec ++++++
--- /var/tmp/diff_new_pack.mMT3eh/_old  2023-05-23 14:54:39.214522242 +0200
+++ /var/tmp/diff_new_pack.mMT3eh/_new  2023-05-23 14:54:39.222522290 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           primecount
-Version:        7.7
+Version:        7.8
 Release:        0
 Summary:        Count the number of primes
 License:        BSD-2-Clause

++++++ primecount-7.7.tar.gz -> primecount-7.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/CMakeLists.txt 
new/primecount-7.8/CMakeLists.txt
--- old/primecount-7.7/CMakeLists.txt   2023-03-26 17:45:44.000000000 +0200
+++ new/primecount-7.8/CMakeLists.txt   2023-03-28 09:44:59.000000000 +0200
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 3.4...3.22)
 project(primecount CXX)
 set(PRIMECOUNT_VERSION_MAJOR 7)
-set(PRIMECOUNT_VERSION_MINOR 7)
+set(PRIMECOUNT_VERSION_MINOR 8)
 set(PRIMECOUNT_VERSION 
"${PRIMECOUNT_VERSION_MAJOR}.${PRIMECOUNT_VERSION_MINOR}")
 
 # Build options ######################################################
@@ -199,8 +199,11 @@
 # (e.g. libprimesieve-dev) and link against that version.
 
 if(BUILD_LIBPRIMESIEVE)
+    set(COPY_BUILD_EXAMPLES "${BUILD_EXAMPLES}")
     set(COPY_BUILD_MANPAGE "${BUILD_MANPAGE}")
     set(COPY_BUILD_TESTS "${BUILD_TESTS}")
+
+    set(BUILD_EXAMPLES OFF CACHE BOOL "Build example programs" FORCE)
     set(BUILD_MANPAGE OFF CACHE BOOL "Build primesieve manpage" FORCE)
     set(BUILD_TESTS OFF CACHE BOOL "Build primesieve tests" FORCE)
     option(BUILD_PRIMESIEVE "Build primesieve binary" OFF)
@@ -214,6 +217,7 @@
         target_compile_options(libprimesieve-static PRIVATE "${POPCNT_FLAG}")
     endif()
 
+    set(BUILD_EXAMPLES "${COPY_BUILD_EXAMPLES}" CACHE BOOL "Build example 
programs" FORCE)
     set(BUILD_MANPAGE "${COPY_BUILD_MANPAGE}" CACHE BOOL "Regenerate man page 
using a2x" FORCE)
     set(BUILD_TESTS "${COPY_BUILD_TESTS}" CACHE BOOL "Build test programs" 
FORCE)
 else()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/ChangeLog new/primecount-7.8/ChangeLog
--- old/primecount-7.7/ChangeLog        2023-03-26 17:45:44.000000000 +0200
+++ new/primecount-7.8/ChangeLog        2023-03-28 09:44:59.000000000 +0200
@@ -1,3 +1,22 @@
+Changes in primecount-7.8, 2023-03-27
+
+I fixed the pi(-n) crash yesterday for 64-bit integers. Unfortunately
+I forgot to fix the same issue for 128-bit integers. Hence this
+release fixes the same issue for 128-bit integers.
+
+* api.cpp: Add missing check for negative numbers in pi(int128_t x),
+           pi_deleglise_rivat(int128_t x), pi_gourdon(int128_t x).
+* test/api.cpp: Add more pi(-n) tests.
+* test/api_c.cpp: Add more primecount_pi(-n) tests.
+* test/pi_cache.cpp: Add new test.
+* test/pi_deleglise_rivat.cpp: Add new test.
+* test/pi_gourdon.cpp: Add new test.
+* test/pi_legendre.cpp: Add new test.
+* test/pi_lmo5.cpp: Add new test.
+* test/pi_lmo_parallel.cpp: Add new test.
+* test/pi_meissel.cpp: Add new test.
+* CMakeLists.txt: Disable building libprimesieve examples.
+
 Changes in primecount-7.7, 2023-03-26
 
 This is a bug fix release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/include/primecount.h 
new/primecount-7.8/include/primecount.h
--- old/primecount-7.7/include/primecount.h     2023-03-26 17:45:44.000000000 
+0200
+++ new/primecount-7.8/include/primecount.h     2023-03-28 09:44:59.000000000 
+0200
@@ -16,9 +16,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#define PRIMECOUNT_VERSION "7.7"
+#define PRIMECOUNT_VERSION "7.8"
 #define PRIMECOUNT_VERSION_MAJOR 7
-#define PRIMECOUNT_VERSION_MINOR 7
+#define PRIMECOUNT_VERSION_MINOR 8
 
 #ifdef __cplusplus
 extern "C" {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/include/primecount.hpp 
new/primecount-7.8/include/primecount.hpp
--- old/primecount-7.7/include/primecount.hpp   2023-03-26 17:45:44.000000000 
+0200
+++ new/primecount-7.8/include/primecount.hpp   2023-03-28 09:44:59.000000000 
+0200
@@ -17,9 +17,9 @@
 #include <string>
 #include <stdint.h>
 
-#define PRIMECOUNT_VERSION "7.7"
+#define PRIMECOUNT_VERSION "7.8"
 #define PRIMECOUNT_VERSION_MAJOR 7
-#define PRIMECOUNT_VERSION_MINOR 7
+#define PRIMECOUNT_VERSION_MINOR 8
 
 namespace primecount {
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/src/api.cpp 
new/primecount-7.8/src/api.cpp
--- old/primecount-7.7/src/api.cpp      2023-03-26 17:45:44.000000000 +0200
+++ new/primecount-7.8/src/api.cpp      2023-03-28 09:44:59.000000000 +0200
@@ -2,7 +2,7 @@
 /// @file  api.cpp
 ///        primecount's C++ API.
 ///
-/// Copyright (C) 2021 Kim Walisch, <kim.wali...@gmail.com>
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
 ///
 /// This file is distributed under the BSD License. See the COPYING
 /// file in the top level directory.
@@ -13,6 +13,7 @@
 #include <primesieve.hpp>
 #include <gourdon.hpp>
 #include <int128_t.hpp>
+#include <macros.hpp>
 #include <PiTable.hpp>
 #include <print.hpp>
 #include <to_string.hpp>
@@ -36,20 +37,16 @@
 
 namespace primecount {
 
-int64_t pi_cache(int64_t x, bool is_print)
+std::string pi(const std::string& x)
 {
-  if (is_print)
-  {
-    print("");
-    print("=== pi_cache(x) ===");
-    print("x", x);
-    print("threads", 1);
-  }
-
-  if (x < 2)
-    return 0;
+  return pi(x, get_num_threads());
+}
 
-  return PiTable::pi_cache(x);
+std::string pi(const std::string& x, int threads)
+{
+  maxint_t n = to_maxint(x);
+  maxint_t res = pi(n, threads);
+  return to_string(res);
 }
 
 int64_t pi(int64_t x)
@@ -90,34 +87,21 @@
     return pi_gourdon_64(x, threads, is_print);
 }
 
-#ifdef HAVE_INT128_T
-
-int128_t pi(int128_t x)
-{
-  return pi(x, get_num_threads());
-}
-
-int128_t pi(int128_t x, int threads)
+int64_t pi_cache(int64_t x, bool is_print)
 {
-  // use 64-bit if possible
-  if (x <= std::numeric_limits<int64_t>::max())
-    return pi((int64_t) x, threads);
-
-  return pi_gourdon_128(x, threads);
-}
-
-#endif
+  if (x < 2)
+    return 0;
 
-std::string pi(const std::string& x)
-{
-  return pi(x, get_num_threads());
-}
+  if (is_print)
+  {
+    print("");
+    print("=== pi_cache(x) ===");
+    print("x", x);
+    print("threads", 1);
+  }
 
-std::string pi(const std::string& x, int threads)
-{
-  maxint_t n = to_maxint(x);
-  maxint_t res = pi(n, threads);
-  return to_string(res);
+  ASSERT(x >= 0);
+  return PiTable::pi_cache(x);
 }
 
 int64_t pi_deleglise_rivat(int64_t x, int threads)
@@ -132,9 +116,33 @@
 
 #ifdef HAVE_INT128_T
 
+int128_t pi(int128_t x)
+{
+  return pi(x, get_num_threads());
+}
+
+int128_t pi(int128_t x, int threads)
+{
+  // Prevent 64-bit cast to random
+  // integer if x <= -2^63.
+  if (x < 0)
+    return 0;
+
+  // Use 64-bit if possible
+  if (x <= std::numeric_limits<int64_t>::max())
+    return pi((int64_t) x, threads);
+  else
+    return pi_gourdon_128(x, threads);
+}
+
 int128_t pi_deleglise_rivat(int128_t x, int threads)
 {
-  // use 64-bit if possible
+  // Prevent 64-bit cast to random
+  // integer if x <= -2^63.
+  if (x < 0)
+    return 0;
+
+  // Use 64-bit if possible
   if (x <= std::numeric_limits<int64_t>::max())
     return pi_deleglise_rivat_64((int64_t) x, threads);
   else
@@ -143,7 +151,12 @@
 
 int128_t pi_gourdon(int128_t x, int threads)
 {
-  // use 64-bit if possible
+  // Prevent 64-bit cast to random
+  // integer if x <= -2^63.
+  if (x < 0)
+    return 0;
+
+  // Use 64-bit if possible
   if (x <= std::numeric_limits<int64_t>::max())
     return pi_gourdon_64((int64_t) x, threads);
   else
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/api.cpp 
new/primecount-7.8/test/api.cpp
--- old/primecount-7.7/test/api.cpp     2023-03-26 17:45:44.000000000 +0200
+++ new/primecount-7.8/test/api.cpp     2023-03-28 09:44:59.000000000 +0200
@@ -2,13 +2,14 @@
 /// @file   api.cpp
 /// @brief  Test primecount's C++ API.
 ///
-/// Copyright (C) 2022 Kim Walisch, <kim.wali...@gmail.com>
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
 ///
 /// This file is distributed under the BSD License. See the COPYING
 /// file in the top level directory.
 ///
 
 #include <primecount.hpp>
+#include <int128_t.hpp>
 
 #include <stdint.h>
 #include <iostream>
@@ -32,18 +33,36 @@
   set_num_threads(3);
   std::cout << "new threads: " << get_num_threads() << std::endl;
 
-  // Test 64-bit pi(-1)
+  // Test 64-bit pi(-x)
   int64_t n = -1;
   int64_t res = pi(n);
   std::cout << "pi(" << n << ") = " << res;
   check(res == 0);
 
-  // Test 128-bit pi(-1)
+  n = -9223372036854775807ll;
+  res = pi(n);
+  std::cout << "pi(" << n << ") = " << res;
+  check(res == 0);
+
   std::string in = "-1";
   std::string out = pi(in);
   std::cout << "pi(" << in << ") = " << out;
   check(out == "0");
 
+#ifdef HAVE_INT128_T
+  // Test 128-bit pi(-x)
+  in = "-1208925819614629174696176";
+  out = pi(in);
+  std::cout << "pi(" << in << ") = " << out;
+  check(out == "0");
+
+  // Test using INT128_MIN+1
+  in = "-170141183460469231731687303715884105727";
+  out = pi(in);
+  std::cout << "pi(" << in << ") = " << out;
+  check(out == "0");  
+#endif
+
   n = (int64_t) 1e10;
   res = pi(n);
   std::cout << "pi(" << n << ") = " << res;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/api_c.c 
new/primecount-7.8/test/api_c.c
--- old/primecount-7.7/test/api_c.c     2023-03-26 17:45:44.000000000 +0200
+++ new/primecount-7.8/test/api_c.c     2023-03-28 09:44:59.000000000 +0200
@@ -35,18 +35,35 @@
   primecount_set_num_threads(3);
   printf("new threads: %d\n", primecount_get_num_threads());
 
-  // Test 64-bit pi(-1)
+  // Test 64-bit pi(-x)
   int64_t n = -1;
   int64_t res = primecount_pi(n);
   printf("primecount_pi(%"PRId64") = %"PRId64, n, res);
   check(res == 0);
 
-  // Test 128-bit pi(-1)
+  n = -9223372036854775807;
+  res = primecount_pi(n);
+  printf("primecount_pi(%"PRId64") = %"PRId64, n, res);
+  check(res == 0);
+
   char out[32];
   primecount_pi_str("-1", out, sizeof(out));
   printf("primecount_pi_str(-1) = %s", out);
   check(strcmp(out, "0") == 0);
 
+  if (strlen(primecount_get_max_x()) > 25)
+  {
+    // Test 128-bit pi(-x)
+    primecount_pi_str("-1208925819614629174696176", out, sizeof(out));
+    printf("primecount_pi_str(-1208925819614629174696176) = %s", out);
+    check(strcmp(out, "0") == 0);
+
+    // Test using INT128_MIN+1
+    primecount_pi_str("-170141183460469231731687303715884105727", out, 
sizeof(out));
+    printf("primecount_pi_str(-170141183460469231731687303715884105727) = %s", 
out);
+    check(strcmp(out, "0") == 0);
+  }
+
   n = (int64_t) 1e10;
   res = primecount_pi(n);
   printf("primecount_pi(%"PRId64") = %"PRId64, n, res);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/nth_prime.cpp 
new/primecount-7.8/test/nth_prime.cpp
--- old/primecount-7.7/test/nth_prime.cpp       1970-01-01 01:00:00.000000000 
+0100
+++ new/primecount-7.8/test/nth_prime.cpp       2023-03-28 09:44:59.000000000 
+0200
@@ -0,0 +1,63 @@
+///
+/// @file   nth_prime.cpp
+/// @brief  Test the nth_prime(n) function
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primesieve.hpp>
+#include <PiTable.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+
+using namespace primecount;
+
+void check_equal(int64_t x,
+                 int64_t res1,
+                 int64_t res2)
+{
+  bool OK = (res1 == res2);
+  std::cout << "nth_prime(" << x << ") = " << res1 << "   " << (OK ? "OK" : 
"ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int64_t n = 1;
+  int64_t prime = 0;
+  int64_t limit_small = PiTable::max_cached() + 100;
+  primesieve::iterator iter;
+
+  for (; n < limit_small; n++)
+  {
+    prime = iter.next_prime();
+    check_equal(n, nth_prime(n), prime);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(1, 100000);
+  n = limit_small - 1;
+
+  // Test random increment
+  for (int64_t i = 0; i < 100; i++)
+  {
+    int64_t next = dist(gen);
+    n += next;
+    prime = primesieve::nth_prime(next, prime);
+    check_equal(n, nth_prime(n), prime);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/nthprime.cpp 
new/primecount-7.8/test/nthprime.cpp
--- old/primecount-7.7/test/nthprime.cpp        2023-03-26 17:45:44.000000000 
+0200
+++ new/primecount-7.8/test/nthprime.cpp        1970-01-01 01:00:00.000000000 
+0100
@@ -1,63 +0,0 @@
-///
-/// @file   nthprime.cpp
-/// @brief  Test the nth_prime(n) function
-///
-/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
-///
-/// This file is distributed under the BSD License. See the COPYING
-/// file in the top level directory.
-///
-
-#include <primecount.hpp>
-#include <primesieve.hpp>
-#include <PiTable.hpp>
-
-#include <stdint.h>
-#include <iostream>
-#include <cstdlib>
-#include <random>
-
-using namespace primecount;
-
-void check_equal(int64_t x,
-                 int64_t res1,
-                 int64_t res2)
-{
-  bool OK = (res1 == res2);
-  std::cout << "nth_prime(" << x << ") = " << res1 << "   " << (OK ? "OK" : 
"ERROR") << "\n";
-  if (!OK)
-    std::exit(1);
-}
-
-int main()
-{
-  int64_t n = 1;
-  int64_t prime = 0;
-  int64_t limit_small = PiTable::max_cached() + 100;
-  primesieve::iterator iter;
-
-  for (; n < limit_small; n++)
-  {
-    prime = iter.next_prime();
-    check_equal(n, nth_prime(n), prime);
-  }
-
-  std::random_device rd;
-  std::mt19937 gen(rd());
-  std::uniform_int_distribution<int64_t> dist(1, 100000);
-  n = limit_small - 1;
-
-  // Test random increment
-  for (int64_t i = 0; i < 100; i++)
-  {
-    int64_t next = dist(gen);
-    n += next;
-    prime = primesieve::nth_prime(next, prime);
-    check_equal(n, nth_prime(n), prime);
-  }
-
-  std::cout << std::endl;
-  std::cout << "All tests passed successfully!" << std::endl;
-
-  return 0;
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_cache.cpp 
new/primecount-7.8/test/pi_cache.cpp
--- old/primecount-7.7/test/pi_cache.cpp        1970-01-01 01:00:00.000000000 
+0100
+++ new/primecount-7.8/test/pi_cache.cpp        2023-03-28 09:44:59.000000000 
+0200
@@ -0,0 +1,59 @@
+///
+/// @file   pi_cache.cpp
+/// @brief  Test the pi_cache(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount-internal.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  {
+    int64_t x = -1;
+    int64_t res = pi_cache(x);
+    std::cout << "pi_cache(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_cache(x);
+    std::cout << "pi_cache(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_deleglise_rivat.cpp 
new/primecount-7.8/test/pi_deleglise_rivat.cpp
--- old/primecount-7.7/test/pi_deleglise_rivat.cpp      1970-01-01 
01:00:00.000000000 +0100
+++ new/primecount-7.8/test/pi_deleglise_rivat.cpp      2023-03-28 
09:44:59.000000000 +0200
@@ -0,0 +1,76 @@
+///
+/// @file   pi_deleglise_rivat.cpp
+/// @brief  Test the pi_deleglise_rivat(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primecount-internal.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int threads = get_num_threads();
+
+  {
+    int64_t x = -1;
+    int64_t res = pi_deleglise_rivat(x, threads);
+    std::cout << "pi_deleglise_rivat(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_deleglise_rivat(x, threads);
+    std::cout << "pi_deleglise_rivat(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(0, 1 << 28);
+
+  for (int i = 0; i < 1000; i++)
+  {
+    int64_t x = dist(gen);
+    int64_t res1 = pi_deleglise_rivat(x, threads);
+    int64_t res2 = pi_legendre(x, threads);
+    std::cout << "pi_deleglise_rivat(" << x << ") = " << res1;
+    check(res1 == res2);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_gourdon.cpp 
new/primecount-7.8/test/pi_gourdon.cpp
--- old/primecount-7.7/test/pi_gourdon.cpp      1970-01-01 01:00:00.000000000 
+0100
+++ new/primecount-7.8/test/pi_gourdon.cpp      2023-03-28 09:44:59.000000000 
+0200
@@ -0,0 +1,77 @@
+///
+/// @file   pi_gourdon.cpp
+/// @brief  Test the pi_gourdon(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primecount-internal.hpp>
+#include <gourdon.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int threads = get_num_threads();
+
+  {
+    int64_t x = -1;
+    int64_t res = pi_gourdon(x, threads);
+    std::cout << "pi_gourdon(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_gourdon(x, threads);
+    std::cout << "pi_gourdon(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(0, 1 << 28);
+
+  for (int i = 0; i < 1000; i++)
+  {
+    int64_t x = dist(gen);
+    int64_t res1 = pi_gourdon(x, threads);
+    int64_t res2 = pi_legendre(x, threads);
+    std::cout << "pi_gourdon(" << x << ") = " << res1;
+    check(res1 == res2);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_legendre.cpp 
new/primecount-7.8/test/pi_legendre.cpp
--- old/primecount-7.7/test/pi_legendre.cpp     1970-01-01 01:00:00.000000000 
+0100
+++ new/primecount-7.8/test/pi_legendre.cpp     2023-03-28 09:44:59.000000000 
+0200
@@ -0,0 +1,77 @@
+///
+/// @file   pi_legendre.cpp
+/// @brief  Test the pi_legendre(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primecount-internal.hpp>
+#include <PiTable.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int threads = get_num_threads();
+
+  {
+    int64_t x = -1;
+    int64_t res = pi_legendre(x, threads);
+    std::cout << "pi_legendre(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_legendre(x, threads);
+    std::cout << "pi_legendre(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(0, PiTable::max_cached());
+
+  for (int i = 0; i < 1000; i++)
+  {
+    int64_t x = dist(gen);
+    int64_t res1 = pi_legendre(x, threads);
+    int64_t res2 = pi_cache(x);
+    std::cout << "pi_legendre(" << x << ") = " << res1;
+    check(res1 == res2);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_lmo5.cpp 
new/primecount-7.8/test/pi_lmo5.cpp
--- old/primecount-7.7/test/pi_lmo5.cpp 1970-01-01 01:00:00.000000000 +0100
+++ new/primecount-7.8/test/pi_lmo5.cpp 2023-03-28 09:44:59.000000000 +0200
@@ -0,0 +1,76 @@
+///
+/// @file   pi_lmo5.cpp
+/// @brief  Test the pi_lmo5(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primecount-internal.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int threads = get_num_threads();
+
+  {
+    int64_t x = -1;
+    int64_t res = pi_lmo5(x);
+    std::cout << "pi_lmo5(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_lmo5(x);
+    std::cout << "pi_lmo5(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(0, 1 << 28);
+
+  for (int i = 0; i < 1000; i++)
+  {
+    int64_t x = dist(gen);
+    int64_t res1 = pi_lmo5(x);
+    int64_t res2 = pi_legendre(x, threads);
+    std::cout << "pi_lmo5(" << x << ") = " << res1;
+    check(res1 == res2);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_lmo_parallel.cpp 
new/primecount-7.8/test/pi_lmo_parallel.cpp
--- old/primecount-7.7/test/pi_lmo_parallel.cpp 1970-01-01 01:00:00.000000000 
+0100
+++ new/primecount-7.8/test/pi_lmo_parallel.cpp 2023-03-28 09:44:59.000000000 
+0200
@@ -0,0 +1,76 @@
+///
+/// @file   pi_lmo_parallel.cpp
+/// @brief  Test the pi_lmo_parallel(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primecount-internal.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int threads = get_num_threads();
+
+  {
+    int64_t x = -1;
+    int64_t res = pi_lmo_parallel(x, threads);
+    std::cout << "pi_lmo_parallel(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_lmo_parallel(x, threads);
+    std::cout << "pi_lmo_parallel(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(0, 1 << 28);
+
+  for (int i = 0; i < 1000; i++)
+  {
+    int64_t x = dist(gen);
+    int64_t res1 = pi_lmo_parallel(x, threads);
+    int64_t res2 = pi_legendre(x, threads);
+    std::cout << "pi_lmo_parallel(" << x << ") = " << res1;
+    check(res1 == res2);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/primecount-7.7/test/pi_meissel.cpp 
new/primecount-7.8/test/pi_meissel.cpp
--- old/primecount-7.7/test/pi_meissel.cpp      1970-01-01 01:00:00.000000000 
+0100
+++ new/primecount-7.8/test/pi_meissel.cpp      2023-03-28 09:44:59.000000000 
+0200
@@ -0,0 +1,76 @@
+///
+/// @file   pi_meissel.cpp
+/// @brief  Test the pi_meissel(x) function.
+///
+/// Copyright (C) 2023 Kim Walisch, <kim.wali...@gmail.com>
+///
+/// This file is distributed under the BSD License. See the COPYING
+/// file in the top level directory.
+///
+
+#include <primecount.hpp>
+#include <primecount-internal.hpp>
+
+#include <stdint.h>
+#include <iostream>
+#include <cstdlib>
+#include <random>
+#include <vector>
+
+using namespace primecount;
+
+std::vector<int64_t> pix =
+{
+    0, 0, 1, 2, 2, 3, 3, 4, 4, 4,
+    4, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+    8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
+    10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
+    12, 13, 13, 14, 14, 14, 14, 15, 15, 15,
+    15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
+    17, 18, 18, 18, 18, 18, 18, 19, 19, 19,
+    19, 20, 20, 21, 21, 21, 21, 21, 21
+};
+
+void check(bool OK)
+{
+  std::cout << "   " << (OK ? "OK" : "ERROR") << "\n";
+  if (!OK)
+    std::exit(1);
+}
+
+int main()
+{
+  int threads = get_num_threads();
+
+  {
+    int64_t x = -1;
+    int64_t res = pi_meissel(x, threads);
+    std::cout << "pi_meissel(" << x << ") = " << res;
+    check(res == 0);
+  }
+
+  for (int64_t x = 0; x < (int64_t) pix.size(); x++)
+  {
+    int64_t res = pi_meissel(x, threads);
+    std::cout << "pi_meissel(" << x << ") = " << res;
+    check(res == pix[x]);
+  }
+
+  std::random_device rd;
+  std::mt19937 gen(rd());
+  std::uniform_int_distribution<int64_t> dist(0, 1 << 28);
+
+  for (int i = 0; i < 1000; i++)
+  {
+    int64_t x = dist(gen);
+    int64_t res1 = pi_meissel(x, threads);
+    int64_t res2 = pi_legendre(x, threads);
+    std::cout << "pi_meissel(" << x << ") = " << res1;
+    check(res1 == res2);
+  }
+
+  std::cout << std::endl;
+  std::cout << "All tests passed successfully!" << std::endl;
+
+  return 0;
+}

Reply via email to