[L-function] Make a more consistent L-function package (#836816)

pcpa pcpa at fedoraproject.org
Sat Jul 7 13:04:48 UTC 2012


commit f5329bab51ad2338916476b6fa129ed4637df218
Author: pcpa <paulo.cesar.pereira.de.andrade at gmail.com>
Date:   Sat Jul 7 10:04:37 2012 -0400

    Make a more consistent L-function package (#836816)

 L-1.23-lcalc_to_double.patch |   22 +++++
 L-1.23-pari.patch            |   50 ++++++++++++
 L-function.spec              |  147 ++++++++++++++++++++++------------
 lcalc.1                      |  180 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 347 insertions(+), 52 deletions(-)
---
diff --git a/L-1.23-lcalc_to_double.patch b/L-1.23-lcalc_to_double.patch
new file mode 100644
index 0000000..b55d54d
--- /dev/null
+++ b/L-1.23-lcalc_to_double.patch
@@ -0,0 +1,22 @@
+--- L-1.23/include/Lcommon.h.orig	2011-04-09 04:09:25.984121006 -0300
++++ L-1.23/include/Lcommon.h	2011-04-09 04:09:58.750265003 -0300
+@@ -25,6 +25,8 @@ inline double lcalc_to_double(const Doub
+ #ifdef USE_MPFR
+ inline double lcalc_to_double(const double& x) { return x; }
+ #endif
++
++#if 0
+ //inline double lcalc_to_double(const long double& x) { return x; }
+ inline double lcalc_to_double(const int& x) { return x; }
+ inline double lcalc_to_double(const long long& x) { return x; }
+@@ -33,6 +35,10 @@ inline double lcalc_to_double(const char
+ inline double lcalc_to_double(const long int& x) { return x; }
+ inline double lcalc_to_double(const unsigned int& x) { return x; }
+ inline double lcalc_to_double(const long unsigned int& x) { return x; }
++#else
++#  define lcalc_to_double(x)	((double)(x))
++#endif
++
+ #define Int(x) (int)(lcalc_to_double(x))
+ #define Long(x) (Long)(lcalc_to_double(x))
+ #define double(x) (double)(lcalc_to_double(x))
diff --git a/L-1.23-pari.patch b/L-1.23-pari.patch
new file mode 100644
index 0000000..0af0ded
--- /dev/null
+++ b/L-1.23-pari.patch
@@ -0,0 +1,50 @@
+--- L-1.23/src/Lcommandline_elliptic.cc.orig	2010-11-10 21:35:25.461708009 -0200
++++ L-1.23/src/Lcommandline_elliptic.cc	2010-11-10 21:35:32.065708275 -0200
+@@ -121,11 +121,11 @@ void data_E(char *a1, char *a2, char *a3
+ 
+ 
+     F = cgetg(6, t_VEC);
+-    F[1] = lgeti(BIGDEFAULTPREC);
+-    F[2] = lgeti(BIGDEFAULTPREC);
+-    F[3] = lgeti(BIGDEFAULTPREC);
+-    F[4] = lgeti(BIGDEFAULTPREC);
+-    F[5] = lgeti(BIGDEFAULTPREC);
++    F[1] = (long)cgeti(BIGDEFAULTPREC);
++    F[2] = (long)cgeti(BIGDEFAULTPREC);
++    F[3] = (long)cgeti(BIGDEFAULTPREC);
++    F[4] = (long)cgeti(BIGDEFAULTPREC);
++    F[5] = (long)cgeti(BIGDEFAULTPREC);
+ 
+     //gaffsg(a1,(GEN) F[1]);
+     //gaffsg(a2,(GEN) F[2]);
+--- L-1.23/src/Lcommandline.cc.orig	2012-01-23 21:29:04.756255578 -0200
++++ L-1.23/src/Lcommandline.cc	2012-01-23 21:29:47.660447013 -0200
+@@ -30,6 +30,13 @@ Foundation, Inc., 59 Temple Place - Suit
+ 
+ #include "Lcommandline.h"
+ #include "cmdline.h"
++#include <pari/pari.h>
++
++/* No-operation error recovery routine for PARI.  This is needed for
++ * allocatemem(), which calls the error recovery routine (because
++ * allocatemem() destroys the PARI stack).
++ */
++void pari_err_recover_nop(long errnum) {return;}
+ 
+ int main (int argc, char *argv[])
+ {
+@@ -473,7 +480,13 @@ int main (int argc, char *argv[])
+ 
+ #ifdef INCLUDE_PARI
+         if(do_elliptic_curve){
+-             allocatemoremem((int) N_terms*16+1000000); //XXXXXXXXX this should depend on whether we're double or long double or mpfr double
++             /* allocatemem() calls the callback function cb_pari_err_recover(),
++              * which we temporarily change to do nothing. */
++             void (*saved_err_recover)(long) = cb_pari_err_recover;
++             cb_pari_err_recover = pari_err_recover_nop;
++             allocatemem(N_terms*16 + 1000000); //XXXXXXXXX this should depend on whether we're double or long double or mpfr double
++             cb_pari_err_recover = saved_err_recover;
++
+              if (my_verbose>0) cout << "Will precompute " << N_terms << " elliptic L-function dirichlet coefficients..." << endl;
+              initialize_new_L(a1,a2,a3,a4,a6,N_terms); 
+         }
diff --git a/L-function.spec b/L-function.spec
index b6e636c..a3e2ff8 100644
--- a/L-function.spec
+++ b/L-function.spec
@@ -1,79 +1,122 @@
-Name:           L-function
-Version:        1.23
-Release:        4%{?dist}
-Summary:        L-function calculator
-Group:          Development/Libraries
-License:        GPLv2+
-URL:            http://pmmac03.math.uwaterloo.ca/~mrubinst/L_function_public/L.html
-Source0:        http://pmmac03.math.uwaterloo.ca/%7Emrubinst/L_function_public/CODE/L-%{version}.tar.gz
-Patch0:         L-fix-broken-include-of-libc++.diff
-
-BuildRequires:  pari-devel
-
+Name:		L-function
+Version:	1.23
+Release:	5%{?dist}
+Summary:	C++ L-function class library and command line interface
+Group:		Applications/Engineering
+License:	GPLv2+
+Source0:	http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/CODE/L-1.23.tar.gz
+# From sage tarball, lcalc spkg, debian directory
+Source1:	lcalc.1
+URL:		http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/L.html
+BuildRequires:	gmp-devel
+BuildRequires:	pari-devel
+Patch0:		L-fix-broken-include-of-libc++.diff
+# Build with newer pari
+Patch1:		L-1.23-pari.patch
+# Correct problem with inline functions casting to double with gcc 4.6 or newer
+Patch2:		L-1.23-lcalc_to_double.patch
 
 %description
-A library and a command-line executable that do computations on a class
-of special functions called L-functions. Among others, this class
-includes the Riemann zeta function and the Ramanujan tau function.
-
+C++ L-function class library and command line interface.
 
-%package        devel
-Summary:        Development files for %{name}
-Group:          Development/Libraries
-Requires:       %{name} = %{version}-%{release}
-Provides:       %{name}-static = %{version}-%{release}
-
-%description    devel
-The %{name}-devel package contains libraries and header files for
-developing applications that use %{name}.
+%package	devel
+Summary:	Development libraries/headers for %{name}
+Group:		Development/Libraries
+Requires:	%{name}%{?_isa} = %{version}-%{release}
 
+%description	devel
+Headers and libraries for development with %{name}.
 
 %prep
 %setup -q -n L-%{version}
 %patch0 -p1
+%patch1 -p1
+%patch2 -p1
 rm -f .*DS_Store
 rm -f include/.*{DS_Store,.swp}
 rm -f src/.*{DS_Store,.swp}
-sed -i -e 's|^[^#]*LDFLAGS2.*LDFLAGS1.*$|LDFLAGS2 = $(LDFLAGS1)|' src/Makefile
-sed -i -e 's/\r//' src/example_programs/example.cc
 
+# Make it actually link with the generated library
+sed -e 's|/lib/|/%{_lib}/|g' \
+ -e 's|^[^#]*LDFLAGS2.*LDFLAGS1.*$|LDFLAGS2 = $(LDFLAGS1)|' \
+ -e 's|libLfunction.so|libLfunction.so.%{version}|g' \
+ -e 's|\($(CC).*cc\) libLfunction.so.%{version}|\1 -L. -lLfunction|g' \
+ -e 's|-Xlinker -rpath .*||;' \
+ -e "s|\(DYN_OPTION=shared\)|\1 -Wl,-soname=libLfunction.so.%{version} -lgomp|" \
+ -e 's|#\(OPENMP_FLAG = -fopenmp\)|\1|' \
+ -i src/Makefile
+sed -i -e 's/\r//' src/example_programs/example.cc
+# Upstream tarball comes with a prebuilt library
+rm -f src/libLfunction.a
 
 %build
-cd src
-make %{?_smp_mflags} EXTRA="%{optflags} -lpari" \
-  PREPROCESSOR_DEFINE=-DINCLUDE_PARI \
-  LOCATION_PARI_H=%{_includedir}/pari \
-  LOCATION_PARI_LIBRARY=%{_libdir}
-cd ..
+pushd src
+    # Create link before library is created
+    ln -sf libLfunction.so.%{version} libLfunction.so
+    make							\
+	PARI_DEFINE="-DINCLUDE_PARI"				\
+	LOCATION_PARI_H="%{_includedir}/pari"			\
+	LOCATION_PARI_LIBRARY="%{_libdir}"			\
+	all
+popd
 rm -f src/example_programs/example
 
-
 %install
-mkdir -p $RPM_BUILD_ROOT%{_bindir}
-mkdir -p $RPM_BUILD_ROOT%{_libdir}
-install -p -m 0755 src/lcalc $RPM_BUILD_ROOT%{_bindir}/
-install -p -m 0644 src/libLfunction.a $RPM_BUILD_ROOT%{_libdir}/
-
-mkdir -p $RPM_BUILD_ROOT%{_includedir}/Lfunction
-for file in include/*.h; do
-  install -p -m 0644 $file $RPM_BUILD_ROOT%{_includedir}/Lfunction/
-done
-
-rm %{buildroot}%{_libdir}/*.a
+mkdir -p $RPM_BUILD_ROOT{%{_includedir},%{_libdir},%{_bindir},%{_mandir}/man1}
+pushd src
+    make INSTALL_DIR="$RPM_BUILD_ROOT%{_prefix}" install
+    mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}
+    pushd example_data_files
+	for sample in *; do
+	    install -p -m644 $sample $RPM_BUILD_ROOT%{_datadir}/%{name}/$sample
+	done
+    popd
+    install -m644 example_programs/example.cc \
+	$RPM_BUILD_ROOT%{_datadir}/%{name}/example.cc
+popd
+install -p -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_mandir}/man1
+ln -sf libLfunction.so.%{version} $RPM_BUILD_ROOT%{_libdir}/libLfunction.so
+# Correct permissions
+chmod 644 $RPM_BUILD_ROOT%{_includedir}/Lfunction/*.h
+# Make install creates include/Lfunction but sagemath wants include/lcalc
+pushd $RPM_BUILD_ROOT%{_includedir}
+    ln -sf Lfunction lcalc
+popd
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
 
 %files
-%defattr(-,root,root,-)
-%doc README COPYING
+%doc CONTRIBUTORS
+%doc COPYING
+%doc README
 %{_bindir}/lcalc
-
+%{_libdir}/libLfunction.so.%{version}
+%{_mandir}/man1/*
 
 %files devel
-%defattr(-,root,root,-)
-%doc src/example_programs
-%{_includedir}/Lfunction
-
+%doc %{_datadir}/%{name}
+%dir %{_includedir}/Lfunction
+%{_includedir}/lcalc
+%{_includedir}/Lfunction/*
+%{_libdir}/libLfunction.so
 
 %changelog
+* Sun Jul 1 2012 pcpa <paulo.cesar.pereira.de.andrade at gmail.com> - 1.23-5
+- Merge with duplicate review request #821195 that had changelog
+  + Correct license tag.
+  + Install example source code.
+  + Add %%post sections for library.
+  + Build lcalc with openmp support.
+  + Rename to L to match upstream tarball.
+  + Add proper documentation to main package.
+  + Remove the "see also" section of lcalc.1 as there is no info page.
+  + Initial lcalc spec.
+- Do not provide %{name}-static as no such library is/was installed.
+- Install CONTRIBUTORS as documentation.
+- Remove %%defattr usage.
+
 * Sat Apr 21 2012 Peter Robinson <pbrobinson at fedoraproject.org> - 1.23-4
 - Fix build failure (since F-11!) 
 
diff --git a/lcalc.1 b/lcalc.1
new file mode 100644
index 0000000..c0c26e5
--- /dev/null
+++ b/lcalc.1
@@ -0,0 +1,180 @@
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.36.
+.TH LCALC "1" "May 2008" "lcalc 1.11 Feb 5, 2008" "User Commands"
+.SH NAME
+lcalc \- program for calculating with L-functions
+.SH SYNOPSIS
+.B lcalc
+[\fIOPTIONS\fR]...
+.SH DESCRIPTION
+lcalc 1.11 Feb 5, 2008
+.PP
+This program computes zeros and values of L\-function.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Print help and exit
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+Print version and exit
+.TP
+\fB\-v\fR, \fB\-\-value\fR
+compute L\-function at x+iy. Should be used in
+conjuction with x and y options
+(default=off)
+.TP
+\fB\-x\fR, \fB\-\-x\fR=\fIDouble\fR
+Used with value,value\-line\-segment, and
+zeros\-interval options  (default=`.5')
+.TP
+\fB\-y\fR, \fB\-\-y\fR=\fIDouble\fR
+Used with value,value\-line\-segment, and
+zeros\-interval options  (default=`0')
+.TP
+\fB\-\-value\-file\fR=\fIfilename\fR
+compute L\-function at points specified in file
+.TP
+\fB\-\-value\-line\-segment\fR
+compute L\-function along a line segment
+connecting (x,y) to (X,Y) at number\-sample
+points  (default=off)
+.TP
+\fB\-X\fR, \fB\-\-X\fR=\fIDouble\fR
+Used with value\-line\-segment  (default=`.5')
+.TP
+\fB\-Y\fR, \fB\-\-Y\fR=\fIDouble\fR
+Used with value\-line\-segment  (default=`100')
+.TP
+\fB\-n\fR, \fB\-\-number\-samples\fR=\fIINT\fR
+Used with value\-line\-segment, and interpolate
+options  (default=`1000')
+.TP
+\fB\-z\fR, \fB\-\-zeros\fR=\fIINT\fR
+number of zeros to find
+.TP
+\fB\-Z\fR, \fB\-\-zeros\-interval\fR
+number of zeros to find in an interval
+(1/2+ix,1/2+iy) using steps of size stepsize.
+Use with the x,y, and stepsize options
+(default=off)
+.TP
+\fB\-\-stepsize\fR=\fIDouble\fR
+Used with zeros\-interval
+.TP
+\fB\-d\fR, \fB\-\-derivative\fR=\fIINT\fR
+compute derivative. use \fB\-d\fR \fB\-1\fR to specify
+logarithmic derivative.
+.TP
+\fB\-e\fR, \fB\-\-elliptic\-curve\fR
+specify an elliptic curve over Q. Use with the
+a1 a2 a3 a4 a6 options  (default=off)
+.TP
+\fB\-\-a1\fR=\fIrational_number\fR
+Used with the elliptic\-curve option
+.TP
+\fB\-\-a2\fR=\fIrational_number\fR
+Used with the elliptic\-curve option
+.TP
+\fB\-\-a3\fR=\fIrational_number\fR
+Used with the elliptic\-curve option
+.TP
+\fB\-\-a4\fR=\fIrational_number\fR
+Used with the elliptic\-curve option
+.TP
+\fB\-\-a6\fR=\fIrational_number\fR
+Used with the elliptic\-curve option
+.TP
+\fB\-F\fR, \fB\-\-file\-input\fR=\fIfilename\fR
+input a file with basic L\-function data
+.TP
+\fB\-u\fR, \fB\-\-url\fR=\fIurl\fR
+input a web based file with basic L\-function
+data. Specify the url of the file
+.TP
+\fB\-i\fR, \fB\-\-interpolate\fR=\fIfilename2\fR
+interpolate between two L\-functions and find
+their zeros. Should be used in conjunction
+with file\-input
+.TP
+\fB\-C\fR, \fB\-\-output\-character\fR=\fISTRING\fR if twisting, output the character
+(possible
+values="1", "2" default=`1')
+.TP
+\fB\-o\fR, \fB\-\-output\-data\fR=\fInumber\fR Dirichlet coeffs
+output basic data for the underlying L\-function
+.IP
+(default=`10')
+.TP
+\fB\-\-verbose\fR=\fIINT\fR
+verbosity > 0 outputs extra info  (default=`0')
+.TP
+\fB\-P\fR, \fB\-\-precision\fR=\fIINT\fR
+number digits precision  (default=`14')
+.TP
+\fB\-S\fR, \fB\-\-sacrifice\fR=\fIINT\fR
+number digits to sacrifice  (default=`2')
+.TP
+\fB\-r\fR, \fB\-\-rank\-compute\fR
+compute the rank  (default=off)
+.TP
+\fB\-\-rank\-verify\fR=\fIINT\fR
+verify if specified rank is correct
+.TP
+\fB\-l\fR, \fB\-\-rank\-limit\fR=\fIINT\fR
+when doing quadratic twists limit to
+L\-functions with specified rank
+.TP
+\fB\-t\fR, \fB\-\-tau\fR
+Ramanujan tau L\-function (weight 12, full
+level)  (default=off)
+.TP
+\fB\-q\fR, \fB\-\-twist\-quadratic\fR
+twist by fundamental quadratic characters,
+start <= discriminant <= finish. Use with
+start and finish options.  (default=off)
+.TP
+\fB\-s\fR, \fB\-\-start\fR=\fIinteger\fR
+Used with various twisting options
+.TP
+\fB\-f\fR, \fB\-\-finish\fR=\fIinteger\fR
+Used with various twisting options. Default has
+finish=start
+.TP
+\fB\-\-twist\-quadratic\-even\fR
+twist by fundamental quadratic characters, even
+functional eqn, start <= discriminant <=
+finish  (default=off)
+.TP
+\fB\-p\fR, \fB\-\-twist\-primitive\fR
+twist by all primitive Dirichlet characters
+with start <= conductor <= finish. For
+L\-functions with complex Dirichlet
+coefficients, conjugate characters are
+considered equaivalent  (default=off)
+.TP
+\fB\-A\fR, \fB\-\-twist\-all\fR
+twist by all Dirichlet characters with start <=
+conductor <= finish.  (default=off)
+.TP
+\fB\-a\fR, \fB\-\-twist\-all\-no\-conj\-pairs\fR twist by all Dirichlet characters with start <=
+conductor <= finish. For L\-functions with
+complex Dirichlet coefficients, conjugate
+pairs of characters are considered equivalent
+.IP
+(default=off)
+.TP
+\fB\-c\fR, \fB\-\-twist\-complex\-no\-conj\-pairs\fR
+twist by all complex primitive Dirichlet
+.IP
+characters with start <= conductor <= finish.
+For L\-functions with complex Dirichlet
+coefficients, conjugate pairs of characters
+are considered equivalent  (default=off)
+.TP
+\fB\-g\fR, \fB\-\-twist\-generic\fR
+twist by a generic complex Dirichlet characters
+with start <= conductor <= finish.
+(default=off)
+.TP
+\fB\-D\fR, \fB\-\-degree\fR=\fIdegree\fR
+can only be used in conjuction with
+twist\-primitive (?). Select characters of
+specified degree. Not yet implemented


More information about the scm-commits mailing list