gnu: Add OpenMPI
[jackhill/guix/guix.git] / gnu / packages / maths.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
4 ;;; Copyright © 2014 John Darrington <jmd@gnu.org>
5 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
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)
28 #:use-module (guix utils)
29 #:use-module (guix build-system cmake)
30 #:use-module (guix build-system gnu)
31 #:use-module (gnu packages algebra)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages cmake)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages curl)
36 #:use-module (gnu packages elf)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages fltk)
39 #:use-module (gnu packages fontutils)
40 #:use-module (gnu packages gettext)
41 #:use-module (gnu packages gcc)
42 #:use-module (gnu packages gd)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages less)
46 #:use-module (gnu packages xorg)
47 #:use-module (gnu packages gl)
48 #:use-module (gnu packages multiprecision)
49 #:use-module (gnu packages pcre)
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages pkg-config)
52 #:use-module (gnu packages python)
53 #:use-module (gnu packages readline)
54 #:use-module (gnu packages tcsh)
55 #:use-module (gnu packages texinfo)
56 #:use-module (gnu packages texlive)
57 #:use-module (gnu packages xml))
58
59 (define-public units
60 (package
61 (name "units")
62 (version "2.11")
63 (source (origin
64 (method url-fetch)
65 (uri (string-append "mirror://gnu/units/units-" version
66 ".tar.gz"))
67 (sha256 (base32
68 "1gjs3wc212aaiq4r76hx9nl1h3fa39n0ljwl9420d6ixl3rdmdjk"))))
69 (build-system gnu-build-system)
70 (synopsis "Conversion between thousands of scales")
71 (description
72 "GNU Units converts numeric quantities between units of measure. It
73 can handle scale changes through adaptive usage of standard scale prefixes
74 (micro-, kilo-, etc.). It can also handle nonlinear conversions such as
75 Fahrenheit to Celsius. Its interpreter is powerful enough to be used
76 effectively as a scientific calculator.")
77 (license license:gpl3+)
78 (home-page "http://www.gnu.org/software/units/")))
79
80 (define-public gsl
81 (package
82 (name "gsl")
83 (version "1.16")
84 (source
85 (origin
86 (method url-fetch)
87 (uri (string-append "mirror://gnu/gsl/gsl-"
88 version ".tar.gz"))
89 (sha256
90 (base32
91 "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k"))))
92 (build-system gnu-build-system)
93 (arguments
94 `(#:parallel-tests? #f
95 #:phases
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)))
107 (home-page "http://www.gnu.org/software/gsl/")
108 (synopsis "Numerical library for C and C++")
109 (description
110 "The GNU Scientific Library is a library for numerical analysis in C
111 and C++. It includes a wide range of mathematical routines, with over 1000
112 functions in total. Subject areas covered by the library include:
113 differential equations, linear algebra, Fast Fourier Transforms and random
114 numbers.")
115 (license license:gpl3+)))
116
117 (define-public glpk
118 (package
119 (name "glpk")
120 (version "4.54")
121 (source
122 (origin
123 (method url-fetch)
124 (uri (string-append "mirror://gnu/glpk/glpk-"
125 version ".tar.gz"))
126 (sha256
127 (base32
128 "18gr2anv8gyps6j9f22k7li6w07glvww666sdqblvlq2hh3whwmb"))))
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/")
135 (synopsis "GNU Linear Programming Kit, supporting the MathProg language")
136 (description
137 "GLPK is a C library for solving large-scale linear programming (LP),
138 mixed integer programming (MIP), and other related problems. It supports the
139 GNU MathProg modeling language, a subset of the AMPL language, and features a
140 translator for the language. In addition to the C library, a stand-alone
141 LP/MIP solver is included in the package.")
142 (license license:gpl3+)))
143
144 (define-public pspp
145 (package
146 (name "pspp")
147 (version "0.8.2")
148 (source
149 (origin
150 (method url-fetch)
151 (uri (string-append "mirror://gnu/pspp/pspp-"
152 version ".tar.gz"))
153 (sha256
154 (base32
155 "1w7h3dglgx0jlq1wb605b8pgfsk2vr1q2q2rj7bsajh9ihbcsixr"))))
156 (build-system gnu-build-system)
157 (inputs
158 `(("cairo" ,cairo)
159 ("fontconfig" ,fontconfig)
160 ("gettext" ,gnu-gettext)
161 ("gsl" ,gsl)
162 ("libxml2" ,libxml2)
163 ("pango" ,pango)
164 ("readline" ,readline)
165 ("gtk" ,gtk+-2)
166 ("gtksourceview" ,gtksourceview)
167 ("zlib" ,zlib)))
168 (native-inputs
169 `(("perl" ,perl)
170 ("pkg-config" ,pkg-config)))
171 (home-page "http://www.gnu.org/software/pspp/")
172 (synopsis "Statistical analysis")
173 (description
174 "GNU PSPP is a statistical analysis program. It can perform
175 descriptive statistics, T-tests, linear regression and non-parametric tests.
176 It features both a graphical interface as well as command-line input. PSPP is
177 designed to interoperate with Gnumeric, LibreOffice and OpenOffice. Data can
178 be imported from spreadsheets, text files and database sources and it can be
179 output in text, PostScript, PDF or HTML.")
180 (license license:gpl3+)))
181
182 (define-public lapack
183 (package
184 (name "lapack")
185 (version "3.5.0")
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
193 "0lk3f97i9imqascnlf6wr5mjpyxqcdj73pgj97dj2mgvyg9z1n4s"))))
194 (build-system cmake-build-system)
195 (home-page "http://www.netlib.org/lapack/")
196 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
197 (inputs `(("fortran" ,gfortran-4.8)
198 ("python" ,python-2)))
199 (arguments
200 `(#:configure-flags '("-DBUILD_SHARED_LIBS:BOOL=YES")
201 #:phases (alist-cons-before
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))))
207 %standard-phases)))
208 (synopsis "Library for numerical linear algebra")
209 (description
210 "LAPACK is a Fortran 90 library for solving the most commonly occurring
211 problems in numerical linear algebra.")
212 (license (license:bsd-style "file://LICENSE"
213 "See LICENSE in the distribution."))))
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
237 utility. It was originally created to allow scientists and students to
238 visualize mathematical functions and data interactively, but has grown to
239 support many non-interactive uses such as web scripting. It is also used as a
240 plotting 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
244 "http://gnuplot.cvs.sourceforge.net/gnuplot/gnuplot/Copyright"))))
245
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
260 (alist-cons-before
261 'configure 'patch-configure
262 (lambda _
263 (substitute* "configure"
264 (("/bin/mv") "mv")))
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
270 extremely large and complex data collections.")
271 (license (license:x11-style
272 "http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/COPYING"))))
273
274
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)
299 ("hdf5-lib" ,hdf5 "lib")
300 ("hdf5-include" ,hdf5 "include")
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
325 for numerical computations. It can be used for both linear and non-linear
326 applications and it provides great support for visualizing results. Work may
327 be performed both at the interactive command-line as well as via script
328 files.")
329 (license license:gpl3+)))
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")
364 (description "Gmsh is a 3D finite element grid generator with a built-in
365 CAD engine and post-processor. Its design goal is to provide a fast, light
366 and user-friendly meshing tool with parametric input and advanced
367 visualization capabilities. Gmsh is built around four modules: geometry,
368 mesh, solver and post-processing. The specification of any input to these
369 modules is done either interactively using the graphical user interface or in
370 ASCII text files using Gmsh's own scripting language.")
371 (license license:gpl2+)))
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)
394 ("superlu" ,superlu)
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"
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"))
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
452 data structures and routines for the scalable (parallel) solution of
453 scientific 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."))))
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 "
495 PLAT =
496 SuperLUroot = ~a
497 SUPERLULIB = ~a/lib/libsuperlu.a
498 TMGLIB = libtmglib.a
499 BLASDEF = -DUSE_VENDOR_BLAS
500 BLASLIB = -L~a/lib -lblas
501 LIBS = $(SUPERLULIB) $(BLASLIB)
502 ARCH = ar
503 ARCHFLAGS = cr
504 RANLIB = ranlib
505 CC = gcc
506 PIC = -fPIC
507 CFLAGS = -O3 -DPRNTlevel=0 $(PIC)
508 NOOPTS = -O0 $(PIC)
509 FORTRAN = gfortran
510 FFLAGS = -O2 $(PIC)
511 LOADER = $(CC)
512 CDEFS = -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,
543 sparse, nonsymmetric systems of linear equations on high performance machines.
544 The library is written in C and is callable from either C or Fortran. The
545 library routines perform an LU decomposition with partial pivoting and
546 triangular system solves through forward and back substitution. The library
547 also provides threshold-based ILU factorization preconditioners.")
548 (license license:bsd-3)))