1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
5 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages algebra)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages autotools)
26 #:use-module (gnu packages compression)
27 #:use-module (gnu packages documentation)
28 #:use-module (gnu packages fltk)
29 #:use-module (gnu packages gl)
30 #:use-module (gnu packages graphviz)
31 #:use-module (gnu packages image)
32 #:use-module (gnu packages multiprecision)
33 #:use-module (gnu packages maths)
34 #:use-module (gnu packages mpi)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages readline)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages python)
39 #:use-module (gnu packages shells)
40 #:use-module (gnu packages tex)
41 #:use-module (gnu packages xiph)
42 #:use-module (gnu packages xorg)
43 #:use-module ((guix licenses) #:prefix license:)
44 #:use-module (guix packages)
45 #:use-module (guix download)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system cmake)
48 #:use-module (guix utils))
58 "http://www.multiprecision.org/mpfrcx/download/mpfrcx-"
62 "0grw66b255r574lvll1bqccm5myj2m8ajzsjaygcyq9zjnnbnhhy"))))
63 (build-system gnu-build-system)
67 ("mpc" ,mpc))) ; Header files are included by mpfrcx.h.
68 (synopsis "Arithmetic of polynomials over arbitrary precision numbers")
70 "Mpfrcx is a library for the arithmetic of univariate polynomials over
71 arbitrary precision real (mpfr) or complex (mpc) numbers, without control
72 on the rounding. For the time being, only the few functions needed to
73 implement the floating point approach to complex multiplication are
74 implemented. On the other hand, these comprise asymptotically fast
75 multiplication routines such as Toom–Cook and the FFT.")
76 (license license:lgpl2.1+)
77 (home-page "http://mpfrcx.multiprecision.org/")))
86 "http://www.multiprecision.org/cm/download/cm-"
90 "1nf5kr0nqmhbzrsrinky18z0ighjpsmb5cr8zyg8jf04bfbyrfmc"))))
91 (build-system gnu-build-system)
94 ("zlib" ,zlib))) ; Header files included from cm_common.h.
96 `(("pari-gp" ,pari-gp)))
97 (synopsis "CM constructions for elliptic curves")
99 "The CM software implements the construction of ring class fields of
100 imaginary quadratic number fields and of elliptic curves with complex
101 multiplication via floating point approximations. It consists of libraries
102 that can be called from within a C program and of executable command
104 (license license:gpl3+)
105 (home-page "http://cm.multiprecision.org/")))
114 "http://perso.ens-lyon.fr/damien.stehle/fplll/libfplll-"
117 "1cbiby7ykis4z84swclpysrljmqhfcllpkcbll1m08rzskgb1a6b"))))
118 (build-system gnu-build-system)
119 (inputs `(("gmp" ,gmp)
121 (synopsis "Library for LLL-reduction of euclidean lattices")
123 "fplll LLL-reduces euclidean lattices. Since version 3, it can also
124 solve the shortest vector problem.")
125 (license license:lgpl2.1+)
126 (home-page "http://perso.ens-lyon.fr/damien.stehle/fplll/")))
128 (define-public pari-gp
135 "http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-"
139 "04dqi697czd8mmw8aiwzrkgbvkjassqagg6lfy3lkf1k5qi9g9rr"))))
140 (build-system gnu-build-system)
141 (native-inputs `(("texlive" ,texlive-minimal)))
142 (inputs `(("gmp" ,gmp)
145 ("readline" ,readline)))
147 '(#:make-flags '("all")
148 #:test-target "dobench"
149 #:phases (modify-phases %standard-phases
151 (lambda* (#:key outputs #:allow-other-keys)
152 (let ((out (assoc-ref outputs "out")))
154 (system* "./Configure"
155 (string-append "--prefix=" out)))))))))
156 (synopsis "PARI/GP, a computer algebra system for number theory")
158 "PARI/GP is a widely used computer algebra system designed for fast
159 computations in number theory (factorisations, algebraic number theory,
160 elliptic curves...), but it also contains a large number of other useful
161 functions to compute with mathematical entities such as matrices,
162 polynomials, power series, algebraic numbers, etc., and a lot of
163 transcendental functions.
164 PARI is also available as a C library to allow for faster computations.")
165 (license license:gpl2+)
166 (home-page "http://pari.math.u-bordeaux.fr/")))
175 "http://pari.math.u-bordeaux.fr/pub/pari/GP2C/gp2c-"
179 "1q003mkagc5ib6lqb2xfay7j4ffkwv7xlnznp6wdrq2sbqq4vyak"))))
180 (build-system gnu-build-system)
181 (native-inputs `(("perl" ,perl)))
182 (inputs `(("pari-gp" ,pari-gp)))
185 (list (string-append "--with-paricfg="
186 (assoc-ref %build-inputs "pari-gp")
187 "/lib/pari/pari.cfg"))))
188 (synopsis "PARI/GP, a computer algebra system for number theory")
190 "PARI/GP is a widely used computer algebra system designed for fast
191 computations in number theory (factorisations, algebraic number theory,
192 elliptic curves...), but it also contains a large number of other useful
193 functions to compute with mathematical entities such as matrices,
194 polynomials, power series, algebraic numbers, etc., and a lot of
195 transcendental functions.
196 PARI is also available as a C library to allow for faster computations.
198 GP2C, the GP to C compiler, translates GP scripts to PARI programs.")
199 (license license:gpl2)
200 (home-page "http://pari.math.u-bordeaux.fr/")))
202 (define-public giac-xcas
205 (version "1.2.2-103")
208 ;; "~parisse/giac" is not used because the maintainer regularly
209 ;; overwrites the release tarball there, introducing a checksum
210 ;; mismatch every time. See
211 ;; <https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/README>
212 (uri (string-append "https://www-fourier.ujf-grenoble.fr/"
213 "~parisse/debian/dists/stable/main/"
214 "source/giac_" version ".tar.gz"))
217 "1qrhjw2sdvyv2x8fqs9isqv8rgldn448gfxbi7zbva8m5va5b3z1"))))
218 (build-system gnu-build-system)
221 (modify-phases %standard-phases
222 (add-after 'unpack 'patch-bin-cp
224 ;; Some Makefiles contain hard-coded "/bin/cp".
225 (substitute* (find-files "doc" "^Makefile")
226 (("/bin/cp") (which "cp")))
228 (add-after 'unpack 'disable-broken-test
230 ;; Disable failing test. Actually, the results are correct but
231 ;; a sorting discrepancy prevents the test from being validated.
232 (substitute* "check/Makefile.in"
244 ("libxinerama" ,libxinerama)
254 ("texlive" ,texlive-minimal)))
255 (native-inputs `(("readline" ,readline)))
256 (home-page "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html")
257 (synopsis "Computer algebra system")
259 "Giac/Xcas is a computer algebra system. It has a compatibility mode for
260 maple, mupad and the TI89. It is available as a standalone program (graphic
261 or text interfaces) or as a C++ library.")
262 (license license:gpl3+)))
271 "http://flintlib.org/flint-"
274 "11syazv1a8rrnac3wj3hnyhhflpqcmq02q8pqk2m6g2k6h0gxwfb"))
275 (patches (search-patches "flint-ldconfig.patch"))))
276 (build-system gnu-build-system)
279 ("mpfr" ,mpfr))) ; header files from both are included by flint/arith.h
281 `(#:parallel-tests? #f ; seems to be necessary on arm
283 (modify-phases %standard-phases
285 (lambda* (#:key inputs outputs #:allow-other-keys)
286 (let ((out (assoc-ref outputs "out"))
287 (gmp (assoc-ref inputs "gmp"))
288 (mpfr (assoc-ref inputs "mpfr")))
289 ;; do not pass "--enable-fast-install", which makes the
290 ;; homebrew configure process fail
293 (string-append "--prefix=" out)
294 (string-append "--with-gmp=" gmp)
295 (string-append "--with-mpfr=" mpfr)))))))))
296 (synopsis "Fast library for number theory")
298 "FLINT is a C library for number theory. It supports arithmetic
299 with numbers, polynomials, power series and matrices over many base
300 rings, including multiprecision integers and rationals, integers
301 modulo n, p-adic numbers, finite fields (prime and non-prime order)
302 and real and complex numbers (via the Arb extension library).
304 Operations that can be performed include conversions, arithmetic,
305 GCDs, factoring, solving linear systems, and evaluating special
306 functions. In addition, FLINT provides various low-level routines for
308 (license license:gpl2+)
309 (home-page "http://flintlib.org/")))
318 "https://github.com/fredrik-johansson/arb/archive/"
320 (file-name (string-append name "-" version ".tar.gz"))
323 "04hhcpshfkcq9fr4hixbhpps50yf9drk62xgkvlcaj5kb4nyrx7l"))
324 (patches (search-patches "arb-ldconfig.patch"))))
325 (build-system gnu-build-system)
327 `(("flint" ,flint))) ; flint.h is included by arf.h
335 (lambda* (#:key inputs outputs #:allow-other-keys)
336 (let ((out (assoc-ref outputs "out"))
337 (flint (assoc-ref inputs "flint"))
338 (gmp (assoc-ref inputs "gmp"))
339 (mpfr (assoc-ref inputs "mpfr")))
340 ;; do not pass "--enable-fast-install", which makes the
341 ;; homebrew configure process fail
344 (string-append "--prefix=" out)
345 (string-append "--with-flint=" flint)
346 (string-append "--with-gmp=" gmp)
347 (string-append "--with-mpfr=" mpfr)))))
349 (synopsis "Arbitrary precision floating-point ball arithmetic")
351 "Arb is a C library for arbitrary-precision floating-point ball
352 arithmetic. It supports efficient high-precision computation with
353 polynomials, power series, matrices and special functions over the
354 real and complex numbers, with automatic, rigorous error control.")
355 (license license:gpl2+)
356 (home-page "http://fredrikj.net/arb/")))
364 (uri (string-append "http://shoup.net/ntl/ntl-"
367 "115frp5flyvw9wghz4zph1b3llmr5nbxk1skgsggckr81fh3gmxq"))))
368 (build-system gnu-build-system)
370 `(("libtool" ,libtool)
371 ("perl" ,perl))) ; for configuration
372 ;; FIXME: Add optional input gf2x once available; then also add
373 ;; configure flag "NTL_GF2X_LIB=on".
378 (modify-phases %standard-phases
380 (lambda* (#:key outputs #:allow-other-keys)
382 (system* "./configure"
383 (string-append "PREFIX=" (assoc-ref outputs "out"))
384 ;; Do not build especially for the build machine.
386 ;; Also do not tune to the build machine.
390 (synopsis "C++ library for number theory")
392 "NTL is a C++ library providing data structures and algorithms
393 for manipulating signed, arbitrary length integers, and for vectors,
394 matrices, and polynomials over the integers and over finite fields.")
395 (license license:gpl2+)
396 (home-page "http://shoup.net/ntl/")))
398 (define-public singular
404 (uri (string-append "http://www.mathematik.uni-kl.de/ftp/pub/"
405 "Math/Singular/SOURCES/"
406 (string-join (string-split version #\.) "-")
407 "/singular-" version ".tar.gz"))
409 "0viidy2fz62rln9p0s9qfs7fnm55c6fw1agydd1py26gxylp1ksc"))))
410 (build-system gnu-build-system)
412 `(("doxygen" ,doxygen)
413 ("graphviz" ,graphviz)
422 ("readline" ,readline)))
425 (list (string-append "--with-ntl="
426 (assoc-ref %build-inputs "ntl")))))
427 (synopsis "Computer algebra system for polynomial computations")
429 "Singular is a computer algebra system for polynomial computations,
430 with special emphasis on commutative and non-commutative algebra, algebraic
431 geometry and singularity theory.")
432 ;; Singular itself is dual licensed gpl2 or gpl3, but some of the
433 ;; libraries with which it links are licensed under lgpl3+, so the
434 ;; combined work becomes gpl3. See COPYING in the source code.
435 (license license:gpl3)
436 (home-page "http://www.singular.uni-kl.de/index.php")))
438 (define-public gmp-ecm
444 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
448 "00jzzwqp49m01vwsr9z1w7bvm8lb69l3f62x7qr8sfz0xiczxnpm"))))
449 (build-system gnu-build-system)
453 `(#:configure-flags '("--enable-shared"
454 ;; Disable specific assembly routines, which depend
455 ;; on the subarchitecture of the build machine,
456 ;; and use gmp instead.
457 "--disable-asm-redc")))
458 (synopsis "Integer factorization library using the elliptic curve method")
460 "GMP-ECM factors integers using the elliptic curve method (ECM) as well
461 as the P-1 and P+1 algorithms. It provides a library and a stand-alone
463 ;; Most files are under lgpl3+, but some are under gpl3+ or gpl2+,
464 ;; so the combined work is under gpl3+.
465 (license license:gpl3+)
466 (home-page "http://ecm.gforge.inria.fr/")))
474 (uri (string-append "mirror://gnu/bc/bc-" version ".tar.gz"))
477 "0cqf5jkwx6awgd2xc2a0mkpxilzcfmhncdcfg7c9439wgkqxkxjf"))))
478 (build-system gnu-build-system)
479 (inputs `(("readline" ,readline)))
480 (native-inputs `(("flex" ,flex)))
483 (alist-replace 'configure
484 (lambda* (#:key outputs #:allow-other-keys)
485 ;; This old `configure' script doesn't support
486 ;; variables passed as arguments.
487 (let ((out (assoc-ref outputs "out")))
488 (setenv "CONFIG_SHELL" (which "bash"))
492 (string-append "--prefix=" out)
493 ;; By default, man and info pages are put in
494 ;; PREFIX/{man,info}, but we want them in
495 ;; PREFIX/share/{man,info}.
496 (string-append "--mandir=" out "/share/man")
497 (string-append "--infodir=" out "/share/info")))))
499 (home-page "http://www.gnu.org/software/bc/")
500 (synopsis "Arbitrary precision numeric processing language")
502 "bc is an arbitrary precision numeric processing language. It includes
503 an interactive environment for evaluating mathematical statements. Its
504 syntax is similar to that of C, so basic usage is familiar. It also includes
505 \"dc\", a reverse-polish calculator.")
506 (license license:gpl2+)))
508 ;; The original kiss-fft does not have a complete build system and does not
509 ;; build any shared libraries. This is a fork used by Extempore.
510 (define-public kiss-fft-for-extempore
512 (name "kiss-fft-for-extempore")
516 (uri (string-append "https://github.com/extemporelang/kiss_fft/archive/"
518 (file-name (string-append name "-" version ".tar.gz"))
521 "0hkp9l6l4c92fb1l2sh6a6zv1hynpvb2s4d03vd8vxyvybc0l4pv"))))
522 (build-system cmake-build-system)
523 (arguments `(#:tests? #f)) ; no tests included
524 ;; Extempore refuses to build on architectures other than x86_64
525 (supported-systems '("x86_64-linux"))
526 (home-page "https://github.com/extemporelang/kiss_fft")
527 (synopsis "Mixed-radix Fast Fourier Transform")
529 "Kiss FFT attempts to be a reasonably efficient, moderately useful FFT
530 that can use fixed or floating data types and can easily be incorporated into
532 (license license:bsd-3)))
540 (uri (string-append "ftp://ftp.fftw.org/pub/fftw/fftw-"
544 "1kwbx92ps0r7s2mqy7lxbxanslxdzj7dp7r7gmdkzv1j8yqf3kwf"))))
545 (build-system gnu-build-system)
548 '("--enable-shared" "--enable-openmp" "--enable-threads")
549 #:phases (alist-cons-before
552 ;; By default '-mtune=native' is used. However, that may
553 ;; cause the use of ISA extensions (SSE2, etc.) that are
554 ;; not necessarily available on the user's machine when
555 ;; that package is built on a different machine.
556 (substitute* (find-files "." "Makefile$")
557 (("-mtune=native") "")))
559 (native-inputs `(("perl" ,perl)))
560 (home-page "http://fftw.org")
561 (synopsis "Computing the discrete Fourier transform")
563 "FFTW is a C subroutine library for computing the discrete Fourier
564 transform (DFT) in one or more dimensions, of arbitrary input size, and of
565 both real and complex data (as well as of even/odd data---i.e. the discrete
566 cosine/ sine transforms or DCT/DST).")
567 (license license:gpl2+)))
570 (package (inherit fftw)
573 (substitute-keyword-arguments (package-arguments fftw)
574 ((#:configure-flags cf)
575 `(cons "--enable-float" ,cf))))
577 (string-append (package-description fftw)
578 " Single-precision version."))))
580 ;; FIXME: These packages are used temporarily by packages like Ardour until
581 ;; "--enable-flags" is added to the fftw and fftwf packages.
582 (define-public fftw-with-threads
583 (package (inherit fftw)
585 (substitute-keyword-arguments (package-arguments fftw)
586 ((#:configure-flags flags)
587 `(cons "--enable-threads" ,flags))))))
589 (define-public fftwf-with-threads
590 (package (inherit fftwf)
592 (substitute-keyword-arguments (package-arguments fftwf)
593 ((#:configure-flags flags)
594 `(cons "--enable-threads" ,flags))))))
596 (define-public fftw-openmpi
597 (package (inherit fftw)
598 (name "fftw-openmpi")
600 `(("openmpi" ,openmpi)
601 ,@(package-inputs fftw)))
603 (substitute-keyword-arguments (package-arguments fftw)
604 ((#:configure-flags cf)
605 `(cons "--enable-mpi" ,cf))))
607 (string-append (package-description fftw)
608 " With OpenMPI parallelism support."))))
616 (uri (string-append "https://bitbucket.org/eigen/eigen/get/"
620 "1zs5b210mq7nyanky07li6456rrd0xv2nxf6sl2lhkzdq5p067jd"))
621 (file-name (string-append name "-" version ".tar.bz2"))
622 (modules '((guix build utils)))
624 ;; There are 3 test failures in the "unsupported" directory,
625 ;; but maintainers say it's a known issue and it's unsupported
626 ;; anyway, so just skip them.
627 '(substitute* "CMakeLists.txt"
628 (("add_subdirectory\\(unsupported\\)")
629 "# Do not build the tests for unsupported features.\n")
631 ;; <http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1114>.
632 (("\"include/eigen3\"")
633 "\"${CMAKE_INSTALL_PREFIX}/include/eigen3\"")))))
634 (build-system cmake-build-system)
636 '(;; Turn off debugging symbols to save space.
637 #:build-type "Release"
639 #:phases (modify-phases %standard-phases
642 (let* ((cores (parallel-job-count))
643 (dash-j (format #f "-j~a" cores)))
644 ;; First build the tests, in parallel. See
645 ;; <http://eigen.tuxfamily.org/index.php?title=Tests>.
646 (and (zero? (system* "make" "buildtests" dash-j))
648 ;; Then run 'CTest' with -V so we get more
649 ;; details upon failure.
650 (zero? (system* "ctest" "-V" dash-j)))))))))
651 (home-page "http://eigen.tuxfamily.org")
652 (synopsis "C++ template library for linear algebra")
654 "Eigen is a C++ template library for linear algebra: matrices, vectors,
655 numerical solvers, and related algorithms. It provides an elegant API based
656 on \"expression templates\". It is versatile: it supports all matrix sizes,
657 all standard numeric types, various matrix decompositions and geometry
658 features, and more.")
660 ;; Most of the code is MPLv2, with a few files under LGPLv2.1+ or BSD-3.
661 ;; See 'COPYING.README' for details.
662 (license license:mpl2.0)))