gnu: emacs-consult: Fix grammar.
[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>
36757e02 5;;; Copyright © 2016, 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
3e3364fc 6;;; Copyright © 2016, 2020 Jan (janneke) 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>
4b62be5c 9;;; Copyright © 2018, 2019, 2021 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)
36757e02 32 #:use-module (gnu packages texinfo)
c44899a2 33 #:use-module (guix packages)
87f5d366 34 #:use-module (guix download)
24aaf2f2 35 #:use-module (guix utils)
c44899a2
LC
36 #:use-module (guix build-system gnu))
37
38(define-public gmp
39 (package
40 (name "gmp")
76feb6e7 41 (version "6.2.0")
c44899a2 42 (source (origin
87f5d366 43 (method url-fetch)
704197f4 44 (uri
93a6f552
AE
45 (string-append "mirror://gnu/gmp/gmp-"
46 version ".tar.xz"))
c44899a2
LC
47 (sha256
48 (base32
76feb6e7 49 "09hmg8k63mbfrx1x3yy6y1yzbbq85kw5avbibhcgrg9z3ganr3i5"))
fc1adab1 50 (patches (search-patches "gmp-faulty-test.patch"))))
c44899a2
LC
51 (build-system gnu-build-system)
52 (native-inputs `(("m4" ,m4)))
9bf62d9b 53 (outputs '("out" "debug"))
3e3364fc
JN
54 (arguments
55 `(#:parallel-tests? #f ; mpz/reuse fails otherwise
56 #:configure-flags
57 '(;; Build a "fat binary", with routines for several
58 ;; sub-architectures.
59 "--enable-fat"
60 "--enable-cxx"
61 ,@(cond ((target-mingw?)
62 ;; Static and shared cannot be built in one go:
63 ;; they produce different headers. We need shared.
64 `("--disable-static"
65 "--enable-shared"))
66 (else '())))
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.
71 ,@(if (target-mingw?)
72 `(#:phases
73 (modify-phases %standard-phases
74 (add-before 'configure 'setenv
75 (lambda _
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++"
80 ":" gcc "/include"
81 ":" libc "/include"))
82 (format #t "environment variable `CROSS_CPLUS_INCLUDE_PATH' set to `~a'\n"
83 (getenv "CROSS_CPLUS_INCLUDE_PATH"))
84 #t)))))
85 '())))
f50d2669 86 (synopsis "Multiple-precision arithmetic library")
c44899a2 87 (description
245fae90
TGR
88 "The @acronym{GMP, the GNU Multiple Precision Arithmetic} library performs
89arbitrary-precision arithmetic on signed integers, rational numbers and floating
90point numbers. The precision is only limited by the available memory.
91The library is highly optimized, with a design focus on execution speed.
92It is aimed at use in, for example, cryptography and computational algebra.")
4a44e743 93 (license lgpl3+)
75213ad2 94 (home-page "https://gmplib.org/")))
c44899a2 95
8309c389
LC
96(define-public gmp-6.0
97 ;; We keep this one around to bootstrap GCC, to work around a compilation
98 ;; issue on ARM. See
99 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
100 (package
101 (inherit gmp)
102 (version "6.0.0a")
103 (source (origin
104 (method url-fetch)
105 (uri (string-append "mirror://gnu/gmp/gmp-"
106 version ".tar.xz"))
107 (sha256
108 (base32
109 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
fc1adab1
AK
110 (patches (search-patches "gmp-arm-asm-nothumb.patch"
111 "gmp-faulty-test.patch"))))))
8309c389 112
c44899a2
LC
113(define-public mpfr
114 (package
115 (name "mpfr")
e34ae707 116 (version "4.0.2")
c44899a2 117 (source (origin
87f5d366 118 (method url-fetch)
0db342a5 119 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
c44899a2
LC
120 ".tar.xz"))
121 (sha256 (base32
e34ae707 122 "12m3amcavhpqygc499s3fzqlb8f2j2rr7fkqsm10xbjfc04fffqx"))))
c44899a2 123 (build-system gnu-build-system)
9bf62d9b 124 (outputs '("out" "debug"))
a6ef51e3 125 (propagated-inputs `(("gmp" ,gmp))) ; <mpfr.h> refers to <gmp.h>
5b7900d7 126 (synopsis "C library for arbitrary-precision floating-point arithmetic")
c44899a2 127 (description
932b6072 128 "GNU@tie{}@acronym{MPFR, Multiple Precision Floating-Point Reliably} is a C
5b7900d7
TGR
129library for performing multiple-precision, floating-point computations with
130correct rounding.")
4a44e743 131 (license lgpl3+)
617cf5de 132 (home-page "https://www.mpfr.org/")))
c44899a2
LC
133
134(define-public mpc
135 (package
136 (name "mpc")
e48859b2 137 (version "1.1.0")
c44899a2 138 (source (origin
87f5d366 139 (method url-fetch)
c44899a2 140 (uri (string-append
8e1cd713 141 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
945562d4
AE
142 (sha256
143 (base32
e48859b2 144 "0biwnhjm3rx3hc0rfpvyniky4lpzsvdcwhmcn7f0h4iw2hwcb1b9"))))
c44899a2 145 (build-system gnu-build-system)
9bf62d9b 146 (outputs '("out" "debug"))
a6ef51e3
LC
147 (propagated-inputs `(("gmp" ,gmp) ; <mpc.h> refers to both
148 ("mpfr" ,mpfr)))
246db471 149 (synopsis "C library for arbitrary-precision complex arithmetic")
c44899a2 150 (description
aaf80ba7
TGR
151 "GNU@tie{}@acronym{MPC, Multiple Precision Complex library} is a C library
152for performing arithmetic on complex numbers. It supports arbitrarily high
246db471 153precision and correctly rounds the results.")
4a44e743 154 (license lgpl3+)
cd5b85c3 155 (home-page "http://www.multiprecision.org/mpc/")))
61bb3555
NG
156
157(define-public mpfi
158 (package
159 (name "mpfi")
36757e02 160 (version "1.5.4")
f89cebb1
TGR
161 (source
162 (origin
163 (method url-fetch)
164 (uri (string-append "https://gforge.inria.fr/frs/download.php"
36757e02 165 "/latestfile/181/mpfi-" version ".tgz"))
f89cebb1 166 (sha256
36757e02 167 (base32 "0mismr1ll3wp788dq2n22s5irm0dziy75byyfdwz22kjbmckhf9v"))))
61bb3555 168 (build-system gnu-build-system)
36757e02
NG
169 (arguments
170 `(#:tests? #f ;tests are broken in this release
171 #:configure-flags '("--enable-static=no")))
172 (native-inputs
173 `(("automake" ,automake)
174 ("autoreconf" ,autoconf)
175 ("libtool" ,libtool)
176 ("texinfo" ,texinfo)))
177 (propagated-inputs
178 `(("gmp" ,gmp) ; <mpfi.h> refers to both
179 ("mpfr" ,mpfr)))
968612b7 180 (home-page "https://gforge.inria.fr/projects/mpfi/")
24a87a14
TGR
181 (synopsis "C library for arbitrary-precision interval arithmetic")
182 (description
ded545d5 183 "@acronym{MPFI, Multiple Precision Floating-point Interval} is a portable C
24a87a14 184library for arbitrary-precision interval arithmetic, with intervals represented
ded545d5
TGR
185using MPFR reliable floating-point numbers. It's based on the @acronym{GMP, GNU
186Multiple Precision Arithmetic} and GNU@tie{}@acronym{MPFR, Multiple Precision
187Floating-Point Reliably} libraries.
24a87a14
TGR
188
189The purpose of arbitrary-precision interval arithmetic is to get results that
190are both guaranteed, thanks to interval computation, and accurate, thanks to
191multiple-precision arithmetic.")
36757e02 192 (license lgpl2.1+)))
cbc084e1 193
df131dba
AE
194(define-public irram
195 (package
196 (name "irram")
197 (version "2013_01")
198 (source
199 (origin
200 (method url-fetch)
201 (uri (string-append "http://irram.uni-trier.de/irram-files/iRRAM_"
202 version ".tar.bz2"))
203 (sha256
204 (base32 "1cdmvb4hsa161rfdjqyhd9sb3fcr43p3a6nsj7cb4kn9f94qmjpj"))))
205 (build-system gnu-build-system)
206 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
207 ("mpfr" ,mpfr)))
208 (arguments
209 `(#:parallel-build? #f))
210 (synopsis "C++ package for real arithmetic based on the Real-RAM concept")
211 (description
212 "@dfn{iRRAM} is a C++ package for error-free real arithmetic based on
213the concept of a Real-RAM. Its capabilities range from ordinary arithmetic
214over trigonometric functions to linear algebra and differential
215equations. A program using iRRAM is coded in ordinary C++, but may use a
216special class that behaves like real numbers without any
217error. Additionally, iRRAM uses the concept of multi-valued functions.")
218 (license lgpl2.0+)
219 (home-page "http://irram.uni-trier.de/")))
220
cbc084e1
EB
221(define-public qd
222 (package
223 (name "qd")
8eb2c565 224 (version "2.3.22")
f52e8347
TGR
225 (source
226 (origin
227 (method url-fetch)
228 (uri (string-append "https://crd-legacy.lbl.gov/~dhbailey/mpdist/qd-"
229 version ".tar.gz"))
230 (sha256
231 (base32 "1lq609rsp6zpg7zda75lyxzzk1fabzp4jn88j7xfk84mdgjgzh9h"))))
cbc084e1
EB
232 (build-system gnu-build-system)
233 (native-inputs
234 `(("gfortran" ,gfortran)))
235 (arguments
236 `(#:configure-flags `("--disable-enable_fma" ;weird :/
237 "--enable-shared"
238 ,,@(if (string-prefix? "aarch64"
239 (or (%current-target-system)
240 (%current-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")))))
f52e8347 247 (home-page "https://www.davidhbailey.com/dhbsoftware/")
cbc084e1
EB
248 (synopsis "Double-double and quad-double library")
249 (description "This package supports both a double-double
250datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
251decimal digits). The computational library is written in C++. Both C++ and
252Fortran-90 high-level language interfaces are provided to permit one to
253convert an existing C++ or Fortran-90 program to use the library with only
254minor changes to the source code. In most cases only a few type statements
255and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
256and numerical quadrature programs are included.")
257 (license bsd-3)))
7ed018e8
EB
258
259(define-public tomsfastmath
260 (package
261 (name "tomsfastmath")
d0d207cd 262 (version "0.13.1")
7ed018e8
EB
263 (synopsis "Large integer arithmetic library")
264 (source (origin
265 (method url-fetch)
266 (uri (string-append "https://github.com/libtom/tomsfastmath/"
267 "releases/download/v" version "/"
d0d207cd 268 "tfm-" version ".tar.xz"))
7ed018e8
EB
269 (sha256
270 (base32
d0d207cd 271 "0f0pmiaskh89sp0q933pafxb914shpaj5ad8sb5rzk1wv8d7mja7"))))
7ed018e8
EB
272 (build-system gnu-build-system)
273 (native-inputs
274 `(("libtool" ,libtool)))
275 (arguments
276 `(#:make-flags (list "-f" "makefile.shared"
277 (string-append "LIBPATH=" %output "/lib")
278 (string-append "INCPATH=" %output "/include")
279 "GROUP=root" "USER=root"
280 "CC=gcc")
281 #:phases
282 (modify-phases %standard-phases
d0d207cd 283 (delete 'configure) ; no configuration
7ed018e8
EB
284 (replace 'check
285 (lambda* (#:key make-flags #:allow-other-keys)
20fe9728
RW
286 (apply invoke "make"
287 "stest" "test_standalone"
288 make-flags)
289 (invoke "./stest")
290 (invoke "./test")))
7ed018e8
EB
291 (add-before 'install 'install-nogroup
292 (lambda _
d0d207cd 293 ;; Let permissions inherit from the current process.
7ed018e8
EB
294 (substitute* "makefile.shared"
295 (("-g \\$\\(GROUP\\) -o \\$\\(USER\\)") ""))
296 #t))
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)
302 #t)))
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"
308 (lambda (port)
309 (format port "~
310Name: TomsFastMath
311Description: ~a
312Version: ~a
313Libs: -L~a/lib -ltfm~%"
314 ,synopsis ,version out)))
315 (install-file "tomsfastmath.pc" pc-dir)
316 #t))))))
abd402e3 317 (home-page "https://www.libtom.net/TomsFastMath/")
7ed018e8
EB
318 (description "TomsFastMath is a large integer library written in portable
319ISO C. It is a port of LibTomMath with optional support for inline assembler
320multiplies.")
321 (license public-domain)))
1a753385 322
4b62be5c
EF
323(define-public libtomcrypt
324 (package
325 (name "libtomcrypt")
326 (version "1.18.2")
327 (outputs '("out" "static"))
328 (source
329 (origin
330 (method url-fetch)
331 (uri (string-append "https://github.com/libtom/libtomcrypt"
332 "/releases/download/v" version
333 "/crypt-" version ".tar.xz"))
334 (sha256
335 (base32
336 "113vfrgapyv72lalhd3nkw7jnks8az0gcb5wqn9hj19nhcxlrbcn"))
337 (modules '((guix build utils)))
338 (snippet
339 '(begin
340 ;; Patch CVE-2019-17362
341 ;; https://github.com/libtom/libtomcrypt/commit/25c26a3b7a9ad8192ccc923e15cf62bf0108ef94
342 (substitute* "src/pk/asn1/der/utf8/der_decode_utf8_string.c"
343 (("z > 4") "z == 1 || z > 4"))
344 #t))))
345 (build-system gnu-build-system)
346 (arguments
347 `(#:phases
348 (modify-phases %standard-phases
349 (delete 'configure) ; no configure
350 (add-after 'unpack 'prepare-build
351 (lambda _
352 ;; We want the shared library by default so force it to be the
353 ;; default makefile target.
354 (delete-file "makefile")
355 (symlink "makefile.shared" "makefile")
c9c68344
EF
356 ;; We link to libtommath, so we need to add it to the pc file
357 (substitute* "libtomcrypt.pc.in"
358 (("-ltomcrypt") "-ltomcrypt -ltommath"))
4b62be5c
EF
359 #t))
360 (add-after 'build 'build-static
361 (lambda* (#:key make-flags #:allow-other-keys)
362 (apply invoke "make" "-f" "makefile.unix" make-flags)))
363 (replace 'check
364 (lambda* (#:key test-target make-flags #:allow-other-keys)
365 (apply invoke "make" "-f" "makefile.unix" test-target make-flags)
366 (invoke "./test")))
367 (add-after 'install 'install-static-library
368 (lambda* (#:key outputs #:allow-other-keys)
369 (let ((out (assoc-ref outputs "out"))
370 (static (assoc-ref outputs "static")))
371 (mkdir-p (string-append static "/lib"))
372 (mkdir-p (string-append static "/include"))
373 (rename-file (string-append out "/lib/libtomcrypt.a")
374 (string-append static "/lib/libtomcrypt.a"))
375 (copy-recursively (string-append out "/include")
376 (string-append static "/include"))
377 #t))))
378 #:test-target "test"
379 #:make-flags
380 (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
381 "CFLAGS += -DLTM_DESC -DUSE_LTM"
382 (string-append "EXTRALIBS=" (assoc-ref %build-inputs "libtommath")
383 "/lib/libtommath.so")
384 (string-append "CC=" ,(cc-for-target)))))
385 (native-inputs
386 `(("libtool" ,libtool)))
387 (inputs
388 `(("libtommath" ,libtommath)))
389 (home-page "https://www.libtom.net/LibTomCrypt/")
390 (synopsis "Cryptographic toolkit")
391 (description "LibTomCrypt is a fairly comprehensive, modular and portable
392cryptographic toolkit that provides developers with a vast array of well known
393published block ciphers, one-way hash functions, chaining modes, pseudo-random
394number generators, public key cryptography and a plethora of other routines.")
395 (properties `((lint-hidden-cve . ("CVE-2019-17362"))))
396 (license unlicense)))
397
1a753385
EF
398(define-public libtommath
399 (package
400 (name "libtommath")
0201e34c 401 (version "1.2.0")
1a753385
EF
402 (outputs '("out" "static"))
403 (source
404 (origin
405 (method url-fetch)
406 (uri (string-append "https://github.com/libtom/libtommath/releases/"
407 "download/v" version "/ltm-" version ".tar.xz"))
408 (sha256
409 (base32
0201e34c 410 "1c8q1qy88cjhdjlk3g24mra94h34c1ldvkjz0n2988c0yvn5xixp"))))
1a753385
EF
411 (build-system gnu-build-system)
412 (arguments
413 '(#:phases
414 (modify-phases %standard-phases
415 (delete 'configure) ; no configure
416 (add-after 'unpack 'prepare-build
417 (lambda _
1a753385
EF
418 ;; We want the shared library by default so force it to be the
419 ;; default makefile target.
420 (delete-file "makefile")
421 (symlink "makefile.shared" "makefile")
422 #t))
423 (add-after 'install 'remove-static-library
424 (lambda* (#:key outputs #:allow-other-keys)
425 (delete-file (string-append (assoc-ref outputs "out")
426 "/lib/libtommath.a"))
427 #t))
428 (replace 'check
0201e34c
EF
429 (lambda* (#:key test-target make-flags #:allow-other-keys)
430 (apply invoke "make" test-target make-flags)
1a753385
EF
431 (invoke "sh" "test")))
432 (add-after 'install 'install-static-library
433 (lambda* (#:key outputs #:allow-other-keys)
434 (invoke "make" "-f" "makefile.unix" "install"
435 (string-append "PREFIX=" (assoc-ref outputs "static"))
436 (string-append "CC=" (which "gcc"))))))
0201e34c 437 #:test-target "test"
1a753385
EF
438 #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
439 "CC=gcc")))
440 (native-inputs
441 `(("libtool" ,libtool)))
442 (home-page "https://www.libtom.net/LibTomMath/")
443 (synopsis "Portable number theoretic multiple-precision integer library")
444 (description "LibTomMath is a portable number theoretic multiple-precision
445integer library written entirely in C. It's designed to provide an API that is
446simple to work with that provides fairly efficient routines that build out of
447the box without configuration.")
448 (license unlicense)))
cf3f12f6 449
0201e34c 450(define-public libtommath-1.1
cf3f12f6
EF
451 (package
452 (inherit libtommath)
0201e34c
EF
453 (version "1.1.0")
454 (source
455 (origin
456 (method url-fetch)
457 (uri (string-append "https://github.com/libtom/libtommath/releases/"
458 "download/v" version "/ltm-" version ".tar.xz"))
459 (sha256
460 (base32
461 "1bbyagqzfdbg37k1n08nsqzdf44z8zsnjjinqbsyj7rxg246qilh"))
462 (patches (search-patches "libtommath-fix-linkage.patch"))))
463 (arguments
464 (substitute-keyword-arguments (package-arguments libtommath)
465 ((#:phases phases)
466 `(modify-phases ,phases
467 (add-after 'unpack 'patch-coreutils-call
468 (lambda _
469 ;; Don't pull in coreutils.
470 (substitute* "makefile_include.mk"
471 (("arch") "uname -m"))
472 #t))))
473 ((#:test-target _) "test_standalone")))))
474
475(define-public libtommath-1.0
476 (package
477 (inherit libtommath-1.1)
cf3f12f6
EF
478 (version "1.0.1")
479 (outputs '("out"))
480 (source
481 (origin
482 (method url-fetch)
483 (uri (string-append "https://github.com/libtom/libtommath/releases/"
484 "download/v" version "/ltm-" version ".tar.xz"))
485 (sha256
486 (base32
487 "0sbccdwbkfc680id2fi0x067j23biqcjqilwkk7y9339knrjy0s7"))))
488 (arguments
0201e34c 489 (substitute-keyword-arguments (package-arguments libtommath-1.1)
cf3f12f6
EF
490 ((#:phases phases)
491 `(modify-phases ,phases
492 (delete 'install-static-library)))))))