34fe9e524c837aef758c14f3bf50b71c93ff0a6e
[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 (define-public pynac
188 (package
189 (name "pynac")
190 (version "0.7.26")
191 (source
192 (origin
193 (method git-fetch)
194 (uri (git-reference
195 (url "https://github.com/pynac/pynac/")
196 (commit (string-append "pynac-" version))))
197 (file-name (git-file-name name version))
198 (sha256
199 (base32 "09d2p74x1arkydlxy6pw4p4byi7r8q7f29w373h4d8a215kadc6d"))))
200 (build-system gnu-build-system)
201 (native-inputs
202 `(("autoconf" ,autoconf)
203 ("automake" ,automake)
204 ("libtool" ,libtool)
205 ("pkg-config" ,pkg-config)))
206 (inputs
207 `(("flint" ,flint)
208 ("gmp" ,gmp)
209 ("python" ,python)
210 ("singular" ,singular)))
211 (synopsis "Sage fork of GiNaC")
212 (description "Pynac is a derivative of the C++ library GiNaC, which
213 allows manipulation of symbolic expressions. It currently provides the
214 backend for symbolic expressions in Sage. The main difference between
215 Pynac and GiNaC is that Pynac relies on Sage to provide the operations
216 on numerical types, while GiNaC depends on CLN for this purpose.")
217 (license license:gpl2+)
218 (home-page "http://pynac.org/")))
219
220 ;; Sage has become upstream of the following package.
221 (define-public zn-poly
222 (package
223 (name "zn-poly")
224 (version "0.9.2")
225 (source
226 (origin
227 (method git-fetch)
228 (uri (git-reference
229 (url (string-append "https://gitlab.com/sagemath/"
230 "zn_poly.git/"))
231 (commit version)))
232 (file-name (git-file-name "zn_poly" version))
233 (sha256
234 (base32 "1wbc3apxcldxfcw1dnwnn7fvlfb6bwvlr8glvgv6hf79p9r2s4j0"))))
235 (build-system gnu-build-system)
236 (native-inputs
237 `(("python" ,python-2)))
238 (inputs
239 `(("gmp" ,gmp)))
240 (arguments
241 `(#:phases
242 (modify-phases %standard-phases
243 (replace 'configure
244 ;; The configure script chokes on --enable-fast-install.
245 (lambda* (#:key inputs outputs #:allow-other-keys)
246 (invoke "./configure"
247 (string-append "--prefix=" (assoc-ref outputs "out"))
248 "--cflags=-O3 -fPIC")))
249 (add-before 'build 'prepare-build
250 (lambda _
251 (setenv "CC" "gcc")
252 #t))
253 (add-after 'build 'build-so
254 (lambda _
255 (invoke "make" "libzn_poly.so")))
256 (add-after 'install 'install-so
257 (lambda* (#:key outputs #:allow-other-keys)
258 (let* ((out (assoc-ref outputs "out"))
259 (lib (string-append out "/lib"))
260 (soname (string-append "libzn_poly-" ,version ".so"))
261 (target (string-append lib "/" soname)))
262 (install-file "libzn_poly.a" lib)
263 (install-file soname lib)
264 (symlink target
265 (string-append lib "/libzn_poly.so"))
266 (symlink target
267 (string-append lib "/libzn_poly-"
268 ,(version-major+minor version)
269 ".so")))
270 #t)))))
271 (synopsis "Arithmetic for polynomials over Z/NZ")
272 (description "zn_poly implements the arithmetic of polynomials the
273 coefficients of which are modular integers.")
274 (license (list license:gpl2 license:gpl3)) ; dual licensed
275 (home-page "https://gitlab.com/sagemath/zn_poly")))
276
277 (define-public brial
278 (package
279 (name "brial")
280 (version "1.2.8")
281 (source
282 (origin
283 (method git-fetch)
284 (uri (git-reference
285 (url "https://github.com/BRiAl/BRiAl/")
286 (commit version)))
287 (file-name (git-file-name name version))
288 (sha256
289 (base32 "0qhgckd4fvbs40jw14mvw89rccv94d3df27kipd27hxd4cx7y80y"))))
290 (build-system gnu-build-system)
291 (native-inputs
292 `(("autoconf" ,autoconf)
293 ("automake" ,automake)
294 ("libtool" ,libtool)
295 ("pkg-config" ,pkg-config)))
296 (inputs
297 `(("boost" ,boost)
298 ("libpng" ,libpng)
299 ("m4ri" ,m4ri)))
300 (arguments
301 ;; We are missing the boost unit test framework.
302 `(#:tests? #f
303 #:configure-flags (list "--without-boost-unit-test-framework")))
304 (synopsis "Arithmetic of polynomials over boolean rings")
305 (description "BRiAl is the successor to PolyBoRi maintained by the
306 Sage community. Its core is a C++ library, which provides high-level data
307 types for Boolean polynomials and monomials, exponent vectors, as well as
308 for the underlying polynomial rings and subsets of the powerset of the
309 Boolean variables. As a unique approach, binary decision diagrams are
310 used as internal storage type for polynomial structures.")
311 (license license:gpl2+)
312 (home-page "https://github.com/BRiAl/BRiAl/")))
313
314 (define-public lcalc
315 (package
316 (name "lcalc")
317 (version "1.23")
318 ;; The original home page of the project has disappeared, as well as
319 ;; code hosted by the original author on Google Code. The latter has
320 ;; been copied to gitlab.com/sagemath and purportedly contains patches
321 ;; for a never released version 1.3, that supposedly follows 1.23.
322 ;; We use the tarball as well as the patches hosted inside the sage
323 ;; package system distributed with the sage tarball.
324 (source
325 (origin
326 (method url-fetch)
327 (uri (string-append "ftp://ftp.fu-berlin.de/unix/misc/sage/spkg/"
328 "upstream/lcalc/lcalc-1.23.tar.bz2"))
329 (sha256
330 (base32
331 "1c6dsdshgxhqppjxvxhp8yhpxaqvnz3d1mlh26r571gkq8z2bm43"))
332 (patches (search-patches "lcalc-lcommon-h.patch"
333 "lcalc-default-parameters-1.patch"
334 "lcalc-default-parameters-2.patch"
335 "lcalc-using-namespace-std.patch"))))
336 (build-system gnu-build-system)
337 (arguments
338 `(#:tests? #f ;no tests
339 #:phases
340 (modify-phases %standard-phases
341 (delete 'configure)
342 (add-before 'build 'prepare-build
343 (lambda* (#:key outputs #:allow-other-keys)
344 (chdir "src")
345 (let ((out (assoc-ref outputs "out")))
346 (substitute* "Makefile"
347 (("^INSTALL_DIR= /usr/local")
348 (string-append "INSTALL_DIR=" out))
349 ;; Sage renames the include directory, so we do it also.
350 (("include/Lfunction")
351 "include/libLfunction")))
352 #t))
353 (add-before 'install 'make-output-dirs
354 (lambda* (#:key outputs #:allow-other-keys)
355 (let* ((out (assoc-ref outputs "out"))
356 (bin (string-append out "/bin"))
357 (lib (string-append out "/lib"))
358 (include (string-append out "/include")))
359 (mkdir-p bin)
360 (mkdir-p lib)
361 (mkdir-p include))
362 #t)))))
363 ;; FIXME:
364 ;; We need to add pari-gp and probably pari related patches from the
365 ;; sage project, as well as uncomment the line setting PARI_DEFINE in
366 ;; the Makefile to get the full functionality of this package.
367 ;; For the time being, we hope that sage can be compiled without.
368 (synopsis "C++ library for L-functions")
369 (description "Lcalc computes L-functions, in particular the Riemann
370 zeta function and its twists by quadratic characters.")
371 (license license:gpl2+)
372 (home-page "https://gitlab.com/sagemath/sage")))
373
374 (define-public ratpoints
375 (package
376 (name "ratpoints")
377 (version "2.1.3")
378 (source (origin
379 (method url-fetch)
380 (uri (string-append
381 "http://www.mathe2.uni-bayreuth.de/stoll/programs/"
382 "ratpoints-" version ".tar.gz"))
383 (sha256
384 (base32
385 "0zhad84sfds7izyksbqjmwpfw4rvyqk63yzdjd3ysd32zss5bgf4"))
386 (patches
387 ;; Taken from
388 ;; <https://git.sagemath.org/sage.git/plain/build/pkgs/ratpoints/patches/>
389 (search-patches "ratpoints-sturm_and_rp_private.patch"))))
390 (build-system gnu-build-system)
391 (arguments
392 `(#:test-target "test"
393 #:make-flags
394 (list (string-append "INSTALL_DIR=" (assoc-ref %outputs "out"))
395 "CCFLAGS=-fPIC")
396 #:phases
397 (modify-phases %standard-phases
398 (delete 'configure) ;no configure script
399 (add-before 'install 'create-install-directories
400 (lambda* (#:key outputs #:allow-other-keys)
401 (let ((out (assoc-ref outputs "out")))
402 (mkdir-p out)
403 (with-directory-excursion out
404 (for-each (lambda (d) (mkdir-p d))
405 '("bin" "include" "lib"))))
406 #t)))))
407 (inputs
408 `(("gmp" ,gmp)))
409 (home-page "http://www.mathe2.uni-bayreuth.de/stoll/programs/")
410 (synopsis "Find rational points on hyperelliptic curves")
411 (description "Ratpoints tries to find all rational points within
412 a given height bound on a hyperelliptic curve in a very efficient way,
413 by using an optimized quadratic sieve algorithm.")
414 (license license:gpl2+)))