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, 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
6 ;;; Copyright © 2016, 2020 Jan (janneke) 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 (gnu packages texinfo)
33 #:use-module (guix packages)
34 #:use-module (guix download)
35 #:use-module (guix utils)
36 #:use-module (guix build-system gnu))
45 (string-append "mirror://gnu/gmp/gmp-"
49 "09hmg8k63mbfrx1x3yy6y1yzbbq85kw5avbibhcgrg9z3ganr3i5"))
50 (patches (search-patches "gmp-faulty-test.patch"))))
51 (build-system gnu-build-system)
52 (native-inputs `(("m4" ,m4)))
53 (outputs '("out" "debug"))
55 `(#:parallel-tests? #f ; mpz/reuse fails otherwise
57 '(;; Build a "fat binary", with routines for several
61 ,@(cond ((target-mingw?)
62 ;; Static and shared cannot be built in one go:
63 ;; they produce different headers. We need shared.
67 ;; Remove after core-updates merge.
68 ;; Workaround for gcc-7 transition breakage, -system and cross-build,
69 ;; Note: See <http://bugs.gnu.org/22186> for why not 'CPATH'.
70 ;; Note: See <http://bugs.gnu.org/30756> for why not 'C_INCLUDE_PATH' & co.
73 (modify-phases %standard-phases
74 (add-before 'configure 'setenv
76 (let ((gcc (assoc-ref %build-inputs "cross-gcc"))
77 (libc (assoc-ref %build-inputs "cross-libc")))
78 (setenv "CROSS_CPLUS_INCLUDE_PATH"
79 (string-append gcc "/include/c++"
82 (format #t "environment variable `CROSS_CPLUS_INCLUDE_PATH' set to `~a'\n"
83 (getenv "CROSS_CPLUS_INCLUDE_PATH"))
86 (synopsis "Multiple-precision arithmetic library")
88 "The @acronym{GMP, the GNU Multiple Precision Arithmetic} library performs
89 arbitrary-precision arithmetic on signed integers, rational numbers and floating
90 point numbers. The precision is only limited by the available memory.
91 The library is highly optimized, with a design focus on execution speed.
92 It is aimed at use in, for example, cryptography and computational algebra.")
94 (home-page "https://gmplib.org/")))
96 (define-public gmp-6.0
97 ;; We keep this one around to bootstrap GCC, to work around a compilation
99 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
105 (uri (string-append "mirror://gnu/gmp/gmp-"
109 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
110 (patches (search-patches "gmp-arm-asm-nothumb.patch"
111 "gmp-faulty-test.patch"))))))
119 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
122 "12m3amcavhpqygc499s3fzqlb8f2j2rr7fkqsm10xbjfc04fffqx"))))
123 (build-system gnu-build-system)
124 (outputs '("out" "debug"))
125 (propagated-inputs `(("gmp" ,gmp))) ; <mpfr.h> refers to <gmp.h>
126 (synopsis "C library for arbitrary-precision floating-point arithmetic")
128 "GNU@tie{}@acronym{MPFR, Multiple Precision Floating-Point Reliably} is a C
129 library for performing multiple-precision, floating-point computations with
132 (home-page "https://www.mpfr.org/")))
141 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
144 "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9"))))
145 (build-system gnu-build-system)
146 (outputs '("out" "debug"))
147 (propagated-inputs `(("gmp" ,gmp) ; <mpc.h> refers to both
149 (synopsis "C library for arbitrary-precision complex arithmetic")
151 "GNU@tie{}@acronym{MPC, Multiple Precision Complex library} is a C library
152 for performing arithmetic on complex numbers. It supports arbitrarily high
153 precision and correctly rounds the results.")
155 (home-page "http://www.multiprecision.org/mpc/")))
164 (uri (string-append "https://gforge.inria.fr/frs/download.php"
165 "/latestfile/181/mpfi-" version ".tgz"))
167 (base32 "0mismr1ll3wp788dq2n22s5irm0dziy75byyfdwz22kjbmckhf9v"))))
168 (build-system gnu-build-system)
170 `(#:tests? #f ;tests are broken in this release
171 #:configure-flags '("--enable-static=no")))
173 `(("automake" ,automake)
174 ("autoreconf" ,autoconf)
176 ("texinfo" ,texinfo)))
178 `(("gmp" ,gmp) ; <mpfi.h> refers to both
180 (home-page "https://gforge.inria.fr/projects/mpfi/")
181 (synopsis "C library for arbitrary-precision interval arithmetic")
183 "@acronym{MPFI, Multiple Precision Floating-point Interval} is a portable C
184 library for arbitrary-precision interval arithmetic, with intervals represented
185 using MPFR reliable floating-point numbers. It's based on the @acronym{GMP, GNU
186 Multiple Precision Arithmetic} and GNU@tie{}@acronym{MPFR, Multiple Precision
187 Floating-Point Reliably} libraries.
189 The purpose of arbitrary-precision interval arithmetic is to get results that
190 are both guaranteed, thanks to interval computation, and accurate, thanks to
191 multiple-precision arithmetic.")
201 (uri (string-append "http://irram.uni-trier.de/irram-files/iRRAM_"
204 (base32 "1cdmvb4hsa161rfdjqyhd9sb3fcr43p3a6nsj7cb4kn9f94qmjpj"))))
205 (build-system gnu-build-system)
206 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
209 `(#:parallel-build? #f))
210 (synopsis "C++ package for real arithmetic based on the Real-RAM concept")
212 "@dfn{iRRAM} is a C++ package for error-free real arithmetic based on
213 the concept of a Real-RAM. Its capabilities range from ordinary arithmetic
214 over trigonometric functions to linear algebra and differential
215 equations. A program using iRRAM is coded in ordinary C++, but may use a
216 special class that behaves like real numbers without any
217 error. Additionally, iRRAM uses the concept of multi-valued functions.")
219 (home-page "http://irram.uni-trier.de/")))
228 (uri (string-append "https://crd-legacy.lbl.gov/~dhbailey/mpdist/qd-"
231 (base32 "1lq609rsp6zpg7zda75lyxzzk1fabzp4jn88j7xfk84mdgjgzh9h"))))
232 (build-system gnu-build-system)
234 `(("gfortran" ,gfortran)))
236 `(#:configure-flags `("--disable-enable_fma" ;weird :/
238 ,,@(if (string-prefix? "aarch64"
239 (or (%current-target-system)
241 ;; XXX: The qd_test test fails numerical
242 ;; accuracy checks for 'dd_real::exp()' on
243 ;; aarch64 with GCC 5.4 at -O2. Disabling
244 ;; expensive optimizations lets it pass.
245 '("CXXFLAGS=-O3 -fno-expensive-optimizations")
246 '("CXXFLAGS=-O3")))))
247 (home-page "https://www.davidhbailey.com/dhbsoftware/")
248 (synopsis "Double-double and quad-double library")
249 (description "This package supports both a double-double
250 datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
251 decimal digits). The computational library is written in C++. Both C++ and
252 Fortran-90 high-level language interfaces are provided to permit one to
253 convert an existing C++ or Fortran-90 program to use the library with only
254 minor changes to the source code. In most cases only a few type statements
255 and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
256 and numerical quadrature programs are included.")
259 (define-public tomsfastmath
261 (name "tomsfastmath")
263 (synopsis "Large integer arithmetic library")
266 (uri (string-append "https://github.com/libtom/tomsfastmath/"
267 "releases/download/v" version "/"
268 "tfm-" version ".tar.xz"))
271 "0f0pmiaskh89sp0q933pafxb914shpaj5ad8sb5rzk1wv8d7mja7"))))
272 (build-system gnu-build-system)
274 `(("libtool" ,libtool)))
276 `(#:make-flags (list "-f" "makefile.shared"
277 (string-append "LIBPATH=" %output "/lib")
278 (string-append "INCPATH=" %output "/include")
279 "GROUP=root" "USER=root"
282 (modify-phases %standard-phases
283 (delete 'configure) ; no configuration
285 (lambda* (#:key make-flags #:allow-other-keys)
287 "stest" "test_standalone"
291 (add-before 'install 'install-nogroup
293 ;; Let permissions inherit from the current process.
294 (substitute* "makefile.shared"
295 (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
297 (add-after 'install 'install-doc
298 (lambda* (#:key outputs #:allow-other-keys)
299 (let ((docdir (string-append (assoc-ref outputs "out")
300 "/share/doc/tomsfastmath")))
301 (install-file "doc/tfm.pdf" docdir)
303 (add-after 'install 'install-pc
304 (lambda* (#:key outputs #:allow-other-keys)
305 (let* ((out (assoc-ref outputs "out"))
306 (pc-dir (string-append out "/lib/pkgconfig")))
307 (call-with-output-file "tomsfastmath.pc"
313 Libs: -L~a/lib -ltfm~%"
314 ,synopsis ,version out)))
315 (install-file "tomsfastmath.pc" pc-dir)
317 (home-page "https://www.libtom.net/TomsFastMath/")
318 (description "TomsFastMath is a large integer library written in portable
319 ISO C. It is a port of LibTomMath with optional support for inline assembler
321 (license public-domain)))
323 (define-public libtommath
327 (outputs '("out" "static"))
331 (uri (string-append "https://github.com/libtom/libtommath/releases/"
332 "download/v" version "/ltm-" version ".tar.xz"))
335 "1c8q1qy88cjhdjlk3g24mra94h34c1ldvkjz0n2988c0yvn5xixp"))))
336 (build-system gnu-build-system)
339 (modify-phases %standard-phases
340 (delete 'configure) ; no configure
341 (add-after 'unpack 'prepare-build
343 ;; We want the shared library by default so force it to be the
344 ;; default makefile target.
345 (delete-file "makefile")
346 (symlink "makefile.shared" "makefile")
348 (add-after 'install 'remove-static-library
349 (lambda* (#:key outputs #:allow-other-keys)
350 (delete-file (string-append (assoc-ref outputs "out")
351 "/lib/libtommath.a"))
354 (lambda* (#:key test-target make-flags #:allow-other-keys)
355 (apply invoke "make" test-target make-flags)
356 (invoke "sh" "test")))
357 (add-after 'install 'install-static-library
358 (lambda* (#:key outputs #:allow-other-keys)
359 (invoke "make" "-f" "makefile.unix" "install"
360 (string-append "PREFIX=" (assoc-ref outputs "static"))
361 (string-append "CC=" (which "gcc"))))))
363 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
366 `(("libtool" ,libtool)))
367 (home-page "https://www.libtom.net/LibTomMath/")
368 (synopsis "Portable number theoretic multiple-precision integer library")
369 (description "LibTomMath is a portable number theoretic multiple-precision
370 integer library written entirely in C. It's designed to provide an API that is
371 simple to work with that provides fairly efficient routines that build out of
372 the box without configuration.")
373 (license unlicense)))
375 (define-public libtommath-1.1
382 (uri (string-append "https://github.com/libtom/libtommath/releases/"
383 "download/v" version "/ltm-" version ".tar.xz"))
386 "1bbyagqzfdbg37k1n08nsqzdf44z8zsnjjinqbsyj7rxg246qilh"))
387 (patches (search-patches "libtommath-fix-linkage.patch"))))
389 (substitute-keyword-arguments (package-arguments libtommath)
391 `(modify-phases ,phases
392 (add-after 'unpack 'patch-coreutils-call
394 ;; Don't pull in coreutils.
395 (substitute* "makefile_include.mk"
396 (("arch") "uname -m"))
398 ((#:test-target _) "test_standalone")))))
400 (define-public libtommath-1.0
402 (inherit libtommath-1.1)
408 (uri (string-append "https://github.com/libtom/libtommath/releases/"
409 "download/v" version "/ltm-" version ".tar.xz"))
412 "0sbccdwbkfc680id2fi0x067j23biqcjqilwkk7y9339knrjy0s7"))))
414 (substitute-keyword-arguments (package-arguments libtommath-1.1)
416 `(modify-phases ,phases
417 (delete 'install-static-library)))))))