gnu: flint: Rewrite using the modify-phases syntax.
[jackhill/guix/guix.git] / gnu / packages / algebra.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
bbea9565 2;;; Copyright © 2012, 2013, 2014, 2015 Andreas Enge <andreas@enge.fr>
8f4b1dfb 3;;; Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org>
e2ca23c5 4;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
2ed139c4 5;;;
233e7676 6;;; This file is part of GNU Guix.
2ed139c4 7;;;
233e7676 8;;; GNU Guix is free software; you can redistribute it and/or modify it
2ed139c4
AE
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;;;
233e7676 13;;; GNU Guix is distributed in the hope that it will be useful, but
2ed139c4
AE
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
233e7676 19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
2ed139c4 20
1ffa7090 21(define-module (gnu packages algebra)
59a43334 22 #:use-module (gnu packages)
10b1f688 23 #:use-module (gnu packages compression)
1ffa7090 24 #:use-module (gnu packages multiprecision)
0fc54d4b 25 #:use-module (gnu packages mpi)
1ffa7090
LC
26 #:use-module (gnu packages perl)
27 #:use-module (gnu packages readline)
28 #:use-module (gnu packages flex)
9f51293c 29 #:use-module ((guix licenses) #:prefix license:)
2ed139c4
AE
30 #:use-module (guix packages)
31 #:use-module (guix download)
7569c5cb 32 #:use-module (guix build-system gnu)
8f4b1dfb 33 #:use-module (guix build-system cmake)
7569c5cb 34 #:use-module (guix utils))
2ed139c4
AE
35
36
37(define-public mpfrcx
38 (package
39 (name "mpfrcx")
9c68798d 40 (version "0.4.2")
2ed139c4
AE
41 (source (origin
42 (method url-fetch)
43 (uri (string-append
44 "http://www.multiprecision.org/mpfrcx/download/mpfrcx-"
45 version ".tar.gz"))
46 (sha256
47 (base32
9c68798d 48 "0grw66b255r574lvll1bqccm5myj2m8ajzsjaygcyq9zjnnbnhhy"))))
2ed139c4 49 (build-system gnu-build-system)
878c8f3f
AE
50 (propagated-inputs
51 `(("gmp" ,gmp)
52 ("mpfr" ,mpfr)
53 ("mpc" ,mpc))) ; Header files are included by mpfrcx.h.
35b9e423 54 (synopsis "Arithmetic of polynomials over arbitrary precision numbers")
2ed139c4 55 (description
35b9e423 56 "Mpfrcx is a library for the arithmetic of univariate polynomials over
2ed139c4 57arbitrary precision real (mpfr) or complex (mpc) numbers, without control
35b9e423 58on the rounding. For the time being, only the few functions needed to
2ed139c4 59implement the floating point approach to complex multiplication are
35b9e423 60implemented. On the other hand, these comprise asymptotically fast
e881752c 61multiplication routines such as Toom–Cook and the FFT.")
9f51293c 62 (license license:lgpl2.1+)
2ed139c4
AE
63 (home-page "http://mpfrcx.multiprecision.org/")))
64
10b1f688
AE
65(define-public cm
66 (package
67 (name "cm")
68 (version "0.2.1")
69 (source (origin
70 (method url-fetch)
71 (uri (string-append
72 "http://www.multiprecision.org/cm/download/cm-"
73 version ".tar.gz"))
74 (sha256
75 (base32
76 "1r5dx5qy0ka2sq26n9jll9iy4sjqg0jp5r3jnbjhpgxvmj8jbhq8"))))
77 (build-system gnu-build-system)
78 (propagated-inputs
79 `(("mpfrcx" ,mpfrcx)
80 ("zlib" ,zlib))) ; Header files included from cm_common.h.
81 (inputs
82 `(("pari-gp" ,pari-gp)))
83 (synopsis "CM constructions for elliptic curves")
84 (description
85 "The CM software implements the construction of ring class fields of
86imaginary quadratic number fields and of elliptic curves with complex
87multiplication via floating point approximations. It consists of libraries
88that can be called from within a C program and of executable command
89line applications.")
90 (license license:gpl2+)
91 (home-page "http://cm.multiprecision.org/")))
92
2ed139c4
AE
93(define-public fplll
94 (package
95 (name "fplll")
5a15ed50 96 (version "4.0.4")
2ed139c4
AE
97 (source (origin
98 (method url-fetch)
99 (uri (string-append
100 "http://perso.ens-lyon.fr/damien.stehle/fplll/libfplll-"
101 version ".tar.gz"))
102 (sha256 (base32
5a15ed50 103 "1cbiby7ykis4z84swclpysrljmqhfcllpkcbll1m08rzskgb1a6b"))))
2ed139c4
AE
104 (build-system gnu-build-system)
105 (inputs `(("gmp" ,gmp)
106 ("mpfr" ,mpfr)))
35b9e423 107 (synopsis "Library for LLL-reduction of euclidean lattices")
2ed139c4 108 (description
35b9e423 109 "fplll LLL-reduces euclidean lattices. Since version 3, it can also
2ed139c4 110solve the shortest vector problem.")
9f51293c 111 (license license:lgpl2.1+)
2ed139c4 112 (home-page "http://perso.ens-lyon.fr/damien.stehle/fplll/")))
4e6b699d 113
90a6d47c
AE
114(define-public pari-gp
115 (package
116 (name "pari-gp")
66b2b085 117 (version "2.7.4")
90a6d47c
AE
118 (source (origin
119 (method url-fetch)
120 (uri (string-append
121 "http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-"
122 version ".tar.gz"))
f78c66aa
AE
123 (sha256
124 (base32
66b2b085 125 "0k1qqagfl6zn7gvwmsqffj6g9yrzqvszwh2mblhmxpjlw1pigfh8"))))
90a6d47c
AE
126 (build-system gnu-build-system)
127 (inputs `(("gmp" ,gmp)
128 ("perl" ,perl)
129 ("readline" ,readline)))
130 (arguments
12abb19d 131 '(#:make-flags '("gp")
f78c66aa
AE
132 ;; FIXME: building the documentation requires tex; once this is
133 ;; available, replace "gp" by "all"
12abb19d
LC
134 #:test-target "dobench"
135 #:phases
136 (alist-replace
137 'configure
ee172b1a
AE
138 (lambda* (#:key outputs #:allow-other-keys)
139 (let ((out (assoc-ref outputs "out")))
12abb19d 140 (zero?
ee172b1a 141 (system* "./Configure" (string-append "--prefix=" out)))))
12abb19d 142 %standard-phases)))
90a6d47c
AE
143 (synopsis "PARI/GP, a computer algebra system for number theory")
144 (description
145 "PARI/GP is a widely used computer algebra system designed for fast
146computations in number theory (factorisations, algebraic number theory,
147elliptic curves...), but it also contains a large number of other useful
148functions to compute with mathematical entities such as matrices,
149polynomials, power series, algebraic numbers, etc., and a lot of
150transcendental functions.
151PARI is also available as a C library to allow for faster computations.")
9f51293c 152 (license license:gpl2+)
90a6d47c 153 (home-page "http://pari.math.u-bordeaux.fr/")))
ed9f9a77 154
f854a8c1
AE
155(define-public gp2c
156 (package
157 (name "gp2c")
324bdcd8 158 (version "0.0.9pl3")
f854a8c1
AE
159 (source (origin
160 (method url-fetch)
161 (uri (string-append
162 "http://pari.math.u-bordeaux.fr/pub/pari/GP2C/gp2c-"
163 version ".tar.gz"))
324bdcd8
AE
164 (sha256
165 (base32
166 "0wbghihwlcx3w4j1la3bjf5gcrkk6lp9syw6iimqndq1f73ijlq3"))))
f854a8c1 167 (build-system gnu-build-system)
c67ccedd 168 (native-inputs `(("perl" ,perl)))
f854a8c1
AE
169 (inputs `(("pari-gp" ,pari-gp)))
170 (arguments
171 '(#:configure-flags
172 (list (string-append "--with-paricfg="
173 (assoc-ref %build-inputs "pari-gp")
174 "/lib/pari/pari.cfg"))))
175 (synopsis "PARI/GP, a computer algebra system for number theory")
176 (description
177 "PARI/GP is a widely used computer algebra system designed for fast
178computations in number theory (factorisations, algebraic number theory,
179elliptic curves...), but it also contains a large number of other useful
180functions to compute with mathematical entities such as matrices,
181polynomials, power series, algebraic numbers, etc., and a lot of
182transcendental functions.
183PARI is also available as a C library to allow for faster computations.
184
185GP2C, the GP to C compiler, translates GP scripts to PARI programs.")
9f51293c 186 (license license:gpl2)
f854a8c1
AE
187 (home-page "http://pari.math.u-bordeaux.fr/")))
188
d7ab698a
AE
189(define-public flint
190 (package
191 (name "flint")
b42c8753 192 (version "2.4.5")
d7ab698a
AE
193 (source (origin
194 (method url-fetch)
195 (uri (string-append
196 "http://flintlib.org/flint-"
197 version ".tar.gz"))
198 (sha256 (base32
b42c8753 199 "1qq11sxliy499a9g656dgk47ffb951q4gl6ddjbq838gy16kb2g4"))))
d7ab698a 200 (build-system gnu-build-system)
df15d17d 201 (propagated-inputs
d7ab698a 202 `(("gmp" ,gmp)
df15d17d 203 ("mpfr" ,mpfr))) ; header files from both are included by flint/arith.h
d7ab698a
AE
204 (arguments
205 `(#:phases
91430de6
AE
206 (modify-phases %standard-phases
207 (replace 'configure
208 (lambda* (#:key inputs outputs #:allow-other-keys)
209 (let ((out (assoc-ref outputs "out"))
210 (gmp (assoc-ref inputs "gmp"))
211 (mpfr (assoc-ref inputs "mpfr")))
212 ;; Drop test failing with gmp-6 due to changed invertibility
213 ;; of 0 in Z/1 Z, which according to the flint authors has no
214 ;; impact on flint.
215 ;; FIXME: Drop with later version.
216 (delete-file "fmpz/test/t-invmod.c")
217 ;; do not pass "--enable-fast-install", which makes the
218 ;; homebrew configure process fail
219 (zero? (system*
220 "./configure"
221 (string-append "--prefix=" out)
222 (string-append "--with-gmp=" gmp)
223 (string-append "--with-mpfr=" mpfr)))))))))
d7ab698a
AE
224 (synopsis "Fast library for number theory")
225 (description
226 "FLINT is a C library for number theory. It supports arithmetic
227with numbers, polynomials, power series and matrices over many base
228rings, including multiprecision integers and rationals, integers
229modulo n, p-adic numbers, finite fields (prime and non-prime order)
230and real and complex numbers (via the Arb extension library).
231
232Operations that can be performed include conversions, arithmetic,
233GCDs, factoring, solving linear systems, and evaluating special
234functions. In addition, FLINT provides various low-level routines for
235fast arithmetic.")
9f51293c 236 (license license:gpl2+)
d7ab698a
AE
237 (home-page "http://flintlib.org/")))
238
6b8e8285
AE
239(define-public arb
240 (package
241 (name "arb")
424ce93d 242 (version "2.7.0")
6b8e8285
AE
243 (source (origin
244 (method url-fetch)
245 (uri (string-append
246 "https://github.com/fredrik-johansson/arb/archive/"
247 version ".tar.gz"))
f586c877 248 (file-name (string-append name "-" version ".tar.gz"))
424ce93d
AE
249 (sha256
250 (base32
251 "1rwkffs57v8mry63rq8l2dyw69zfs9rg5fpbfllqp3nkjnkp1fly"))))
6b8e8285 252 (build-system gnu-build-system)
480d19e6
AE
253 (propagated-inputs
254 `(("flint" ,flint))) ; flint.h is included by arf.h
6b8e8285 255 (inputs
480d19e6 256 `(("gmp" ,gmp)
6b8e8285
AE
257 ("mpfr" ,mpfr)))
258 (arguments
259 `(#:phases
260 (alist-replace
261 'configure
262 (lambda* (#:key inputs outputs #:allow-other-keys)
263 (let ((out (assoc-ref outputs "out"))
264 (flint (assoc-ref inputs "flint"))
265 (gmp (assoc-ref inputs "gmp"))
266 (mpfr (assoc-ref inputs "mpfr")))
267 ;; do not pass "--enable-fast-install", which makes the
268 ;; homebrew configure process fail
269 (zero? (system*
270 "./configure"
271 (string-append "--prefix=" out)
272 (string-append "--with-flint=" flint)
273 (string-append "--with-gmp=" gmp)
274 (string-append "--with-mpfr=" mpfr)))))
275 %standard-phases)))
276 (synopsis "Arbitrary precision floating-point ball arithmetic")
277 (description
278 "Arb is a C library for arbitrary-precision floating-point ball
279arithmetic. It supports efficient high-precision computation with
280polynomials, power series, matrices and special functions over the
281real and complex numbers, with automatic, rigorous error control.")
9f51293c 282 (license license:gpl2+)
6b8e8285
AE
283 (home-page "http://fredrikj.net/arb/")))
284
ed9f9a77
LC
285(define-public bc
286 (package
287 (name "bc")
288 (version "1.06")
289 (source (origin
290 (method url-fetch)
291 (uri (string-append "mirror://gnu/bc/bc-" version ".tar.gz"))
292 (sha256
293 (base32
294 "0cqf5jkwx6awgd2xc2a0mkpxilzcfmhncdcfg7c9439wgkqxkxjf"))))
295 (build-system gnu-build-system)
c4c4cc05
JD
296 (inputs `(("readline" ,readline)))
297 (native-inputs `(("flex" ,flex)))
ed9f9a77
LC
298 (arguments
299 '(#:phases
300 (alist-replace 'configure
301 (lambda* (#:key outputs #:allow-other-keys)
302 ;; This old `configure' script doesn't support
303 ;; variables passed as arguments.
304 (let ((out (assoc-ref outputs "out")))
305 (setenv "CONFIG_SHELL" (which "bash"))
306 (zero?
e2ca23c5
MW
307 (system*
308 "./configure"
309 (string-append "--prefix=" out)
310 ;; By default, man and info pages are put in
311 ;; PREFIX/{man,info}, but we want them in
312 ;; PREFIX/share/{man,info}.
313 (string-append "--mandir=" out "/share/man")
314 (string-append "--infodir=" out "/share/info")))))
ed9f9a77
LC
315 %standard-phases)))
316 (home-page "http://www.gnu.org/software/bc/")
f50d2669 317 (synopsis "Arbitrary precision numeric processing language")
ed9f9a77 318 (description
a22dc0c4
LC
319 "bc is an arbitrary precision numeric processing language. It includes
320an interactive environment for evaluating mathematical statements. Its
321syntax is similar to that of C, so basic usage is familiar. It also includes
322\"dc\", a reverse-polish calculator.")
9f51293c 323 (license license:gpl2+)))
37e6cdcd
LC
324
325(define-public fftw
326 (package
327 (name "fftw")
2cf287df 328 (version "3.3.4")
37e6cdcd
LC
329 (source (origin
330 (method url-fetch)
331 (uri (string-append "ftp://ftp.fftw.org/pub/fftw/fftw-"
332 version".tar.gz"))
333 (sha256
334 (base32
2cf287df 335 "10h9mzjxnwlsjziah4lri85scc05rlajz39nqf3mbh4vja8dw34g"))))
37e6cdcd
LC
336 (build-system gnu-build-system)
337 (arguments
e5c66f8c 338 '(#:configure-flags '("--enable-shared" "--enable-openmp")
37e6cdcd
LC
339 #:phases (alist-cons-before
340 'build 'no-native
341 (lambda _
342 ;; By default '-mtune=native' is used. However, that may
343 ;; cause the use of ISA extensions (SSE2, etc.) that are
344 ;; not necessarily available on the user's machine when
345 ;; that package is built on a different machine.
346 (substitute* (find-files "." "Makefile$")
347 (("-mtune=native") "")))
348 %standard-phases)))
349 (native-inputs `(("perl" ,perl)))
350 (home-page "http://fftw.org")
351 (synopsis "Computing the discrete Fourier transform")
352 (description
353 "FFTW is a C subroutine library for computing the discrete Fourier
354transform (DFT) in one or more dimensions, of arbitrary input size, and of
355both real and complex data (as well as of even/odd data---i.e. the discrete
356cosine/ sine transforms or DCT/DST).")
9f51293c 357 (license license:gpl2+)))
7569c5cb
EB
358
359(define-public fftwf
360 (package (inherit fftw)
361 (name "fftwf")
362 (arguments
363 (substitute-keyword-arguments (package-arguments fftw)
364 ((#:configure-flags cf)
365 `(cons "--enable-float" ,cf))))
366 (description
367 (string-append (package-description fftw)
368 " Single-precision version."))))
e5c66f8c
EB
369
370(define-public fftw-openmpi
371 (package (inherit fftw)
372 (name "fftw-openmpi")
373 (inputs
374 `(("openmpi" ,openmpi)
375 ,@(package-inputs fftw)))
376 (arguments
377 (substitute-keyword-arguments (package-arguments fftw)
378 ((#:configure-flags cf)
379 `(cons "--enable-mpi" ,cf))))
380 (description
381 (string-append (package-description fftw)
382 " With OpenMPI parallelism support."))))
8f4b1dfb
LC
383
384(define-public eigen
385 (package
386 (name "eigen")
80e907fe 387 (version "3.2.5")
8f4b1dfb
LC
388 (source (origin
389 (method url-fetch)
390 (uri (string-append "https://bitbucket.org/eigen/eigen/get/"
9b268f12 391 version ".tar.bz2"))
8f4b1dfb
LC
392 (sha256
393 (base32
80e907fe 394 "1yf27mfq1x38wlsghkvpjgs8xd5rvbbikf1wyj2l3qw8h6w6qvjz"))
8f4b1dfb
LC
395 (modules '((guix build utils)))
396 (snippet
397 ;; There are 3 test failures in the "unsupported" directory,
398 ;; but maintainers say it's a known issue and it's unsupported
399 ;; anyway, so just skip them.
400 '(substitute* "CMakeLists.txt"
401 (("add_subdirectory\\(unsupported\\)")
402 "# Do not build the tests for unsupported features.\n")))))
403 (build-system cmake-build-system)
404 (arguments
405 '(;; Turn off debugging symbols to save space.
406 #:build-type "Release"
407
408 ;; Use 'make check', as per
409 ;; <http://eigen.tuxfamily.org/index.php?title=Tests>.
410 #:test-target "check"
411
412 #:phases (alist-cons-before
413 'check 'build-tests
414 (lambda _
415 ;; First build the tests, in parallel.
416 ;; See <http://eigen.tuxfamily.org/index.php?title=Tests>.
fc3cbc67 417 (let* ((cores (parallel-job-count))
8f4b1dfb
LC
418 (dash-j (format #f "-j~a" cores)))
419 ;; These variables are supposed to be honored.
420 (setenv "EIGEN_MAKE_ARGS" dash-j)
421 (setenv "EIGEN_CTEST_ARGS" dash-j)
422
423 (zero? (system* "make" "buildtests" dash-j))))
424 %standard-phases)))
425 (home-page "http://eigen.tuxfamily.org")
426 (synopsis "C++ template library for linear algebra")
427 (description
428 "Eigen is a C++ template library for linear algebra: matrices, vectors,
429numerical solvers, and related algorithms. It provides an elegant API based
430on \"expression templates\". It is versatile: it supports all matrix sizes,
431all standard numeric types, various matrix decompositions and geometry
432features, and more.")
433
434 ;; Most of the code is MPLv2, with a few files under LGPLv2.1+ or BSD-3.
435 ;; See 'COPYING.README' for details.
9f51293c 436 (license license:mpl2.0)))