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>
7 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
65 (uri (string-append "mirror://gnu/units/units-" version
68 "1gjs3wc212aaiq4r76hx9nl1h3fa39n0ljwl9420d6ixl3rdmdjk"))))
69 (build-system gnu-build-system)
70 (synopsis "Conversion between thousands of scales")
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/")))
87 (uri (string-append "mirror://gnu/gsl/gsl-"
91 "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k"))))
92 (build-system gnu-build-system)
94 `(#:parallel-tests? #f
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)))
107 (home-page "http://www.gnu.org/software/gsl/")
108 (synopsis "Numerical library for C and C++")
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
115 (license license:gpl3+)))
124 (uri (string-append "mirror://gnu/glpk/glpk-"
128 "18gr2anv8gyps6j9f22k7li6w07glvww666sdqblvlq2hh3whwmb"))))
129 (build-system gnu-build-system)
133 `(#:configure-flags '("--with-gmp")))
134 (home-page "http://www.gnu.org/software/glpk/")
135 (synopsis "GNU Linear Programming Kit, supporting the MathProg language")
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+)))
151 (uri (string-append "mirror://gnu/pspp/pspp-"
155 "1w7h3dglgx0jlq1wb605b8pgfsk2vr1q2q2rj7bsajh9ihbcsixr"))))
156 (build-system gnu-build-system)
159 ("fontconfig" ,fontconfig)
160 ("gettext" ,gnu-gettext)
164 ("readline" ,readline)
166 ("gtksourceview" ,gtksourceview)
170 ("pkg-config" ,pkg-config)))
171 (home-page "http://www.gnu.org/software/pspp/")
172 (synopsis "Statistical analysis")
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+)))
182 (define-public lapack
189 (uri (string-append "http://www.netlib.org/lapack/lapack-"
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)))
200 `(#:configure-flags '("-DBUILD_SHARED_LIBS:BOOL=YES")
201 #:phases (alist-cons-before
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))))
208 (synopsis "Library for numerical linear algebra")
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."))))
215 (define-public gnuplot
222 (uri (string-append "mirror://sourceforge/gnuplot/gnuplot/"
223 version "/gnuplot-" version ".tar.gz"))
226 "1xd7gqdhlk7k1p9yyqf9vkk811nadc7m4si0q3nb6cpv4pxglpyz"))))
227 (build-system gnu-build-system)
228 (inputs `(("readline" ,readline)
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"))))
253 (uri (string-append "http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-"
256 (base32 "0f9n0v3p3lwc7564791a39c6cn1d3dbrn7d1j3ikqsi27a8hy23d"))))
257 (build-system gnu-build-system)
261 'configure 'patch-configure
263 (substitute* "configure"
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"))))
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
284 (uri (string-append "mirror://gnu/octave/octave-"
288 "0ks9pr154syw0vb3jn6xsnrkkrbvf9y7i7gaxa28rz6ngxbxvq9l"))))
289 (build-system gnu-build-system)
292 ("readline" ,readline)
297 ("fontconfig" ,fontconfig)
298 ("freetype" ,freetype)
299 ("hdf5-lib" ,hdf5 "lib")
300 ("hdf5-include" ,hdf5 "include")
305 `(("gfortran" ,gfortran-4.8)
306 ("pkg-config" ,pkg-config)
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
316 ("ghostscript" ,ghostscript)
317 ("gnuplot" ,gnuplot)))
319 `(#:configure-flags (list (string-append "--with-shell="
320 (assoc-ref %build-inputs "bash")
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
329 (license license:gpl3+)))
338 (uri (string-append "http://www.geuz.org/gmsh/src/gmsh-"
339 version "-source.tgz"))
341 (base32 "0jv2yvk28w86rx5mvjkb0w12ff2jxih7axnpvznpd295lg5jg7hr"))
342 (modules '((guix build utils)))
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
350 ("gfortran" ,gfortran-4.8)
352 ("hdf5-lib" ,hdf5 "lib")
353 ("hdf5-include" ,hdf5 "include")
357 ("libxext" ,libxext)))
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+)))
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"))
384 (base32 "0v5dg6dhdjpi5ianvd4mm6hsvxzv1bsxwnh9f9myag0a0d9xk9iv"))
386 (list (search-patch "petsc-fix-threadcomm.patch")))))
387 (build-system gnu-build-system)
389 `(("python" ,python-2)
392 `(("gfortran" ,gfortran-4.8)
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
399 `(#:test-target "test"
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"))
412 ;; PETSc's configure script is actually a python script, so we can't
414 (lambda* (#:key outputs (configure-flags '())
416 (let* ((prefix (assoc-ref outputs "out"))
417 (flags `(,(string-append "--prefix=" prefix)
419 (format #t "build directory: ~s~%" (getcwd))
420 (format #t "configure flags: ~s~%" flags)
421 (zero? (apply system* "./configure" flags))))
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"))
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"
446 ;; Once installed, should uninstall with Guix
447 "conf/uninstall.py"))))
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"))))
457 (define-public petsc-complex
458 (package (inherit petsc)
459 (name "petsc-complex")
461 (substitute-keyword-arguments (package-arguments petsc)
462 ((#:configure-flags cf)
463 `(cons "--with-scalar-type=complex" ,cf))))
465 (string-append (package-description petsc)
466 " Complex scalar type version."))))
468 (define-public superlu
475 (uri (string-append "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
476 "superlu_" version ".tar.gz"))
478 (base32 "10b785s9s4x0m9q7ihap09275pq4km3k2hk76jiwdfdr5qr2168n"))))
479 (build-system gnu-build-system)
484 ("gfortran" ,gfortran-4.8)))
486 `(#:parallel-build? #f
487 #:tests? #f ;tests are run as part of `make all`
491 (lambda* (#:key inputs outputs #:allow-other-keys)
492 (call-with-output-file "make.inc"
497 SUPERLULIB = ~a/lib/libsuperlu.a
499 BLASDEF = -DUSE_VENDOR_BLAS
500 BLASLIB = -L~a/lib -lblas
501 LIBS = $(SUPERLULIB) $(BLASLIB)
507 CFLAGS = -O3 -DPRNTlevel=0 $(PIC)
514 (assoc-ref outputs "out")
515 (assoc-ref inputs "lapack")))))
517 'build 'create-install-directories
518 (lambda* (#:key outputs #:allow-other-keys)
521 (mkdir-p (string-append (assoc-ref outputs "out")
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'~%"
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")
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)))