about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/math/pari
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/applications/science/math/pari')
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/default.nix91
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/gp2c.nix28
-rw-r--r--nixpkgs/pkgs/applications/science/math/pari/rnfdisc.patch51
3 files changed, 170 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/applications/science/math/pari/default.nix b/nixpkgs/pkgs/applications/science/math/pari/default.nix
new file mode 100644
index 000000000000..fc1a2e0abf8c
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/default.nix
@@ -0,0 +1,91 @@
+{ lib, stdenv
+, fetchurl
+, gmp
+, readline
+, libX11
+, tex
+, perl
+, withThread ? true, libpthreadstubs
+}:
+
+assert withThread -> libpthreadstubs != null;
+
+stdenv.mkDerivation rec {
+  pname = "pari";
+  version = "2.13.1";
+
+  src = fetchurl {
+    urls = [
+      "https://pari.math.u-bordeaux.fr/pub/pari/unix/${pname}-${version}.tar.gz"
+      # old versions are at the url below
+      "https://pari.math.u-bordeaux.fr/pub/pari/OLD/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz"
+    ];
+    sha256 = "sha256-gez31wzNquIwFlz/Ynyc4uwpe48i+fQHQiedhfht/LE=";
+  };
+
+  patches = [
+    # rebased version of 3edb98db78, see
+    # https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2284
+    ./rnfdisc.patch
+  ];
+
+  buildInputs = [
+    gmp
+    readline
+    libX11
+    tex
+    perl
+  ] ++ lib.optionals withThread [
+    libpthreadstubs
+  ];
+
+  configureScript = "./Configure";
+  configureFlags = [
+    "--with-gmp=${gmp.dev}"
+    "--with-readline=${readline.dev}"
+  ] ++ lib.optional stdenv.isDarwin "--host=x86_64-darwin"
+  ++ lib.optional withThread "--mt=pthread";
+
+  preConfigure = ''
+    export LD=$CC
+  '';
+
+  postConfigure = lib.optionalString stdenv.isDarwin ''
+    echo 'echo x86_64-darwin' > config/arch-osname
+  '';
+
+  makeFlags = [ "all" ];
+
+  meta = with lib; {
+    description = "Computer algebra system for high-performance number theory computations";
+    longDescription = ''
+       PARI/GP is a widely used computer algebra system designed for fast
+       computations in number theory (factorizations, algebraic number theory,
+       elliptic curves...), but also contains a large number of other useful
+       functions to compute with mathematical entities such as matrices,
+       polynomials, power series, algebraic numbers etc., and a lot of
+       transcendental functions. PARI is also available as a C library to allow
+       for faster computations.
+
+       Originally developed by Henri Cohen and his co-workers (Université
+       Bordeaux I, France), PARI is now under the GPL and maintained by Karim
+       Belabas with the help of many volunteer contributors.
+
+       - PARI is a C library, allowing fast computations.
+       - gp is an easy-to-use interactive shell giving access to the PARI
+         functions.
+       - GP is the name of gp's scripting language.
+       - gp2c, the GP-to-C compiler, combines the best of both worlds by
+         compiling GP scripts to the C language and transparently loading the
+         resulting functions into gp. (gp2c-compiled scripts will typically run
+         3 or 4 times faster.) gp2c currently only understands a subset of the
+         GP language.
+    '';
+    homepage = "http://pari.math.u-bordeaux.fr";
+    downloadPage = "http://pari.math.u-bordeaux.fr/download.html";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ ertes AndersonTorres ] ++ teams.sage.members;
+    platforms = platforms.linux ++ platforms.darwin;
+    updateWalker = true;
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix b/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix
new file mode 100644
index 000000000000..23183f83b36b
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/gp2c.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv
+, pari
+, fetchurl
+, perl }:
+
+stdenv.mkDerivation rec {
+  pname = "gp2c";
+  version = "0.0.12";
+
+  src = fetchurl {
+    url = "https://pari.math.u-bordeaux.fr/pub/pari/GP2C/${pname}-${version}.tar.gz";
+    sha256 = "039ip7qkwwv46wrcdrz7y12m30kazzkjr44kqbc0h137g4wzd7zf";
+  };
+
+  buildInputs = [ pari perl ];
+
+  configureFlags = [
+    "--with-paricfg=${pari}/lib/pari/pari.cfg"
+    "--with-perl=${perl}/bin/perl" ];
+
+  meta = with lib; {
+    description =  "A compiler to translate GP scripts to PARI programs";
+    homepage = "http://pari.math.u-bordeaux.fr/";
+    downloadPage = "http://pari.math.u-bordeaux.fr/download.html";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+  };
+}
diff --git a/nixpkgs/pkgs/applications/science/math/pari/rnfdisc.patch b/nixpkgs/pkgs/applications/science/math/pari/rnfdisc.patch
new file mode 100644
index 000000000000..6acac96481d5
--- /dev/null
+++ b/nixpkgs/pkgs/applications/science/math/pari/rnfdisc.patch
@@ -0,0 +1,51 @@
+commit 0d8a3ac970291c62b56104172418b3f2ca30927c
+Author: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
+Date:   Sun Mar 28 13:27:24 2021 +0200
+
+    rnfdisc_factored: remove spurious Q_primpart [#2284]
+
+diff --git a/src/basemath/base2.c b/src/basemath/base2.c
+index 7e7d0db9d..c461826f4 100644
+--- a/src/basemath/base2.c
++++ b/src/basemath/base2.c
+@@ -3582,7 +3582,7 @@ rnfdisc_factored(GEN nf, GEN pol, GEN *pd)
+ 
+   nf = checknf(nf);
+   pol = rnfdisc_get_T(nf, pol, &lim);
+-  disc = nf_to_scalar_or_basis(nf, nfX_disc(nf, Q_primpart(pol)));
++  disc = nf_to_scalar_or_basis(nf, nfX_disc(nf, pol));
+   pol = nfX_to_monic(nf, pol, NULL);
+   fa = idealfactor_partial(nf, disc, lim);
+   P = gel(fa,1); l = lg(P);
+diff --git a/src/test/32/rnf b/src/test/32/rnf
+index 1e743f415..c016dce00 100644
+--- a/src/test/32/rnf
++++ b/src/test/32/rnf
+@@ -853,9 +853,10 @@ error("inconsistent dimensions in idealtwoelt.")
+ 0
+ 0
+ 1
+-[[7361, 3786, 318, 5823; 0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1], [-3, 6, -2, 0]
+-~]
+-[2, -1]
++[[433, 322, 318, 1318/17; 0, 1, 0, 12/17; 0, 0, 1, 5/17; 0, 0, 0, 1/17], [25
++/17, -12/17, 12/17, 16/17]~]
++[1, -1]
++[[12, 0, 0, 0; 0, 12, 4, 0; 0, 0, 4, 0; 0, 0, 0, 4], [6, 5, -1, 2]~]
+   ***   at top-level: rnfdedekind(nf,P,pr2,1)
+   ***                 ^-----------------------
+   *** rnfdedekind: sorry, Dedekind in the difficult case is not yet implemented.
+diff --git a/src/test/in/rnf b/src/test/in/rnf
+index 7851ae291..318d5349e 100644
+--- a/src/test/in/rnf
++++ b/src/test/in/rnf
+@@ -212,6 +212,9 @@ k = nfinit(y^4 + 10*y^2 + 17);
+ rnfdisc(k, x^2 - x + 1/Mod(y,k.pol))
+ rnfdisc(k, x^2 - x + 1/2)
+ 
++k = nfinit(y^4 - 10*y^2 + 1);
++rnfdisc(k,x^2-(y^3/2+y^2-5*y/2+1))
++
+ \\ ERRORS, keep at end of file
+ rnfdedekind(nf, P, pr2, 1)
+ rnfdedekind(nf, P)