1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013, 2015, 2017 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2016, 2017 Nicolas Goaziou <mail@nicolasgoaziou.fr>
5 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
7 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages algebra)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages autotools)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages documentation)
31 #:use-module (gnu packages ed)
32 #:use-module (gnu packages flex)
33 #:use-module (gnu packages fltk)
34 #:use-module (gnu packages gl)
35 #:use-module (gnu packages graphviz)
36 #:use-module (gnu packages image)
37 #:use-module (gnu packages maths)
38 #:use-module (gnu packages mpi)
39 #:use-module (gnu packages multiprecision)
40 #:use-module (gnu packages perl)
41 #:use-module (gnu packages python)
42 #:use-module (gnu packages readline)
43 #:use-module (gnu packages shells)
44 #:use-module (gnu packages tex)
45 #:use-module (gnu packages texinfo)
46 #:use-module (gnu packages xiph)
47 #:use-module (gnu packages xorg)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix build-system cmake)
50 #:use-module (guix download)
51 #:use-module ((guix licenses) #:prefix license:)
52 #:use-module (guix packages)
53 #:use-module (guix utils))
63 "http://www.multiprecision.org/mpfrcx/download/mpfrcx-"
67 "0grw66b255r574lvll1bqccm5myj2m8ajzsjaygcyq9zjnnbnhhy"))))
68 (build-system gnu-build-system)
72 ("mpc" ,mpc))) ; Header files are included by mpfrcx.h.
73 (synopsis "Arithmetic of polynomials over arbitrary precision numbers")
75 "Mpfrcx is a library for the arithmetic of univariate polynomials over
76 arbitrary precision real (mpfr) or complex (mpc) numbers, without control
77 on the rounding. For the time being, only the few functions needed to
78 implement the floating point approach to complex multiplication are
79 implemented. On the other hand, these comprise asymptotically fast
80 multiplication routines such as Toom–Cook and the FFT.")
81 (license license:lgpl2.1+)
82 (home-page "http://mpfrcx.multiprecision.org/")))
91 "http://www.multiprecision.org/cm/download/cm-"
95 "1nf5kr0nqmhbzrsrinky18z0ighjpsmb5cr8zyg8jf04bfbyrfmc"))))
96 (build-system gnu-build-system)
99 ("zlib" ,zlib))) ; Header files included from cm_common.h.
101 `(("pari-gp" ,pari-gp)))
102 (synopsis "CM constructions for elliptic curves")
104 "The CM software implements the construction of ring class fields of
105 imaginary quadratic number fields and of elliptic curves with complex
106 multiplication via floating point approximations. It consists of libraries
107 that can be called from within a C program and of executable command
109 (license license:gpl3+)
110 (home-page "http://cm.multiprecision.org/")))
119 "http://perso.ens-lyon.fr/damien.stehle/fplll/libfplll-"
122 "1cbiby7ykis4z84swclpysrljmqhfcllpkcbll1m08rzskgb1a6b"))))
123 (build-system gnu-build-system)
124 (inputs `(("gmp" ,gmp)
126 (synopsis "Library for LLL-reduction of euclidean lattices")
128 "fplll LLL-reduces euclidean lattices. Since version 3, it can also
129 solve the shortest vector problem.")
130 (license license:lgpl2.1+)
131 (home-page "http://perso.ens-lyon.fr/damien.stehle/fplll/")))
133 (define-public pari-gp
140 "http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-"
144 "0zi08qz9nk17wwdna4xb2vp3i3mh5sgv1y8wqbf0j2sfryxlr8ls"))))
145 (build-system gnu-build-system)
146 (native-inputs `(("texlive" ,texlive-tiny)))
147 (inputs `(("gmp" ,gmp)
150 ("readline" ,readline)))
152 '(#:make-flags '("all")
153 #:test-target "dobench"
154 #:phases (modify-phases %standard-phases
156 (lambda* (#:key outputs #:allow-other-keys)
157 (let ((out (assoc-ref outputs "out")))
159 (system* "./Configure"
160 (string-append "--prefix=" out)))))))))
161 (synopsis "PARI/GP, a computer algebra system for number theory")
163 "PARI/GP is a widely used computer algebra system designed for fast
164 computations in number theory (factorisations, algebraic number theory,
165 elliptic curves...), but it also contains a large number of other useful
166 functions to compute with mathematical entities such as matrices,
167 polynomials, power series, algebraic numbers, etc., and a lot of
168 transcendental functions.
169 PARI is also available as a C library to allow for faster computations.")
170 (license license:gpl2+)
171 (home-page "http://pari.math.u-bordeaux.fr/")))
180 "http://pari.math.u-bordeaux.fr/pub/pari/GP2C/gp2c-"
184 "1xhpz5p81iw261ay1kip283ggr0ir8ydz8qx3v24z8jfms1r3y70"))))
185 (build-system gnu-build-system)
186 (native-inputs `(("perl" ,perl)))
187 (inputs `(("pari-gp" ,pari-gp)))
190 (list (string-append "--with-paricfg="
191 (assoc-ref %build-inputs "pari-gp")
192 "/lib/pari/pari.cfg"))))
193 (synopsis "PARI/GP, a computer algebra system for number theory")
195 "PARI/GP is a widely used computer algebra system designed for fast
196 computations in number theory (factorisations, algebraic number theory,
197 elliptic curves...), but it also contains a large number of other useful
198 functions to compute with mathematical entities such as matrices,
199 polynomials, power series, algebraic numbers, etc., and a lot of
200 transcendental functions.
201 PARI is also available as a C library to allow for faster computations.
203 GP2C, the GP to C compiler, translates GP scripts to PARI programs.")
204 (license license:gpl2)
205 (home-page "http://pari.math.u-bordeaux.fr/")))
207 (define-public giac-xcas
213 ;; "~parisse/giac" is not used because the maintainer regularly
214 ;; overwrites the release tarball there, introducing a checksum
215 ;; mismatch every time. See
216 ;; <https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/README>
217 (uri (string-append "https://www-fourier.ujf-grenoble.fr/"
218 "~parisse/debian/dists/stable/main/"
219 "source/giac_" version ".tar.gz"))
222 "1w7d4sdjbvqiibnfkhrqy9np3smsysilfba9pry3q1qn5g5y6nrp"))))
223 (build-system gnu-build-system)
226 (modify-phases %standard-phases
227 (add-after 'unpack 'patch-bin-cp
229 ;; Some Makefiles contain hard-coded "/bin/cp".
230 (substitute* (find-files "doc" "^Makefile")
231 (("/bin/cp") (which "cp")))
233 (add-after 'unpack 'disable-broken-test
235 ;; Disable failing test. Actually, the results are correct but
236 ;; a sorting discrepancy prevents the test from being validated.
237 (substitute* "check/Makefile.in"
249 ("libxinerama" ,libxinerama)
259 ("texlive" ,texlive-tiny)))
260 (native-inputs `(("readline" ,readline)))
261 (home-page "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html")
262 (synopsis "Computer algebra system")
264 "Giac/Xcas is a computer algebra system. It has a compatibility mode for
265 maple, mupad and the TI89. It is available as a standalone program (graphic
266 or text interfaces) or as a C++ library.")
267 (license license:gpl3+)))
276 "http://flintlib.org/flint-"
279 "11syazv1a8rrnac3wj3hnyhhflpqcmq02q8pqk2m6g2k6h0gxwfb"))
280 (patches (search-patches "flint-ldconfig.patch"))))
281 (build-system gnu-build-system)
284 ("mpfr" ,mpfr))) ; header files from both are included by flint/arith.h
286 `(#:parallel-tests? #f ; seems to be necessary on arm
288 (modify-phases %standard-phases
290 (lambda* (#:key inputs outputs #:allow-other-keys)
291 (let ((out (assoc-ref outputs "out"))
292 (gmp (assoc-ref inputs "gmp"))
293 (mpfr (assoc-ref inputs "mpfr")))
294 ;; do not pass "--enable-fast-install", which makes the
295 ;; homebrew configure process fail
298 (string-append "--prefix=" out)
299 (string-append "--with-gmp=" gmp)
300 (string-append "--with-mpfr=" mpfr)))))))))
301 (synopsis "Fast library for number theory")
303 "FLINT is a C library for number theory. It supports arithmetic
304 with numbers, polynomials, power series and matrices over many base
305 rings, including multiprecision integers and rationals, integers
306 modulo n, p-adic numbers, finite fields (prime and non-prime order)
307 and real and complex numbers (via the Arb extension library).
309 Operations that can be performed include conversions, arithmetic,
310 GCDs, factoring, solving linear systems, and evaluating special
311 functions. In addition, FLINT provides various low-level routines for
313 (license license:gpl2+)
314 (home-page "http://flintlib.org/")))
323 "https://github.com/fredrik-johansson/arb/archive/"
325 (file-name (string-append name "-" version ".tar.gz"))
328 "0jwcv9ssvi8axb1y7m2h4ykgyl015cl6g28gfl92l4dgnag585ak"))))
329 (build-system gnu-build-system)
331 `(("flint" ,flint))) ; flint.h is included by arf.h
339 (lambda* (#:key inputs outputs #:allow-other-keys)
340 (let ((out (assoc-ref outputs "out"))
341 (flint (assoc-ref inputs "flint"))
342 (gmp (assoc-ref inputs "gmp"))
343 (mpfr (assoc-ref inputs "mpfr")))
344 ;; do not pass "--enable-fast-install", which makes the
345 ;; homebrew configure process fail
348 (string-append "--prefix=" out)
349 (string-append "--with-flint=" flint)
350 (string-append "--with-gmp=" gmp)
351 (string-append "--with-mpfr=" mpfr)))))
353 (synopsis "Arbitrary precision floating-point ball arithmetic")
355 "Arb is a C library for arbitrary-precision floating-point ball
356 arithmetic. It supports efficient high-precision computation with
357 polynomials, power series, matrices and special functions over the
358 real and complex numbers, with automatic, rigorous error control.")
359 (license license:gpl2+)
360 (home-page "http://fredrikj.net/arb/")))
368 (uri (string-append "http://shoup.net/ntl/ntl-"
371 "115frp5flyvw9wghz4zph1b3llmr5nbxk1skgsggckr81fh3gmxq"))))
372 (build-system gnu-build-system)
374 `(("libtool" ,libtool)
375 ("perl" ,perl))) ; for configuration
376 ;; FIXME: Add optional input gf2x once available; then also add
377 ;; configure flag "NTL_GF2X_LIB=on".
382 (modify-phases %standard-phases
384 (lambda* (#:key outputs #:allow-other-keys)
386 (system* "./configure"
387 (string-append "PREFIX=" (assoc-ref outputs "out"))
388 ;; Do not build especially for the build machine.
390 ;; Also do not tune to the build machine.
394 (synopsis "C++ library for number theory")
396 "NTL is a C++ library providing data structures and algorithms
397 for manipulating signed, arbitrary length integers, and for vectors,
398 matrices, and polynomials over the integers and over finite fields.")
399 (license license:gpl2+)
400 (home-page "http://shoup.net/ntl/")))
402 (define-public singular
408 (uri (string-append "http://www.mathematik.uni-kl.de/ftp/pub/"
409 "Math/Singular/SOURCES/"
410 (string-join (string-split version #\.) "-")
411 "/singular-" version ".tar.gz"))
413 "0viidy2fz62rln9p0s9qfs7fnm55c6fw1agydd1py26gxylp1ksc"))))
414 (build-system gnu-build-system)
416 `(("doxygen" ,doxygen)
417 ("graphviz" ,graphviz)
426 ("readline" ,readline)))
429 (list (string-append "--with-ntl="
430 (assoc-ref %build-inputs "ntl")))))
431 (synopsis "Computer algebra system for polynomial computations")
433 "Singular is a computer algebra system for polynomial computations,
434 with special emphasis on commutative and non-commutative algebra, algebraic
435 geometry and singularity theory.")
436 ;; Singular itself is dual licensed gpl2 or gpl3, but some of the
437 ;; libraries with which it links are licensed under lgpl3+, so the
438 ;; combined work becomes gpl3. See COPYING in the source code.
439 (license license:gpl3)
440 (home-page "http://www.singular.uni-kl.de/index.php")))
442 (define-public gmp-ecm
448 (uri (string-append "https://gforge.inria.fr/frs/download.php/"
452 "00jzzwqp49m01vwsr9z1w7bvm8lb69l3f62x7qr8sfz0xiczxnpm"))))
453 (build-system gnu-build-system)
457 `(#:configure-flags '("--enable-shared"
458 ;; Disable specific assembly routines, which depend
459 ;; on the subarchitecture of the build machine,
460 ;; and use gmp instead.
461 "--disable-asm-redc")))
462 (synopsis "Integer factorization library using the elliptic curve method")
464 "GMP-ECM factors integers using the elliptic curve method (ECM) as well
465 as the P-1 and P+1 algorithms. It provides a library and a stand-alone
467 ;; Most files are under lgpl3+, but some are under gpl3+ or gpl2+,
468 ;; so the combined work is under gpl3+.
469 (license license:gpl3+)
470 (home-page "http://ecm.gforge.inria.fr/")))
478 (uri (string-append "mirror://gnu/bc/bc-" version ".tar.gz"))
481 "0amh9ik44jfg66csyvf4zz1l878c4755kjndq9j0270akflgrbb2"))))
482 (build-system gnu-build-system)
486 ("texinfo" ,texinfo)))
489 (list "--with-readline")))
490 (home-page "https://www.gnu.org/software/bc/")
491 (synopsis "Arbitrary precision numeric processing language")
493 "bc is an arbitrary precision numeric processing language. It includes
494 an interactive environment for evaluating mathematical statements. Its
495 syntax is similar to that of C, so basic usage is familiar. It also includes
496 \"dc\", a reverse-polish calculator.")
497 (license license:gpl2+)))
499 ;; The original kiss-fft does not have a complete build system and does not
500 ;; build any shared libraries. This is a fork used by Extempore.
501 (define-public kiss-fft-for-extempore
503 (name "kiss-fft-for-extempore")
507 (uri (string-append "https://github.com/extemporelang/kiss_fft/archive/"
509 (file-name (string-append name "-" version ".tar.gz"))
512 "0hkp9l6l4c92fb1l2sh6a6zv1hynpvb2s4d03vd8vxyvybc0l4pv"))))
513 (build-system cmake-build-system)
514 (arguments `(#:tests? #f)) ; no tests included
515 ;; Extempore refuses to build on architectures other than x86_64
516 (supported-systems '("x86_64-linux"))
517 (home-page "https://github.com/extemporelang/kiss_fft")
518 (synopsis "Mixed-radix Fast Fourier Transform")
520 "Kiss FFT attempts to be a reasonably efficient, moderately useful FFT
521 that can use fixed or floating data types and can easily be incorporated into
523 (license license:bsd-3)))
531 (uri (string-append "ftp://ftp.fftw.org/pub/fftw/fftw-"
535 "1kwbx92ps0r7s2mqy7lxbxanslxdzj7dp7r7gmdkzv1j8yqf3kwf"))))
536 (build-system gnu-build-system)
539 '("--enable-shared" "--enable-openmp" "--enable-threads")
540 #:phases (alist-cons-before
543 ;; By default '-mtune=native' is used. However, that may
544 ;; cause the use of ISA extensions (SSE2, etc.) that are
545 ;; not necessarily available on the user's machine when
546 ;; that package is built on a different machine.
547 (substitute* (find-files "." "Makefile$")
548 (("-mtune=native") "")))
550 (native-inputs `(("perl" ,perl)))
551 (home-page "http://fftw.org")
552 (synopsis "Computing the discrete Fourier transform")
554 "FFTW is a C subroutine library for computing the discrete Fourier
555 transform (DFT) in one or more dimensions, of arbitrary input size, and of
556 both real and complex data (as well as of even/odd data---i.e. the discrete
557 cosine/ sine transforms or DCT/DST).")
558 (license license:gpl2+)))
561 (package (inherit fftw)
564 (substitute-keyword-arguments (package-arguments fftw)
565 ((#:configure-flags cf)
566 `(cons "--enable-float" ,cf))))
568 (string-append (package-description fftw)
569 " Single-precision version."))))
571 (define-public fftw-openmpi
572 (package (inherit fftw)
573 (name "fftw-openmpi")
575 `(("openmpi" ,openmpi)
576 ,@(package-inputs fftw)))
578 (substitute-keyword-arguments (package-arguments fftw)
579 ((#:configure-flags cf)
580 `(cons "--enable-mpi" ,cf))))
582 (string-append (package-description fftw)
583 " With OpenMPI parallelism support."))))
591 (uri (string-append "https://bitbucket.org/eigen/eigen/get/"
595 "1zs5b210mq7nyanky07li6456rrd0xv2nxf6sl2lhkzdq5p067jd"))
596 (file-name (string-append name "-" version ".tar.bz2"))
597 (modules '((guix build utils)))
599 ;; There are 3 test failures in the "unsupported" directory,
600 ;; but maintainers say it's a known issue and it's unsupported
601 ;; anyway, so just skip them.
602 '(substitute* "CMakeLists.txt"
603 (("add_subdirectory\\(unsupported\\)")
604 "# Do not build the tests for unsupported features.\n")
606 ;; <http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1114>.
607 (("\"include/eigen3\"")
608 "\"${CMAKE_INSTALL_PREFIX}/include/eigen3\"")))))
609 (build-system cmake-build-system)
611 '(;; Turn off debugging symbols to save space.
612 #:build-type "Release"
614 #:phases (modify-phases %standard-phases
617 (let* ((cores (parallel-job-count))
618 (dash-j (format #f "-j~a" cores)))
619 ;; First build the tests, in parallel. See
620 ;; <http://eigen.tuxfamily.org/index.php?title=Tests>.
621 (and (zero? (system* "make" "buildtests" dash-j))
623 ;; Then run 'CTest' with -V so we get more
624 ;; details upon failure.
625 (zero? (system* "ctest" "-V" dash-j)))))))))
626 (home-page "http://eigen.tuxfamily.org")
627 (synopsis "C++ template library for linear algebra")
629 "Eigen is a C++ template library for linear algebra: matrices, vectors,
630 numerical solvers, and related algorithms. It provides an elegant API based
631 on \"expression templates\". It is versatile: it supports all matrix sizes,
632 all standard numeric types, various matrix decompositions and geometry
633 features, and more.")
635 ;; Most of the code is MPLv2, with a few files under LGPLv2.1+ or BSD-3.
636 ;; See 'COPYING.README' for details.
637 (license license:mpl2.0)))