Ticket #10430: pari-2.4.3.alpha.p2.diff

File pari-2.4.3.alpha.p2.diff, 43.5 KB (added by jdemeyer, 11 years ago)

spkg patch .p0 to .p2, for reference

  • .hgignore

    diff -r 66fcd4b37c83 .hgignore
    a b  
    11src/
    2 patches/files
  • SPKG.txt

    diff -r 66fcd4b37c83 SPKG.txt
    a b  
    4848  1) ./spkg-make
    4949     This will download the SVN sources to the directory parisvn/
    5050     and will also download galdata.tgz and ellsea-small.tgz.
    51      Then, a src/ directory will be created and the patches in
    52      patches/*.patch will be applied (with the patched files stored
    53      in patches/files).
    54      WARNING: This script will remove any existing src/ and
    55      patches/files/ directories.
     51     Then, a src/ directory will be created.
     52     WARNING: This script will remove any existing src/ directory.
    5653     NOTES: The script ./spkg-make will actually compile PARI/GP, but
    5754     the compiled files are not used for the spkg.  We only need a few
    5855     files, in particular those created by bison.
     
    8380
    8481== Changelog ==
    8582
     83=== pari-2.4.3.alpha.p2 (Jeroen Demeyer, December 9th, 2010) ===
     84 * Use `patch` to apply patches (at -p0 level because this is how svn
     85   gives the diffs).
     86 * Apply patches for PARI bugs 1084, 1132, 1141, 1143, 1144.
     87 * Move all comments about the patches to patches/README.txt
     88 * Try building first with -O3, when that fails try -O2, then -O1,
     89   then -O0.
     90 * Simplify the "install" part of spkg-install by doing "make install"
     91   instead of copying everything by hand.  This requires a small patch
     92   to config/Makefile.SH (install_doc_no_make.patch) to ensure that
     93   "make install-doc" does not build the documentation.
     94
    8695=== pari-2.4.3.alpha.p0 (Jeroen Demeyer, November 4th, 2010) ===
    8796 * Update to PARI 2.4.3 (by using SVN revision 12623).  Note that the
    8897   PARI developers consider version 2.4.3 to be an "alpha" version with
  • patches/README.txt

    diff -r 66fcd4b37c83 patches/README.txt
    a b  
    33longer, or are still but now for a different reason. (Do not delete that!)
    44
    55======================================================================
    6 Files patched as of pari-2.4.3.alpha.p0:
     6Files patched as of pari-2.4.3.alpha.p2:
    77======================================================================
    88
    9 Configuration files:
     9Patches to configuration files:
    1010* config/get_ld: cwitty: Disable -rpath.
    1111* config/get_tests: John Cremona: Disable testing of ellglobalred in
    1212                    "make test-all" in spkg-check, since it requires
    13                     the elldata database which we do not include.
    14 * config/get_config_options: Catch invalid arguments to "--graphic".
    15 * config/get_fltk; Add libstdc++; check presence of FLTK headers, too.
    16 * config/get_X11: Search X11 library in */lib64/*, too (not just */lib/*).
    17 * config/get_dlcflags: Add -fno-common to DLCFLAGS on Darwin.  Fixed
    18   upstream, but probably in a bad way.
     13                    the elldata database which we do not include since
     14                                        it is about 14MB.
     15* config/get_config_options: leif: Catch invalid arguments to "--graphic"
     16  (and treat such as an error) since otherwise strange compilation errors
     17  might occur (cf. #9722, too).
     18* config/get_fltk: leif: Explicitly link against libstdc++ when using FLTK
     19  (for plotting) to support Fedora 13, and do an extra check for the FLTK
     20  include dir (cf. #9722).
     21* config/get_X11: leif: Also search */lib64/* for X11 libraries (since on
     22  some systems this is really a separate directory, i.e. neither a
     23  symbolic link to */lib/* nor the target of a symbolic link */lib/*; cf.
     24  #9722, too).
     25* config/get_dlcflags: jdemeyer: Add -fno-common to DLCFLAGS on Darwin.
     26  Fixed upstream, but probably in a bad way.
     27* install_doc_no_make.patch: Do not build the documentation when doing
     28  install-doc or install-docpdf.  We must not build the documentation
     29  because that requires tex.  On the other hand, to have ? and ?? work
     30  within gp, we must install the .tex files (but not .dvi files).  So
     31  simply not doing install-doc doesn't work.
    1932
    2033C files:
    21 * src/kernel/gmp/mp.c: Needed so that Sage can catch PARI's error signals.
    22                        Also allow disabling use of "GMP internals".
    23 * src/language/init.c: Needed so that Sage can catch PARI's error signals.
     34* src/kernel/gmp/mp.c, src/language/init.c:
     35  These two are needed so that Sage can catch PARI's error signals.
     36  In addition, let PARI use "GMP internals" (access members of GMP
     37  structures directly) *conditionally*. (We *don't* disable that by
     38  default, since at least currently this is compatible with both GMP
     39  *and* MPIR. To disable the use, add "-DPARI_DONT_USE_GMP_INTERNALS"
     40  to CFLAGS. This is a trivial patch to mp.c only; see also the comment
     41  there.):
     42
     43Upstream patches included (file name refers to the ticket in PARI's bug
     44tracking system, see
     45http://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=NNNN
     46where NNNN is the bug number):
     47* pari_1084.patch: exotic branch cut convention (#9620).  jdemeyer:
     48  removed the parts of the patch involving the COMPAT and CHANGES files
     49  as they are documentation only and give patch conflicts.  Rebased
     50  a hunk in src/basemath/trans1.c to make the patch apply cleanly.
     51* pari_1132.patch: nffactor() returns reducible factor (#10279)
     52* pari_1141.patch: factoring non-square-free polynomial over number
     53  fields (#10369)
     54* pari_1143.patch: rnfisnorm failing for non-integral elements (#2329)
     55* pari_1144.patch: rnfisnorminit requires leading coefficient 1 to be
     56  in ZZ instead of the base field (#2329)
    2457
    2558======================================================================
    2659Files previously patched:
  • new file patches/install_doc_no_make.patch

    diff -r 66fcd4b37c83 patches/install_doc_no_make.patch
    - +  
     1Index: config/Makefile.SH
     2===================================================================
     3--- config/Makefile.SH  (revision 12623)
     4+++ config/Makefile.SH  (working copy)
     5@@ -398,7 +398,6 @@
     6 
     7 install-doc::
     8        -mkdir -p \$(BINDIR) \$(DOCDIR)
     9-       -cd $doc; \$(MAKE) all
     10        -\$(INSTALL_PROGRAM) $doc/gphelp    \$(BINDIR)
     11        -\$(INSTALL_DATA) $doc/Makefile     \$(DOCDIR)
     12        -\$(INSTALL_DATA) $doc/translations \$(DOCDIR)
     13@@ -424,7 +423,6 @@
     14 
     15 install-docpdf::
     16        -mkdir -p \$(BINDIR) \$(DOCDIR)
     17-       -cd $doc; \$(MAKE) docpdf
     18        -\$(INSTALL_DATA) $doc/libpari.pdf  \$(DOCDIR)
     19        -\$(INSTALL_DATA) $doc/users.pdf    \$(DOCDIR)
     20        -\$(INSTALL_DATA) $doc/tutorial.pdf \$(DOCDIR)
  • new file patches/pari_1084.patch

    diff -r 66fcd4b37c83 patches/pari_1084.patch
    - +  
     1Index: src/basemath/trans1.c
     2===================================================================
     3--- src/basemath/trans1.c       (revision 12623)
     4+++ src/basemath/trans1.c       (working copy)
     5@@ -2134,7 +2134,7 @@
     6       gel(y,2) = mppi(lg(x)); return y;
     7 
     8     case t_COMPLEX:
     9-      if (gequal0(gel(x,2))) return glog(gel(x,1), prec);
     10+      if (ismpzero(gel(x,2))) return glog(gel(x,1), prec);
     11       if (prec >= LOGAGMCX_LIMIT) return logagmcx(x, prec);
     12       y = cgetg(3,t_COMPLEX);
     13       gel(y,2) = garg(x,prec);
     14Index: src/basemath/trans2.c
     15===================================================================
     16--- src/basemath/trans2.c       (revision 12623)
     17+++ src/basemath/trans2.c       (working copy)
     18@@ -141,7 +141,8 @@
     19     case t_REAL:
     20       return mpatan(x);
     21 
     22-    case t_COMPLEX:
     23+    case t_COMPLEX: /* atan(x) = -i atanh(ix) */
     24+      if (ismpzero(gel(x,2))) return gatan(gel(x,1), prec);
     25       av = avma; return gerepilecopy(av, mulcxmI(gath(mulcxI(x),prec)));
     26 
     27     case t_INTMOD: case t_PADIC: pari_err(typeer,"gatan");
     28@@ -197,10 +198,11 @@
     29       y = cgetg(3,t_COMPLEX);
     30       gel(y,1) = Pi2n(-1, lg(x));
     31       gel(y,2) = mpach(x);
     32-      if (sx < 0) { togglesign(gel(y,1)); togglesign(gel(y,2)); }
     33+      if (sx < 0) togglesign(gel(y,1)); else togglesign(gel(y,2));
     34       return y;
     35 
     36-    case t_COMPLEX:
     37+    case t_COMPLEX: /* asin(z) = -i asinh(iz) */
     38+      if (ismpzero(gel(x,2))) return gasin(gel(x,1), prec);
     39       av = avma;
     40       return gerepilecopy(av, mulcxmI(gash(mulcxI(x), prec)));
     41 
     42@@ -269,12 +271,16 @@
     43       if (expo(x) < 0) return mpacos(x);
     44 
     45       y = cgetg(3,t_COMPLEX); p1 = mpach(x);
     46-      if (sx < 0) gel(y,1) = mppi(lg(x));
     47-      else { gel(y,1) = gen_0; togglesign(p1); }
     48+      if (sx < 0) { gel(y,1) = mppi(lg(x)); togglesign(p1); }
     49+      else gel(y,1) = gen_0;
     50       gel(y,2) = p1; return y;
     51 
     52-    case t_COMPLEX: av = avma;
     53-      return gerepilecopy(av, mulcxmI(gach(x,prec)));
     54+    case t_COMPLEX:
     55+      if (ismpzero(gel(x,2))) return gacos(gel(x,1), prec);
     56+      av = avma;
     57+      p1 = gadd(x, mulcxI(gsqrt(gsubsg(1,gsqr(x)), prec)));
     58+      y = glog(p1,prec); /* log(x + I*sqrt(1-x^2)) */
     59+      return gerepilecopy(av, mulcxmI(y));
     60 
     61     case t_INTMOD: case t_PADIC: pari_err(typeer,"gacos");
     62     case t_SER:
     63@@ -530,7 +536,7 @@
     64 }
     65 /********************************************************************/
     66 /**                                                                **/
     67-/**                     ARG-HYPERBOLIC SINE                        **/
     68+/**                     AREA HYPERBOLIC SINE                       **/
     69 /**                                                                **/
     70 /********************************************************************/
     71 
     72@@ -552,31 +558,23 @@
     73 GEN
     74 gash(GEN x, long prec)
     75 {
     76-  long sx, sy, sz;
     77   pari_sp av;
     78   GEN a, y, p1;
     79 
     80-  if (gequal0(x)) return gcopy(x);
     81   switch(typ(x))
     82   {
     83     case t_REAL:
     84+      if (!signe(x)) return rcopy(x);
     85       return mpash(x);
     86 
     87-    case t_COMPLEX: av = avma;
     88+    case t_COMPLEX:
     89+      if (ismpzero(gel(x,2))) return gash(gel(x,1), prec);
     90+      av = avma;
     91+      if (ismpzero(gel(x,1))) /* avoid cancellation */
     92+        return gerepilecopy(av, mulcxI(gasin(gel(x,2), prec)));
     93       p1 = gadd(x, gsqrt(gaddsg(1,gsqr(x)), prec));
     94-      y = glog(p1,prec);
     95-      sz = (typ(y)==t_COMPLEX)? gsigne(gel(y,1)): gsigne(y);
     96-      if (typ(p1) == t_COMPLEX) {
     97-        sx = gsigne(gel(p1,1));
     98-        sy = gsigne(gel(p1,2));
     99-      } else {
     100-        sx = gsigne(p1);
     101-        sy = 0;
     102-      }
     103-      if (sx > 0 || (!sx && sy*sz<=0)) return gerepileupto(av, y);
     104-
     105-      p1 = mppi(prec); if (sy<0) setsigne(p1,-1);
     106-      return gerepileupto(av, gsub(mkcomplex(gen_0,p1), y));
     107+      y = glog(p1,prec); /* log (x + sqrt(1+x^2)) */
     108+      return gerepileupto(av, y);
     109     case t_INTMOD: case t_PADIC: pari_err(typeer,"gash");
     110     default:
     111       av = avma; if (!(y = toser_i(x))) break;
     112@@ -598,7 +596,7 @@
     113 }
     114 /********************************************************************/
     115 /**                                                                **/
     116-/**                     ARG-HYPERBOLIC COSINE                      **/
     117+/**                     AREA HYPERBOLIC COSINE                     **/
     118 /**                                                                **/
     119 /********************************************************************/
     120 
     121@@ -630,17 +628,18 @@
     122       if (s == 0) b = acos0(e);
     123       else if (e < 0) b = mpacos(x); /* -1 < x < 1 */
     124       else {
     125-        if (!absrnz_egal1(x)) { a = mpach(x); togglesign(a); }
     126+        if (!absrnz_egal1(x)) a = mpach(x);
     127         b = mppi(lg(x));
     128       }
     129       gel(y,1) = a;
     130       gel(y,2) = b; return y;
     131     }
     132     case t_COMPLEX:
     133+      if (ismpzero(gel(x,2))) return gach(gel(x,1), prec);
     134       av = avma;
     135-      p1 = gadd(x, gsqrt(gaddsg(-1,gsqr(x)), prec)); /* x + sqrt(x^2-1) */
     136-      y = glog(p1,prec);
     137-      if (typ(y) == t_COMPLEX && signe(y[2]) < 0) y = gneg(y);
     138+      p1 = gadd(x, gsqrt(gaddsg(-1,gsqr(x)), prec));
     139+      y = glog(p1,prec); /* log(x + sqrt(x^2-1)) */
     140+      if (signe(real_i(y)) < 0) y = gneg(y);
     141       return gerepileupto(av, y);
     142 
     143     case t_INTMOD: case t_PADIC: pari_err(typeer,"gach");
     144@@ -674,7 +673,7 @@
     145 }
     146 /********************************************************************/
     147 /**                                                                **/
     148-/**                     ARG-HYPERBOLIC TANGENT                     **/
     149+/**                     AREA HYPERBOLIC TANGENT                    **/
     150 /**                                                                **/
     151 /********************************************************************/
     152 
     153@@ -694,26 +693,33 @@
     154 GEN
     155 gath(GEN x, long prec)
     156 {
     157+  long sx;
     158   pari_sp av;
     159   GEN a, y, z;
     160 
     161   switch(typ(x))
     162   {
     163     case t_REAL:
     164-      if (!signe(x)) return real_0_bit(expo(x));
     165+      sx = signe(x);
     166+      if (!sx) return real_0_bit(expo(x));
     167       if (expo(x) < 0) return mpath(x);
     168 
     169       y = cgetg(3,t_COMPLEX);
     170       av = avma;
     171-      z = invr( subrs(x,1) ); setexpo(z, expo(z)+1); /* 2/(x-1)*/
     172+      z = subrs(x,1);
     173+      if (!signe(z)) pari_err(talker,"singular argument in atanh");
     174+      z = invr(z); setexpo(z, expo(z)+1); /* 2/(x-1)*/
     175       z = addrs(z,1);
     176       if (!signe(z)) pari_err(talker,"singular argument in atanh");
     177       z = logr_abs(z);
     178-      setexpo(z, expo(z)-1);
     179+      setexpo(z, expo(z)-1); /* (1/2)log((1+x)/(x-1)) */
     180       gel(y,1) = gerepileuptoleaf(av, z);
     181-      gel(y,2) = Pi2n(-1, lg(x)); return y;
     182+      gel(y,2) = Pi2n(-1, lg(x));
     183+      if (sx > 0) togglesign(gel(y,2));
     184+      return y;
     185 
     186-    case t_COMPLEX:
     187+    case t_COMPLEX: /* 2/(1-z) - 1 = (1+z) / (1-z) */
     188+      if (ismpzero(gel(x,2))) return gath(gel(x,1), prec);
     189       av = avma; z = glog( gaddgs(gdivsg(2,gsubsg(1,x)),-1), prec );
     190       return gerepileupto(av, gmul2n(z,-1));
     191 
     192Index: src/functions/transcendental/atanh
     193===================================================================
     194--- src/functions/transcendental/atanh  (revision 12623)
     195+++ src/functions/transcendental/atanh  (working copy)
     196@@ -3,6 +3,6 @@
     197 C-Name: gath
     198 Prototype: Gp
     199 Help: atanh(x): inverse hyperbolic tangent of x.
     200-Doc: principal branch of $\text{tanh}^{-1}(x)$, i.e.~such
     201- that $\text{Im(atanh}(x))\in{} ]-\pi/2,\pi/2]$. If $x\in \R$ and $|x|>1$ then
     202- $\text{atanh}(x)$ is complex.
     203+Doc: principal branch of $\text{tanh}^{-1}(x) = log ((1+x)/(1-x)) / 2$. In
     204+ particular $\text{Im(atanh}(x))\in{} [-\pi/2,\pi/2]$; if $x\in \R$ and
     205+ $|x|>1$ then $\text{atanh}(x)$ is complex.
     206Index: src/functions/transcendental/acosh
     207===================================================================
     208--- src/functions/transcendental/acosh  (revision 12623)
     209+++ src/functions/transcendental/acosh  (working copy)
     210@@ -3,6 +3,8 @@
     211 C-Name: gach
     212 Prototype: Gp
     213 Help: acosh(x): inverse hyperbolic cosine of x.
     214-Doc: principal branch of $\text{cosh}^{-1}(x)$,
     215- i.e.~such that $\text{Im(acosh}(x))\in [0,\pi]$. If
     216- $x\in \R$ and $x<1$, then $\text{acosh}(x)$ is complex.
     217+Doc: principal branch of $\text{cosh}^{-1}(x) = 2
     218+  \log(\sqrt{(x+1)/2} + \sqrt{(x-1)/2})$. In particular,
     219+ $\text{Re}(\text{acosh}(x))\geq 0$ and
     220+ $\text{In}(\text{acosh}(x))\in ]-\pi,\pi]0$; if $x\in \R$ and $x<1$, then
     221+ $\text{acosh}(x)$ is complex.
     222Index: src/functions/transcendental/log
     223===================================================================
     224--- src/functions/transcendental/log    (revision 12623)
     225+++ src/functions/transcendental/log    (working copy)
     226@@ -6,7 +6,10 @@
     227 Description:
     228  (gen):gen:prec        glog($1, prec)
     229 Doc: principal branch of the natural logarithm of
     230- $x$, i.e.~such that $\text{Im(log}(x))\in{} ]-\pi,\pi]$. The result is complex
     231+ $x \in \C^*$, i.e.~such that $\text{Im(log}(x))\in{} ]-\pi,\pi]$.
     232+ The branch cut lies
     233+ along the negative real axis, continuous with quadrant 2, i.e.~such that
     234+ $\lim_{b\to 0^+} \log (a+bi) = \log a$ for $a \in\R^*$. The result is complex
     235  (with imaginary part equal to $\pi$) if $x\in \R$ and $x < 0$. In general,
     236  the algorithm uses the formula
     237  $$\log(x) \approx {\pi\over 2\text{agm}(1, 4/s)} - m \log 2, $$
     238Index: src/functions/transcendental/atan
     239===================================================================
     240--- src/functions/transcendental/atan   (revision 12623)
     241+++ src/functions/transcendental/atan   (working copy)
     242@@ -2,6 +2,10 @@
     243 Section: transcendental
     244 C-Name: gatan
     245 Prototype: Gp
     246-Help: atan(x): inverse tangent of x.
     247-Doc: principal branch of $\text{tan}^{-1}(x)$, i.e.~such
     248- that $\text{Re(atan}(x))\in{} ]-\pi/2,\pi/2[$.
     249+Help: atan(x): arc tangent of x.
     250+Doc: principal branch of $\text{tan}^{-1}(x) = \log ((1+ix)/(1-ix)) /
     251+ 2i$. In particular $\text{Re(atan}(x))\in{} ]-\pi/2,\pi/2[$.
     252+ The branch cut is in two pieces:
     253+ $]-i\infty,-i[$, continuous with quadrant IV, and $]i,+i \infty[$ continuous
     254+ with quadrant II. The function satisfies $i \text{atan}(x) =
     255+ -i\text{atanh}(ix)$ for all $x\neq \pm i$.
     256Index: src/functions/transcendental/acos
     257===================================================================
     258--- src/functions/transcendental/acos   (revision 12623)
     259+++ src/functions/transcendental/acos   (working copy)
     260@@ -2,7 +2,10 @@
     261 Section: transcendental
     262 C-Name: gacos
     263 Prototype: Gp
     264-Help: acos(x): inverse cosine of x.
     265-Doc: principal branch of $\text{cos}^{-1}(x)$, i.e.~such that
     266- $\text{Re(acos}(x))\in [0,\pi]$. If $x\in \R$ and $|x|>1$, then
     267- $\text{acos}(x)$ is complex.
     268+Help: acos(x): arc cosine of x.
     269+Doc: principal branch of $\text{cos}^{-1}(x) = -i \log (x + i\sqrt{1-x^2})$.
     270+ In particular, $\text{Re(acos}(x))\in [0,\pi]$ and if $x\in \R$ and $|x|>1$,
     271+ then $\text{acos}(x)$ is complex. The branch cut is in two pieces:
     272+ $]-\infty,-1]$ , continuous with quadrant II, and $[1,+\infty[$, continuous
     273+ with quadrant IV. We have $\text{acos}(x) = \pi/2 - \text{asin}(x)$ for all
     274+ $x$.
     275Index: src/functions/transcendental/sqrt
     276===================================================================
     277--- src/functions/transcendental/sqrt   (revision 12623)
     278+++ src/functions/transcendental/sqrt   (working copy)
     279@@ -6,16 +6,14 @@
     280 Description:
     281  (real):gen           sqrtr($1)
     282  (gen):gen:prec       gsqrt($1, prec)
     283-Doc: principal branch of the square root of $x$,
     284- i.e.~such that $\text{Arg}(\text{sqrt}(x))\in{} ]-\pi/2, \pi/2]$, or in other
     285- words such that $\Re(\text{sqrt}(x))>0$ or $\Re(\text{sqrt}(x))=0$ and
     286- $\Im(\text{sqrt}(x))\ge 0$. If $x\in \R$ and $x<0$, then the result is
     287- complex with positive imaginary part.
     288+Doc: principal branch of the square root of $x$, defined as $\sqrt{x} =
     289+ \exp(\log x / 2)$. In particular, we have
     290+ $\text{Arg}(\text{sqrt}(x))\in{} ]-\pi/2, \pi/2]$, and if $x\in \R$ and $x<0$,
     291+ then the result is complex with positive imaginary part.
     292 
     293- Intmod a prime and $p$-adics are allowed as arguments. In that case,
     294+ Intmod a prime $p$ and $p$-adics are allowed as arguments. In that case,
     295  the square root (if it exists) which is returned is the one whose
     296- first $p$-adic digit (or its unique $p$-adic digit in the case of
     297- intmods) is in the interval $[0,p/2]$. When the argument is an
     298+ first $p$-adic digit is in the interval $[0,p/2]$. When the argument is an
     299  intmod a non-prime (or a non-prime-adic), the result is undefined.
     300 Variant: For a \typ{PADIC} $x$, the function
     301  \fun{GEN}{Qp_sqrt}{GEN x} is also available.
     302Index: src/functions/transcendental/asin
     303===================================================================
     304--- src/functions/transcendental/asin   (revision 12623)
     305+++ src/functions/transcendental/asin   (working copy)
     306@@ -2,7 +2,10 @@
     307 Section: transcendental
     308 C-Name: gasin
     309 Prototype: Gp
     310-Help: asin(x): inverse sine of x.
     311-Doc: principal branch of $\text{sin}^{-1}(x)$, i.e.~such
     312- that $\text{Re(asin}(x))\in [-\pi/2,\pi/2]$. If $x\in \R$ and $|x|>1$ then
     313- $\text{asin}(x)$ is complex.
     314+Help: asin(x): arc sine of x.
     315+Doc: principal branch of $\text{sin}^{-1}(x) = -i \log(ix + \sqrt{1 - x^2})$.
     316+ In particular, $\text{Re(asin}(x))\in [-\pi/2,\pi/2]$ and if $x\in \R$ and
     317+ $|x|>1$ then $\text{asin}(x)$ is complex. The branch cut is in two pieces:
     318+ $]-\infty,-1]$, continuous with quadrant II, and $[1,+\infty[$ continuous
     319+ with quadrant IV. The function satisfies $i \text{asin}(x) =
     320+ \text{asinh}(ix)$.
     321Index: src/functions/transcendental/asinh
     322===================================================================
     323--- src/functions/transcendental/asinh  (revision 12623)
     324+++ src/functions/transcendental/asinh  (working copy)
     325@@ -3,5 +3,8 @@
     326 C-Name: gash
     327 Prototype: Gp
     328 Help: asinh(x): inverse hyperbolic sine of x.
     329-Doc: principal branch of $\text{sinh}^{-1}(x)$, i.e.~such
     330- that $\text{Im(asinh}(x))\in [-\pi/2,\pi/2]$.
     331+Doc: principal branch of $\text{sinh}^{-1}(x) = \log(x + \sqrt{1+x^2})$. In
     332+ particular $\text{Im(asinh}(x))\in [-\pi/2,\pi/2]$.
     333+ The branch cut is in two pieces: [-i oo ,-i],  continuous with quadrant III
     334+ and [i,+i oo [ continuous with quadrant I.
     335+
     336Index: src/headers/pariinl.h
     337===================================================================
     338--- src/headers/pariinl.h       (revision 12623)
     339+++ src/headers/pariinl.h       (working copy)
     340@@ -1352,6 +1352,7 @@
     341 /*                         MISCELLANEOUS                           */
     342 /*                                                                 */
     343 /*******************************************************************/
     344+INLINE int ismpzero(GEN x) { return is_intreal_t(typ(x)) && !signe(x); }
     345 INLINE int isintzero(GEN x) { return typ(x) == t_INT && !signe(x); }
     346 INLINE int isint1(GEN x) { return typ(x)==t_INT && equali1(x); }
     347 INLINE int isintm1(GEN x){ return typ(x)==t_INT && equalim1(x);}
     348Index: src/headers/paridecl.h
     349===================================================================
     350--- src/headers/paridecl.h      (revision 12623)
     351+++ src/headers/paridecl.h      (working copy)
     352@@ -3027,6 +3027,7 @@
     353 INLINE int    isint1(GEN x);
     354 INLINE int    isintm1(GEN x);
     355 INLINE int    isintzero(GEN x);
     356+INLINE int    ismpzero(GEN x);
     357 INLINE int    isonstack(GEN x);
     358 INLINE void   killblock(GEN x);
     359 INLINE GEN    leading_term(GEN x);
     360Index: doc/usersFUNCS.tex
     361===================================================================
     362--- doc/usersFUNCS.tex  (revision 12623)
     363+++ doc/usersFUNCS.tex  (working copy)
     364@@ -393,8 +393,9 @@
     365 @eprog
     366 
     367 Note that even if the argument is real, the result may be complex
     368-(e.g.~$\text{acos}(2.0)$ or $\text{acosh}(0.0)$).
     369-Note also that the principal branch is always chosen.
     370+(e.g.~$\text{acos}(2.0)$ or $\text{acosh}(0.0)$). See each individual
     371+function help for the definition of the branch cuts and choice of principal
     372+value.
     373 
     374 \item If the argument is either an integer, a rational, an exact complex
     375 number or a quadratic number, it is first converted to a real
     376@@ -420,7 +421,7 @@
     377 then the function is evaluated for every possible complex embedding of that
     378 algebraic number.  A column vector of results is returned, with one component
     379 for each complex embedding.  Therefore, the number of components equals
     380-the degree of the polynomial defining the number field.
     381+the degree of the \typ{POLMOD} modulus.
     382 
     383 \item If the argument is an intmod or a $p$-adic, at present only a
     384 few functions like \kbd{sqrt} (square root), \kbd{sqr} (square), \kbd{log},
     385Index: doc/usersch5.tex
     386===================================================================
     387--- doc/usersch5.tex    (revision 12623)
     388+++ doc/usersch5.tex    (working copy)
     389@@ -6258,6 +6258,9 @@
     390 otherwise. Contrary to \kbd{isintzero}, this includes recursive objects, for
     391 instance vectors, whose components are $0$.
     392 
     393+\fun{int}{ismpzero}{GEN x} returns 1 (true) if \kbd{x} is a \typ{INT} or
     394+a \typ{REAL} equal to~0.
     395+
     396 \fun{int}{isintzero}{GEN x} returns 1 (true) if \kbd{x} is a \typ{INT}
     397 equal to~0.
     398 
  • new file patches/pari_1132.patch

    diff -r 66fcd4b37c83 patches/pari_1132.patch
    - +  
     1Index: src/test/32/nffactor
     2===================================================================
     3--- src/test/32/nffactor        (revision 12730)
     4+++ src/test/32/nffactor        (working copy)
     5@@ -691,4 +691,5 @@
     6 
     7 [x + Mod(y^7 + 1, y^12 - y^11 + y^9 - y^8 + y^6 - y^4 + y^3 - y + 1) 1]
     8 
     9-Total time spent: 21869
     10+[x + (-2*y^3 + y), x + (-4/3*y^3 + 2/3*y), x + (-2/3*y^3 + 1/3*y)]~
     11+Total time spent: 32849
     12Index: src/test/in/nffactor
     13===================================================================
     14--- src/test/in/nffactor        (revision 12730)
     15+++ src/test/in/nffactor        (working copy)
     16@@ -70,3 +70,6 @@
     17 
     18 \\ Bug #1075
     19 nffactor(polcyclo(21,y), x^2-y^7)
     20+
     21+\\ Bug #1132
     22+do(y^4-y^2+1, 3*x^3+(-12*y^3+6*y)*x^2-11*y^2*x+(2*y^3-4*y))
     23Index: src/modules/nffactor.c
     24===================================================================
     25--- src/modules/nffactor.c      (revision 12730)
     26+++ src/modules/nffactor.c      (working copy)
     27@@ -375,36 +375,34 @@
     28   return u;
     29 }
     30 
     31-/* Warning: return L->topowden * (best lift) */
     32+/* Warning: return L->topowden * (best lift). */
     33 static GEN
     34-nf_bestlift_to_pol(GEN elt, GEN *cu, GEN bound, nflift_t *L)
     35+nf_bestlift_to_pol(GEN elt, GEN bound, nflift_t *L)
     36 {
     37   pari_sp av = avma;
     38   GEN u,v = nf_bestlift(elt,bound,L);
     39   if (!v) return NULL;
     40-  v = gclone(v); avma = av;
     41   if (ZV_isscalar(v))
     42   {
     43-    if (L->topowden) {
     44+    if (L->topowden)
     45       u = mulii(L->topowden, gel(v,1));
     46-      if (cu) *cu = icopy(gel(v,1));
     47-    } else {
     48+    else
     49       u = icopy(gel(v,1));
     50-      if (cu) *cu = u;
     51-    }
     52+    u = gerepileuptoint(av, u);
     53   }
     54   else
     55   {
     56+    v = gclone(v); avma = av;
     57     u = RgV_dotproduct(L->topow, v);
     58-    if (cu) *cu = typ(u) == t_POL ? ZV_content(v): u;
     59+    gunclone(v);
     60   }
     61-  gunclone(v); return u;
     62+  return u;
     63 }
     64 
     65 /* return the T->powden * (lift of pol with coefficients of T2-norm <= C)
     66- * if it exists */
     67+ * if it exists. */
     68 static GEN
     69-nf_pol_lift(GEN pol, GEN *c, GEN bound, nfcmbf_t *T)
     70+nf_pol_lift(GEN pol, GEN bound, nfcmbf_t *T)
     71 {
     72   long i, l = lg(pol);
     73   GEN t, x = cgetg(l,t_POL);
     74@@ -412,13 +410,10 @@
     75   x[1] = pol[1];
     76   t = gel(pol,l-1);
     77   gel(x,l-1) = mul_content(T->L->topowden, t);
     78-  if (c) *c = t;
     79   for (i=l-2; i>1; i--)
     80   {
     81-    GEN ct;
     82-    t = nf_bestlift_to_pol(gel(pol,i), c ? &ct: NULL, bound, T->L);
     83+    t = nf_bestlift_to_pol(gel(pol,i), bound, T->L);
     84     if (!t) return NULL;
     85-    if (c) *c = gcdii(*c, ct);
     86     gel(x,i) = t;
     87   }
     88   return x;
     89@@ -851,54 +846,29 @@
     90 }
     91 
     92 typedef struct {
     93-  GEN lt, C, C2, C2lt, C2ltpol;
     94+  GEN lt, C, C2lt, C2ltpol;
     95 } div_data;
     96 
     97 static void
     98 init_div_data(div_data *D, GEN pol, GEN C)
     99 {
     100-  GEN C2, C2lt, lc = leading_term(pol), lt = is_pm1(lc)? NULL: absi(lc);
     101+  GEN C2lt, lc = leading_term(pol), lt = is_pm1(lc)? NULL: absi(lc);
     102   if (C)
     103   {
     104-    C2 = sqri(C);
     105+    GEN C2 = sqri(C);
     106     C2lt = lt ? mulii(C2, lt): C2;
     107   }
     108   else
     109-  {
     110-    C2 = NULL;
     111     C2lt = lt;
     112-  }
     113   D->lt = lt;
     114   D->C = C;
     115-  D->C2 = C2;
     116   D->C2lt = C2lt;
     117   D->C2ltpol = C2lt? RgX_Rg_mul(pol, C2lt): pol;
     118 }
     119 static void
     120-update_target(div_data *D, GEN cy, GEN pol)
     121+update_target(div_data *D, GEN pol)
     122 {
     123-  GEN C2ltpol, C2lt;
     124-  if (D->lt) {
     125-    GEN Clt;
     126-    D->lt = diviiexact(D->lt, cy); /* correct leading coeff for cofactor of y */
     127-    if (D->C)
     128-    {
     129-      Clt = mulii(D->C, D->lt);
     130-      C2lt = mulii(D->C, Clt);
     131-    }
     132-    else
     133-      C2lt = Clt = D->lt;
     134-    /* cofactor of y has leading coeff C old_lt : must be multiplied by
     135-     * new_lt / C old_lt = 1/(C*cy) to obtain the new 'pol'
     136-     * C2ltpol obtained by multiplying further by
     137-     * C^2 new_lt : pol * C new_lt / cy */
     138-    C2ltpol = RgX_Rg_mul(RgX_Rg_div(pol,cy), Clt);
     139-  } else {
     140-    C2ltpol = D->C? RgX_Rg_mul(pol, D->C): pol;
     141-    C2lt = D->C2;
     142-  }
     143-  D->C2ltpol = C2ltpol;
     144-  D->C2lt    = C2lt;
     145+  D->C2ltpol = D->C? RgX_Rg_mul(pol, D->C): pol;
     146 }
     147 
     148 /* nb = number of modular factors; return a "good" K such that naive
     149@@ -993,7 +963,7 @@
     150     }
     151     if (curdeg <= klim) /* trial divide */
     152     {
     153-      GEN t, cy, y, q;
     154+      GEN t, y, q;
     155       pari_sp av;
     156 
     157       av = avma;
     158@@ -1026,7 +996,7 @@
     159         y = FqX_centermod(q, Tpk, pk, pks2);
     160       }
     161       /* y = C*lt*\prod_{i in ind} famod[i] */
     162-      y = nf_pol_lift(y, D.lt ? &cy : NULL, bound, T);
     163+      y = nf_pol_lift(y, bound, T);
     164       if (!y)
     165       {
     166         if (DEBUGLEVEL>3) fprintferr("@");
     167@@ -1043,9 +1013,7 @@
     168       /* pol in O_K[X] with leading coeff lt in Z,
     169        * y = C*lt \prod famod[i] is in O_K[X] with leading coeff in Z
     170        * q = C^2 * lt * pol / y = C * (lt * pol) / (lt*\prod famod[i]), a
     171-       * K-rational factor, in fact in Z[Y]/nf.pol)[X] as above.
     172-       * cy is the Z-content of (y/C), i.e. the largest integer such that
     173-       * (y/C*cy) is in O_K[X]; it divides lt */
     174+       * K-rational factor, in fact in Z[Y]/nf.pol)[X] as above. */
     175 
     176       /* found a factor */
     177       if (D.C2lt) y = RgX_int_normalize(y); /* monic */
     178@@ -1068,7 +1036,7 @@
     179       if (lfamod < 2*K) goto END;
     180       i = 1; curdeg = deg[ind[1]];
     181 
     182-      update_target(&D, cy, pol);
     183+      update_target(&D, pol);
     184       if (DEBUGLEVEL > 2)
     185       {
     186         fprintferr("\n"); msgTIMER(&ti, "to find factor %Ps",y);
     187@@ -1133,15 +1101,11 @@
     188   for (i = 1;;)
     189   {
     190     pari_sp av = avma;
     191-    GEN cy;
     192     if (DEBUGLEVEL) fprintferr("nf_LLL_cmbf: checking factor %ld\n", i);
     193     y = chk_factors_get(D.lt, famod, gel(piv,i), Tpk, pk);
     194 
     195-    if (! (y = nf_pol_lift(y, D.lt ? &cy : NULL, bound, T)) ) return NULL;
     196-    if (D.lt)
     197-      gerepileall(av, 2, &y, &cy);
     198-    else
     199-      y = gerepilecopy(av, y);
     200+    if (! (y = nf_pol_lift(y, bound, T)) ) return NULL;
     201+    y = gerepilecopy(av, y);
     202     /* y is the candidate factor */
     203     pol = RgXQX_divrem(D.C2ltpol, y, nfT, ONLY_DIVIDES);
     204     if (!pol) return NULL;
     205@@ -1150,7 +1114,7 @@
     206     gel(list,i) = y;
     207     if (++i >= r) break;
     208 
     209-    update_target(&D, cy, pol);
     210+    update_target(&D, pol);
     211   }
     212   gel(list,i) = RgX_int_normalize(pol); return list;
     213 }
     214@@ -1527,7 +1491,7 @@
     215   {
     216     GEN q, r = gel(z,i);
     217 
     218-    r = nf_bestlift_to_pol(ltdn? gmul(ltdn,r): r, NULL, NULL, L);
     219+    r = nf_bestlift_to_pol(ltdn? gmul(ltdn,r): r, NULL, L);
     220     gel(Cltdnx_r,2) = gneg(r); /* check P(r) == 0 */
     221     q = RgXQX_divrem(C2ltdnpol, Cltdnx_r, nfpol, ONLY_DIVIDES); /* integral */
     222     if (q) {
  • new file patches/pari_1141.patch

    diff -r 66fcd4b37c83 patches/pari_1141.patch
    - +  
     1Index: src/test/32/nffactor
     2===================================================================
     3--- src/test/32/nffactor        (revision 12763)
     4+++ src/test/32/nffactor        (working copy)
     5@@ -692,4 +692,5 @@
     6 [x + Mod(y^7 + 1, y^12 - y^11 + y^9 - y^8 + y^6 - y^4 + y^3 - y + 1) 1]
     7 
     8 [x + (-2*y^3 + y), x + (-4/3*y^3 + 2/3*y), x + (-2/3*y^3 + 1/3*y)]~
     9-Total time spent: 32849
     10+[x + (-1/3*y - 1/3), x + (2/3*y + 2/3)]~
     11+Total time spent: 8712
     12Index: src/test/in/nffactor
     13===================================================================
     14--- src/test/in/nffactor        (revision 12763)
     15+++ src/test/in/nffactor        (working copy)
     16@@ -73,3 +73,7 @@
     17 
     18 \\ Bug #1132
     19 do(y^4-y^2+1, 3*x^3+(-12*y^3+6*y)*x^2-11*y^2*x+(2*y^3-4*y))
     20+
     21+\\ Bug #1141
     22+do(y^2-y+1, (x-(1+y)/3)^2*(x+2*(1+y)/3))
     23+
     24Index: src/modules/nffactor.c
     25===================================================================
     26--- src/modules/nffactor.c      (revision 12763)
     27+++ src/modules/nffactor.c      (working copy)
     28@@ -450,13 +450,13 @@
     29     { /* compute valuations mod a prime of degree 1 (avoid coeff explosion) */
     30       pari_sp av1 = avma;
     31       long j;
     32-      GEN quo, p, r, Bp, E = cgetalloc(t_VECSMALL,n+1);
     33+      GEN quo, p, r, Bp, lb = leading_term(B), E = cgetalloc(t_VECSMALL,n+1);
     34       byteptr pt = diffptr;
     35       ulong pp = 0;
     36       for (;; avma = av1)
     37       {
     38         NEXT_PRIME_VIADIFF_CHECK(pp, pt);
     39-        if (! umodiu(bad,pp)) continue;
     40+        if (! umodiu(bad,pp) || !umodiu(lb, pp)) continue;
     41         p = utoipos(pp);
     42         r = FpX_oneroot(T, p);
     43         if (!r) continue;
  • new file patches/pari_1143.patch

    diff -r 66fcd4b37c83 patches/pari_1143.patch
    - +  
     1Index: src/basemath/buch4.c
     2===================================================================
     3--- src/basemath/buch4.c        (revision 12768)
     4+++ src/basemath/buch4.c        (working copy)
     5@@ -618,8 +618,9 @@
     6   *S2 = shallowconcat(*S2, idealprimedec(rel,p));
     7 }
     8 
     9+/* N a t_INT */
     10 static void
     11-fa_pr_append(GEN nf,GEN rel,GEN N,GEN *prod,GEN *S1,GEN *S2)
     12+Zfa_pr_append(GEN nf,GEN rel,GEN N,GEN *prod,GEN *S1,GEN *S2)
     13 {
     14   if (!is_pm1(N))
     15   {
     16@@ -628,6 +629,18 @@
     17     for (i=1; i<l; i++) pr_append(nf,rel,gel(v,i),prod,S1,S2);
     18   }
     19 }
     20+/* N a t_INT or t_FRAC */
     21+static void
     22+fa_pr_append(GEN nf,GEN rel,GEN N,GEN *prod,GEN *S1,GEN *S2)
     23+{
     24+  if (typ(N) == t_FRAC)
     25+  {
     26+    Zfa_pr_append(nf,rel,gel(N,1),prod,S1,S2);
     27+    Zfa_pr_append(nf,rel,gel(N,2),prod,S1,S2);
     28+  }
     29+  else
     30+    Zfa_pr_append(nf,rel,N,prod,S1,S2);
     31+}
     32 
     33 static GEN
     34 pol_up(GEN rnfeq, GEN x, long v)
  • new file patches/pari_1144.patch

    diff -r 66fcd4b37c83 patches/pari_1144.patch
    - +  
     1Index: src/basemath/base5.c
     2===================================================================
     3--- src/basemath/base5.c        (revision 12767)
     4+++ src/basemath/base5.c        (working copy)
     5@@ -65,8 +65,11 @@
     6     long tc = typ(c);
     7     switch(tc)
     8     {
     9-      case t_POLMOD: c = gel(c,2); /* fall through */
     10-      case t_POL:    c = RgX_RgXQ_eval(c, alpha, polabs); break;
     11+      case t_POLMOD: c = gel(c,2);
     12+        if (typ(c) != t_POL) break;
     13+        c = RgX_RgXQ_eval(c, alpha, polabs); break;
     14+      case t_POL:
     15+        c = RgX_RgXQ_eval(c, alpha, polabs); break;
     16       default:
     17         if (!is_const_t(tc)) pari_err(talker, "incorrect data in eltreltoabs");
     18     }
  • spkg-install

    diff -r 66fcd4b37c83 spkg-install
    a b  
    1010fi
    1111
    1212TOP=`pwd`
    13 PATCHED="$TOP/patches/files"
    1413
    15 ###########################################################
    16 ## Patching src files.  See patches/README.txt for details.
    17 ###########################################################
     14#######################################################################
     15# Apply all patches.  See patches/README.txt for details about the
     16# patches.
     17#######################################################################
     18cd src
     19for patch in ../patches/*.patch; do
     20    patch -p0 <$patch
     21    if [ $? -ne 0 ]; then
     22        echo >&2 "Error applying $patch"
     23        exit 1
     24    fi
     25done
    1826
    19 cd src
    2027
    21 # These two are needed so that Sage can catch PARI's error signals.
    22 # In addition, let PARI use "GMP internals" (access members of GMP
    23 # structures directly) *conditionally*. (We *don't* disable that by
    24 # default, since at least currently this is compatible with both GMP
    25 # *and* MPIR. To disable the use, add "-DPARI_DONT_USE_GMP_INTERNALS"
    26 # to CFLAGS. This is a trivial patch to mp.c only; see also the comment
    27 # there.):
    28 cp "$PATCHED/init.c"  src/language/init.c
    29 cp "$PATCHED/mp.c"    src/kernel/gmp/mp.c
     28# Limit virtual memory to 400MB.
     29# This is needed because some broken versions of gcc have run-away
     30# memory usage (see #10120).
     31ulimit -v 409600
    3032
    31 # cwitty: Disable -rpath:
    32 cp "$PATCHED/get_ld" config/
    3333
    34 # John Cremona: Copy over a lightly patched get_tests, so that "make
    35 # test-all" does not test ellglobalred (which requires the elldata
    36 # package Sage does not install, nor ship, since it is about 14 MB):
    37 cp "$PATCHED/get_tests" config/
     34# Prepare all variables for building PARI/GP, except for CFLAGS
     35set_environment()
     36{
     37    # Save current working directory (the src directory)
     38    CUR=`pwd`
    3839
    39 # leif: Catch invalid arguments to "--graphic" (and treat such as an error)
    40 # since otherwise strange compilation errors might occur (cf. #9722, too).
    41 cp "$PATCHED/get_config_options" config/
     40    # This is needed or there are weird locale problems involving rpath
     41    # with building Sage:
     42    LC_ALL=C
     43    export LC_ALL
     44    LANG=C
     45    export LANG
    4246
    43 # leif: Explicitly link against libstdc++ when using FLTK (for plotting) to
    44 # support Fedora 13, and do an extra check for the FLTK include dir (cf. #9722):
    45 cp "$PATCHED/get_fltk" config/
    46 
    47 # leif: Also search */lib64/* for X11 libraries (since on some systems this
    48 # is really a separate directory, i.e. neither a symbolic link to */lib/* nor
    49 # the target of a symbolic link */lib/*; cf. #9722, too):
    50 cp "$PATCHED/get_X11" config/
    51 
    52 # Add -fno-common to DLCFLAGS on all Darwin systems instead of
    53 # PPC/PPC64 only.
    54 cp "$PATCHED/get_dlcflags" config/
    55 
    56 
    57 # This is needed or there are weird locale problems involving rpath
    58 # with building Sage:
    59 LC_ALL=C
    60 export LC_ALL
    61 LANG=C
    62 export LANG
    63 
    64 
    65 build()
    66 {
    6747    # Add the proper flags for 64-bit build mode on OS X and OpenSolaris x64.
    6848    # Setting CFLAGS is not sufficient on Solaris since PARI 2.4.3, as this
    6949    # flag is not being used when the checks for GMP and Readline are made,
     
    8161        CC="$CC $CFLAG64" && export CC
    8262    fi
    8363
    84     if [ "x$SAGE_DEBUG" = xyes ]; then
    85        # Disable optimisation, add debug symbols. Good for debugging or
    86        # working around compiler bugs:
    87        CFLAGS="$CFLAGS -O0 -g"
    88     else
    89        CFLAGS="-O3 -g $CFLAGS" # Default optimisation, with debug symbols.
    90                                # Prepend to not override user's setting.
    91     fi
    92     export CFLAGS
    93 
    94     CUR=`pwd`
    95 
    9664    # On my systems PARI does *not* build correctly with these set! (and
    9765    # they are set by sage-env).  It builds, but doesn't run.  Something
    9866    # about missing _start symbol.
     
    184152    unset dfltlibdir dfltmandir dfltsysdatadir dfltobjdir
    185153    # The following get set because we pass the respective parameters:
    186154    # prefix kernel with_gmp with_readline
     155}
    187156
    188157
     158# Build PARI with the current CFLAGS.
     159# Note that this function returns 1 on error, it does NOT exit
     160# spkg-install, so be sure to check the exit status of this function!
     161build()
     162{
     163    export CFLAGS
     164
    189165    # Configure PARI/GP, forcing bash instead of /bin/sh.  It is not
    190166    # strictly necessary to use bash, but it hopefully makes the script
    191167    # less system-dependent.  Since Sage assumes the existence of bash
     
    197173        --kernel=gmp
    198174
    199175    if [ $? -ne 0 ]; then
    200         echo "Error: Configuring PARI with readline and GMP kernel failed."
    201         exit 1
     176        echo >&2 "Error: Configuring PARI with readline and GMP kernel failed."
     177        return 1
    202178    fi
    203179
    204180    if [ ! -f Makefile ]; then
    205         echo "Error: Unable to configure PARI: No Makefile generated!"
    206         exit 1
     181        echo >&2 "Error: Unable to configure PARI: No Makefile generated!"
     182        return 1
    207183    fi
    208184
    209     echo "Building and installing PARI/GP..."
    210185    if [ "$UNAME" = "CYGWIN" ]; then
    211186        # There are weird bugs in PARI's build process on Windows XP
    212187        # under Cygwin.
     
    215190    else
    216191        $MAKE gp
    217192    fi
     193    return $?
     194}
    218195
     196
     197install()
     198{
     199    echo "Installing PARI/GP..."
     200
     201    $MAKE install install-lib-sta
    219202    if [ $? -ne 0 ]; then
    220         echo "Error building GP"
     203        echo >&2 "Error installing PARI"
    221204        exit 1
    222205    fi
    223206
    224     cp -f gp "$SAGE_LOCAL/bin/"    # avoid "make install"
    225 
    226     # Install documentation source (compressed), for use by gphelp:
    227     mkdir -p "$SAGE_LOCAL/share/pari/doc/"
    228     cp -f doc/usersch*.tex "$SAGE_LOCAL/share/pari/doc/"
    229     bzip2 -9 -f "$SAGE_LOCAL/share/pari/doc/"usersch*.tex
    230     cp -f doc/translations "$SAGE_LOCAL/share/pari/doc/"
    231 
    232     # And install gphelp:
    233     cp -f doc/gphelp "$SAGE_LOCAL/bin/"
    234 
    235     $MAKE install-lib-sta
    236 
    237     if [ $? -ne 0 ]; then
    238         echo "Error installing PARI's static library"
    239         exit 1
    240     fi
    241 
    242     # Instead of "make install" we do the following, to avoid building
    243     # the PARI documentation (which requires latex; or more precisely,
    244     # *hangs* under a default Cygwin with latex, since some fonts are missing):
    245     cd "`config/objdir`"
    246     $MAKE install-include
    247 
    248     if [ $? -ne 0 ]; then
    249         echo "Error installing PARI's include files"
    250         exit 1
    251     fi
    252 
    253     cp -f libpari* "$SAGE_LOCAL/lib/"
    254     cd "$CUR"
    255 
    256207    # On Cygwin, we need the dll for PARI to be in the same
    257208    # directory as the gp binary, or it doesn't find it.
    258209    # Note that just using a symlink doesn't work.
    259210    if [ "$UNAME" = "CYGWIN" ]; then
    260         CUR=`pwd`
    261211        cd "$SAGE_LOCAL"/bin/
    262212        cp -f "$SAGE_LOCAL"/lib/*pari*.dll .
    263         cd "$CUR"
    264213    fi
     214    cd "$CUR"
    265215
    266216    if [ "$UNAME" = "Darwin" ]; then
    267217        # The following is a hack to get the library installed correctly
     
    271221        $MAKE install-lib-sta
    272222
    273223        if [ $? -ne 0 ]; then
    274             echo "Error reinstalling PARI's static libraries (OS X trick)"
     224            echo >&2 "Error reinstalling PARI's static libraries (OS X trick)"
    275225            exit 1
    276226        fi
    277227
     
    280230        cd "$CUR"
    281231    fi
    282232
    283     echo "Installing extra Galois groups data..."
    284     $MAKE install-data
    285     if [ $? -ne 0 ]; then
    286         echo "Error installing extra Galois groups data."
    287         exit 1
    288     fi
    289 
    290233    # Copy gprc.expect to $SAGE_LOCAL/etc
    291234    cp -f "$TOP/gprc.expect" "$SAGE_LOCAL/etc"
    292235    if [ $? -ne 0 ]; then
    293         echo "Error installing gprc.expect"
     236        echo >&2 "Error installing gprc.expect"
    294237        exit 1
    295238    fi
    296239}
    297240
    298 build
     241
     242set_environment
     243
     244# Configure and compile PARI/GP
     245# We may try multiple builds with various CFLAGS, until we get a
     246# successful build.  If we do get a successful build, set
     247# $build_success to "yes"
     248build_success=no
     249if [ "x$SAGE_DEBUG" = xyes ]; then
     250    # Disable optimisation, add debug symbols.
     251    CFLAGS="$CFLAGS -O0 -g"
     252    echo "==========================================="
     253    echo "Building PARI/GP with optimization flag -O0"
     254    echo "==========================================="
     255    if build; then
     256        build_success=yes
     257    fi
     258else
     259    # First try -O3, then -O2 and so on until the build works.
     260    # This is mainly meant to work around compiler bugs.
     261    initial_CFLAGS="-g $CFLAGS"
     262    for optflag in -O3 -O2 -O1 -O0; do
     263        CFLAGS="$optflag $initial_CFLAGS"
     264        echo "==========================================="
     265        echo "Building PARI/GP with optimization flag $optflag"
     266        echo "==========================================="
     267        if build; then
     268            build_success=yes
     269            break
     270        fi
     271    done
     272fi
     273
     274if [ $build_success -ne yes ]; then
     275    echo >&2 "Error building PARI/GP"
     276    exit 1
     277fi
     278
     279# Install PARI/GP
     280install
     281
    299282
    300283# All (previous) errors are catched in build(), so we don't test $? here.
    301284# Although we perhaps should also check success of the numerous copy commands
  • spkg-make

    diff -r 66fcd4b37c83 spkg-make
    a b  
    2626#   mechanism very similar to "make svnsnapshot" from PARI.
    2727# * The files parisvn/galdata.tgz and parisvn/seadata-small.tgz are
    2828#   extracted.
    29 # * The patches in patches/*.patch are applied and the complete patched
    30 #   files are copied to patches/files
    3129#
    3230# AUTHOR: Jeroen Demeyer (July 2010)
    3331
     
    8280done
    8381
    8482
    85 # Run through the patches in patches/*.patch and prepare the patched
    86 # files in patches/files
    87 rm -rf ../patches/files
    88 mkdir ../patches/files
    89 for patch in ../patches/*.patch; do
    90         # Check that every patch file changes only one file
    91         numfilesinpatch=`grep -c -e '^+++ ' "$patch"`
    92         if [ "$numfilesinpatch" != "1" ]; then
    93                 echo "Bad patch file $patch.  It must patch exactly one file."
    94         fi
    95 
    96         srcfile=`sed -n 's|^+++ \([^\t]*\)\(\t.*\)\?|\1|p' "$patch"`
    97         outfile="../patches/files/`basename $srcfile`"
    98         patch -o "$outfile" -p0 <"$patch" || exit
    99         chmod "--reference=$srcfile" "$outfile"
    100 done
    101 
    102 
    10383# We're done!
    10484cd ..
    10585echo "======================================================"