1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2018 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
6 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
9 ;;; Copyright © 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
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 multiprecision)
27 #:use-module (guix licenses)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages autotools)
30 #:use-module (gnu packages m4)
31 #:use-module (gnu packages gcc)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix utils)
35 #:use-module (guix build-system gnu))
44 (string-append "mirror://gnu/gmp/gmp-"
48 "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7"))
49 (patches (search-patches "gmp-faulty-test.patch"))))
50 (build-system gnu-build-system)
51 (native-inputs `(("m4" ,m4)))
52 (outputs '("out" "debug"))
53 (arguments `(#:parallel-tests? #f ; mpz/reuse fails otherwise
55 '(;; Build a "fat binary", with routines for several
59 ,@(cond ((target-mingw?)
60 ;; Static and shared cannot be built in one go:
61 ;; they produce different headers. We need shared.
65 (synopsis "Multiple-precision arithmetic library")
67 "@dfn{GMP} (the GNU Multiple Precision Arithmetic Library) is a library for
68 arbitrary-precision arithmetic, operating on signed integers, rational numbers
69 and floating point numbers. The precision is only limited by the available
70 memory. The library is highly optimized, with a design focus on execution
71 speed. It is aimed at use in, for example, cryptography and computational
74 (home-page "https://gmplib.org/")))
76 (define-public gmp-6.0
77 ;; We keep this one around to bootstrap GCC, to work around a compilation
79 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
85 (uri (string-append "mirror://gnu/gmp/gmp-"
89 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
90 (patches (search-patches "gmp-arm-asm-nothumb.patch"
91 "gmp-faulty-test.patch"))))))
99 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
102 "0vp1lrc08gcmwdaqck6bpzllkrykvp06vz5gnqpyw0v3h9h4m1v7"))))
103 (build-system gnu-build-system)
104 (outputs '("out" "debug"))
105 (propagated-inputs `(("gmp" ,gmp))) ; <mpfr.h> refers to <gmp.h>
106 (synopsis "C library for arbitrary-precision floating-point arithmetic")
108 "GNU@tie{}@dfn{MPFR} (Multiple Precision Floating-Point Reliably) is a C
109 library for performing multiple-precision, floating-point computations with
112 (home-page "https://www.mpfr.org/")))
121 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
124 "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9"))))
125 (build-system gnu-build-system)
126 (outputs '("out" "debug"))
127 (propagated-inputs `(("gmp" ,gmp) ; <mpc.h> refers to both
129 (synopsis "C library for arbitrary-precision complex arithmetic")
131 "GNU@tie{}@dfn{MPC} (Multiple Precision Complex library) is a C library for
132 performing arithmetic on complex numbers. It supports arbitrarily high
133 precision and correctly rounds the results.")
135 (home-page "http://multiprecision.org/mpc/")))
144 (uri (string-append "https://gforge.inria.fr/frs/download.php"
145 "/latestfile/181/" name "-" version ".tar.bz2"))
147 (base32 "0bqr8yibl7jbrp0bw7xk1lm7nis7rv26jsz6y8ycvih8n9bx90r3"))))
148 (build-system gnu-build-system)
149 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
151 (synopsis "C library for arbitrary-precision interval arithmetic")
153 "@dfn{MPFI} (Multiple Precision Floating-point Interval) is a portable C
154 library for arbitrary-precision interval arithmetic, with intervals represented
155 using MPFR reliable floating-point numbers. It's based on the @dfn{GMP} (GNU
156 Multiple Precision Arithmetic) and GNU@tie{}@dfn{MPFR} (Multiple Precision
157 Floating-Point Reliably) libraries.
159 The purpose of arbitrary-precision interval arithmetic is to get results that
160 are both guaranteed, thanks to interval computation, and accurate, thanks to
161 multiple-precision arithmetic.")
163 (home-page "https://perso.ens-lyon.fr/nathalie.revol/software.html")))
172 (uri (string-append "http://irram.uni-trier.de/irram-files/iRRAM_"
175 (base32 "1cdmvb4hsa161rfdjqyhd9sb3fcr43p3a6nsj7cb4kn9f94qmjpj"))))
176 (build-system gnu-build-system)
177 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
180 `(#:parallel-build? #f))
181 (synopsis "C++ package for real arithmetic based on the Real-RAM concept")
183 "@dfn{iRRAM} is a C++ package for error-free real arithmetic based on
184 the concept of a Real-RAM. Its capabilities range from ordinary arithmetic
185 over trigonometric functions to linear algebra and differential
186 equations. A program using iRRAM is coded in ordinary C++, but may use a
187 special class that behaves like real numbers without any
188 error. Additionally, iRRAM uses the concept of multi-valued functions.")
190 (home-page "http://irram.uni-trier.de/")))
198 (uri (string-append "http://crd.lbl.gov/~dhbailey/mpdist/qd-"
202 "0wpgdzjcbanwd0c9mk90n04nas0q5fwc5zkrlbxyn6yjd2n8k3i6"))))
203 (build-system gnu-build-system)
205 `(("gfortran" ,gfortran)))
207 `(#:configure-flags `("--disable-enable_fma" ;weird :/
209 ,,@(if (string-prefix? "aarch64"
210 (or (%current-target-system)
212 ;; XXX: The qd_test test fails numerical
213 ;; accuracy checks for 'dd_real::exp()' on
214 ;; aarch64 with GCC 5.4 at -O2. Disabling
215 ;; expensive optimizations lets it pass.
216 '("CXXFLAGS=-O3 -fno-expensive-optimizations")
217 '("CXXFLAGS=-O3")))))
218 (home-page "http://crd-legacy.lbl.gov/~dhbailey/mpdist/")
219 (synopsis "Double-double and quad-double library")
220 (description "This package supports both a double-double
221 datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
222 decimal digits). The computational library is written in C++. Both C++ and
223 Fortran-90 high-level language interfaces are provided to permit one to
224 convert an existing C++ or Fortran-90 program to use the library with only
225 minor changes to the source code. In most cases only a few type statements
226 and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
227 and numerical quadrature programs are included.")
230 (define-public tomsfastmath
232 (name "tomsfastmath")
234 (synopsis "Large integer arithmetic library")
237 (uri (string-append "https://github.com/libtom/tomsfastmath/"
238 "releases/download/v" version "/"
239 "tfm-" version ".tar.xz"))
242 "0f0pmiaskh89sp0q933pafxb914shpaj5ad8sb5rzk1wv8d7mja7"))))
243 (build-system gnu-build-system)
245 `(("libtool" ,libtool)))
247 `(#:make-flags (list "-f" "makefile.shared"
248 (string-append "LIBPATH=" %output "/lib")
249 (string-append "INCPATH=" %output "/include")
250 "GROUP=root" "USER=root"
253 (modify-phases %standard-phases
254 (delete 'configure) ; no configuration
256 (lambda* (#:key make-flags #:allow-other-keys)
258 "stest" "test_standalone"
262 (add-before 'install 'install-nogroup
264 ;; Let permissions inherit from the current process.
265 (substitute* "makefile.shared"
266 (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
268 (add-after 'install 'install-doc
269 (lambda* (#:key outputs #:allow-other-keys)
270 (let ((docdir (string-append (assoc-ref outputs "out")
271 "/share/doc/tomsfastmath")))
272 (install-file "doc/tfm.pdf" docdir)
274 (add-after 'install 'install-pc
275 (lambda* (#:key outputs #:allow-other-keys)
276 (let* ((out (assoc-ref outputs "out"))
277 (pc-dir (string-append out "/lib/pkgconfig")))
278 (call-with-output-file "tomsfastmath.pc"
284 Libs: -L~a/lib -ltfm~%"
285 ,synopsis ,version out)))
286 (install-file "tomsfastmath.pc" pc-dir)
288 (home-page "https://www.libtom.net/TomsFastMath/")
289 (description "TomsFastMath is a large integer library written in portable
290 ISO C. It is a port of LibTomMath with optional support for inline assembler
292 (license public-domain)))
294 (define-public libtommath
298 (outputs '("out" "static"))
302 (uri (string-append "https://github.com/libtom/libtommath/releases/"
303 "download/v" version "/ltm-" version ".tar.xz"))
306 "1bbyagqzfdbg37k1n08nsqzdf44z8zsnjjinqbsyj7rxg246qilh"))
307 (patches (search-patches "libtommath-fix-linkage.patch"))))
308 (build-system gnu-build-system)
311 (modify-phases %standard-phases
312 (delete 'configure) ; no configure
313 (add-after 'unpack 'prepare-build
315 ;; Don't pull in coreutils.
316 (substitute* "makefile_include.mk"
317 (("arch") "uname -m"))
319 ;; We want the shared library by default so force it to be the
320 ;; default makefile target.
321 (delete-file "makefile")
322 (symlink "makefile.shared" "makefile")
324 (add-after 'install 'remove-static-library
325 (lambda* (#:key outputs #:allow-other-keys)
326 (delete-file (string-append (assoc-ref outputs "out")
327 "/lib/libtommath.a"))
330 (lambda* (#:key make-flags #:allow-other-keys)
331 (apply invoke "make" "test_standalone" make-flags)
332 (invoke "sh" "test")))
333 (add-after 'install 'install-static-library
334 (lambda* (#:key outputs #:allow-other-keys)
335 (invoke "make" "-f" "makefile.unix" "install"
336 (string-append "PREFIX=" (assoc-ref outputs "static"))
337 (string-append "CC=" (which "gcc"))))))
338 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
341 `(("libtool" ,libtool)))
342 (home-page "https://www.libtom.net/LibTomMath/")
343 (synopsis "Portable number theoretic multiple-precision integer library")
344 (description "LibTomMath is a portable number theoretic multiple-precision
345 integer library written entirely in C. It's designed to provide an API that is
346 simple to work with that provides fairly efficient routines that build out of
347 the box without configuration.")
348 (license unlicense)))
350 (define-public libtommath-1.0
358 (uri (string-append "https://github.com/libtom/libtommath/releases/"
359 "download/v" version "/ltm-" version ".tar.xz"))
362 "0sbccdwbkfc680id2fi0x067j23biqcjqilwkk7y9339knrjy0s7"))))
364 (substitute-keyword-arguments (package-arguments libtommath)
366 `(modify-phases ,phases
367 (delete 'install-static-library)))))))