Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / gnu / packages / sagemath.scm
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, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
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.
12 ;;;
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.
17 ;;;
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/>.
20
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))
40
41
42 (define-public python-cypari2
43 (package
44 (name "python-cypari2")
45 (version "2.1.1")
46 (source
47 (origin
48 (method url-fetch)
49 (uri (pypi-uri "cypari2" version))
50 (sha256
51 (base32
52 "1nwkzgqvbw6361x0rpggy1q5nx663fswhpvg8md6xhqyfwpgc7nz"))))
53 (build-system python-build-system)
54 (native-inputs
55 `(("python-cython" ,python-cython)))
56 (propagated-inputs
57 `(("python-cysignals" ,python-cysignals)))
58 (inputs
59 `(("gmp" ,gmp)
60 ("pari-gp", pari-gp)))
61 (home-page "https://cypari2.readthedocs.io/")
62 (synopsis
63 "Python interface to the number theory library libpari")
64 (description
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+)))
69
70 (define-public python2-cypari2
71 (package-with-python2 python-cypari2))
72
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
75 ;; release.
76 (define-public python-gmpy2
77 (package
78 (name "python-gmpy2")
79 (version "2.1.0b1")
80 (source (origin
81 (method git-fetch)
82 (uri (git-reference
83 (url "https://github.com/aleaxit/gmpy")
84 (commit (string-append "gmpy2-" version))))
85 (file-name (git-file-name name version))
86 (sha256
87 (base32
88 "0ljvnmhxqdfsp0yy4c2hynhk5sggm63kkqsq4iwq4k9vsnx2xm97"))))
89 (build-system python-build-system)
90 (native-inputs
91 `(("unzip" ,unzip)))
92 (inputs
93 `(("gmp" ,gmp)
94 ("mpfr" ,mpfr)
95 ("mpc" ,mpc)))
96 (home-page "https://github.com/aleaxit/gmpy")
97 (synopsis
98 "GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x")
99 (description
100 "This package provides a Python interface to the GNU multiprecision
101 libraries GMO, MPFR and MPC.")
102 (license license:lgpl3+)))
103
104 (define-public python2-gmpy2
105 (package-with-python2 python-gmpy2))
106
107 (define-public cliquer
108 (package
109 (name "cliquer")
110 (version "1.21")
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.
115 (source
116 (origin
117 (method url-fetch)
118 (uri "http://users.ox.ac.uk/~coml0531/sage/cliquer-1.21.tar.gz")
119 (sha256
120 (base32
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")))
132
133 (define-public libbraiding
134 (package
135 (name "libbraiding")
136 (version "1.0")
137 (source
138 (origin
139 (method git-fetch)
140 (uri (git-reference
141 (url (string-append "https://github.com/miguelmarco/"
142 name))
143 (commit version)))
144 (file-name (git-file-name name version))
145 (sha256
146 (base32
147 "0l68rikfr7k2l547gb3pp3g8cj5zzxwipm79xrb5r8ffj466ydxg"))))
148 (build-system gnu-build-system)
149 (native-inputs
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")))
158
159 (define-public libhomfly
160 (package
161 (name "libhomfly")
162 (version "1.02r6")
163 (source
164 (origin
165 (method git-fetch)
166 (uri (git-reference
167 (url (string-append "https://github.com/miguelmarco/"
168 name))
169 (commit version)))
170 (file-name (git-file-name name version))
171 (sha256
172 (base32
173 "0sv3cwrf9v9sb5a8wbhjmarxvya13ma3j8y8592f9ymxlk5y0ldk"))))
174 (build-system gnu-build-system)
175 (native-inputs
176 `(("autoconf" ,autoconf)
177 ("automake" ,automake)
178 ("libtool" ,libtool)))
179 (inputs
180 `(("libgc" ,libgc)))
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")))
186
187 ;; The following three packages from the Linbox group are needed in
188 ;; an outdated version for Sage.
189
190 (define-public givaro-4.0.4
191 (package (inherit givaro)
192 (name "givaro")
193 (version "4.0.4")
194 (source (origin
195 (method git-fetch)
196 (uri (git-reference
197 (url "https://github.com/linbox-team/givaro")
198 (commit (string-append "v" version))))
199 (file-name (git-file-name name version))
200 (sha256
201 (base32
202 "199p8wyj5i63jbnk7j8qbdbfp5rm2lpmcxyk3mdjy9bz7ygx3hhy"))))))
203
204 (define-public fflas-ffpack-2.3.2
205 (package (inherit fflas-ffpack)
206 (name "fflas-ffpack")
207 (version "2.3.2")
208 (source (origin
209 (method git-fetch)
210 (uri (git-reference
211 (url "https://github.com/linbox-team/fflas-ffpack")
212 (commit (string-append "v" version))))
213 (file-name (git-file-name name version))
214 (sha256
215 (base32
216 "1cqhassj2dny3gx0iywvmnpq8ca0d6m82xl5rz4mb8gaxr2kwddl"))))
217 (propagated-inputs
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.
221 (arguments
222 (substitute-keyword-arguments (package-arguments fflas-ffpack)
223 ((#:tests? _ #f) #f)))))
224
225 (define-public linbox-1.5.2
226 (package (inherit linbox)
227 (version "1.5.2")
228 (name "linbox")
229 (source (origin
230 (method git-fetch)
231 (uri (git-reference
232 (url "https://github.com/linbox-team/linbox")
233 (commit (string-append "v" version))))
234 (file-name (git-file-name name version))
235 (sha256
236 (base32
237 "1wfivlwp30mzdy1697w7rzb8caajim50mc8h27k82yipn2qc5n4i"))))
238 (inputs
239 `(("fflas-ffpack" ,fflas-ffpack-2.3.2)))))
240
241 (define-public pynac
242 (package
243 (name "pynac")
244 (version "0.7.26")
245 (source
246 (origin
247 (method git-fetch)
248 (uri (git-reference
249 (url "https://github.com/pynac/pynac/")
250 (commit (string-append "pynac-" version))))
251 (file-name (git-file-name name version))
252 (sha256
253 (base32 "09d2p74x1arkydlxy6pw4p4byi7r8q7f29w373h4d8a215kadc6d"))))
254 (build-system gnu-build-system)
255 (native-inputs
256 `(("autoconf" ,autoconf)
257 ("automake" ,automake)
258 ("libtool" ,libtool)
259 ("pkg-config" ,pkg-config)))
260 (inputs
261 `(("flint" ,flint)
262 ("gmp" ,gmp)
263 ("python" ,python)
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/")))
273
274 ;; Sage has become upstream of the following package.
275 (define-public zn-poly
276 (package
277 (name "zn-poly")
278 (version "0.9.2")
279 (source
280 (origin
281 (method git-fetch)
282 (uri (git-reference
283 (url (string-append "https://gitlab.com/sagemath/"
284 "zn_poly.git/"))
285 (commit version)))
286 (file-name (git-file-name "zn_poly" version))
287 (sha256
288 (base32 "1wbc3apxcldxfcw1dnwnn7fvlfb6bwvlr8glvgv6hf79p9r2s4j0"))))
289 (build-system gnu-build-system)
290 (native-inputs
291 `(("python" ,python-2)))
292 (inputs
293 `(("gmp" ,gmp)))
294 (arguments
295 `(#:phases
296 (modify-phases %standard-phases
297 (replace 'configure
298 ;; The configure script chokes on --enable-fast-install.
299 (lambda* (#:key inputs outputs #:allow-other-keys)
300 (invoke "./configure"
301 (string-append "--prefix=" (assoc-ref outputs "out"))
302 "--cflags=-O3 -fPIC")))
303 (add-before 'build 'prepare-build
304 (lambda _
305 (setenv "CC" "gcc")
306 #t))
307 (add-after 'build 'build-so
308 (lambda _
309 (invoke "make" "libzn_poly.so")))
310 (add-after 'install 'install-so
311 (lambda* (#:key outputs #:allow-other-keys)
312 (let* ((out (assoc-ref outputs "out"))
313 (lib (string-append out "/lib"))
314 (soname (string-append "libzn_poly-" ,version ".so"))
315 (target (string-append lib "/" soname)))
316 (install-file "libzn_poly.a" lib)
317 (install-file soname lib)
318 (symlink target
319 (string-append lib "/libzn_poly.so"))
320 (symlink target
321 (string-append lib "/libzn_poly-"
322 ,(version-major+minor version)
323 ".so")))
324 #t)))))
325 (synopsis "Arithmetic for polynomials over Z/NZ")
326 (description "zn_poly implements the arithmetic of polynomials the
327 coefficients of which are modular integers.")
328 (license (list license:gpl2 license:gpl3)) ; dual licensed
329 (home-page "https://gitlab.com/sagemath/zn_poly")))
330
331 (define-public brial
332 (package
333 (name "brial")
334 (version "1.2.6")
335 (source
336 (origin
337 (method git-fetch)
338 (uri (git-reference
339 (url "https://github.com/BRiAl/BRiAl/")
340 (commit version)))
341 (file-name (git-file-name name version))
342 (sha256
343 (base32 "1mc1zjr3mxcx6bg0js5k9jx65japg7644b0aj1al75m4nwh2ygab"))))
344 (build-system gnu-build-system)
345 (native-inputs
346 `(("autoconf" ,autoconf)
347 ("automake" ,automake)
348 ("libtool" ,libtool)
349 ("pkg-config" ,pkg-config)))
350 (inputs
351 `(("boost" ,boost)
352 ("libpng" ,libpng)
353 ("m4ri" ,m4ri)))
354 (arguments
355 ;; We are missing the boost unit test framework.
356 `(#:tests? #f
357 #:configure-flags (list "--without-boost-unit-test-framework")))
358 (synopsis "Arithmetic of polynomials over boolean rings")
359 (description "BRiAl is the successor to PolyBoRi maintained by the
360 Sage community. Its core is a C++ library, which provides high-level data
361 types for Boolean polynomials and monomials, exponent vectors, as well as
362 for the underlying polynomial rings and subsets of the powerset of the
363 Boolean variables. As a unique approach, binary decision diagrams are
364 used as internal storage type for polynomial structures.")
365 (license license:gpl2+)
366 (home-page "https://github.com/BRiAl/BRiAl/")))
367
368 (define-public lcalc
369 (package
370 (name "lcalc")
371 (version "1.23")
372 ;; The original home page of the project has disappeared, as well as
373 ;; code hosted by the original author on Google Code. The latter has
374 ;; been copied to gitlab.com/sagemath and purportedly contains patches
375 ;; for a never released version 1.3, that supposedly follows 1.23.
376 ;; We use the tarball as well as the patches hosted inside the sage
377 ;; package system distributed with the sage tarball.
378 (source
379 (origin
380 (method url-fetch)
381 (uri (string-append "ftp://ftp.fu-berlin.de/unix/misc/sage/spkg/"
382 "upstream/lcalc/lcalc-1.23.tar.bz2"))
383 (sha256
384 (base32
385 "1c6dsdshgxhqppjxvxhp8yhpxaqvnz3d1mlh26r571gkq8z2bm43"))
386 (patches (search-patches "lcalc-lcommon-h.patch"
387 "lcalc-default-parameters-1.patch"
388 "lcalc-default-parameters-2.patch"
389 "lcalc-using-namespace-std.patch"))))
390 (build-system gnu-build-system)
391 (arguments
392 `(#:tests? #f ;no tests
393 #:phases
394 (modify-phases %standard-phases
395 (delete 'configure)
396 (add-before 'build 'prepare-build
397 (lambda* (#:key outputs #:allow-other-keys)
398 (chdir "src")
399 (let ((out (assoc-ref outputs "out")))
400 (substitute* "Makefile"
401 (("^INSTALL_DIR= /usr/local")
402 (string-append "INSTALL_DIR=" out))
403 ;; Sage renames the include directory, so we do it also.
404 (("include/Lfunction")
405 "include/libLfunction")))
406 #t))
407 (add-before 'install 'make-output-dirs
408 (lambda* (#:key outputs #:allow-other-keys)
409 (let* ((out (assoc-ref outputs "out"))
410 (bin (string-append out "/bin"))
411 (lib (string-append out "/lib"))
412 (include (string-append out "/include")))
413 (mkdir-p bin)
414 (mkdir-p lib)
415 (mkdir-p include))
416 #t)))))
417 ;; FIXME:
418 ;; We need to add pari-gp and probably pari related patches from the
419 ;; sage project, as well as uncomment the line setting PARI_DEFINE in
420 ;; the Makefile to get the full functionality of this package.
421 ;; For the time being, we hope that sage can be compiled without.
422 (synopsis "C++ library for L-functions")
423 (description "Lcalc computes L-functions, in particular the Riemann
424 zeta function and its twists by quadratic characters.")
425 (license license:gpl2+)
426 (home-page "https://gitlab.com/sagemath/sage")))
427
428 (define-public ratpoints
429 (package
430 (name "ratpoints")
431 (version "2.1.3")
432 (source (origin
433 (method url-fetch)
434 (uri (string-append
435 "http://www.mathe2.uni-bayreuth.de/stoll/programs/"
436 "ratpoints-" version ".tar.gz"))
437 (sha256
438 (base32
439 "0zhad84sfds7izyksbqjmwpfw4rvyqk63yzdjd3ysd32zss5bgf4"))
440 (patches
441 ;; Taken from
442 ;; <https://git.sagemath.org/sage.git/plain/build/pkgs/ratpoints/patches/>
443 (search-patches "ratpoints-sturm_and_rp_private.patch"))))
444 (build-system gnu-build-system)
445 (arguments
446 `(#:test-target "test"
447 #:make-flags
448 (list (string-append "INSTALL_DIR=" (assoc-ref %outputs "out"))
449 "CCFLAGS=-fPIC")
450 #:phases
451 (modify-phases %standard-phases
452 (delete 'configure) ;no configure script
453 (add-before 'install 'create-install-directories
454 (lambda* (#:key outputs #:allow-other-keys)
455 (let ((out (assoc-ref outputs "out")))
456 (mkdir-p out)
457 (with-directory-excursion out
458 (for-each (lambda (d) (mkdir-p d))
459 '("bin" "include" "lib"))))
460 #t)))))
461 (inputs
462 `(("gmp" ,gmp)))
463 (home-page "http://www.mathe2.uni-bayreuth.de/stoll/programs/")
464 (synopsis "Find rational points on hyperelliptic curves")
465 (description "Ratpoints tries to find all rational points within
466 a given height bound on a hyperelliptic curve in a very efficient way,
467 by using an optimized quadratic sieve algorithm.")
468 (license license:gpl2+)))