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 "The @acronym{GMP, the GNU Multiple Precision Arithmetic} library performs
68 arbitrary-precision arithmetic on signed integers, rational numbers and floating
69 point numbers. The precision is only limited by the available memory.
70 The library is highly optimized, with a design focus on execution speed.
71 It is aimed at use in, for example, cryptography and computational algebra.")
73 (home-page "https://gmplib.org/")))
75 (define-public gmp-6.0
76 ;; We keep this one around to bootstrap GCC, to work around a compilation
78 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
84 (uri (string-append "mirror://gnu/gmp/gmp-"
88 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
89 (patches (search-patches "gmp-arm-asm-nothumb.patch"
90 "gmp-faulty-test.patch"))))))
98 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
101 "12m3amcavhpqygc499s3fzqlb8f2j2rr7fkqsm10xbjfc04fffqx"))))
102 (build-system gnu-build-system)
103 (outputs '("out" "debug"))
104 (propagated-inputs `(("gmp" ,gmp))) ; <mpfr.h> refers to <gmp.h>
105 (synopsis "C library for arbitrary-precision floating-point arithmetic")
107 "GNU@tie{}@acronym{MPFR, Multiple Precision Floating-Point Reliably} is a C
108 library for performing multiple-precision, floating-point computations with
111 (home-page "https://www.mpfr.org/")))
120 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
123 "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9"))))
124 (build-system gnu-build-system)
125 (outputs '("out" "debug"))
126 (propagated-inputs `(("gmp" ,gmp) ; <mpc.h> refers to both
128 (synopsis "C library for arbitrary-precision complex arithmetic")
130 "GNU@tie{}@acronym{MPC, Multiple Precision Complex library} is a C library
131 for performing arithmetic on complex numbers. It supports arbitrarily high
132 precision and correctly rounds the results.")
134 (home-page "http://multiprecision.org/mpc/")))
143 (uri (string-append "https://gforge.inria.fr/frs/download.php"
144 "/latestfile/181/" name "-" version ".tar.bz2"))
146 (base32 "0bqr8yibl7jbrp0bw7xk1lm7nis7rv26jsz6y8ycvih8n9bx90r3"))))
147 (build-system gnu-build-system)
148 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
150 (synopsis "C library for arbitrary-precision interval arithmetic")
152 "@acronym{MPFI, Multiple Precision Floating-point Interval} is a portable C
153 library for arbitrary-precision interval arithmetic, with intervals represented
154 using MPFR reliable floating-point numbers. It's based on the @acronym{GMP, GNU
155 Multiple Precision Arithmetic} and GNU@tie{}@acronym{MPFR, Multiple Precision
156 Floating-Point Reliably} libraries.
158 The purpose of arbitrary-precision interval arithmetic is to get results that
159 are both guaranteed, thanks to interval computation, and accurate, thanks to
160 multiple-precision arithmetic.")
162 (home-page "https://perso.ens-lyon.fr/nathalie.revol/software.html")))
171 (uri (string-append "http://irram.uni-trier.de/irram-files/iRRAM_"
174 (base32 "1cdmvb4hsa161rfdjqyhd9sb3fcr43p3a6nsj7cb4kn9f94qmjpj"))))
175 (build-system gnu-build-system)
176 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
179 `(#:parallel-build? #f))
180 (synopsis "C++ package for real arithmetic based on the Real-RAM concept")
182 "@dfn{iRRAM} is a C++ package for error-free real arithmetic based on
183 the concept of a Real-RAM. Its capabilities range from ordinary arithmetic
184 over trigonometric functions to linear algebra and differential
185 equations. A program using iRRAM is coded in ordinary C++, but may use a
186 special class that behaves like real numbers without any
187 error. Additionally, iRRAM uses the concept of multi-valued functions.")
189 (home-page "http://irram.uni-trier.de/")))
198 (uri (string-append "https://crd-legacy.lbl.gov/~dhbailey/mpdist/qd-"
201 (base32 "1lq609rsp6zpg7zda75lyxzzk1fabzp4jn88j7xfk84mdgjgzh9h"))))
202 (build-system gnu-build-system)
204 `(("gfortran" ,gfortran)))
206 `(#:configure-flags `("--disable-enable_fma" ;weird :/
208 ,,@(if (string-prefix? "aarch64"
209 (or (%current-target-system)
211 ;; XXX: The qd_test test fails numerical
212 ;; accuracy checks for 'dd_real::exp()' on
213 ;; aarch64 with GCC 5.4 at -O2. Disabling
214 ;; expensive optimizations lets it pass.
215 '("CXXFLAGS=-O3 -fno-expensive-optimizations")
216 '("CXXFLAGS=-O3")))))
217 (home-page "https://www.davidhbailey.com/dhbsoftware/")
218 (synopsis "Double-double and quad-double library")
219 (description "This package supports both a double-double
220 datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
221 decimal digits). The computational library is written in C++. Both C++ and
222 Fortran-90 high-level language interfaces are provided to permit one to
223 convert an existing C++ or Fortran-90 program to use the library with only
224 minor changes to the source code. In most cases only a few type statements
225 and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
226 and numerical quadrature programs are included.")
229 (define-public tomsfastmath
231 (name "tomsfastmath")
233 (synopsis "Large integer arithmetic library")
236 (uri (string-append "https://github.com/libtom/tomsfastmath/"
237 "releases/download/v" version "/"
238 "tfm-" version ".tar.xz"))
241 "0f0pmiaskh89sp0q933pafxb914shpaj5ad8sb5rzk1wv8d7mja7"))))
242 (build-system gnu-build-system)
244 `(("libtool" ,libtool)))
246 `(#:make-flags (list "-f" "makefile.shared"
247 (string-append "LIBPATH=" %output "/lib")
248 (string-append "INCPATH=" %output "/include")
249 "GROUP=root" "USER=root"
252 (modify-phases %standard-phases
253 (delete 'configure) ; no configuration
255 (lambda* (#:key make-flags #:allow-other-keys)
257 "stest" "test_standalone"
261 (add-before 'install 'install-nogroup
263 ;; Let permissions inherit from the current process.
264 (substitute* "makefile.shared"
265 (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
267 (add-after 'install 'install-doc
268 (lambda* (#:key outputs #:allow-other-keys)
269 (let ((docdir (string-append (assoc-ref outputs "out")
270 "/share/doc/tomsfastmath")))
271 (install-file "doc/tfm.pdf" docdir)
273 (add-after 'install 'install-pc
274 (lambda* (#:key outputs #:allow-other-keys)
275 (let* ((out (assoc-ref outputs "out"))
276 (pc-dir (string-append out "/lib/pkgconfig")))
277 (call-with-output-file "tomsfastmath.pc"
283 Libs: -L~a/lib -ltfm~%"
284 ,synopsis ,version out)))
285 (install-file "tomsfastmath.pc" pc-dir)
287 (home-page "https://www.libtom.net/TomsFastMath/")
288 (description "TomsFastMath is a large integer library written in portable
289 ISO C. It is a port of LibTomMath with optional support for inline assembler
291 (license public-domain)))
293 (define-public libtommath
297 (outputs '("out" "static"))
301 (uri (string-append "https://github.com/libtom/libtommath/releases/"
302 "download/v" version "/ltm-" version ".tar.xz"))
305 "1c8q1qy88cjhdjlk3g24mra94h34c1ldvkjz0n2988c0yvn5xixp"))))
306 (build-system gnu-build-system)
309 (modify-phases %standard-phases
310 (delete 'configure) ; no configure
311 (add-after 'unpack 'prepare-build
313 ;; We want the shared library by default so force it to be the
314 ;; default makefile target.
315 (delete-file "makefile")
316 (symlink "makefile.shared" "makefile")
318 (add-after 'install 'remove-static-library
319 (lambda* (#:key outputs #:allow-other-keys)
320 (delete-file (string-append (assoc-ref outputs "out")
321 "/lib/libtommath.a"))
324 (lambda* (#:key test-target make-flags #:allow-other-keys)
325 (apply invoke "make" test-target make-flags)
326 (invoke "sh" "test")))
327 (add-after 'install 'install-static-library
328 (lambda* (#:key outputs #:allow-other-keys)
329 (invoke "make" "-f" "makefile.unix" "install"
330 (string-append "PREFIX=" (assoc-ref outputs "static"))
331 (string-append "CC=" (which "gcc"))))))
333 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
336 `(("libtool" ,libtool)))
337 (home-page "https://www.libtom.net/LibTomMath/")
338 (synopsis "Portable number theoretic multiple-precision integer library")
339 (description "LibTomMath is a portable number theoretic multiple-precision
340 integer library written entirely in C. It's designed to provide an API that is
341 simple to work with that provides fairly efficient routines that build out of
342 the box without configuration.")
343 (license unlicense)))
345 (define-public libtommath-1.1
352 (uri (string-append "https://github.com/libtom/libtommath/releases/"
353 "download/v" version "/ltm-" version ".tar.xz"))
356 "1bbyagqzfdbg37k1n08nsqzdf44z8zsnjjinqbsyj7rxg246qilh"))
357 (patches (search-patches "libtommath-fix-linkage.patch"))))
359 (substitute-keyword-arguments (package-arguments libtommath)
361 `(modify-phases ,phases
362 (add-after 'unpack 'patch-coreutils-call
364 ;; Don't pull in coreutils.
365 (substitute* "makefile_include.mk"
366 (("arch") "uname -m"))
368 ((#:test-target _) "test_standalone")))))
370 (define-public libtommath-1.0
372 (inherit libtommath-1.1)
378 (uri (string-append "https://github.com/libtom/libtommath/releases/"
379 "download/v" version "/ltm-" version ".tar.xz"))
382 "0sbccdwbkfc680id2fi0x067j23biqcjqilwkk7y9339knrjy0s7"))))
384 (substitute-keyword-arguments (package-arguments libtommath-1.1)
386 `(modify-phases ,phases
387 (delete 'install-static-library)))))))