1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
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 algebra)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages multiprecision)
25 #:use-module (gnu packages mpi)
26 #:use-module (gnu packages perl)
27 #:use-module (gnu packages readline)
28 #:use-module (gnu packages flex)
29 #:use-module (gnu packages xorg)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system cmake)
35 #:use-module (guix utils))
45 "http://www.multiprecision.org/mpfrcx/download/mpfrcx-"
49 "0grw66b255r574lvll1bqccm5myj2m8ajzsjaygcyq9zjnnbnhhy"))))
50 (build-system gnu-build-system)
54 ("mpc" ,mpc))) ; Header files are included by mpfrcx.h.
55 (synopsis "Arithmetic of polynomials over arbitrary precision numbers")
57 "Mpfrcx is a library for the arithmetic of univariate polynomials over
58 arbitrary precision real (mpfr) or complex (mpc) numbers, without control
59 on the rounding. For the time being, only the few functions needed to
60 implement the floating point approach to complex multiplication are
61 implemented. On the other hand, these comprise asymptotically fast
62 multiplication routines such as Toom–Cook and the FFT.")
63 (license license:lgpl2.1+)
64 (home-page "http://mpfrcx.multiprecision.org/")))
73 "http://www.multiprecision.org/cm/download/cm-"
77 "1r5dx5qy0ka2sq26n9jll9iy4sjqg0jp5r3jnbjhpgxvmj8jbhq8"))))
78 (build-system gnu-build-system)
81 ("zlib" ,zlib))) ; Header files included from cm_common.h.
83 `(("pari-gp" ,pari-gp)))
84 (synopsis "CM constructions for elliptic curves")
86 "The CM software implements the construction of ring class fields of
87 imaginary quadratic number fields and of elliptic curves with complex
88 multiplication via floating point approximations. It consists of libraries
89 that can be called from within a C program and of executable command
91 (license license:gpl2+)
92 (home-page "http://cm.multiprecision.org/")))
101 "http://perso.ens-lyon.fr/damien.stehle/fplll/libfplll-"
104 "1cbiby7ykis4z84swclpysrljmqhfcllpkcbll1m08rzskgb1a6b"))))
105 (build-system gnu-build-system)
106 (inputs `(("gmp" ,gmp)
108 (synopsis "Library for LLL-reduction of euclidean lattices")
110 "fplll LLL-reduces euclidean lattices. Since version 3, it can also
111 solve the shortest vector problem.")
112 (license license:lgpl2.1+)
113 (home-page "http://perso.ens-lyon.fr/damien.stehle/fplll/")))
115 (define-public pari-gp
122 "http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-"
126 "0k1qqagfl6zn7gvwmsqffj6g9yrzqvszwh2mblhmxpjlw1pigfh8"))))
127 (build-system gnu-build-system)
128 (inputs `(("gmp" ,gmp)
131 ("readline" ,readline)))
133 '(#:make-flags '("gp")
134 ;; FIXME: building the documentation requires tex; once this is
135 ;; available, replace "gp" by "all"
136 #:test-target "dobench"
140 (lambda* (#:key outputs #:allow-other-keys)
141 (let ((out (assoc-ref outputs "out")))
143 (system* "./Configure" (string-append "--prefix=" out)))))
145 (synopsis "PARI/GP, a computer algebra system for number theory")
147 "PARI/GP is a widely used computer algebra system designed for fast
148 computations in number theory (factorisations, algebraic number theory,
149 elliptic curves...), but it also contains a large number of other useful
150 functions to compute with mathematical entities such as matrices,
151 polynomials, power series, algebraic numbers, etc., and a lot of
152 transcendental functions.
153 PARI is also available as a C library to allow for faster computations.")
154 (license license:gpl2+)
155 (home-page "http://pari.math.u-bordeaux.fr/")))
164 "http://pari.math.u-bordeaux.fr/pub/pari/GP2C/gp2c-"
168 "0wbghihwlcx3w4j1la3bjf5gcrkk6lp9syw6iimqndq1f73ijlq3"))))
169 (build-system gnu-build-system)
170 (native-inputs `(("perl" ,perl)))
171 (inputs `(("pari-gp" ,pari-gp)))
174 (list (string-append "--with-paricfg="
175 (assoc-ref %build-inputs "pari-gp")
176 "/lib/pari/pari.cfg"))))
177 (synopsis "PARI/GP, a computer algebra system for number theory")
179 "PARI/GP is a widely used computer algebra system designed for fast
180 computations in number theory (factorisations, algebraic number theory,
181 elliptic curves...), but it also contains a large number of other useful
182 functions to compute with mathematical entities such as matrices,
183 polynomials, power series, algebraic numbers, etc., and a lot of
184 transcendental functions.
185 PARI is also available as a C library to allow for faster computations.
187 GP2C, the GP to C compiler, translates GP scripts to PARI programs.")
188 (license license:gpl2)
189 (home-page "http://pari.math.u-bordeaux.fr/")))
198 "http://flintlib.org/flint-"
201 "11syazv1a8rrnac3wj3hnyhhflpqcmq02q8pqk2m6g2k6h0gxwfb"))
202 (patches (map search-patch '("flint-ldconfig.patch")))))
203 (build-system gnu-build-system)
206 ("mpfr" ,mpfr))) ; header files from both are included by flint/arith.h
208 `(#:parallel-tests? #f ; seems to be necessary on arm
210 (modify-phases %standard-phases
212 (lambda* (#:key inputs outputs #:allow-other-keys)
213 (let ((out (assoc-ref outputs "out"))
214 (gmp (assoc-ref inputs "gmp"))
215 (mpfr (assoc-ref inputs "mpfr")))
216 ;; do not pass "--enable-fast-install", which makes the
217 ;; homebrew configure process fail
220 (string-append "--prefix=" out)
221 (string-append "--with-gmp=" gmp)
222 (string-append "--with-mpfr=" mpfr)))))))))
223 (synopsis "Fast library for number theory")
225 "FLINT is a C library for number theory. It supports arithmetic
226 with numbers, polynomials, power series and matrices over many base
227 rings, including multiprecision integers and rationals, integers
228 modulo n, p-adic numbers, finite fields (prime and non-prime order)
229 and real and complex numbers (via the Arb extension library).
231 Operations that can be performed include conversions, arithmetic,
232 GCDs, factoring, solving linear systems, and evaluating special
233 functions. In addition, FLINT provides various low-level routines for
235 (license license:gpl2+)
236 (home-page "http://flintlib.org/")))
245 "https://github.com/fredrik-johansson/arb/archive/"
247 (file-name (string-append name "-" version ".tar.gz"))
250 "1rwkffs57v8mry63rq8l2dyw69zfs9rg5fpbfllqp3nkjnkp1fly"))))
251 (build-system gnu-build-system)
253 `(("flint" ,flint))) ; flint.h is included by arf.h
261 (lambda* (#:key inputs outputs #:allow-other-keys)
262 (let ((out (assoc-ref outputs "out"))
263 (flint (assoc-ref inputs "flint"))
264 (gmp (assoc-ref inputs "gmp"))
265 (mpfr (assoc-ref inputs "mpfr")))
266 ;; do not pass "--enable-fast-install", which makes the
267 ;; homebrew configure process fail
270 (string-append "--prefix=" out)
271 (string-append "--with-flint=" flint)
272 (string-append "--with-gmp=" gmp)
273 (string-append "--with-mpfr=" mpfr)))))
275 (synopsis "Arbitrary precision floating-point ball arithmetic")
277 "Arb is a C library for arbitrary-precision floating-point ball
278 arithmetic. It supports efficient high-precision computation with
279 polynomials, power series, matrices and special functions over the
280 real and complex numbers, with automatic, rigorous error control.")
281 (license license:gpl2+)
282 (home-page "http://fredrikj.net/arb/")))
290 (uri (string-append "mirror://gnu/bc/bc-" version ".tar.gz"))
293 "0cqf5jkwx6awgd2xc2a0mkpxilzcfmhncdcfg7c9439wgkqxkxjf"))))
294 (build-system gnu-build-system)
295 (inputs `(("readline" ,readline)))
296 (native-inputs `(("flex" ,flex)))
299 (alist-replace 'configure
300 (lambda* (#:key outputs #:allow-other-keys)
301 ;; This old `configure' script doesn't support
302 ;; variables passed as arguments.
303 (let ((out (assoc-ref outputs "out")))
304 (setenv "CONFIG_SHELL" (which "bash"))
308 (string-append "--prefix=" out)
309 ;; By default, man and info pages are put in
310 ;; PREFIX/{man,info}, but we want them in
311 ;; PREFIX/share/{man,info}.
312 (string-append "--mandir=" out "/share/man")
313 (string-append "--infodir=" out "/share/info")))))
315 (home-page "http://www.gnu.org/software/bc/")
316 (synopsis "Arbitrary precision numeric processing language")
318 "bc is an arbitrary precision numeric processing language. It includes
319 an interactive environment for evaluating mathematical statements. Its
320 syntax is similar to that of C, so basic usage is familiar. It also includes
321 \"dc\", a reverse-polish calculator.")
322 (license license:gpl2+)))
330 (uri (string-append "ftp://ftp.fftw.org/pub/fftw/fftw-"
334 "10h9mzjxnwlsjziah4lri85scc05rlajz39nqf3mbh4vja8dw34g"))))
335 (build-system gnu-build-system)
337 '(#:configure-flags '("--enable-shared" "--enable-openmp")
338 #:phases (alist-cons-before
341 ;; By default '-mtune=native' is used. However, that may
342 ;; cause the use of ISA extensions (SSE2, etc.) that are
343 ;; not necessarily available on the user's machine when
344 ;; that package is built on a different machine.
345 (substitute* (find-files "." "Makefile$")
346 (("-mtune=native") "")))
348 (native-inputs `(("perl" ,perl)))
349 (home-page "http://fftw.org")
350 (synopsis "Computing the discrete Fourier transform")
352 "FFTW is a C subroutine library for computing the discrete Fourier
353 transform (DFT) in one or more dimensions, of arbitrary input size, and of
354 both real and complex data (as well as of even/odd data---i.e. the discrete
355 cosine/ sine transforms or DCT/DST).")
356 (license license:gpl2+)))
359 (package (inherit fftw)
362 (substitute-keyword-arguments (package-arguments fftw)
363 ((#:configure-flags cf)
364 `(cons "--enable-float" ,cf))))
366 (string-append (package-description fftw)
367 " Single-precision version."))))
369 (define-public fftw-openmpi
370 (package (inherit fftw)
371 (name "fftw-openmpi")
373 `(("openmpi" ,openmpi)
374 ,@(package-inputs fftw)))
376 (substitute-keyword-arguments (package-arguments fftw)
377 ((#:configure-flags cf)
378 `(cons "--enable-mpi" ,cf))))
380 (string-append (package-description fftw)
381 " With OpenMPI parallelism support."))))
389 (uri (string-append "https://bitbucket.org/eigen/eigen/get/"
393 "0gil5ksmgcg6v3nw0v613mvpzz4n33xhawqs8l7fj7rnlpwm4cwa"))
394 (modules '((guix build utils)))
396 ;; There are 3 test failures in the "unsupported" directory,
397 ;; but maintainers say it's a known issue and it's unsupported
398 ;; anyway, so just skip them.
399 '(substitute* "CMakeLists.txt"
400 (("add_subdirectory\\(unsupported\\)")
401 "# Do not build the tests for unsupported features.\n")))))
402 (build-system cmake-build-system)
404 '(;; Turn off debugging symbols to save space.
405 #:build-type "Release"
407 ;; Use 'make check', as per
408 ;; <http://eigen.tuxfamily.org/index.php?title=Tests>.
409 #:test-target "check"
411 #:phases (alist-cons-before
414 ;; First build the tests, in parallel.
415 ;; See <http://eigen.tuxfamily.org/index.php?title=Tests>.
416 (let* ((cores (parallel-job-count))
417 (dash-j (format #f "-j~a" cores)))
418 ;; These variables are supposed to be honored.
419 (setenv "EIGEN_MAKE_ARGS" dash-j)
420 (setenv "EIGEN_CTEST_ARGS" dash-j)
422 (zero? (system* "make" "buildtests" dash-j))))
424 (home-page "http://eigen.tuxfamily.org")
425 (synopsis "C++ template library for linear algebra")
427 "Eigen is a C++ template library for linear algebra: matrices, vectors,
428 numerical solvers, and related algorithms. It provides an elegant API based
429 on \"expression templates\". It is versatile: it supports all matrix sizes,
430 all standard numeric types, various matrix decompositions and geometry
431 features, and more.")
433 ;; Most of the code is MPLv2, with a few files under LGPLv2.1+ or BSD-3.
434 ;; See 'COPYING.README' for details.
435 (license license:mpl2.0)))