sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.41k stars 475 forks source link

Upgrade to lcalc-2.0.4 #32037

Closed orlitzky closed 2 years ago

orlitzky commented 3 years ago

The new lcalc 2.0.3 has been released. Note in particular:

In this ticket we upgrade to lcalc 2.0.3 and:

Depends on #32061 Depends on #31837

CC: @JohnCremona @antonio-rojas @kiwifb @dimpase

Component: packages: standard

Author: Michael Orlitzky, Frédéric Chapoton

Branch: cbb7908

Reviewer: Antonio Rojas, Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/32037

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 8d70dfd to 4c40554

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

882bbc2Trac #32037: update the doctest for the DirichletGroup(5)[1] L-function.
6c127ffTrac #32037: lower all lcalc tolerances to 1e-8.
5404c18Trac #32037: add abs_tol to an lcalc test to fix a new failure.
4c40554Trac #32037: update an lcalc doctest that counts zeros.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 4c40554 to 1b6cdbc

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f4a1551Trac #32037: add tolerance to a few sage/lfunctions/lcalc.py doctests.
e4ea9c2Trac #32037: delete a failing doctest.
1b6cdbcTrac #32037: replace some ellipeses with abs_tol.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 1b6cdbc to fec80eb

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

fec80ebTrac #32037: replace some ellipses with abs_tol.
orlitzky commented 3 years ago
comment:40

I've fixed all of the problems I know about, and deleted the one remaining failing doctest that no one knows what to do with. Pending a ptestlong, I think it's ready for a serious look.

DaveWitteMorris commented 3 years ago
comment:41

The branch is red. Is there a merge conflict?

orlitzky commented 3 years ago
comment:42

Replying to @DaveWitteMorris:

The branch is red. Is there a merge conflict?

Probably the gcc-11 patch that was added for the lcalc SPKG before sage-9.4. I can rebase after my ptestlong finishes.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from fec80eb to 1750827

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

eab9b44Trac #32037: adjust doctest tolerance for lcalc-2.0.1 in lseries_ell.py.
1750827Trac #32037: weaken doctest tolerance for lcalc-2.0.1 in modular/dirichlet.py.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 1750827 to dce49da

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

dce49daTrac #32037: tweak a doctest in elliptic_curves/ell_rational_field.py.
antonio-rojas commented 3 years ago
comment:45

Doesn't merge cleanly on current develop, please rebase

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from dce49da to c5d8924

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

1a4df39Trac #32037: update the doctest for the DirichletGroup(5)[1] L-function.
44e5d57Trac #32037: lower all lcalc tolerances to 1e-8.
d1dbfb5Trac #32037: add abs_tol to an lcalc test to fix a new failure.
a84d284Trac #32037: update an lcalc doctest that counts zeros.
1727c69Trac #32037: add tolerance to a few sage/lfunctions/lcalc.py doctests.
191147fTrac #32037: delete a failing doctest.
0b668c9Trac #32037: replace some ellipses with abs_tol.
9e3f55fTrac #32037: adjust doctest tolerance for lcalc-2.0.1 in lseries_ell.py.
7fc9b89Trac #32037: weaken doctest tolerance for lcalc-2.0.1 in modular/dirichlet.py.
c5d8924Trac #32037: tweak a doctest in elliptic_curves/ell_rational_field.py.
orlitzky commented 3 years ago
comment:47

should be ok now

antonio-rojas commented 3 years ago
comment:48

This breaks build of sagelib with GCC 11, which worked fine with 1.23 (will all patches on top)

In file included from /usr/include/lcalc/Lglobals.h:70,
                 from /usr/include/lcalc/L.h:43,
                 from build/cythonized/sage/libs/lcalc/lcalc_sage.h:1,
                 from build/cythonized/sage/libs/lcalc/lcalc_Lfunction.cpp:676:
/usr/include/c++/11.1.0/limits: In static member function ‘static constexpr double std::numeric_limits<double>::min()’:
/usr/include/c++/11.1.0/limits:1748:44: error: call to non-‘constexpr’ function ‘double lcalc_to_double(const long double&)’
 1748 |       min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; }
      |                                            ^~~~~~~~~~~
/usr/include/lcalc/Lcommon.h:35:15: note: ‘double lcalc_to_double(const long double&)’ declared here
   35 | inline double lcalc_to_double(const long double& x) { return x; }
      |               ^~~~~~~~~~~~~~~
orlitzky commented 3 years ago
comment:49

Ok, thanks, I'll have to investigate after the holiday (it would take more than a day to build gcc-11 on my laptop). The absence of constexpr in lcalc is "correct," since lcalc can use MPFR for its double type and the MPFR type is not a constexpr.

dimpase commented 3 years ago
comment:50

we can add archlinux, or some other way to get gcc 11, on lcalc CI.

https://stackoverflow.com/a/67406788/557937

we can make a macro expanding to constexpr or to "", and set it up at configure time.

orlitzky commented 3 years ago
comment:51

I'm still not 100% sure what's going on, but this is a -std=c++11 problem and not a gcc-11 problem. If you let gcc-11 pick the standard, everything works. But if you specify -std=c++11, then even the following trivial program will fail,

#include <lcalc/L.h>

The errors suggest that somehow lcalc_to_double() from lcalc is being invoked in the C++ standard library's min() function that's just trying to return a constant:

In file included from /usr/include/lcalc/Lglobals.h:70,
                 from /usr/include/lcalc/L.h:43,
                 from conftest.cpp:1:
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/limits: In static member function 'static constexpr double std::numeric_limits<double>::min()':
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include/g++-v11/limits:1748:44: error: call to non-'constexpr' function 'double lcalc_to_double(const long double&)'
 1748 |       min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; }
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

1a4061aTrac #32037: update to lcalc-2.0.2 to fix the build with std=c++11.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from c5d8924 to 1a4061a

orlitzky commented 3 years ago
comment:53

There was a recent change that started adding -std=gnu++11 to our CXXFLAGS and broke lcalc. I released lcalc-2.0.2 which should work again.

antonio-rojas commented 3 years ago
comment:54

I confirm sagelib builds fine again with GCC 11

dimpase commented 3 years ago
comment:55

what change was adding the -std=gnu++11 ?

it is certainly important that all the Sage C++ libs are compatible wrt to C++ ABI.

mkoeppe commented 3 years ago
comment:56

I haven't followed the discussion on the ticket, but if a specific C++ standard is needed to use the headers, then it is best to declare it in the .pxd file using distutils: extra_compile_args=-std=c++11.

sage_setup.command.sage_build_cython does set this as a default - but I consider this only legacy behavior of our homegrown build system for sagelib.

It will have to be tested with ./configure --enable-editable, which switches the sagelib build to a simpler build system.

orlitzky commented 3 years ago
comment:57

Replying to @dimpase:

what change was adding the -std=gnu++11 ?

The switch to c++11 is actually pretty old (see e.g. 370c03505f290f). What must have changed is that -std=gnu++11 started being added earlier in the build process, before we try to detect lcalc (I know something changed because detecting lcalc-2.0.1 used to work before I rebased onto develop). Regardless, adding the flag early is the right thing to do if we're ultimately going to be compiling code against these libraries with -std=gnu++11 in CXXFLAGS.

For me now, that flag gets added while detecting GCC.

orlitzky commented 3 years ago
comment:58

Replying to @mkoeppe:

I haven't followed the discussion on the ticket, but if a specific C++ standard is needed to use the headers, then it is best to declare it in the .pxd file using distutils: extra_compile_args=-std=c++11.

No special flags are needed. The latest lcalc-2.0.2 will work with any of the 11, 14, or 17 standards.

antonio-rojas commented 3 years ago
comment:59

With my distro packages, getting one test failure only

File "/usr/lib/python3.9/site-packages/sage/lfunctions/zero_sums.pyx", line 832, in sage.lfunctions.zero_sums.LFunctionZeroSum_abstract._zerosum_cauchy
Failed example:
    E.lseries().zeros(2)
Expected:
    [6.36261389, 8.60353962]
Got:
    [6.36261390, 8.60353962]
**********************************************************************
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 1a4061a to 12ac186

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

12ac186Trac #32037: add tolerance to a test in sage/lfunctions/zero_sums.pyx.
dimpase commented 3 years ago
comment:61

tests run on https://github.com/sagemath/sagetrac-mirror/actions/runs/1009717554

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 12ac186 to 2d13818

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

f58d06eTrac #32037: update an lcalc doctest that counts zeros.
3f69117Trac #32037: add tolerance to a few sage/lfunctions/lcalc.py doctests.
b642382Trac #32037: delete a failing doctest.
51750e3Trac #32037: replace some ellipses with abs_tol.
0eeb073Trac #32037: adjust doctest tolerance for lcalc-2.0.1 in lseries_ell.py.
c99d844Trac #32037: weaken doctest tolerance for lcalc-2.0.1 in modular/dirichlet.py.
300ee89Trac #32037: tweak a doctest in elliptic_curves/ell_rational_field.py.
1012352Trac #32037: update to lcalc-2.0.2 to fix the build with std=c++11.
57d4c29Trac #32037: add tolerance to a test in sage/lfunctions/zero_sums.pyx.
2d13818Trac #32037: upgrade to lcalc-2.0.3.
orlitzky commented 3 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,4 @@
-I've just tagged a 2.0.1 release of lcalc: https://gitlab.com/sagemath/lcalc/-/tags/2.0.1
+I've just tagged a 2.0.3 release of lcalc: https://gitlab.com/sagemath/lcalc/-/tags/2.0.3

 There are a few issues that need to be addressed during the upgrade.
orlitzky commented 3 years ago
comment:63

I accidentally broke the soname in the last version, so here's v2.0.3 to fix it. Also rebased onto the latest gengetopt branch.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Changed commit from 2d13818 to dd656cf

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 3 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

dd656cfTrac #32037: make getgetopt an order-only dependency of lcalc.
slel commented 3 years ago

Author: Michael Orlitzky, Frédéric Chapoton

antonio-rojas commented 2 years ago
comment:67

I've been shipping this downstream for 3 months without issues

mkoeppe commented 2 years ago
comment:68

Ticket description should be cleaned up

slel commented 2 years ago
comment:69

I tried to reduce the ticket description to a digest.

Not sure what the conclusion was on item 7, so I left that out.

The ticket description from before my edit is reproduced below.


I've just tagged a 2.0.3 release of lcalc: https://gitlab.com/sagemath/lcalc/-/tags/2.0.3

There are a few issues that need to be addressed during the upgrade.

  1. The build requires GNU gengetopt, so we'll need a new gengetopt SPKG for lcalc to depend on. (It doesn't need to go in the DEPCHECK macro though, since it's a build-only dependency.)

  2. The build system is now sane. This should make life easier in the long run, but means that spkg-* need to be rewritten. ./configure --with-pari should suffice.

  3. The lcalc spkg shouldn't depend on mpfr (I'm not sure why it ever did).

  4. spkg-configure.m4 should be modified to find the new version, for example...

diff --git a/build/pkgs/lcalc/spkg-configure.m4 b/build/pkgs/lcalc/spkg-configure.m4
index 19a87c8d30..b332294eae 100644
--- a/build/pkgs/lcalc/spkg-configure.m4
+++ b/build/pkgs/lcalc/spkg-configure.m4
@@ -1,20 +1,20 @@
 SAGE_SPKG_CONFIGURE([lcalc], [
-    m4_pushdef([SAGE_LCALC_MINVER],["1.22"])
-    SAGE_SPKG_DEPCHECK([pari mpfr], [
+    m4_pushdef([SAGE_LCALC_MINVER],["2.0.0"])
+    SAGE_SPKG_DEPCHECK([pari], [
         AC_PATH_PROG([LCALC], [lcalc])
         AS_IF([test x$LCALC = x], [
            AC_MSG_NOTICE([lcalc not found. Installing lcalc])
            sage_spkg_install_lcalc=yes], [
            AC_MSG_CHECKING([is lcalc's version good enough? ])
-           lcalc_ver=`$LCALC --version 2>>/dev/null | $SED -e 's/lcalc\ //' | $SED -e 's/\ .*//g'`
+           lcalc_ver=$($LCALC --version 2>>/dev/null | $SED -e 's/lcalc\ //' | cut -d' ' -f2)
            AX_COMPARE_VERSION([$lcalc_ver], [ge], [$SAGE_LCALC_MINVER], [
                AC_MSG_RESULT([yes.])
-               AC_CHECK_HEADER([Lfunction/L.h], [], [sage_spkg_install_lcalc=yes])
+               AC_CHECK_HEADER([lcalc/L.h], [], [sage_spkg_install_lcalc=yes])
           AC_MSG_CHECKING([whether we can link and run a program using libLfunction])
           LCALC_SAVED_LIBS=$LIBS
           LIBS="$LIBS -lLfunction"
           AC_RUN_IFELSE([
-            AC_LANG_PROGRAM([[#include <Lfunction/L.h>]],
+            AC_LANG_PROGRAM([[#include <lcalc/L.h>]],
                       [[initialize_globals();
                         Complex x;
                         x = Pi*I;

However, lcalc-2.0.0 comes with a pkg-config file, so we could greatly simplify that.

  1. The public API header has moved to lcalc/L.h:
diff --git a/src/sage/libs/lcalc/lcalc_sage.h b/src/sage/libs/lcalc/lcalc_sage.h
index 498528917f..18e5232cbe 100644
--- a/src/sage/libs/lcalc/lcalc_sage.h
+++ b/src/sage/libs/lcalc/lcalc_sage.h
@@ -1,4 +1,4 @@
-#include "Lfunction/L.h"
+#include "lcalc/L.h"
 int *new_ints(int l)
 {
     return new int[l];
  1. The find_zeros_via_N_v() function was removed, and replaced by find_zeros(). Here's a patch:
diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pxd b/src/sage/libs/lcalc/lcalc_Lfunction.pxd
index d1dbb5d95d..5edf0844f3 100644
--- a/src/sage/libs/lcalc/lcalc_Lfunction.pxd
+++ b/src/sage/libs/lcalc/lcalc_Lfunction.pxd
@@ -21,7 +21,7 @@ cdef extern from "lcalc_sage.h":
         int (* compute_rank) ()
         double (* N) (double T)
         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
-        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)
+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
         void (*print_data_L)()

         #Constructor and destructor
@@ -38,7 +38,7 @@ cdef extern from "lcalc_sage.h":
         double (* N) (double T)
         double *dirichlet_coefficient
         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
-        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)
+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
         void (*print_data_L)()

         #Constructor and destructor
@@ -54,7 +54,7 @@ cdef extern from "lcalc_sage.h":
         int (* compute_rank) ()
         double (* N) (double T)
         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
-        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)
+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
         void (*print_data_L)()

         #Constructor and destructor
@@ -70,7 +70,7 @@ cdef extern from "lcalc_sage.h":
         int (* compute_rank) ()
         double (* N) (double T)
         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
-        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)#puts result in vector<double> result
+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
         void (*find_zeros_via_N)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, char *filename) #puts result in filename

         #Constructor and destructor
@@ -111,7 +111,7 @@ cdef class Lfunction:
     #strange bug, replacing Double with double gives me a compile error
     cdef Double __typedN(self, double T)
     cdef void __find_zeros_v(self, double T1, double T2, double stepsize,doublevec *result)
-    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula,doublevec *result)
+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)

     cdef str _repr
diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pyx b/src/sage/libs/lcalc/lcalc_Lfunction.pyx
index 7e54d7e78d..409987c5d0 100644
--- a/src/sage/libs/lcalc/lcalc_Lfunction.pyx
+++ b/src/sage/libs/lcalc/lcalc_Lfunction.pyx
@@ -307,8 +307,7 @@ cdef class Lfunction:
         return returnvalue

     #The default values are from L.h. See L.h
-    def find_zeros_via_N(self, count=0, do_negative=False, max_refine=1025,
-                         rank=-1, test_explicit_formula=0):
+    def find_zeros_via_N(self, count=0, start=0, max_refine=1025, rank=-1):
         """
         Finds ``count`` number of zeros with positive imaginary part
         starting at real axis. This function also verifies that all
@@ -317,8 +316,7 @@ cdef class Lfunction:
         INPUT:

         - ``count`` - number of zeros to be found
-        - ``do_negative`` - (default: False) False to ignore zeros below the
-          real axis.
+        - ``start`` - (default: 0) how many initial zeros to skip
         - ``max_refine`` - when some zeros are found to be missing, the step
           size used to find zeros is refined. max_refine gives an upper limit
           on when lcalc should give up. Use default value unless you know
@@ -326,13 +324,9 @@ cdef class Lfunction:
         - ``rank`` - integer (default: -1) analytic rank of the L-function.
           If -1 is passed, then we attempt to compute it. (Use default if in
           doubt)
-        - ``test_explicit_formula`` - integer (default: 0) If nonzero, test
-          the explicit formula for additional confidence that all the zeros
-          have been found and are accurate. This is still being tested, so
-          using the default is recommended.

         OUTPUT:
-        
+
         list -- A list of the imaginary parts of the zeros that have been found

         EXAMPLES::
@@ -356,14 +350,10 @@ cdef class Lfunction:
             sage: L.find_zeros_via_N(3)
             [14.1347251417..., 21.0220396387..., 25.0108575801...]
         """
-        cdef Integer count_I = Integer(count)
-        cdef Integer do_negative_I = Integer(do_negative)
-        cdef RealNumber max_refine_R = RRR(max_refine)
-        cdef Integer rank_I = Integer(rank)
-        cdef Integer test_explicit_I = Integer(test_explicit_formula)
+        cdef const char *message_stamp = ""
         cdef doublevec result
         sig_on()
-        self.__find_zeros_via_N_v(mpz_get_si(count_I.value), mpz_get_si(do_negative_I.value), mpfr_get_d(max_refine_R.value, MPFR_RNDN), mpz_get_si(rank_I.value), mpz_get_si(test_explicit_I.value), &result)
+        self.__find_zeros(count, start, max_refine, rank, message_stamp, &result)
         sig_off()
         returnvalue = []
         for i in range(result.size()):
@@ -390,7 +380,7 @@ cdef class Lfunction:
     cdef void __find_zeros_v(self,double T1, double T2, double stepsize, doublevec *result):
         raise NotImplementedError

-    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
         raise NotImplementedError

 ##############################################################################
@@ -486,8 +476,8 @@ cdef class Lfunction_I(Lfunction):
     cdef double __typedN(self, double T):
         return (<c_Lfunction_I *>self.thisptr).N(T)

-    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
-        (<c_Lfunction_I *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
+        (<c_Lfunction_I *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)

     # debug tools
     def _print_data_to_standard_output(self):
@@ -624,8 +614,8 @@ cdef class Lfunction_D(Lfunction):
     cdef double __typedN(self, double T):
         return (<c_Lfunction_D *>self.thisptr).N(T)

-    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
-        (<c_Lfunction_D *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
+    cdef int __find_zeros(self, long count, long start,double max_refine, int rank, const char* message_stamp, doublevec *result):
+        (<c_Lfunction_D *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)

     # debug tools
     def _print_data_to_standard_output(self):
@@ -769,8 +759,8 @@ cdef class Lfunction_C:
     cdef double __typedN(self, double T):
         return (<c_Lfunction_C *>self.thisptr).N(T)

-    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
-        (<c_Lfunction_C *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
+        (<c_Lfunction_C *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)

     # debug tools
     def _print_data_to_standard_output(self):
@@ -854,8 +844,8 @@ cdef class Lfunction_Zeta(Lfunction):
     cdef double __typedN(self, double T):
         return (<c_Lfunction_Zeta *>self.thisptr).N(T)

-    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
-        (<c_Lfunction_Zeta *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
+        (<c_Lfunction_Zeta *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)

     def __dealloc__(self):
         """
  1. Some tests need tolerance updates because the answers have changed slightly.

  2. Two tests give different answers entirely and require help from someone who knows what an L-function is. These are discussed on #24820 as well:

**********************************************************************
File "src/sage/libs/lcalc/lcalc_Lfunction.pyx", line 194, in sage.libs.lcalc.lcalc_Lfunction.Lfunction.hardy_z_function
Failed example:
    L.hardy_z_function(.4+.3*I)
Expected:
    0.2166144222685... - 0.00408187127850...*I
Got:
    0.0240947990422036 + 0.215308871779581*I
**********************************************************************
File "src/sage/libs/lcalc/lcalc_Lfunction.pyx", line 350, in sage.libs.lcalc.lcalc_Lfunction.Lfunction.find_zeros_via_N
Failed example:
    L.find_zeros_via_N(3)
Expected:
    [6.18357819545..., 8.45722917442..., 12.6749464170...]
Got:
    [-4.13290370521286, 6.18357819545086, 8.45722917442320]
**********************************************************************
slel commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,251 +1,17 @@
-I've just tagged a 2.0.3 release of lcalc: https://gitlab.com/sagemath/lcalc/-/tags/2.0.3
+The new lcalc 2.0.3 has been released.
+Note in particular:

-There are a few issues that need to be addressed during the upgrade.
+- sane build system
+- comes with a pkg-config file
+- public API header has moved to `lcalc/L.h`
+- the `find_zeros_via_N_v()` function was removed
+  and replaced by `find_zeros()`

-0. The build requires GNU gengetopt, so we'll need a new gengetopt SPKG for lcalc to depend on. (It doesn't need to go in the DEPCHECK macro though, since it's a build-only dependency.)
-1. The build system is now sane. This should make life easier in the long run, but means that spkg-* need to be rewritten. `./configure --with-pari` should suffice.
+In this ticket we upgrade to lcalc 2.0.3 and:

-2. The lcalc spkg shouldn't depend on mpfr (I'm not sure why it ever did).
+- add gengetopt as a new standard SPKG
+- adjust dependencies
+- adjust spkg-* files for the saner build system
+- adjust spkg-configure.m4 to find the new version
+- adjust tolerance in some doctests

-3. spkg-configure.m4 should be modified to find the new version, for example...
-
-```patch
-diff --git a/build/pkgs/lcalc/spkg-configure.m4 b/build/pkgs/lcalc/spkg-configure.m4
-index 19a87c8d30..b332294eae 100644
---- a/build/pkgs/lcalc/spkg-configure.m4
-+++ b/build/pkgs/lcalc/spkg-configure.m4
-@@ -1,20 +1,20 @@
- SAGE_SPKG_CONFIGURE([lcalc], [
--    m4_pushdef([SAGE_LCALC_MINVER],["1.22"])
--    SAGE_SPKG_DEPCHECK([pari mpfr], [
-+    m4_pushdef([SAGE_LCALC_MINVER],["2.0.0"])
-+    SAGE_SPKG_DEPCHECK([pari], [
-         AC_PATH_PROG([LCALC], [lcalc])
-         AS_IF([test x$LCALC = x], [
-            AC_MSG_NOTICE([lcalc not found. Installing lcalc])
-            sage_spkg_install_lcalc=yes], [
-            AC_MSG_CHECKING([is lcalc's version good enough? ])
--           lcalc_ver=`$LCALC --version 2>>/dev/null | $SED -e 's/lcalc\ //' | $SED -e 's/\ .*//g'`
-+           lcalc_ver=$($LCALC --version 2>>/dev/null | $SED -e 's/lcalc\ //' | cut -d' ' -f2)
-            AX_COMPARE_VERSION([$lcalc_ver], [ge], [$SAGE_LCALC_MINVER], [
-                AC_MSG_RESULT([yes.])
--               AC_CHECK_HEADER([Lfunction/L.h], [], [sage_spkg_install_lcalc=yes])
-+               AC_CHECK_HEADER([lcalc/L.h], [], [sage_spkg_install_lcalc=yes])
-           AC_MSG_CHECKING([whether we can link and run a program using libLfunction])
-           LCALC_SAVED_LIBS=$LIBS
-           LIBS="$LIBS -lLfunction"
-           AC_RUN_IFELSE([
--            AC_LANG_PROGRAM([[#include <Lfunction/L.h>]],
-+            AC_LANG_PROGRAM([[#include <lcalc/L.h>]],
-                       [[initialize_globals();
-                         Complex x;
-                         x = Pi*I;
-```
-
-However, lcalc-2.0.0 comes with a pkg-config file, so we could greatly simplify that.
-
-4. The public API header has moved to `lcalc/L.h`:
-
-```patch
-diff --git a/src/sage/libs/lcalc/lcalc_sage.h b/src/sage/libs/lcalc/lcalc_sage.h
-index 498528917f..18e5232cbe 100644
---- a/src/sage/libs/lcalc/lcalc_sage.h
-+++ b/src/sage/libs/lcalc/lcalc_sage.h
-@@ -1,4 +1,4 @@
--#include "Lfunction/L.h"
-+#include "lcalc/L.h"
- int *new_ints(int l)
- {
-     return new int[l];
-
-```
-
-5. The `find_zeros_via_N_v()` function was removed, and replaced by `find_zeros()`. Here's a patch:
-
-```patch
-diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pxd b/src/sage/libs/lcalc/lcalc_Lfunction.pxd
-index d1dbb5d95d..5edf0844f3 100644
---- a/src/sage/libs/lcalc/lcalc_Lfunction.pxd
-+++ b/src/sage/libs/lcalc/lcalc_Lfunction.pxd
-@@ -21,7 +21,7 @@ cdef extern from "lcalc_sage.h":
-         int (* compute_rank) ()
-         double (* N) (double T)
-         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
--        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)
-+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
-         void (*print_data_L)()
- 
-         #Constructor and destructor
-@@ -38,7 +38,7 @@ cdef extern from "lcalc_sage.h":
-         double (* N) (double T)
-         double *dirichlet_coefficient
-         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
--        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)
-+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
-         void (*print_data_L)()
- 
-         #Constructor and destructor
-@@ -54,7 +54,7 @@ cdef extern from "lcalc_sage.h":
-         int (* compute_rank) ()
-         double (* N) (double T)
-         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
--        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)
-+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
-         void (*print_data_L)()
- 
-         #Constructor and destructor
-@@ -70,7 +70,7 @@ cdef extern from "lcalc_sage.h":
-         int (* compute_rank) ()
-         double (* N) (double T)
-         void  (* find_zeros_v)(double T1, double T2, double stepsize, doublevec result )
--        void (*find_zeros_via_N_v)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec result)#puts result in vector<double> result
-+        int (*find_zeros)(long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
-         void (*find_zeros_via_N)(long count,int do_negative,double max_refine, int rank, int test_explicit_formula, char *filename) #puts result in filename
- 
-         #Constructor and destructor
-@@ -111,7 +111,7 @@ cdef class Lfunction:
-     #strange bug, replacing Double with double gives me a compile error
-     cdef Double __typedN(self, double T)
-     cdef void __find_zeros_v(self, double T1, double T2, double stepsize,doublevec *result)
--    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula,doublevec *result)
-+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec* result)
- 
-     cdef str _repr
-
-```
-
-```patch
-diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pyx b/src/sage/libs/lcalc/lcalc_Lfunction.pyx
-index 7e54d7e78d..409987c5d0 100644
---- a/src/sage/libs/lcalc/lcalc_Lfunction.pyx
-+++ b/src/sage/libs/lcalc/lcalc_Lfunction.pyx
-@@ -307,8 +307,7 @@ cdef class Lfunction:
-         return returnvalue
- 
-     #The default values are from L.h. See L.h
--    def find_zeros_via_N(self, count=0, do_negative=False, max_refine=1025,
--                         rank=-1, test_explicit_formula=0):
-+    def find_zeros_via_N(self, count=0, start=0, max_refine=1025, rank=-1):
-         """
-         Finds ``count`` number of zeros with positive imaginary part
-         starting at real axis. This function also verifies that all
-@@ -317,8 +316,7 @@ cdef class Lfunction:
-         INPUT:
- 
-         - ``count`` - number of zeros to be found
--        - ``do_negative`` - (default: False) False to ignore zeros below the
--          real axis.
-+        - ``start`` - (default: 0) how many initial zeros to skip
-         - ``max_refine`` - when some zeros are found to be missing, the step
-           size used to find zeros is refined. max_refine gives an upper limit
-           on when lcalc should give up. Use default value unless you know
-@@ -326,13 +324,9 @@ cdef class Lfunction:
-         - ``rank`` - integer (default: -1) analytic rank of the L-function.
-           If -1 is passed, then we attempt to compute it. (Use default if in
-           doubt)
--        - ``test_explicit_formula`` - integer (default: 0) If nonzero, test
--          the explicit formula for additional confidence that all the zeros
--          have been found and are accurate. This is still being tested, so
--          using the default is recommended.
- 
-         OUTPUT:
--        
-+
-         list -- A list of the imaginary parts of the zeros that have been found
- 
-         EXAMPLES::
-@@ -356,14 +350,10 @@ cdef class Lfunction:
-             sage: L.find_zeros_via_N(3)
-             [14.1347251417..., 21.0220396387..., 25.0108575801...]
-         """
--        cdef Integer count_I = Integer(count)
--        cdef Integer do_negative_I = Integer(do_negative)
--        cdef RealNumber max_refine_R = RRR(max_refine)
--        cdef Integer rank_I = Integer(rank)
--        cdef Integer test_explicit_I = Integer(test_explicit_formula)
-+        cdef const char *message_stamp = ""
-         cdef doublevec result
-         sig_on()
--        self.__find_zeros_via_N_v(mpz_get_si(count_I.value), mpz_get_si(do_negative_I.value), mpfr_get_d(max_refine_R.value, MPFR_RNDN), mpz_get_si(rank_I.value), mpz_get_si(test_explicit_I.value), &result)
-+        self.__find_zeros(count, start, max_refine, rank, message_stamp, &result)
-         sig_off()
-         returnvalue = []
-         for i in range(result.size()):
-@@ -390,7 +380,7 @@ cdef class Lfunction:
-     cdef void __find_zeros_v(self,double T1, double T2, double stepsize, doublevec *result):
-         raise NotImplementedError
- 
--    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
-+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
-         raise NotImplementedError
- 
- ##############################################################################
-@@ -486,8 +476,8 @@ cdef class Lfunction_I(Lfunction):
-     cdef double __typedN(self, double T):
-         return (<c_Lfunction_I *>self.thisptr).N(T)
- 
--    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
--        (<c_Lfunction_I *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
-+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
-+        (<c_Lfunction_I *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)
- 
-     # debug tools
-     def _print_data_to_standard_output(self):
-@@ -624,8 +614,8 @@ cdef class Lfunction_D(Lfunction):
-     cdef double __typedN(self, double T):
-         return (<c_Lfunction_D *>self.thisptr).N(T)
- 
--    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
--        (<c_Lfunction_D *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
-+    cdef int __find_zeros(self, long count, long start,double max_refine, int rank, const char* message_stamp, doublevec *result):
-+        (<c_Lfunction_D *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)
- 
-     # debug tools
-     def _print_data_to_standard_output(self):
-@@ -769,8 +759,8 @@ cdef class Lfunction_C:
-     cdef double __typedN(self, double T):
-         return (<c_Lfunction_C *>self.thisptr).N(T)
- 
--    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
--        (<c_Lfunction_C *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
-+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
-+        (<c_Lfunction_C *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)
- 
-     # debug tools
-     def _print_data_to_standard_output(self):
-@@ -854,8 +844,8 @@ cdef class Lfunction_Zeta(Lfunction):
-     cdef double __typedN(self, double T):
-         return (<c_Lfunction_Zeta *>self.thisptr).N(T)
- 
--    cdef void __find_zeros_via_N_v(self, long count,int do_negative,double max_refine, int rank, int test_explicit_formula, doublevec *result):
--        (<c_Lfunction_Zeta *>self.thisptr).find_zeros_via_N_v(count, do_negative, max_refine, rank, test_explicit_formula, result[0])
-+    cdef int __find_zeros(self, long count, long start, double max_refine, int rank, const char* message_stamp, doublevec *result):
-+        (<c_Lfunction_Zeta *>self.thisptr).find_zeros(count, start, max_refine, rank, message_stamp, result)
- 
-     def __dealloc__(self):
-         """
-```
-
-6. Some tests need tolerance updates because the answers have changed slightly.
-
-7. Two tests give different answers entirely and require help from someone who knows what an L-function is. These are discussed on #24820 as well:
-
-```
-**********************************************************************
-File "src/sage/libs/lcalc/lcalc_Lfunction.pyx", line 194, in sage.libs.lcalc.lcalc_Lfunction.Lfunction.hardy_z_function
-Failed example:
-    L.hardy_z_function(.4+.3*I)
-Expected:
-    0.2166144222685... - 0.00408187127850...*I
-Got:
-    0.0240947990422036 + 0.215308871779581*I
-**********************************************************************
-File "src/sage/libs/lcalc/lcalc_Lfunction.pyx", line 350, in sage.libs.lcalc.lcalc_Lfunction.Lfunction.find_zeros_via_N
-Failed example:
-    L.find_zeros_via_N(3)
-Expected:
-    [6.18357819545..., 8.45722917442..., 12.6749464170...]
-Got:
-    [-4.13290370521286, 6.18357819545086, 8.45722917442320]
-**********************************************************************
-```
slel commented 2 years ago

Reviewer: Antonio Rojas

orlitzky commented 2 years ago
comment:70

Replying to @slel:

I tried to reduce the ticket description to a digest.

Not sure what the conclusion was on item 7, so I left that out.

Thanks. One of those doctests was updated for the new output, an expected change now that the API automatically determines that the L-function is complex:

https://github.com/sagemath/sagetrac-mirror/commits/8d1221a4

The other was ultimately deleted, because no one can explain either the old or new output:

https://github.com/sagemath/sagetrac-mirror/commits/b642382d

add gengetopt as a new standard SPKG

This is actually still open as a dependency in #32061.

(Edit: link to the correct commits.)

dimpase commented 2 years ago
comment:71

should be good to go now.

mkoeppe commented 2 years ago
comment:72

Needs to be rebased on top of #31837, which brings a patch that does not apply to the new version

mkoeppe commented 2 years ago

Changed dependencies from #32061 to #32061, #31837

mkoeppe commented 2 years ago
comment:73

... as seen in https://github.com/mkoeppe/sage/runs/4127380314?check_suite_focus=true