1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr>
4 ;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages sagemath)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix build-system gnu)
24 #:use-module (guix build-system python)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix packages)
28 #:use-module (guix utils)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages algebra)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages bdw-gc)
33 #:use-module (gnu packages boost)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages multiprecision)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages python-xyz))
42 (define-public python-cypari2
44 (name "python-cypari2")
49 (uri (pypi-uri "cypari2" version))
52 "1nwkzgqvbw6361x0rpggy1q5nx663fswhpvg8md6xhqyfwpgc7nz"))))
53 (build-system python-build-system)
55 `(("python-cython" ,python-cython)))
57 `(("python-cysignals" ,python-cysignals)))
60 ("pari-gp", pari-gp)))
61 (home-page "https://cypari2.readthedocs.io/")
63 "Python interface to the number theory library libpari")
65 "Cypari2 provides a Python interface to the number theory library
66 PARI/GP. It has been spun off from the SageMath mathematics software system,
67 but it can be used independently.")
68 (license license:gpl2+)))
70 (define-public python2-cypari2
71 (package-with-python2 python-cypari2))
73 ;; The stable version of the following package is not young enough to be
74 ;; used with Sage, since it does not support cython; so we use a beta
76 (define-public python-gmpy2
83 (url "https://github.com/aleaxit/gmpy")
84 (commit (string-append "gmpy2-" version))))
85 (file-name (git-file-name name version))
88 "0ljvnmhxqdfsp0yy4c2hynhk5sggm63kkqsq4iwq4k9vsnx2xm97"))))
89 (build-system python-build-system)
96 (home-page "https://github.com/aleaxit/gmpy")
98 "GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x")
100 "This package provides a Python interface to the GNU multiprecision
101 libraries GMO, MPFR and MPC.")
102 (license license:lgpl3+)))
104 (define-public python2-gmpy2
105 (package-with-python2 python-gmpy2))
107 (define-public cliquer
111 ;; The original source package is available from the home page and
112 ;; has not seen any release since 2010; it comes with only a Makefile
113 ;; without an "install" target. Instead, there is an autotoolized
114 ;; tarball available from the Sage project.
118 (uri "http://users.ox.ac.uk/~coml0531/sage/cliquer-1.21.tar.gz")
121 "1hdzrmrx0nvvj8kbwxrs8swqgkd284khzl623jizixcv28xb77aq"))))
122 (build-system gnu-build-system)
123 (synopsis "C routines for finding cliques in weighted graphs")
124 (description "Cliquer is a set of reentrant C routines for finding
125 cliques in a weighted or unweighted graph. It uses an exact
126 branch-and-bound algorithm. It can search for maximum or maximum-weight
127 cliques or cliques with size or weight within a given range, restrict the
128 search to maximal cliques, store cliques in memory and call a user-defined
129 function for every found clique.")
130 (license license:gpl2+)
131 (home-page "https://users.aalto.fi/~pat/cliquer.html")))
133 (define-public libbraiding
141 (url (string-append "https://github.com/miguelmarco/"
144 (file-name (git-file-name name version))
147 "0l68rikfr7k2l547gb3pp3g8cj5zzxwipm79xrb5r8ffj466ydxg"))))
148 (build-system gnu-build-system)
150 `(("autoconf" ,autoconf)
151 ("automake" ,automake)
152 ("libtool" ,libtool)))
153 (synopsis "Computations with braid groups")
154 (description "libbraiding performs computations with braid groups,
155 in particular it computes normal forms of group elements.")
156 (license license:gpl2+)
157 (home-page "https://github.com/miguelmarco/libbraiding")))
159 (define-public libhomfly
167 (url (string-append "https://github.com/miguelmarco/"
170 (file-name (git-file-name name version))
173 "0sv3cwrf9v9sb5a8wbhjmarxvya13ma3j8y8592f9ymxlk5y0ldk"))))
174 (build-system gnu-build-system)
176 `(("autoconf" ,autoconf)
177 ("automake" ,automake)
178 ("libtool" ,libtool)))
181 (synopsis "Computation of homfly polynomials of links")
182 (description "libhomfly computes homfly polynomials of links,
183 represented as strings.")
184 (license license:public-domain)
185 (home-page "https://github.com/miguelmarco/libhomfly")))
187 ;; The following three packages from the Linbox group are needed in
188 ;; an outdated version for Sage.
190 (define-public givaro-4.0.4
191 (package (inherit givaro)
197 (url "https://github.com/linbox-team/givaro")
198 (commit (string-append "v" version))))
199 (file-name (git-file-name name version))
202 "199p8wyj5i63jbnk7j8qbdbfp5rm2lpmcxyk3mdjy9bz7ygx3hhy"))))))
204 (define-public fflas-ffpack-2.3.2
205 (package (inherit fflas-ffpack)
206 (name "fflas-ffpack")
211 (url "https://github.com/linbox-team/fflas-ffpack")
212 (commit (string-append "v" version))))
213 (file-name (git-file-name name version))
216 "1cqhassj2dny3gx0iywvmnpq8ca0d6m82xl5rz4mb8gaxr2kwddl"))))
218 `(("givaro" ,givaro-4.0.4)))
219 ;; A test fails, but since all tests pass in the latest version,
220 ;; there is not much point in investigating.
222 (substitute-keyword-arguments (package-arguments fflas-ffpack)
223 ((#:tests? _ #f) #f)))))
225 (define-public linbox-1.5.2
226 (package (inherit linbox)
232 (url "https://github.com/linbox-team/linbox")
233 (commit (string-append "v" version))))
234 (file-name (git-file-name name version))
237 "1wfivlwp30mzdy1697w7rzb8caajim50mc8h27k82yipn2qc5n4i"))))
239 `(("fflas-ffpack" ,fflas-ffpack-2.3.2)))))
249 (url "https://github.com/pynac/pynac/")
250 (commit (string-append "pynac-" version))))
251 (file-name (git-file-name name version))
253 (base32 "09d2p74x1arkydlxy6pw4p4byi7r8q7f29w373h4d8a215kadc6d"))))
254 (build-system gnu-build-system)
256 `(("autoconf" ,autoconf)
257 ("automake" ,automake)
259 ("pkg-config" ,pkg-config)))
264 ("singular" ,singular)))
265 (synopsis "Sage fork of GiNaC")
266 (description "Pynac is a derivative of the C++ library GiNaC, which
267 allows manipulation of symbolic expressions. It currently provides the
268 backend for symbolic expressions in Sage. The main difference between
269 Pynac and GiNaC is that Pynac relies on Sage to provide the operations
270 on numerical types, while GiNaC depends on CLN for this purpose.")
271 (license license:gpl2+)
272 (home-page "http://pynac.org/")))
274 ;; Sage has become upstream of the following package.
275 (define-public zn-poly
283 (url (string-append "https://gitlab.com/sagemath/"
286 (file-name (git-file-name "zn_poly" version))
289 "0ra5vy585bqq7g3317iw6fp44iqgqvds3j0l1va6mswimypq4vxb"))))
290 (build-system gnu-build-system)
292 `(("python" ,python-2)))
297 (modify-phases %standard-phases
299 ;; The configure script chokes on --enable-fast-install.
300 (lambda* (#:key inputs outputs #:allow-other-keys)
301 (invoke "./configure"
302 (string-append "--prefix=" (assoc-ref outputs "out"))
303 "--cflags=-O3 -fPIC")))
304 (add-before 'build 'prepare-build
308 (add-after 'build 'build-so
310 (invoke "make" "libzn_poly.so")))
311 (add-after 'install 'install-so
312 (lambda* (#:key outputs #:allow-other-keys)
313 (let* ((out (assoc-ref outputs "out"))
314 (lib (string-append out "/lib"))
315 (soname (string-append "libzn_poly-" ,version ".so"))
316 (target (string-append lib "/" soname)))
317 (install-file "libzn_poly.a" lib)
318 (install-file soname lib)
320 (string-append lib "/libzn_poly.so"))
322 (string-append lib "/libzn_poly-"
323 ,(version-major+minor version)
326 (synopsis "Arithmetic for polynomials over Z/NZ")
327 (description "zn_poly implements the arithmetic of polynomials the
328 coefficients of which are modular integers.")
329 (license (list license:gpl2 license:gpl3)) ; dual licensed
330 (home-page "https://gitlab.com/sagemath/zn_poly")))
340 (url "https://github.com/BRiAl/BRiAl/")
342 (file-name (git-file-name name version))
345 "1nv56fp3brpzanxj7vwvxqdafqfsfhdgq5imr3m94psw5gdfqwja"))))
346 (build-system gnu-build-system)
348 `(("autoconf" ,autoconf)
349 ("automake" ,automake)
351 ("pkg-config" ,pkg-config)))
357 ;; We are missing the boost unit test framework.
359 #:configure-flags (list "--without-boost-unit-test-framework")))
360 (synopsis "Arithmetic of polynomials over boolean rings")
361 (description "BRiAl is the successor to PolyBoRi maintained by the
362 Sage community. Its core is a C++ library, which provides high-level data
363 types for Boolean polynomials and monomials, exponent vectors, as well as
364 for the underlying polynomial rings and subsets of the powerset of the
365 Boolean variables. As a unique approach, binary decision diagrams are
366 used as internal storage type for polynomial structures.")
367 (license license:gpl2+)
368 (home-page "https://gitlab.com/sagemath/zn_poly")))
374 ;; The original home page of the project has disappeared, as well as
375 ;; code hosted by the original author on Google Code. The latter has
376 ;; been copied to gitlab.com/sagemath and purportedly contains patches
377 ;; for a never released version 1.3, that supposedly follows 1.23.
378 ;; We use the tarball as well as the patches hosted inside the sage
379 ;; package system distributed with the sage tarball.
383 (uri (string-append "ftp://ftp.fu-berlin.de/unix/misc/sage/spkg/"
384 "upstream/lcalc/lcalc-1.23.tar.bz2"))
387 "1c6dsdshgxhqppjxvxhp8yhpxaqvnz3d1mlh26r571gkq8z2bm43"))
388 (patches (search-patches "lcalc-lcommon-h.patch"
389 "lcalc-default-parameters-1.patch"
390 "lcalc-default-parameters-2.patch"
391 "lcalc-using-namespace-std.patch"))))
392 (build-system gnu-build-system)
394 `(#:tests? #f ;no tests
396 (modify-phases %standard-phases
398 (add-before 'build 'prepare-build
399 (lambda* (#:key outputs #:allow-other-keys)
401 (let ((out (assoc-ref outputs "out")))
402 (substitute* "Makefile"
403 (("^INSTALL_DIR= /usr/local")
404 (string-append "INSTALL_DIR=" out))
405 ;; Sage renames the include directory, so we do it also.
406 (("include/Lfunction")
407 "include/libLfunction")))
409 (add-before 'install 'make-output-dirs
410 (lambda* (#:key outputs #:allow-other-keys)
411 (let* ((out (assoc-ref outputs "out"))
412 (bin (string-append out "/bin"))
413 (lib (string-append out "/lib"))
414 (include (string-append out "/include")))
420 ;; We need to add pari-gp and probably pari related patches from the
421 ;; sage project, as well as uncomment the line setting PARI_DEFINE in
422 ;; the Makefile to get the full functionality of this package.
423 ;; For the time being, we hope that sage can be compiled without.
424 (synopsis "C++ library for L-functions")
425 (description "Lcalc computes L-functions, in particular the Riemann
426 zeta function and its twists by quadratic characters.")
427 (license license:gpl2+)
428 (home-page "https://gitlab.com/sagemath/sage")))
430 (define-public ratpoints
437 "http://www.mathe2.uni-bayreuth.de/stoll/programs/"
438 "ratpoints-" version ".tar.gz"))
441 "0zhad84sfds7izyksbqjmwpfw4rvyqk63yzdjd3ysd32zss5bgf4"))
444 ;; <https://git.sagemath.org/sage.git/plain/build/pkgs/ratpoints/patches/>
445 (search-patches "ratpoints-sturm_and_rp_private.patch"))))
446 (build-system gnu-build-system)
448 `(#:test-target "test"
450 (list (string-append "INSTALL_DIR=" (assoc-ref %outputs "out"))
453 (modify-phases %standard-phases
454 (delete 'configure) ;no configure script
455 (add-before 'install 'create-install-directories
456 (lambda* (#:key outputs #:allow-other-keys)
457 (let ((out (assoc-ref outputs "out")))
459 (with-directory-excursion out
460 (for-each (lambda (d) (mkdir-p d))
461 '("bin" "include" "lib"))))
465 (home-page "http://www.mathe2.uni-bayreuth.de/stoll/programs/")
466 (synopsis "Find rational points on hyperelliptic curves")
467 (description "Ratpoints tries to find all rational points within
468 a given height bound on a hyperelliptic curve in a very efficient way,
469 by using an optimized quadratic sieve algorithm.")
470 (license license:gpl2+)))