Skip to content

Commit b6bd23d

Browse files
committed
read and use environment variable PARI_SIZE
1 parent 22e165e commit b6bd23d

File tree

8 files changed

+47
-23
lines changed

8 files changed

+47
-23
lines changed

README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ run: either (i) after ./configure, edit ./Makefile and all */Makefile,
3030
setting FLINT_LEVEL=2 (instead of =1); or (ii) edit configure itself
3131
similarly (in two places) and rerun it; or (iii) append
3232
CXXFLAGS='-DFLINT_LEVEL=2' to the make invocation (and ignore warnings
33-
about FLINT_LEVEL being redefined).
33+
about FLINT_LEVEL being redefined). To carry out (ii): run
34+
sed -i '/FLINT_LEVEL/s/1/2/' configure
3435

3536
(c) Boost is optional (from eclib-2013-09-00) and provides parallel
3637
capabilities in the form_finder class. Configure with --with-boost

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Process this file with autoconf to produce a configure script.
44

55
AC_PREREQ([2.65])
6-
AC_INIT([eclib], [20170711], [[email protected]])
6+
AC_INIT([eclib], [20170815], [[email protected]])
77
AM_INIT_AUTOMAKE([-Wall])
88
AC_MSG_NOTICE([Configuring eclib...])
99
AC_CONFIG_SRCDIR([libsrc])
@@ -36,7 +36,7 @@ LT_INIT
3636
# NB The suffix of the library name (libec.so here) is (c-a).a.r
3737

3838
LT_CURRENT=3
39-
LT_REVISION=7
39+
LT_REVISION=8
4040
LT_AGE=0
4141
AC_SUBST(LT_CURRENT)
4242
AC_SUBST(LT_REVISION)

doc/mwrank/mwrank.info

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,13 @@ You can aid the factorization of large integers in several ways:
237237

238238
(a) Pari (i.e. the library libpari) is now a requirement, and is used
239239
to factorization of integers greater than a bound set to 10^8 in
240-
libsrc/marith.cc. This is the only use made of the Pari library.
240+
libsrc/marith.cc. This is the only use made of the Pari library. By
241+
default the pari library is initialized with parisize=1000000. If you
242+
see an error message saying " [hint] set 'parisizemax' to a non-zero
243+
value in your GPRC" do not follow the hint (which is wrong, we are not
244+
using gp at all) but instead set the environment variable PARI_SIZE to
245+
some larger value (e.g. do "export PARI_SIZE=100000000" but this will
246+
depend on your system).
241247

242248
(b) By default the programs initialise an array of primes < 10^6, so
243249
will succeed in factoring all numbers < 10^8 by trial division. This
@@ -272,4 +278,4 @@ John Cremona ([email protected])
272278

273279
3 February 1995, updated 12 January 1998, 25 September 2000, 5 July 2001,
274280
12 November 2003, 5 January 2005, 10 May 2005, 31 December 2011, 2
275-
January 2016.
281+
January 2016, 15 August 2017.

libsrc/eclib/interface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,9 @@ inline int is_approx_zero(const bigcomplex& z)
301301

302302
#undef setbit
303303

304+
// Utility to return a string from an environment variable with a
305+
// default to use if the variable is not set or empty.
306+
307+
string getenv_with_default(string env_var, string def_val);
308+
304309
#endif // #define _INTERFACE_H_

libsrc/eclib/moddata.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ class moddata :public level {
6363
long unitdiv(long res) const {return unitdivlist[reduce(res)];}
6464
};
6565

66-
// Utility to return a string from an environment variable with a
67-
// default to use if the variable is not set or empty.
68-
69-
string getenv_with_default(string env_var, string def_val);
70-
7166
// Returns oldform filename. Default is "newforms/", but can
7267
// be changed via OF_DIR environment variable.
7368
string of_filename(long n, char c);

libsrc/interface.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,16 @@ istream& operator>>(istream& is, CC& z)
307307
return is;
308308
}
309309

310+
string getenv_with_default(string env_var, string def_val)
311+
{
312+
stringstream s;
313+
if (getenv(env_var.c_str()) != NULL) {
314+
s << getenv(env_var.c_str());
315+
} else {
316+
s<<def_val;
317+
}
318+
return s.str();
319+
}
320+
310321
#endif // NTL_ALL
311322

libsrc/moddata.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,6 @@ void moddata::display() const
147147
cout << "unitdivlist: " << unitdivlist << endl;
148148
}
149149

150-
string getenv_with_default(string env_var, string def_val)
151-
{
152-
stringstream s;
153-
if (getenv(env_var.c_str()) != NULL) {
154-
s << getenv(env_var.c_str());
155-
} else {
156-
s<<def_val;
157-
}
158-
return s.str();
159-
}
160-
161150
string of_filename(long n, char c)
162151
{
163152
stringstream s;

libsrc/parifact.cc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
//
2222
//////////////////////////////////////////////////////////////////////////
2323

24+
#include <eclib/interface.h> // for getenv_with_default
2425
#include <pari/pari.h>
2526
#include <eclib/parifact.h>
2627

28+
2729
//#define DEBUG_GPFACT
2830

2931
#include <iostream>
@@ -33,7 +35,13 @@ string
3335
factor(const string n)
3436
{
3537
if (!avma) {
36-
pari_init(1000000, 1000000);
38+
long pari_size = strtol(getenv_with_default("PARI_SIZE", "100000").c_str(), NULL, 0);
39+
if (pari_size==0) // e.g. syntax error in the environment variable PARI_SIZE
40+
pari_size = 1000000;
41+
#ifdef DEBUG_GPFACT
42+
std::cout<<"calling pari_init with pari_size = "<<pari_size<<endl;
43+
#endif
44+
pari_init(pari_size, 1000000);
3745
}
3846
#ifdef DEBUG_GPFACT
3947
std::cout<<"factor called with "<<n<<endl;
@@ -46,6 +54,9 @@ factor(const string n)
4654
settyp(x,t_VEC);
4755

4856
string ans(GENtostr(x));
57+
#ifdef DEBUG_GPFACT
58+
std::cout<<"factor returns "<<ans<<endl;
59+
#endif
4960
avma=av; // restore pari stackpointer
5061
return ans;
5162
}
@@ -54,7 +65,13 @@ int
5465
is_prime(const string p)
5566
{
5667
if (!avma) {
57-
pari_init(1000000, 1000000);
68+
long pari_size = strtol(getenv_with_default("PARI_SIZE", "100000").c_str(), NULL, 0);
69+
#ifdef DEBUG_GPFACT
70+
std::cout<<"calling pari_init with pari_size = "<<pari_size<<endl;
71+
#endif
72+
if (pari_size==0) // e.g. syntax error in the environment variable PARI_SIZE
73+
pari_size = 1000000;
74+
pari_init(pari_size, 1000000);
5875
}
5976
pari_sp av=avma; // store pari stack pointer
6077

0 commit comments

Comments
 (0)