gnu: Add OpenMPI
[jackhill/guix/guix.git] / gnu / packages / maths.scm
CommitLineData
8f8b2451 1;;; GNU Guix --- Functional package management for GNU
06ed5982 2;;; Copyright © 2013, 2014 Andreas Enge <andreas@enge.fr>
da95c817 3;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
668c06ac 4;;; Copyright © 2014 John Darrington <jmd@gnu.org>
f5d5a346 5;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
8f8b2451
AE
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu packages maths)
23 #:use-module (gnu packages)
24 #:use-module ((guix licenses)
25 #:renamer (symbol-prefix-proc 'license:))
26 #:use-module (guix packages)
27 #:use-module (guix download)
0e2672ae 28 #:use-module (guix utils)
da95c817 29 #:use-module (guix build-system cmake)
c9dfa3c7 30 #:use-module (guix build-system gnu)
3de01d3f
EB
31 #:use-module (gnu packages algebra)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages cmake)
c9dfa3c7 34 #:use-module (gnu packages compression)
668c06ac 35 #:use-module (gnu packages curl)
57e544e8 36 #:use-module (gnu packages elf)
3de01d3f 37 #:use-module (gnu packages flex)
668c06ac 38 #:use-module (gnu packages fltk)
f3929800 39 #:use-module (gnu packages fontutils)
1dba6407 40 #:use-module (gnu packages gettext)
da95c817 41 #:use-module (gnu packages gcc)
73fed4f8 42 #:use-module (gnu packages gd)
668c06ac 43 #:use-module (gnu packages ghostscript)
f3929800 44 #:use-module (gnu packages gtk)
668c06ac
JD
45 #:use-module (gnu packages less)
46 #:use-module (gnu packages xorg)
47 #:use-module (gnu packages gl)
b92eee75 48 #:use-module (gnu packages multiprecision)
668c06ac 49 #:use-module (gnu packages pcre)
c9dfa3c7
AE
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages pkg-config)
da95c817 52 #:use-module (gnu packages python)
c9dfa3c7 53 #:use-module (gnu packages readline)
183e44ae 54 #:use-module (gnu packages tcsh)
668c06ac 55 #:use-module (gnu packages texinfo)
73fed4f8 56 #:use-module (gnu packages texlive)
c9dfa3c7 57 #:use-module (gnu packages xml))
8f8b2451
AE
58
59(define-public units
60 (package
61 (name "units")
983815c8 62 (version "2.11")
8f8b2451
AE
63 (source (origin
64 (method url-fetch)
65 (uri (string-append "mirror://gnu/units/units-" version
66 ".tar.gz"))
67 (sha256 (base32
983815c8 68 "1gjs3wc212aaiq4r76hx9nl1h3fa39n0ljwl9420d6ixl3rdmdjk"))))
8f8b2451
AE
69 (build-system gnu-build-system)
70 (synopsis "Conversion between thousands of scales")
71 (description
574e86f9
LC
72 "GNU Units converts numeric quantities between units of measure. It
73can handle scale changes through adaptive usage of standard scale prefixes
74(micro-, kilo-, etc.). It can also handle nonlinear conversions such as
75Fahrenheit to Celsius. Its interpreter is powerful enough to be used
76effectively as a scientific calculator.")
8f8b2451
AE
77 (license license:gpl3+)
78 (home-page "http://www.gnu.org/software/units/")))
c9dfa3c7 79
88bd1804
AE
80(define-public gsl
81 (package
82 (name "gsl")
487da565 83 (version "1.16")
88bd1804
AE
84 (source
85 (origin
86 (method url-fetch)
87 (uri (string-append "mirror://gnu/gsl/gsl-"
88 version ".tar.gz"))
89 (sha256
90 (base32
487da565 91 "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k"))))
88bd1804 92 (build-system gnu-build-system)
71e0f288 93 (arguments
487da565
AE
94 `(#:parallel-tests? #f
95 #:phases
71e0f288
AE
96 (alist-replace
97 'configure
98 (lambda* (#:key target system outputs #:allow-other-keys #:rest args)
99 (let ((configure (assoc-ref %standard-phases 'configure)))
100 ;; disable numerically unstable test on i686, see thread at
101 ;; http://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html
102 (if (string=? (or target system) "i686-linux")
103 (substitute* "ode-initval2/Makefile.in"
104 (("TESTS = \\$\\(check_PROGRAMS\\)") "TESTS =")))
105 (apply configure args)))
106 %standard-phases)))
88bd1804
AE
107 (home-page "http://www.gnu.org/software/gsl/")
108 (synopsis "Numerical library for C and C++")
109 (description
a22dc0c4
LC
110 "The GNU Scientific Library is a library for numerical analysis in C
111and C++. It includes a wide range of mathematical routines, with over 1000
112functions in total. Subject areas covered by the library include:
113differential equations, linear algebra, Fast Fourier Transforms and random
114numbers.")
88bd1804
AE
115 (license license:gpl3+)))
116
b92eee75
AE
117(define-public glpk
118 (package
119 (name "glpk")
1f1c0aff 120 (version "4.54")
b92eee75
AE
121 (source
122 (origin
123 (method url-fetch)
124 (uri (string-append "mirror://gnu/glpk/glpk-"
125 version ".tar.gz"))
126 (sha256
127 (base32
1f1c0aff 128 "18gr2anv8gyps6j9f22k7li6w07glvww666sdqblvlq2hh3whwmb"))))
b92eee75
AE
129 (build-system gnu-build-system)
130 (inputs
131 `(("gmp" ,gmp)))
132 (arguments
133 `(#:configure-flags '("--with-gmp")))
134 (home-page "http://www.gnu.org/software/glpk/")
79c311b8 135 (synopsis "GNU Linear Programming Kit, supporting the MathProg language")
b92eee75
AE
136 (description
137 "GLPK is a C library for solving large-scale linear programming (LP),
138mixed integer programming (MIP), and other related problems. It supports the
139GNU MathProg modeling language, a subset of the AMPL language, and features a
140translator for the language. In addition to the C library, a stand-alone
141LP/MIP solver is included in the package.")
142 (license license:gpl3+)))
143
c9dfa3c7
AE
144(define-public pspp
145 (package
146 (name "pspp")
e7d6f7bf 147 (version "0.8.2")
c9dfa3c7
AE
148 (source
149 (origin
150 (method url-fetch)
151 (uri (string-append "mirror://gnu/pspp/pspp-"
152 version ".tar.gz"))
153 (sha256
154 (base32
e7d6f7bf 155 "1w7h3dglgx0jlq1wb605b8pgfsk2vr1q2q2rj7bsajh9ihbcsixr"))))
c9dfa3c7
AE
156 (build-system gnu-build-system)
157 (inputs
f3929800
AE
158 `(("cairo" ,cairo)
159 ("fontconfig" ,fontconfig)
1dba6407 160 ("gettext" ,gnu-gettext)
c9dfa3c7
AE
161 ("gsl" ,gsl)
162 ("libxml2" ,libxml2)
f3929800 163 ("pango" ,pango)
c9dfa3c7 164 ("readline" ,readline)
e6a5ce8e
JD
165 ("gtk" ,gtk+-2)
166 ("gtksourceview" ,gtksourceview)
c9dfa3c7
AE
167 ("zlib" ,zlib)))
168 (native-inputs
169 `(("perl" ,perl)
170 ("pkg-config" ,pkg-config)))
c9dfa3c7
AE
171 (home-page "http://www.gnu.org/software/pspp/")
172 (synopsis "Statistical analysis")
173 (description
79c311b8
LC
174 "GNU PSPP is a statistical analysis program. It can perform
175descriptive statistics, T-tests, linear regression and non-parametric tests.
176It features both a graphical interface as well as command-line input. PSPP is
177designed to interoperate with Gnumeric, LibreOffice and OpenOffice. Data can
178be imported from spreadsheets, text files and database sources and it can be
179output in text, PostScript, PDF or HTML.")
c9dfa3c7 180 (license license:gpl3+)))
da95c817
NK
181
182(define-public lapack
183 (package
184 (name "lapack")
566146ab 185 (version "3.5.0")
da95c817
NK
186 (source
187 (origin
188 (method url-fetch)
189 (uri (string-append "http://www.netlib.org/lapack/lapack-"
190 version ".tgz"))
191 (sha256
192 (base32
566146ab 193 "0lk3f97i9imqascnlf6wr5mjpyxqcdj73pgj97dj2mgvyg9z1n4s"))))
da95c817
NK
194 (build-system cmake-build-system)
195 (home-page "http://www.netlib.org/lapack/")
57e544e8 196 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
da95c817
NK
197 (inputs `(("fortran" ,gfortran-4.8)
198 ("python" ,python-2)))
199 (arguments
06ed5982 200 `(#:configure-flags '("-DBUILD_SHARED_LIBS:BOOL=YES")
da95c817 201 #:phases (alist-cons-before
6a995754
LC
202 'check 'patch-python
203 (lambda* (#:key inputs #:allow-other-keys)
204 (let ((python (assoc-ref inputs "python")))
205 (substitute* "lapack_testing.py"
206 (("/usr/bin/env python") python))))
06ed5982 207 %standard-phases)))
da95c817
NK
208 (synopsis "Library for numerical linear algebra")
209 (description
210 "LAPACK is a Fortran 90 library for solving the most commonly occurring
211problems in numerical linear algebra.")
212 (license (license:bsd-style "file://LICENSE"
213 "See LICENSE in the distribution."))))
73fed4f8
JD
214
215(define-public gnuplot
216 (package
217 (name "gnuplot")
218 (version "4.6.3")
219 (source
220 (origin
221 (method url-fetch)
222 (uri (string-append "mirror://sourceforge/gnuplot/gnuplot/"
223 version "/gnuplot-" version ".tar.gz"))
224 (sha256
225 (base32
226 "1xd7gqdhlk7k1p9yyqf9vkk811nadc7m4si0q3nb6cpv4pxglpyz"))))
227 (build-system gnu-build-system)
228 (inputs `(("readline" ,readline)
229 ("cairo" ,cairo)
230 ("pango" ,pango)
231 ("gd" ,gd)))
232 (native-inputs `(("texlive" ,texlive)
233 ("pkg-config" ,pkg-config)))
234 (home-page "http://www.gnuplot.info")
235 (synopsis "Command-line driven graphing utility")
236 (description "Gnuplot is a portable command-line driven graphing
237utility. It was originally created to allow scientists and students to
238visualize mathematical functions and data interactively, but has grown to
239support many non-interactive uses such as web scripting. It is also used as a
240plotting engine by third-party applications like Octave.")
241 ;; X11 Style with the additional restriction that derived works may only be
242 ;; distributed as patches to the original.
243 (license (license:fsf-free
668c06ac
JD
244 "http://gnuplot.cvs.sourceforge.net/gnuplot/gnuplot/Copyright"))))
245
7ee3f1a2
JD
246(define-public hdf5
247 (package
248 (name "hdf5")
249 (version "1.8.12")
250 (source
251 (origin
252 (method url-fetch)
253 (uri (string-append "http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-"
254 version ".tar.bz2"))
255 (sha256
256 (base32 "0f9n0v3p3lwc7564791a39c6cn1d3dbrn7d1j3ikqsi27a8hy23d"))))
257 (build-system gnu-build-system)
258 (arguments
259 `(#:phases
d4bf49b1
EB
260 (alist-cons-before
261 'configure 'patch-configure
262 (lambda _
263 (substitute* "configure"
264 (("/bin/mv") "mv")))
7ee3f1a2
JD
265 %standard-phases)))
266 (outputs '("out" "bin" "lib" "include"))
267 (home-page "http://www.hdfgroup.org")
268 (synopsis "Management suite for extremely large and complex data")
269 (description "HDF5 is a suite that makes possible the management of
270extremely large and complex data collections.")
d4bf49b1
EB
271 (license (license:x11-style
272 "http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/COPYING"))))
7ee3f1a2
JD
273
274
668c06ac
JD
275;; For a fully featured Octave, users are strongly recommended also to install
276;; the following packages: texinfo, less, ghostscript, gnuplot.
277(define-public octave
278 (package
279 (name "octave")
280 (version "3.8.0")
281 (source
282 (origin
283 (method url-fetch)
284 (uri (string-append "mirror://gnu/octave/octave-"
285 version ".tar.gz"))
286 (sha256
287 (base32
288 "0ks9pr154syw0vb3jn6xsnrkkrbvf9y7i7gaxa28rz6ngxbxvq9l"))))
289 (build-system gnu-build-system)
290 (inputs
291 `(("lapack" ,lapack)
292 ("readline" ,readline)
293 ("glpk" ,glpk)
294 ("curl" ,curl)
295 ("pcre" ,pcre)
296 ("fltk" ,fltk)
297 ("fontconfig" ,fontconfig)
298 ("freetype" ,freetype)
7ee3f1a2
JD
299 ("hdf5-lib" ,hdf5 "lib")
300 ("hdf5-include" ,hdf5 "include")
668c06ac
JD
301 ("libxft" ,libxft)
302 ("mesa" ,mesa)
303 ("zlib" ,zlib)))
304 (native-inputs
305 `(("gfortran" ,gfortran-4.8)
306 ("pkg-config" ,pkg-config)
307 ("perl" ,perl)
308 ;; The following inputs are not actually used in the build process. However, the
309 ;; ./configure gratuitously tests for their existence and assumes that programs not
310 ;; present at build time are also not, and can never be, available at run time!
311 ;; If these inputs are therefore not present, support for them will be built out.
312 ;; However, Octave will still run without them, albeit without the features they
313 ;; provide.
314 ("less" ,less)
315 ("texinfo" ,texinfo)
316 ("ghostscript" ,ghostscript)
317 ("gnuplot" ,gnuplot)))
318 (arguments
319 `(#:configure-flags (list (string-append "--with-shell="
320 (assoc-ref %build-inputs "bash")
321 "/bin/sh"))))
322 (home-page "http://www.gnu.org/software/octave/")
323 (synopsis "High-level language for numerical computation")
324 (description "GNU Octave is a high-level interpreted language that is specialized
325for numerical computations. It can be used for both linear and non-linear
326applications and it provides great support for visualizing results. Work may
327be performed both at the interactive command-line as well as via script
328files.")
329 (license license:gpl3+)))
3de01d3f
EB
330
331(define-public gmsh
332 (package
333 (name "gmsh")
334 (version "2.8.4")
335 (source
336 (origin
337 (method url-fetch)
338 (uri (string-append "http://www.geuz.org/gmsh/src/gmsh-"
339 version "-source.tgz"))
340 (sha256
341 (base32 "0jv2yvk28w86rx5mvjkb0w12ff2jxih7axnpvznpd295lg5jg7hr"))
342 (modules '((guix build utils)))
343 (snippet
344 ;; Remove non-free METIS code
345 '(delete-file-recursively "contrib/Metis"))))
346 (build-system cmake-build-system)
347 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
348 (propagated-inputs
349 `(("fltk" ,fltk)
350 ("gfortran" ,gfortran-4.8)
351 ("gmp" ,gmp)
352 ("hdf5-lib" ,hdf5 "lib")
353 ("hdf5-include" ,hdf5 "include")
354 ("lapack" ,lapack)
355 ("mesa" ,mesa)
356 ("libx11" ,libx11)
357 ("libxext" ,libxext)))
358 (arguments
359 `(#:configure-flags `("-DENABLE_METIS:BOOL=OFF"
360 "-DENABLE_BUILD_SHARED:BOOL=ON"
361 "-DENABLE_BUILD_DYNAMIC:BOOL=ON")))
362 (home-page "http://www.geuz.org/gmsh/")
363 (synopsis "3D finite element grid generator")
edf684ef
EB
364 (description "Gmsh is a 3D finite element grid generator with a built-in
365CAD engine and post-processor. Its design goal is to provide a fast, light
366and user-friendly meshing tool with parametric input and advanced
367visualization capabilities. Gmsh is built around four modules: geometry,
368mesh, solver and post-processing. The specification of any input to these
369modules is done either interactively using the graphical user interface or in
370ASCII text files using Gmsh's own scripting language.")
3de01d3f 371 (license license:gpl2+)))
b9100e2f
EB
372
373(define-public petsc
374 (package
375 (name "petsc")
376 (version "3.4.4")
377 (source
378 (origin
379 (method url-fetch)
380 ;; The *-lite-* tarball does not contain the *large* documentation
381 (uri (string-append "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
382 "petsc-lite-" version ".tar.gz"))
383 (sha256
384 (base32 "0v5dg6dhdjpi5ianvd4mm6hsvxzv1bsxwnh9f9myag0a0d9xk9iv"))
385 (patches
386 (list (search-patch "petsc-fix-threadcomm.patch")))))
387 (build-system gnu-build-system)
388 (native-inputs
389 `(("python" ,python-2)
390 ("perl" ,perl)))
391 (inputs
392 `(("gfortran" ,gfortran-4.8)
393 ("lapack" ,lapack)
f258212d 394 ("superlu" ,superlu)
b9100e2f
EB
395 ;; leaving out hdf5 and fftw, as petsc expects them to be built with mpi
396 ;; leaving out opengl, as configuration seems to only be for mac
397 ))
398 (arguments
399 `(#:test-target "test"
400 #:parallel-build? #f
401 #:configure-flags
402 `("--with-mpi=0"
f258212d
EB
403 "--with-openmp=1"
404 "--with-superlu=1"
405 ,(string-append "--with-superlu-include="
406 (assoc-ref %build-inputs "superlu") "/include")
407 ,(string-append "--with-superlu-lib="
408 (assoc-ref %build-inputs "superlu") "/lib/libsuperlu.a"))
b9100e2f
EB
409 #:phases
410 (alist-replace
411 'configure
412 ;; PETSc's configure script is actually a python script, so we can't
413 ;; run it with bash.
414 (lambda* (#:key outputs (configure-flags '())
415 #:allow-other-keys)
416 (let* ((prefix (assoc-ref outputs "out"))
417 (flags `(,(string-append "--prefix=" prefix)
418 ,@configure-flags)))
419 (format #t "build directory: ~s~%" (getcwd))
420 (format #t "configure flags: ~s~%" flags)
421 (zero? (apply system* "./configure" flags))))
422 (alist-cons-after
423 'install 'clean-local-references
424 ;; Try to keep installed files from leaking build directory names.
425 (lambda* (#:key inputs outputs #:allow-other-keys)
426 (let ((out (assoc-ref outputs "out"))
427 (fortran (assoc-ref inputs "gfortran")))
428 (substitute* (map (lambda (file)
429 (string-append out "/" file))
430 '("conf/petscvariables"
431 "conf/PETScConfig.cmake"
432 "include/petscconf.h"
433 "include/petscmachineinfo.h"))
434 (((getcwd)) out))
435 ;; Make compiler references point to the store
436 (substitute* (string-append out "/conf/petscvariables")
437 (("= g(cc|\\+\\+|fortran)" _ suffix)
438 (string-append "= " fortran "/bin/g" suffix)))
439 ;; PETSc installs some build logs, which aren't necessary.
440 (for-each (lambda (file)
441 (delete-file (string-append out "/" file)))
442 '("conf/configure.log"
443 "conf/make.log"
444 "conf/test.log"
445 "conf/RDict.db"
446 ;; Once installed, should uninstall with Guix
447 "conf/uninstall.py"))))
448 %standard-phases))))
449 (home-page "http://www.mcs.anl.gov/petsc")
450 (synopsis "Library to solve ODEs and algebraic equations")
451 (description "PETSc, pronounced PET-see (the S is silent), is a suite of
452data structures and routines for the scalable (parallel) solution of
453scientific applications modeled by partial differential equations.")
454 (license (license:bsd-style
455 "http://www.mcs.anl.gov/petsc/documentation/copyright.html"))))
456
457(define-public petsc-complex
458 (package (inherit petsc)
459 (name "petsc-complex")
460 (arguments
461 (substitute-keyword-arguments (package-arguments petsc)
462 ((#:configure-flags cf)
463 `(cons "--with-scalar-type=complex" ,cf))))
464 (description
465 (string-append (package-description petsc)
466 " Complex scalar type version."))))
183e44ae
EB
467
468(define-public superlu
469 (package
470 (name "superlu")
471 (version "4.3")
472 (source
473 (origin
474 (method url-fetch)
475 (uri (string-append "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
476 "superlu_" version ".tar.gz"))
477 (sha256
478 (base32 "10b785s9s4x0m9q7ihap09275pq4km3k2hk76jiwdfdr5qr2168n"))))
479 (build-system gnu-build-system)
480 (native-inputs
481 `(("tcsh" ,tcsh)))
482 (inputs
483 `(("lapack" ,lapack)
484 ("gfortran" ,gfortran-4.8)))
485 (arguments
486 `(#:parallel-build? #f
487 #:tests? #f ;tests are run as part of `make all`
488 #:phases
489 (alist-replace
490 'configure
491 (lambda* (#:key inputs outputs #:allow-other-keys)
492 (call-with-output-file "make.inc"
493 (lambda (port)
494 (format port "
495PLAT =
496SuperLUroot = ~a
497SUPERLULIB = ~a/lib/libsuperlu.a
498TMGLIB = libtmglib.a
499BLASDEF = -DUSE_VENDOR_BLAS
500BLASLIB = -L~a/lib -lblas
501LIBS = $(SUPERLULIB) $(BLASLIB)
502ARCH = ar
503ARCHFLAGS = cr
504RANLIB = ranlib
505CC = gcc
506PIC = -fPIC
507CFLAGS = -O3 -DPRNTlevel=0 $(PIC)
508NOOPTS = -O0 $(PIC)
509FORTRAN = gfortran
510FFLAGS = -O2 $(PIC)
511LOADER = $(CC)
512CDEFS = -DAdd_"
513 (getcwd)
514 (assoc-ref outputs "out")
515 (assoc-ref inputs "lapack")))))
516 (alist-cons-before
517 'build 'create-install-directories
518 (lambda* (#:key outputs #:allow-other-keys)
519 (for-each
520 (lambda (dir)
521 (mkdir-p (string-append (assoc-ref outputs "out")
522 "/" dir)))
523 '("lib" "include")))
524 (alist-replace
525 'install
526 (lambda* (#:key outputs #:allow-other-keys)
527 ;; Library is placed in lib during the build phase. Copy over
528 ;; headers to include.
529 (let* ((out (assoc-ref outputs "out"))
530 (incdir (string-append out "/include")))
531 (for-each (lambda (file)
532 (let ((base (basename file)))
533 (format #t "installing `~a' to `~a'~%"
534 base incdir)
535 (copy-file file
536 (string-append incdir "/" base))))
537 (find-files "SRC" ".*\\.h$"))))
538 %standard-phases)))))
539 (home-page "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/")
540 (synopsis "Supernodal direct solver for sparse linear systems")
541 (description
542 "SuperLU is a general purpose library for the direct solution of large,
543sparse, nonsymmetric systems of linear equations on high performance machines.
544The library is written in C and is callable from either C or Fortran. The
545library routines perform an LU decomposition with partial pivoting and
546triangular system solves through forward and back substitution. The library
547also provides threshold-based ILU factorization preconditioners.")
548 (license license:bsd-3)))