gnu: Add external-program.
[jackhill/guix/guix.git] / gnu / packages / multiprecision.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
42e735df 2;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <ludo@gnu.org>
24aaf2f2 3;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
df131dba 4;;; Copyright © 2015, 2018 Andreas Enge <andreas@enge.fr>
61bb3555 5;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
7f1c32f0 6;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
abd402e3 7;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
cbc084e1 8;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
1a753385 9;;; Copyright © 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
c44899a2 10;;;
233e7676 11;;; This file is part of GNU Guix.
c44899a2 12;;;
233e7676 13;;; GNU Guix is free software; you can redistribute it and/or modify it
c44899a2
LC
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.
17;;;
233e7676 18;;; GNU Guix is distributed in the hope that it will be useful, but
c44899a2
LC
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.
22;;;
23;;; You should have received a copy of the GNU General Public License
233e7676 24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
c44899a2 25
1ffa7090 26(define-module (gnu packages multiprecision)
4a44e743 27 #:use-module (guix licenses)
59a43334 28 #:use-module (gnu packages)
7ed018e8 29 #:use-module (gnu packages autotools)
1ffa7090 30 #:use-module (gnu packages m4)
cbc084e1 31 #:use-module (gnu packages gcc)
c44899a2 32 #:use-module (guix packages)
87f5d366 33 #:use-module (guix download)
24aaf2f2 34 #:use-module (guix utils)
c44899a2
LC
35 #:use-module (guix build-system gnu))
36
37(define-public gmp
38 (package
39 (name "gmp")
89ccb1d8 40 (version "6.1.2")
c44899a2 41 (source (origin
87f5d366 42 (method url-fetch)
704197f4 43 (uri
93a6f552
AE
44 (string-append "mirror://gnu/gmp/gmp-"
45 version ".tar.xz"))
c44899a2
LC
46 (sha256
47 (base32
89ccb1d8 48 "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7"))
fc1adab1 49 (patches (search-patches "gmp-faulty-test.patch"))))
c44899a2
LC
50 (build-system gnu-build-system)
51 (native-inputs `(("m4" ,m4)))
9bf62d9b 52 (outputs '("out" "debug"))
4165fda2
AE
53 (arguments `(#:parallel-tests? #f ; mpz/reuse fails otherwise
54 #:configure-flags
c44899a2
LC
55 '(;; Build a "fat binary", with routines for several
56 ;; sub-architectures.
57 "--enable-fat"
7f1c32f0
JN
58 "--enable-cxx"
59 ,@(cond ((target-mingw?)
60 ;; Static and shared cannot be built in one go:
61 ;; they produce different headers. We need shared.
62 `("--disable-static"
63 "--enable-shared"))
64 (else '())))))
f50d2669 65 (synopsis "Multiple-precision arithmetic library")
c44899a2 66 (description
245fae90
TGR
67 "The @acronym{GMP, the GNU Multiple Precision Arithmetic} library performs
68arbitrary-precision arithmetic on signed integers, rational numbers and floating
69point numbers. The precision is only limited by the available memory.
70The library is highly optimized, with a design focus on execution speed.
71It is aimed at use in, for example, cryptography and computational algebra.")
4a44e743 72 (license lgpl3+)
75213ad2 73 (home-page "https://gmplib.org/")))
c44899a2 74
8309c389
LC
75(define-public gmp-6.0
76 ;; We keep this one around to bootstrap GCC, to work around a compilation
77 ;; issue on ARM. See
78 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
79 (package
80 (inherit gmp)
81 (version "6.0.0a")
82 (source (origin
83 (method url-fetch)
84 (uri (string-append "mirror://gnu/gmp/gmp-"
85 version ".tar.xz"))
86 (sha256
87 (base32
88 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
fc1adab1
AK
89 (patches (search-patches "gmp-arm-asm-nothumb.patch"
90 "gmp-faulty-test.patch"))))))
8309c389 91
c44899a2
LC
92(define-public mpfr
93 (package
94 (name "mpfr")
e34ae707 95 (version "4.0.2")
c44899a2 96 (source (origin
87f5d366 97 (method url-fetch)
0db342a5 98 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
c44899a2
LC
99 ".tar.xz"))
100 (sha256 (base32
e34ae707 101 "12m3amcavhpqygc499s3fzqlb8f2j2rr7fkqsm10xbjfc04fffqx"))))
c44899a2 102 (build-system gnu-build-system)
9bf62d9b 103 (outputs '("out" "debug"))
a6ef51e3 104 (propagated-inputs `(("gmp" ,gmp))) ; <mpfr.h> refers to <gmp.h>
5b7900d7 105 (synopsis "C library for arbitrary-precision floating-point arithmetic")
c44899a2 106 (description
932b6072 107 "GNU@tie{}@acronym{MPFR, Multiple Precision Floating-Point Reliably} is a C
5b7900d7
TGR
108library for performing multiple-precision, floating-point computations with
109correct rounding.")
4a44e743 110 (license lgpl3+)
617cf5de 111 (home-page "https://www.mpfr.org/")))
c44899a2
LC
112
113(define-public mpc
114 (package
115 (name "mpc")
e48859b2 116 (version "1.1.0")
c44899a2 117 (source (origin
87f5d366 118 (method url-fetch)
c44899a2 119 (uri (string-append
8e1cd713 120 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
945562d4
AE
121 (sha256
122 (base32
e48859b2 123 "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9"))))
c44899a2 124 (build-system gnu-build-system)
9bf62d9b 125 (outputs '("out" "debug"))
a6ef51e3
LC
126 (propagated-inputs `(("gmp" ,gmp) ; <mpc.h> refers to both
127 ("mpfr" ,mpfr)))
246db471 128 (synopsis "C library for arbitrary-precision complex arithmetic")
c44899a2 129 (description
aaf80ba7
TGR
130 "GNU@tie{}@acronym{MPC, Multiple Precision Complex library} is a C library
131for performing arithmetic on complex numbers. It supports arbitrarily high
246db471 132precision and correctly rounds the results.")
4a44e743 133 (license lgpl3+)
45fc77e5 134 (home-page "http://multiprecision.org/mpc/")))
61bb3555
NG
135
136(define-public mpfi
137 (package
138 (name "mpfi")
f89cebb1
TGR
139 (version "1.5.3")
140 (source
141 (origin
142 (method url-fetch)
143 (uri (string-append "https://gforge.inria.fr/frs/download.php"
144 "/latestfile/181/" name "-" version ".tar.bz2"))
145 (sha256
146 (base32 "0bqr8yibl7jbrp0bw7xk1lm7nis7rv26jsz6y8ycvih8n9bx90r3"))))
61bb3555
NG
147 (build-system gnu-build-system)
148 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
149 ("mpfr" ,mpfr)))
24a87a14
TGR
150 (synopsis "C library for arbitrary-precision interval arithmetic")
151 (description
ded545d5 152 "@acronym{MPFI, Multiple Precision Floating-point Interval} is a portable C
24a87a14 153library for arbitrary-precision interval arithmetic, with intervals represented
ded545d5
TGR
154using MPFR reliable floating-point numbers. It's based on the @acronym{GMP, GNU
155Multiple Precision Arithmetic} and GNU@tie{}@acronym{MPFR, Multiple Precision
156Floating-Point Reliably} libraries.
24a87a14
TGR
157
158The purpose of arbitrary-precision interval arithmetic is to get results that
159are both guaranteed, thanks to interval computation, and accurate, thanks to
160multiple-precision arithmetic.")
61bb3555
NG
161 (license lgpl2.1+)
162 (home-page "https://perso.ens-lyon.fr/nathalie.revol/software.html")))
cbc084e1 163
df131dba
AE
164(define-public irram
165 (package
166 (name "irram")
167 (version "2013_01")
168 (source
169 (origin
170 (method url-fetch)
171 (uri (string-append "http://irram.uni-trier.de/irram-files/iRRAM_"
172 version ".tar.bz2"))
173 (sha256
174 (base32 "1cdmvb4hsa161rfdjqyhd9sb3fcr43p3a6nsj7cb4kn9f94qmjpj"))))
175 (build-system gnu-build-system)
176 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
177 ("mpfr" ,mpfr)))
178 (arguments
179 `(#:parallel-build? #f))
180 (synopsis "C++ package for real arithmetic based on the Real-RAM concept")
181 (description
182 "@dfn{iRRAM} is a C++ package for error-free real arithmetic based on
183the concept of a Real-RAM. Its capabilities range from ordinary arithmetic
184over trigonometric functions to linear algebra and differential
185equations. A program using iRRAM is coded in ordinary C++, but may use a
186special class that behaves like real numbers without any
187error. Additionally, iRRAM uses the concept of multi-valued functions.")
188 (license lgpl2.0+)
189 (home-page "http://irram.uni-trier.de/")))
190
cbc084e1
EB
191(define-public qd
192 (package
193 (name "qd")
8eb2c565 194 (version "2.3.22")
f52e8347
TGR
195 (source
196 (origin
197 (method url-fetch)
198 (uri (string-append "https://crd-legacy.lbl.gov/~dhbailey/mpdist/qd-"
199 version ".tar.gz"))
200 (sha256
201 (base32 "1lq609rsp6zpg7zda75lyxzzk1fabzp4jn88j7xfk84mdgjgzh9h"))))
cbc084e1
EB
202 (build-system gnu-build-system)
203 (native-inputs
204 `(("gfortran" ,gfortran)))
205 (arguments
206 `(#:configure-flags `("--disable-enable_fma" ;weird :/
207 "--enable-shared"
208 ,,@(if (string-prefix? "aarch64"
209 (or (%current-target-system)
210 (%current-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")))))
f52e8347 217 (home-page "https://www.davidhbailey.com/dhbsoftware/")
cbc084e1
EB
218 (synopsis "Double-double and quad-double library")
219 (description "This package supports both a double-double
220datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
221decimal digits). The computational library is written in C++. Both C++ and
222Fortran-90 high-level language interfaces are provided to permit one to
223convert an existing C++ or Fortran-90 program to use the library with only
224minor changes to the source code. In most cases only a few type statements
225and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
226and numerical quadrature programs are included.")
227 (license bsd-3)))
7ed018e8
EB
228
229(define-public tomsfastmath
230 (package
231 (name "tomsfastmath")
d0d207cd 232 (version "0.13.1")
7ed018e8
EB
233 (synopsis "Large integer arithmetic library")
234 (source (origin
235 (method url-fetch)
236 (uri (string-append "https://github.com/libtom/tomsfastmath/"
237 "releases/download/v" version "/"
d0d207cd 238 "tfm-" version ".tar.xz"))
7ed018e8
EB
239 (sha256
240 (base32
d0d207cd 241 "0f0pmiaskh89sp0q933pafxb914shpaj5ad8sb5rzk1wv8d7mja7"))))
7ed018e8
EB
242 (build-system gnu-build-system)
243 (native-inputs
244 `(("libtool" ,libtool)))
245 (arguments
246 `(#:make-flags (list "-f" "makefile.shared"
247 (string-append "LIBPATH=" %output "/lib")
248 (string-append "INCPATH=" %output "/include")
249 "GROUP=root" "USER=root"
250 "CC=gcc")
251 #:phases
252 (modify-phases %standard-phases
d0d207cd 253 (delete 'configure) ; no configuration
7ed018e8
EB
254 (replace 'check
255 (lambda* (#:key make-flags #:allow-other-keys)
20fe9728
RW
256 (apply invoke "make"
257 "stest" "test_standalone"
258 make-flags)
259 (invoke "./stest")
260 (invoke "./test")))
7ed018e8
EB
261 (add-before 'install 'install-nogroup
262 (lambda _
d0d207cd 263 ;; Let permissions inherit from the current process.
7ed018e8
EB
264 (substitute* "makefile.shared"
265 (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
266 #t))
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)
272 #t)))
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"
278 (lambda (port)
279 (format port "~
280Name: TomsFastMath
281Description: ~a
282Version: ~a
283Libs: -L~a/lib -ltfm~%"
284 ,synopsis ,version out)))
285 (install-file "tomsfastmath.pc" pc-dir)
286 #t))))))
abd402e3 287 (home-page "https://www.libtom.net/TomsFastMath/")
7ed018e8
EB
288 (description "TomsFastMath is a large integer library written in portable
289ISO C. It is a port of LibTomMath with optional support for inline assembler
290multiplies.")
291 (license public-domain)))
1a753385
EF
292
293(define-public libtommath
294 (package
295 (name "libtommath")
0201e34c 296 (version "1.2.0")
1a753385
EF
297 (outputs '("out" "static"))
298 (source
299 (origin
300 (method url-fetch)
301 (uri (string-append "https://github.com/libtom/libtommath/releases/"
302 "download/v" version "/ltm-" version ".tar.xz"))
303 (sha256
304 (base32
0201e34c 305 "1c8q1qy88cjhdjlk3g24mra94h34c1ldvkjz0n2988c0yvn5xixp"))))
1a753385
EF
306 (build-system gnu-build-system)
307 (arguments
308 '(#:phases
309 (modify-phases %standard-phases
310 (delete 'configure) ; no configure
311 (add-after 'unpack 'prepare-build
312 (lambda _
1a753385
EF
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")
317 #t))
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"))
322 #t))
323 (replace 'check
0201e34c
EF
324 (lambda* (#:key test-target make-flags #:allow-other-keys)
325 (apply invoke "make" test-target make-flags)
1a753385
EF
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"))))))
0201e34c 332 #:test-target "test"
1a753385
EF
333 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
334 "CC=gcc")))
335 (native-inputs
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
340integer library written entirely in C. It's designed to provide an API that is
341simple to work with that provides fairly efficient routines that build out of
342the box without configuration.")
343 (license unlicense)))
cf3f12f6 344
0201e34c 345(define-public libtommath-1.1
cf3f12f6
EF
346 (package
347 (inherit libtommath)
0201e34c
EF
348 (version "1.1.0")
349 (source
350 (origin
351 (method url-fetch)
352 (uri (string-append "https://github.com/libtom/libtommath/releases/"
353 "download/v" version "/ltm-" version ".tar.xz"))
354 (sha256
355 (base32
356 "1bbyagqzfdbg37k1n08nsqzdf44z8zsnjjinqbsyj7rxg246qilh"))
357 (patches (search-patches "libtommath-fix-linkage.patch"))))
358 (arguments
359 (substitute-keyword-arguments (package-arguments libtommath)
360 ((#:phases phases)
361 `(modify-phases ,phases
362 (add-after 'unpack 'patch-coreutils-call
363 (lambda _
364 ;; Don't pull in coreutils.
365 (substitute* "makefile_include.mk"
366 (("arch") "uname -m"))
367 #t))))
368 ((#:test-target _) "test_standalone")))))
369
370(define-public libtommath-1.0
371 (package
372 (inherit libtommath-1.1)
cf3f12f6
EF
373 (version "1.0.1")
374 (outputs '("out"))
375 (source
376 (origin
377 (method url-fetch)
378 (uri (string-append "https://github.com/libtom/libtommath/releases/"
379 "download/v" version "/ltm-" version ".tar.xz"))
380 (sha256
381 (base32
382 "0sbccdwbkfc680id2fi0x067j23biqcjqilwkk7y9339knrjy0s7"))))
383 (arguments
0201e34c 384 (substitute-keyword-arguments (package-arguments libtommath-1.1)
cf3f12f6
EF
385 ((#:phases phases)
386 `(modify-phases ,phases
387 (delete 'install-static-library)))))))