gnu: Add QD.
[jackhill/guix/guix.git] / gnu / packages / multiprecision.scm
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 Andreas Enge <andreas@enge.fr>
5 ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
6 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages multiprecision)
26 #:use-module (guix licenses)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages m4)
29 #:use-module (gnu packages gcc)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix utils)
33 #:use-module (guix build-system gnu))
34
35 (define-public gmp
36 (package
37 (name "gmp")
38 (version "6.1.2")
39 (source (origin
40 (method url-fetch)
41 (uri
42 (string-append "mirror://gnu/gmp/gmp-"
43 version ".tar.xz"))
44 (sha256
45 (base32
46 "04hrwahdxyqdik559604r7wrj9ffklwvipgfxgj4ys4skbl6bdc7"))
47 (patches (search-patches "gmp-faulty-test.patch"))))
48 (build-system gnu-build-system)
49 (native-inputs `(("m4" ,m4)))
50 (outputs '("out" "debug"))
51 (arguments `(#:parallel-tests? #f ; mpz/reuse fails otherwise
52 #:configure-flags
53 '(;; Build a "fat binary", with routines for several
54 ;; sub-architectures.
55 "--enable-fat"
56 "--enable-cxx"
57 ,@(cond ((target-mingw?)
58 ;; Static and shared cannot be built in one go:
59 ;; they produce different headers. We need shared.
60 `("--disable-static"
61 "--enable-shared"))
62 (else '())))))
63 (synopsis "Multiple-precision arithmetic library")
64 (description
65 "@dfn{GMP} (the GNU Multiple Precision Arithmetic Library) is a library for
66 arbitrary-precision arithmetic, operating on signed integers, rational numbers
67 and floating point numbers. The precision is only limited by the available
68 memory. The library is highly optimized, with a design focus on execution
69 speed. It is aimed at use in, for example, cryptography and computational
70 algebra.")
71 (license lgpl3+)
72 (home-page "https://gmplib.org/")))
73
74 (define-public gmp-6.0
75 ;; We keep this one around to bootstrap GCC, to work around a compilation
76 ;; issue on ARM. See
77 ;; <https://gmplib.org/list-archives/gmp-bugs/2015-December/003848.html>.
78 (package
79 (inherit gmp)
80 (version "6.0.0a")
81 (source (origin
82 (method url-fetch)
83 (uri (string-append "mirror://gnu/gmp/gmp-"
84 version ".tar.xz"))
85 (sha256
86 (base32
87 "0r5pp27cy7ch3dg5v0rsny8bib1zfvrza6027g2mp5f6v8pd6mli"))
88 (patches (search-patches "gmp-arm-asm-nothumb.patch"
89 "gmp-faulty-test.patch"))))))
90
91 (define-public mpfr
92 (package
93 (name "mpfr")
94 (version "3.1.5")
95 (source (origin
96 (method url-fetch)
97 (uri (string-append "mirror://gnu/mpfr/mpfr-" version
98 ".tar.xz"))
99 (sha256 (base32
100 "1g32l2fg8f62lcyzzh88y3fsh6rk539qc6ahhdgvx7wpnf1dwpq1"))))
101 (build-system gnu-build-system)
102 (outputs '("out" "debug"))
103 (propagated-inputs `(("gmp" ,gmp))) ; <mpfr.h> refers to <gmp.h>
104 (synopsis "C library for arbitrary-precision floating-point arithmetic")
105 (description
106 "GNU@tie{}@dfn{MPFR} (Multiple Precision Floating-Point Reliably) is a C
107 library for performing multiple-precision, floating-point computations with
108 correct rounding.")
109 (license lgpl3+)
110 (home-page "http://www.mpfr.org/")))
111
112 (define-public mpc
113 (package
114 (name "mpc")
115 (version "1.0.3")
116 (source (origin
117 (method url-fetch)
118 (uri (string-append
119 "mirror://gnu/mpc/mpc-" version ".tar.gz"))
120 (sha256
121 (base32
122 "1hzci2zrrd7v3g1jk35qindq05hbl0bhjcyyisq9z209xb3fqzb1"))))
123 (build-system gnu-build-system)
124 (outputs '("out" "debug"))
125 (propagated-inputs `(("gmp" ,gmp) ; <mpc.h> refers to both
126 ("mpfr" ,mpfr)))
127 (synopsis "C library for arbitrary-precision complex arithmetic")
128 (description
129 "GNU@tie{}@dfn{MPC} (Multiple Precision Complex library) is a C library for
130 performing arithmetic on complex numbers. It supports arbitrarily high
131 precision and correctly rounds the results.")
132 (license lgpl3+)
133 (home-page "http://multiprecision.org/mpc/")))
134
135 (define-public mpfi
136 (package
137 (name "mpfi")
138 (version "1.5.3")
139 (source
140 (origin
141 (method url-fetch)
142 (uri (string-append "https://gforge.inria.fr/frs/download.php"
143 "/latestfile/181/" name "-" version ".tar.bz2"))
144 (sha256
145 (base32 "0bqr8yibl7jbrp0bw7xk1lm7nis7rv26jsz6y8ycvih8n9bx90r3"))))
146 (build-system gnu-build-system)
147 (propagated-inputs `(("gmp" ,gmp) ; <mpfi.h> refers to both
148 ("mpfr" ,mpfr)))
149 (synopsis "C library for arbitrary-precision interval arithmetic")
150 (description
151 "@dfn{MPFI} (Multiple Precision Floating-point Interval) is a portable C
152 library for arbitrary-precision interval arithmetic, with intervals represented
153 using MPFR reliable floating-point numbers. It's based on the @dfn{GMP} (GNU
154 Multiple Precision Arithmetic) and GNU@tie{}@dfn{MPFR} (Multiple Precision
155 Floating-Point Reliably) libraries.
156
157 The purpose of arbitrary-precision interval arithmetic is to get results that
158 are both guaranteed, thanks to interval computation, and accurate, thanks to
159 multiple-precision arithmetic.")
160 (license lgpl2.1+)
161 (home-page "https://perso.ens-lyon.fr/nathalie.revol/software.html")))
162
163 (define-public qd
164 (package
165 (name "qd")
166 (version "2.3.18")
167 (source (origin
168 (method url-fetch)
169 (uri (string-append "http://crd.lbl.gov/~dhbailey/mpdist/qd-"
170 version ".tar.gz"))
171 (sha256
172 (base32
173 "0vkihcj9fyv2cycq8515713gbs3yskhmivy8bznvx72i6ddnn2c1"))))
174 (build-system gnu-build-system)
175 (native-inputs
176 `(("gfortran" ,gfortran)))
177 (arguments
178 `(#:configure-flags `("--disable-enable_fma" ;weird :/
179 "--enable-shared"
180 ,,@(if (string-prefix? "aarch64"
181 (or (%current-target-system)
182 (%current-system)))
183 ;; XXX: The qd_test test fails numerical
184 ;; accuracy checks for 'dd_real::exp()' on
185 ;; aarch64 with GCC 5.4 at -O2. Disabling
186 ;; expensive optimizations lets it pass.
187 '("CXXFLAGS=-O3 -fno-expensive-optimizations")
188 '("CXXFLAGS=-O3")))))
189 (home-page "http://crd-legacy.lbl.gov/~dhbailey/mpdist/")
190 (synopsis "Double-double and quad-double library")
191 (description "This package supports both a double-double
192 datatype (approx. 32 decimal digits) and a quad-double datatype (approx. 64
193 decimal digits). The computational library is written in C++. Both C++ and
194 Fortran-90 high-level language interfaces are provided to permit one to
195 convert an existing C++ or Fortran-90 program to use the library with only
196 minor changes to the source code. In most cases only a few type statements
197 and (for Fortran-90 programs) read/write statements need to be changed. PSLQ
198 and numerical quadrature programs are included.")
199 (license bsd-3)))