Merge branch 'master' into core-updates
[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 ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
7 ;;; Copyright © 2014 Mathieu Lirzin <mathieu.lirzin@openmailbox.org>
8 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
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 maths)
26 #:use-module (ice-9 regex)
27 #:use-module (gnu packages)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix utils)
32 #:use-module (guix build-system cmake)
33 #:use-module (guix build-system gnu)
34 #:use-module (gnu packages algebra)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages cmake)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages curl)
39 #:use-module (gnu packages elf)
40 #:use-module (gnu packages flex)
41 #:use-module (gnu packages fltk)
42 #:use-module (gnu packages fontutils)
43 #:use-module (gnu packages gettext)
44 #:use-module (gnu packages gcc)
45 #:use-module (gnu packages gd)
46 #:use-module (gnu packages ghostscript)
47 #:use-module (gnu packages glib)
48 #:use-module (gnu packages gtk)
49 #:use-module (gnu packages less)
50 #:use-module (gnu packages lisp)
51 #:use-module (gnu packages gnome)
52 #:use-module (gnu packages xorg)
53 #:use-module (gnu packages gl)
54 #:use-module (gnu packages m4)
55 #:use-module (gnu packages mpi)
56 #:use-module (gnu packages multiprecision)
57 #:use-module (gnu packages pcre)
58 #:use-module (gnu packages popt)
59 #:use-module (gnu packages perl)
60 #:use-module (gnu packages pkg-config)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages readline)
63 #:use-module (gnu packages tcsh)
64 #:use-module (gnu packages tcl)
65 #:use-module (gnu packages texinfo)
66 #:use-module (gnu packages texlive)
67 #:use-module (gnu packages xml))
68
69 (define-public units
70 (package
71 (name "units")
72 (version "2.11")
73 (source (origin
74 (method url-fetch)
75 (uri (string-append "mirror://gnu/units/units-" version
76 ".tar.gz"))
77 (sha256 (base32
78 "1gjs3wc212aaiq4r76hx9nl1h3fa39n0ljwl9420d6ixl3rdmdjk"))))
79 (build-system gnu-build-system)
80 (synopsis "Conversion between thousands of scales")
81 (description
82 "GNU Units converts numeric quantities between units of measure. It
83 can handle scale changes through adaptive usage of standard scale prefixes
84 (micro-, kilo-, etc.). It can also handle nonlinear conversions such as
85 Fahrenheit to Celsius. Its interpreter is powerful enough to be used
86 effectively as a scientific calculator.")
87 (license license:gpl3+)
88 (home-page "http://www.gnu.org/software/units/")))
89
90 (define-public dionysus
91 (package
92 (name "dionysus")
93 (version "1.3.0")
94 (source (origin
95 (method url-fetch)
96 (uri (string-append "mirror://gnu/dionysus/dionysus-" version
97 ".tar.gz"))
98 (sha256
99 (base32
100 "1aqnvw6z33bzqgd1ga571pnx6vq2zrkckm1cz91grv45h4jr9vgs"))))
101 (build-system gnu-build-system)
102 (inputs `(("tcl" ,tcl))) ;for 'tclsh'
103 (synopsis "Local search for universal constants and scientific values")
104 (description
105 "GNU Dionysus is a convenient system for quickly retrieving the values of
106 mathematical constants used in science and engineering. Values can be
107 searched using a simple command-line tool, choosing from three databases:
108 universal constants, atomic numbers, and constants related to
109 semiconductors.")
110 (license license:gpl3+)
111 (home-page "http://www.gnu.org/software/dionysus/")))
112
113 (define-public gsl
114 (package
115 (name "gsl")
116 (version "1.16")
117 (source
118 (origin
119 (method url-fetch)
120 (uri (string-append "mirror://gnu/gsl/gsl-"
121 version ".tar.gz"))
122 (sha256
123 (base32
124 "0lrgipi0z6559jqh82yx8n4xgnxkhzj46v96dl77hahdp58jzg3k"))))
125 (build-system gnu-build-system)
126 (arguments
127 `(#:parallel-tests? #f
128 #:phases
129 (alist-replace
130 'configure
131 (lambda* (#:key target system outputs #:allow-other-keys #:rest args)
132 (let ((configure (assoc-ref %standard-phases 'configure)))
133 ;; disable numerically unstable test on i686, see thread at
134 ;; http://lists.gnu.org/archive/html/bug-gsl/2011-11/msg00019.html
135 (if (string=? (or target system) "i686-linux")
136 (substitute* "ode-initval2/Makefile.in"
137 (("TESTS = \\$\\(check_PROGRAMS\\)") "TESTS =")))
138 (apply configure args)))
139 %standard-phases)))
140 (home-page "http://www.gnu.org/software/gsl/")
141 (synopsis "Numerical library for C and C++")
142 (description
143 "The GNU Scientific Library is a library for numerical analysis in C
144 and C++. It includes a wide range of mathematical routines, with over 1000
145 functions in total. Subject areas covered by the library include:
146 differential equations, linear algebra, Fast Fourier Transforms and random
147 numbers.")
148 (license license:gpl3+)))
149
150 (define-public glpk
151 (package
152 (name "glpk")
153 (version "4.55")
154 (source
155 (origin
156 (method url-fetch)
157 (uri (string-append "mirror://gnu/glpk/glpk-"
158 version ".tar.gz"))
159 (sha256
160 (base32
161 "1rqx5fzj1mhkifilip5mkxybpj2wkniq5qcn8h1w2vkr2rzhs29p"))))
162 (build-system gnu-build-system)
163 (inputs
164 `(("gmp" ,gmp)))
165 (arguments
166 `(#:configure-flags '("--with-gmp")))
167 (home-page "http://www.gnu.org/software/glpk/")
168 (synopsis "GNU Linear Programming Kit, supporting the MathProg language")
169 (description
170 "GLPK is a C library for solving large-scale linear programming (LP),
171 mixed integer programming (MIP), and other related problems. It supports the
172 GNU MathProg modeling language, a subset of the AMPL language, and features a
173 translator for the language. In addition to the C library, a stand-alone
174 LP/MIP solver is included in the package.")
175 (license license:gpl3+)))
176
177 (define-public pspp
178 (package
179 (name "pspp")
180 (version "0.8.4")
181 (source
182 (origin
183 (method url-fetch)
184 (uri (string-append "mirror://gnu/pspp/pspp-"
185 version ".tar.gz"))
186 (sha256
187 (base32
188 "0b65q45x05ps95pph6glbg7ymdr638nfb0rk9x5x9qm5k073pk5z"))))
189 (build-system gnu-build-system)
190 (inputs
191 `(("cairo" ,cairo)
192 ("fontconfig" ,fontconfig)
193 ("gettext" ,gnu-gettext)
194 ("gsl" ,gsl)
195 ("libxml2" ,libxml2)
196 ("pango" ,pango)
197 ("readline" ,readline)
198 ("gtk" ,gtk+-2)
199 ("gtksourceview" ,gtksourceview)
200 ("zlib" ,zlib)))
201 (native-inputs
202 `(("glib" ,glib "bin") ;for glib-genmarshal
203 ("perl" ,perl)
204 ("pkg-config" ,pkg-config)))
205 (home-page "http://www.gnu.org/software/pspp/")
206 (synopsis "Statistical analysis")
207 (description
208 "GNU PSPP is a statistical analysis program. It can perform
209 descriptive statistics, T-tests, linear regression and non-parametric tests.
210 It features both a graphical interface as well as command-line input. PSPP
211 is designed to interoperate with Gnumeric, LibreOffice and OpenOffice. Data
212 can be imported from spreadsheets, text files and database sources and it can
213 be output in text, PostScript, PDF or HTML.")
214 (license license:gpl3+)))
215
216 (define-public arpack-ng
217 (package
218 (name "arpack-ng")
219 (version "3.2.0")
220 (source
221 (origin
222 (method url-fetch)
223 (uri (string-append "https://github.com/opencollab/arpack-ng/archive/"
224 version ".tar.gz"))
225 (file-name (string-append name "-" version ".tar.gz"))
226 (sha256
227 (base32
228 "1fwch6vipms1ispzg2djvbzv5wag36f1dmmr3xs3mbp6imfyhvff"))))
229 (build-system gnu-build-system)
230 (home-page "https://github.com/opencollab/arpack-ng")
231 (inputs
232 `(("lapack" ,lapack)
233 ("fortran" ,gfortran-4.8)))
234 (synopsis "Fortran subroutines for solving eigenvalue problems")
235 (description
236 "ARPACK-NG is a collection of Fortran77 subroutines designed to solve
237 large scale eigenvalue problems.")
238 (license (license:bsd-style "file://COPYING"
239 "See COPYING in the distribution."))))
240
241 (define-public lapack
242 (package
243 (name "lapack")
244 (version "3.5.0")
245 (source
246 (origin
247 (method url-fetch)
248 (uri (string-append "http://www.netlib.org/lapack/lapack-"
249 version ".tgz"))
250 (sha256
251 (base32
252 "0lk3f97i9imqascnlf6wr5mjpyxqcdj73pgj97dj2mgvyg9z1n4s"))))
253 (build-system cmake-build-system)
254 (home-page "http://www.netlib.org/lapack/")
255 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
256 (inputs `(("fortran" ,gfortran-4.8)
257 ("python" ,python-2)))
258 (arguments
259 `(#:configure-flags '("-DBUILD_SHARED_LIBS:BOOL=YES")
260 #:phases (alist-cons-before
261 'check 'patch-python
262 (lambda* (#:key inputs #:allow-other-keys)
263 (let ((python (assoc-ref inputs "python")))
264 (substitute* "lapack_testing.py"
265 (("/usr/bin/env python") python))))
266 %standard-phases)))
267 (synopsis "Library for numerical linear algebra")
268 (description
269 "LAPACK is a Fortran 90 library for solving the most commonly occurring
270 problems in numerical linear algebra.")
271 (license (license:bsd-style "file://LICENSE"
272 "See LICENSE in the distribution."))))
273
274 (define-public gnuplot
275 (package
276 (name "gnuplot")
277 (version "4.6.3")
278 (source
279 (origin
280 (method url-fetch)
281 (uri (string-append "mirror://sourceforge/gnuplot/gnuplot/"
282 version "/gnuplot-" version ".tar.gz"))
283 (sha256
284 (base32
285 "1xd7gqdhlk7k1p9yyqf9vkk811nadc7m4si0q3nb6cpv4pxglpyz"))))
286 (build-system gnu-build-system)
287 (inputs `(("readline" ,readline)
288 ("cairo" ,cairo)
289 ("pango" ,pango)
290 ("gd" ,gd)))
291 (native-inputs `(("texlive" ,texlive)
292 ("pkg-config" ,pkg-config)))
293 (home-page "http://www.gnuplot.info")
294 (synopsis "Command-line driven graphing utility")
295 (description "Gnuplot is a portable command-line driven graphing
296 utility. It was originally created to allow scientists and students to
297 visualize mathematical functions and data interactively, but has grown to
298 support many non-interactive uses such as web scripting. It is also used as a
299 plotting engine by third-party applications like Octave.")
300 ;; X11 Style with the additional restriction that derived works may only be
301 ;; distributed as patches to the original.
302 (license (license:fsf-free
303 "http://gnuplot.cvs.sourceforge.net/gnuplot/gnuplot/Copyright"))))
304
305 (define-public hdf5
306 (package
307 (name "hdf5")
308 (version "1.8.12")
309 (source
310 (origin
311 (method url-fetch)
312 (uri (string-append "http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-"
313 version "/src/hdf5-"
314 version ".tar.bz2"))
315 (sha256
316 (base32 "0f9n0v3p3lwc7564791a39c6cn1d3dbrn7d1j3ikqsi27a8hy23d"))))
317 (build-system gnu-build-system)
318 (arguments
319 `(#:phases
320 (alist-cons-before
321 'configure 'patch-configure
322 (lambda _
323 (substitute* "configure"
324 (("/bin/mv") "mv")))
325 %standard-phases)))
326 (outputs '("out" "bin" "lib" "include"))
327 (home-page "http://www.hdfgroup.org")
328 (synopsis "Management suite for extremely large and complex data")
329 (description "HDF5 is a suite that makes possible the management of
330 extremely large and complex data collections.")
331 (license (license:x11-style
332 "http://www.hdfgroup.org/ftp/HDF5/current/src/unpacked/COPYING"))))
333
334
335 ;; For a fully featured Octave, users are strongly recommended also to install
336 ;; the following packages: texinfo, less, ghostscript, gnuplot.
337 (define-public octave
338 (package
339 (name "octave")
340 (version "3.8.0")
341 (source
342 (origin
343 (method url-fetch)
344 (uri (string-append "mirror://gnu/octave/octave-"
345 version ".tar.gz"))
346 (sha256
347 (base32
348 "0ks9pr154syw0vb3jn6xsnrkkrbvf9y7i7gaxa28rz6ngxbxvq9l"))))
349 (build-system gnu-build-system)
350 (inputs
351 `(("lapack" ,lapack)
352 ("readline" ,readline)
353 ("glpk" ,glpk)
354 ("curl" ,curl)
355 ("pcre" ,pcre)
356 ("fltk" ,fltk)
357 ("fontconfig" ,fontconfig)
358 ("freetype" ,freetype)
359 ("hdf5-lib" ,hdf5 "lib")
360 ("hdf5-include" ,hdf5 "include")
361 ("libxft" ,libxft)
362 ("mesa" ,mesa)
363 ("zlib" ,zlib)))
364 (native-inputs
365 `(("gfortran" ,gfortran-4.8)
366 ("pkg-config" ,pkg-config)
367 ("perl" ,perl)
368 ;; The following inputs are not actually used in the build process. However, the
369 ;; ./configure gratuitously tests for their existence and assumes that programs not
370 ;; present at build time are also not, and can never be, available at run time!
371 ;; If these inputs are therefore not present, support for them will be built out.
372 ;; However, Octave will still run without them, albeit without the features they
373 ;; provide.
374 ("less" ,less)
375 ("texinfo" ,texinfo)
376 ("ghostscript" ,ghostscript)
377 ("gnuplot" ,gnuplot)))
378 (arguments
379 `(#:configure-flags (list (string-append "--with-shell="
380 (assoc-ref %build-inputs "bash")
381 "/bin/sh"))))
382 (home-page "http://www.gnu.org/software/octave/")
383 (synopsis "High-level language for numerical computation")
384 (description "GNU Octave is a high-level interpreted language that is specialized
385 for numerical computations. It can be used for both linear and non-linear
386 applications and it provides great support for visualizing results. Work may
387 be performed both at the interactive command-line as well as via script
388 files.")
389 (license license:gpl3+)))
390
391 (define-public gmsh
392 (package
393 (name "gmsh")
394 (version "2.8.4")
395 (source
396 (origin
397 (method url-fetch)
398 (uri (string-append "http://www.geuz.org/gmsh/src/gmsh-"
399 version "-source.tgz"))
400 (sha256
401 (base32 "0jv2yvk28w86rx5mvjkb0w12ff2jxih7axnpvznpd295lg5jg7hr"))
402 (modules '((guix build utils)))
403 (snippet
404 ;; Remove non-free METIS code
405 '(delete-file-recursively "contrib/Metis"))))
406 (build-system cmake-build-system)
407 (native-inputs `(("patchelf" ,patchelf))) ;for augment-rpath
408 (propagated-inputs
409 `(("fltk" ,fltk)
410 ("gfortran" ,gfortran-4.8)
411 ("gmp" ,gmp)
412 ("hdf5-lib" ,hdf5 "lib")
413 ("hdf5-include" ,hdf5 "include")
414 ("lapack" ,lapack)
415 ("mesa" ,mesa)
416 ("glu" ,glu)
417 ("libx11" ,libx11)
418 ("libxext" ,libxext)))
419 (arguments
420 `(#:configure-flags `("-DENABLE_METIS:BOOL=OFF"
421 "-DENABLE_BUILD_SHARED:BOOL=ON"
422 "-DENABLE_BUILD_DYNAMIC:BOOL=ON")))
423 (home-page "http://www.geuz.org/gmsh/")
424 (synopsis "3D finite element grid generator")
425 (description "Gmsh is a 3D finite element grid generator with a built-in
426 CAD engine and post-processor. Its design goal is to provide a fast, light
427 and user-friendly meshing tool with parametric input and advanced
428 visualization capabilities. Gmsh is built around four modules: geometry,
429 mesh, solver and post-processing. The specification of any input to these
430 modules is done either interactively using the graphical user interface or in
431 ASCII text files using Gmsh's own scripting language.")
432 (license license:gpl2+)))
433
434 (define-public petsc
435 (package
436 (name "petsc")
437 (version "3.4.4")
438 (source
439 (origin
440 (method url-fetch)
441 ;; The *-lite-* tarball does not contain the *large* documentation
442 (uri (string-append "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/"
443 "petsc-lite-" version ".tar.gz"))
444 (sha256
445 (base32 "0v5dg6dhdjpi5ianvd4mm6hsvxzv1bsxwnh9f9myag0a0d9xk9iv"))
446 (patches
447 (list (search-patch "petsc-fix-threadcomm.patch")))))
448 (build-system gnu-build-system)
449 (native-inputs
450 `(("python" ,python-2)
451 ("perl" ,perl)))
452 (inputs
453 `(("gfortran" ,gfortran-4.8)
454 ("lapack" ,lapack)
455 ("superlu" ,superlu)
456 ;; leaving out hdf5 and fftw, as petsc expects them to be built with mpi
457 ;; leaving out opengl, as configuration seems to only be for mac
458 ))
459 (arguments
460 `(#:test-target "test"
461 #:parallel-build? #f
462 #:configure-flags
463 `("--with-mpi=0"
464 "--with-openmp=1"
465 "--with-superlu=1"
466 ,(string-append "--with-superlu-include="
467 (assoc-ref %build-inputs "superlu") "/include")
468 ,(string-append "--with-superlu-lib="
469 (assoc-ref %build-inputs "superlu") "/lib/libsuperlu.a"))
470 #:phases
471 (alist-replace
472 'configure
473 ;; PETSc's configure script is actually a python script, so we can't
474 ;; run it with bash.
475 (lambda* (#:key outputs (configure-flags '())
476 #:allow-other-keys)
477 (let* ((prefix (assoc-ref outputs "out"))
478 (flags `(,(string-append "--prefix=" prefix)
479 ,@configure-flags)))
480 (format #t "build directory: ~s~%" (getcwd))
481 (format #t "configure flags: ~s~%" flags)
482 (zero? (apply system* "./configure" flags))))
483 (alist-cons-after
484 'configure 'clean-local-references
485 ;; Try to keep build directory names from leaking into compiled code
486 (lambda* (#:key inputs outputs #:allow-other-keys)
487 (let ((out (assoc-ref outputs "out")))
488 (substitute* (find-files "." "^petsc(conf|machineinfo).h$")
489 (((getcwd)) out))))
490 (alist-cons-after
491 'install 'clean-install
492 ;; Try to keep installed files from leaking build directory names.
493 (lambda* (#:key inputs outputs #:allow-other-keys)
494 (let ((out (assoc-ref outputs "out"))
495 (fortran (assoc-ref inputs "gfortran")))
496 (substitute* (map (lambda (file)
497 (string-append out "/" file))
498 '("conf/petscvariables"
499 "conf/PETScConfig.cmake"))
500 (((getcwd)) out))
501 ;; Make compiler references point to the store
502 (substitute* (string-append out "/conf/petscvariables")
503 (("= g(cc|\\+\\+|fortran)" _ suffix)
504 (string-append "= " fortran "/bin/g" suffix)))
505 ;; PETSc installs some build logs, which aren't necessary.
506 (for-each (lambda (file)
507 (let ((f (string-append out "/" file)))
508 (when (file-exists? f)
509 (delete-file f))))
510 '("conf/configure.log"
511 "conf/make.log"
512 "conf/test.log"
513 "conf/error.log"
514 "conf/RDict.db"
515 ;; Once installed, should uninstall with Guix
516 "conf/uninstall.py"))))
517 %standard-phases)))))
518 (home-page "http://www.mcs.anl.gov/petsc")
519 (synopsis "Library to solve PDEs")
520 (description "PETSc, pronounced PET-see (the S is silent), is a suite of
521 data structures and routines for the scalable (parallel) solution of
522 scientific applications modeled by partial differential equations.")
523 (license (license:bsd-style
524 "http://www.mcs.anl.gov/petsc/documentation/copyright.html"))))
525
526 (define-public petsc-complex
527 (package (inherit petsc)
528 (location (source-properties->location (current-source-location)))
529 (name "petsc-complex")
530 (arguments
531 (substitute-keyword-arguments (package-arguments petsc)
532 ((#:configure-flags cf)
533 `(cons "--with-scalar-type=complex" ,cf))))
534 (synopsis "Library to solve PDEs (with complex scalars)")))
535
536 (define-public petsc-openmpi
537 (package (inherit petsc)
538 (name "petsc-openmpi")
539 (inputs
540 `(("openmpi" ,openmpi)
541 ,@(package-inputs petsc)))
542 (arguments
543 (substitute-keyword-arguments (package-arguments petsc)
544 ((#:configure-flags cf)
545 ``("--with-mpiexec=mpirun"
546 ,(string-append "--with-mpi-dir="
547 (assoc-ref %build-inputs "openmpi"))
548 ,@(delete "--with-mpi=0" ,cf)))))
549 (synopsis "Library to solve PDEs (with MPI support)")))
550
551 (define-public petsc-complex-openmpi
552 (package (inherit petsc-complex)
553 (name "petsc-complex-openmpi")
554 (inputs
555 `(("openmpi" ,openmpi)
556 ,@(package-inputs petsc-complex)))
557 (arguments
558 (substitute-keyword-arguments (package-arguments petsc-complex)
559 ((#:configure-flags cf)
560 ``("--with-mpiexec=mpirun"
561 ,(string-append "--with-mpi-dir="
562 (assoc-ref %build-inputs "openmpi"))
563 ,@(delete "--with-mpi=0" ,cf)))))
564 (synopsis "Library to solve PDEs (with complex scalars and MPI support)")))
565
566 (define-public superlu
567 (package
568 (name "superlu")
569 (version "4.3")
570 (source
571 (origin
572 (method url-fetch)
573 (uri (string-append "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
574 "superlu_" version ".tar.gz"))
575 (sha256
576 (base32 "10b785s9s4x0m9q7ihap09275pq4km3k2hk76jiwdfdr5qr2168n"))))
577 (build-system gnu-build-system)
578 (native-inputs
579 `(("tcsh" ,tcsh)))
580 (inputs
581 `(("lapack" ,lapack)
582 ("gfortran" ,gfortran-4.8)))
583 (arguments
584 `(#:parallel-build? #f
585 #:tests? #f ;tests are run as part of `make all`
586 #:phases
587 (alist-replace
588 'configure
589 (lambda* (#:key inputs outputs #:allow-other-keys)
590 (call-with-output-file "make.inc"
591 (lambda (port)
592 (format port "
593 PLAT =
594 SuperLUroot = ~a
595 SUPERLULIB = ~a/lib/libsuperlu.a
596 TMGLIB = libtmglib.a
597 BLASDEF = -DUSE_VENDOR_BLAS
598 BLASLIB = -L~a/lib -lblas
599 LIBS = $(SUPERLULIB) $(BLASLIB)
600 ARCH = ar
601 ARCHFLAGS = cr
602 RANLIB = ranlib
603 CC = gcc
604 PIC = -fPIC
605 CFLAGS = -O3 -DPRNTlevel=0 $(PIC)
606 NOOPTS = -O0 $(PIC)
607 FORTRAN = gfortran
608 FFLAGS = -O2 $(PIC)
609 LOADER = $(CC)
610 CDEFS = -DAdd_"
611 (getcwd)
612 (assoc-ref outputs "out")
613 (assoc-ref inputs "lapack")))))
614 (alist-cons-before
615 'build 'create-install-directories
616 (lambda* (#:key outputs #:allow-other-keys)
617 (for-each
618 (lambda (dir)
619 (mkdir-p (string-append (assoc-ref outputs "out")
620 "/" dir)))
621 '("lib" "include")))
622 (alist-replace
623 'install
624 (lambda* (#:key outputs #:allow-other-keys)
625 ;; Library is placed in lib during the build phase. Copy over
626 ;; headers to include.
627 (let* ((out (assoc-ref outputs "out"))
628 (incdir (string-append out "/include")))
629 (for-each (lambda (file)
630 (let ((base (basename file)))
631 (format #t "installing `~a' to `~a'~%"
632 base incdir)
633 (copy-file file
634 (string-append incdir "/" base))))
635 (find-files "SRC" ".*\\.h$"))))
636 %standard-phases)))))
637 (home-page "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/")
638 (synopsis "Supernodal direct solver for sparse linear systems")
639 (description
640 "SuperLU is a general purpose library for the direct solution of large,
641 sparse, nonsymmetric systems of linear equations on high performance machines.
642 The library is written in C and is callable from either C or Fortran. The
643 library routines perform an LU decomposition with partial pivoting and
644 triangular system solves through forward and back substitution. The library
645 also provides threshold-based ILU factorization preconditioners.")
646 (license license:bsd-3)))
647
648 (define-public superlu-dist
649 (package
650 (name "superlu-dist")
651 (version "3.3")
652 (source
653 (origin
654 (method url-fetch)
655 (uri (string-append "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"
656 "superlu_dist_" version ".tar.gz"))
657 (sha256
658 (base32 "1hnak09yxxp026blq8zhrl7685yip16svwngh1wysqxf8z48vzfj"))
659 (patches (list (search-patch "superlu-dist-scotchmetis.patch")))))
660 (build-system gnu-build-system)
661 (native-inputs
662 `(("tcsh" ,tcsh)))
663 (inputs
664 `(("gfortran" ,gfortran-4.8)))
665 (propagated-inputs
666 `(("openmpi" ,openmpi) ;headers include MPI heades
667 ("lapack" ,lapack) ;required to link with output library
668 ("pt-scotch" ,pt-scotch))) ;same
669 (arguments
670 `(#:parallel-build? #f ;race conditions using ar
671 #:phases
672 (alist-replace
673 'configure
674 (lambda* (#:key inputs outputs #:allow-other-keys)
675 (call-with-output-file "make.inc"
676 (lambda (port)
677 (format port "
678 PLAT =
679 DSuperLUroot = ~a
680 DSUPERLULIB = ~a/lib/libsuperlu_dist.a
681 BLASDEF = -DUSE_VENDOR_BLAS
682 BLASLIB = -L~a/lib -lblas
683 PARMETISLIB = -L~a/lib \
684 -lptscotchparmetis -lptscotch -lptscotcherr -lptscotcherrexit \
685 -lscotch -lscotcherr -lscotcherrexit
686 METISLIB = -L~:*~a/lib \
687 -lscotchmetis -lscotch -lscotcherr -lscotcherrexit
688 LIBS = $(DSUPERLULIB) $(PARMETISLIB) $(METISLIB) $(BLASLIB)
689 ARCH = ar
690 ARCHFLAGS = cr
691 RANLIB = ranlib
692 CC = mpicc
693 PIC = -fPIC
694 CFLAGS = -O3 -g -DPRNTlevel=0 $(PIC)
695 NOOPTS = -O0 -g $(PIC)
696 FORTRAN = mpifort
697 FFLAGS = -O2 -g $(PIC)
698 LOADER = $(CC)
699 CDEFS = -DAdd_"
700 (getcwd)
701 (assoc-ref outputs "out")
702 (assoc-ref inputs "lapack")
703 (assoc-ref inputs "pt-scotch")))))
704 (alist-cons-after
705 'unpack 'remove-broken-symlinks
706 (lambda _
707 (for-each delete-file
708 (find-files "MAKE_INC" "\\.#make\\..*")))
709 (alist-cons-before
710 'build 'create-install-directories
711 (lambda* (#:key outputs #:allow-other-keys)
712 (for-each
713 (lambda (dir)
714 (mkdir-p (string-append (assoc-ref outputs "out")
715 "/" dir)))
716 '("lib" "include")))
717 (alist-replace
718 'check
719 (lambda _
720 (with-directory-excursion "EXAMPLE"
721 (and
722 (zero? (system* "mpirun" "-n" "2"
723 "./pddrive" "-r" "1" "-c" "2" "g20.rua"))
724 (zero? (system* "mpirun" "-n" "2"
725 "./pzdrive" "-r" "1" "-c" "2" "cg20.cua")))))
726 (alist-replace
727 'install
728 (lambda* (#:key outputs #:allow-other-keys)
729 ;; Library is placed in lib during the build phase. Copy over
730 ;; headers to include.
731 (let* ((out (assoc-ref outputs "out"))
732 (incdir (string-append out "/include")))
733 (for-each (lambda (file)
734 (let ((base (basename file)))
735 (format #t "installing `~a' to `~a'~%"
736 base incdir)
737 (copy-file file
738 (string-append incdir "/" base))))
739 (find-files "SRC" ".*\\.h$"))))
740 %standard-phases)))))))
741 (home-page (package-home-page superlu))
742 (synopsis "Parallel supernodal direct solver")
743 (description
744 "SuperLU_DIST is a parallel extension to the serial SuperLU library.
745 It is targeted for distributed memory parallel machines. SuperLU_DIST is
746 implemented in ANSI C, and MPI for communications.")
747 (license license:bsd-3)))
748
749 (define-public scotch
750 (package
751 (name "scotch")
752 (version "6.0.0")
753 (source
754 (origin
755 (method url-fetch)
756 (uri (string-append "https://gforge.inria.fr/frs/download.php/31831/"
757 "scotch_" version ".tar.gz"))
758 (sha256
759 (base32 "0yfqf9lk7chb3h42777x42x4adx0v3n0b41q0cdqrdmscp4iczp5"))
760 (patches (list (search-patch "scotch-test-threading.patch")))))
761 (build-system gnu-build-system)
762 (inputs
763 `(("zlib" ,zlib)
764 ("flex" ,flex)
765 ("bison" ,bison)))
766 (arguments
767 `(#:phases
768 (alist-cons-after
769 'unpack 'chdir-to-src
770 (lambda _ (chdir "src"))
771 (alist-replace
772 'configure
773 (lambda _
774 (call-with-output-file "Makefile.inc"
775 (lambda (port)
776 (format port "
777 EXE =
778 LIB = .a
779 OBJ = .o
780 MAKE = make
781 AR = ar
782 ARFLAGS = -ruv
783 CCS = gcc
784 CCP = mpicc
785 CCD = gcc
786 CPPFLAGS =~{ -D~a~}
787 CFLAGS = -O2 -g $(CPPFLAGS)
788 LDFLAGS = -lz -lm -lrt -lpthread
789 CP = cp
790 LEX = flex -Pscotchyy -olex.yy.c
791 LN = ln
792 MKDIR = mkdir
793 MV = mv
794 RANLIB = ranlib
795 YACC = bison -pscotchyy -y -b y
796 "
797 '("COMMON_FILE_COMPRESS_GZ"
798 "COMMON_PTHREAD"
799 "COMMON_RANDOM_FIXED_SEED"
800 ;; TODO: Define once our MPI supports
801 ;; MPI_THREAD_MULTIPLE
802 ;; "SCOTCH_PTHREAD"
803 ;; "SCOTCH_PTHREAD_NUMBER=2"
804 "restrict=__restrict")))))
805 (alist-replace
806 'install
807 (lambda* (#:key outputs #:allow-other-keys)
808 (let ((out (assoc-ref outputs "out")))
809 (mkdir out)
810 (zero? (system* "make"
811 (string-append "prefix=" out)
812 "install"))))
813 %standard-phases)))))
814 (home-page "http://www.labri.fr/perso/pelegrin/scotch/")
815 (synopsis "Programs and libraries for graph algorithms")
816 (description "SCOTCH is a set of programs and libraries which implement
817 the static mapping and sparse matrix reordering algorithms developed within
818 the SCOTCH project. Its purpose is to apply graph theory, with a divide and
819 conquer approach, to scientific computing problems such as graph and mesh
820 partitioning, static mapping, and sparse matrix ordering, in application
821 domains ranging from structural mechanics to operating systems or
822 bio-chemistry.")
823 ;; See LICENSE_en.txt
824 (license license:cecill-c)))
825
826 (define-public pt-scotch
827 (package (inherit scotch)
828 (name "pt-scotch")
829 (propagated-inputs
830 `(("openmpi" ,openmpi))) ;Headers include MPI headers
831 (arguments
832 (substitute-keyword-arguments (package-arguments scotch)
833 ((#:phases scotch-phases)
834 `(alist-replace
835 'build
836 ;; TODO: Would like to add parallelism here
837 (lambda _
838 (and
839 (zero? (system* "make" "ptscotch"))
840 ;; Install the serial metis compatibility library
841 (zero? (system* "make" "-C" "libscotchmetis" "install"))))
842 (alist-replace
843 'check
844 (lambda _ (zero? (system* "make" "ptcheck")))
845 (alist-replace
846 'install
847 (lambda* (#:key outputs #:allow-other-keys)
848 (let ((out (assoc-ref outputs "out")))
849 (mkdir out)
850 (zero? (system* "make"
851 (string-append "prefix=" out)
852 "install"))))
853 ,scotch-phases))))))
854 (synopsis "Programs and libraries for graph algorithms (with MPI)")))
855
856 (define-public gsegrafix
857 (package
858 (name "gsegrafix")
859 (version "1.0.6")
860 (source
861 (origin
862 (method url-fetch)
863 (uri (string-append "mirror://gnu/" name "/" name "-"
864 version ".tar.gz"))
865 (sha256
866 (base32
867 "1b13hvx063zv970y750bx41wpx6hwd5ngjhbdrna8w8yy5kmxcda"))))
868 (build-system gnu-build-system)
869 (arguments
870 `(#:configure-flags '("LDFLAGS=-lm")))
871 (inputs
872 `(("libgnomecanvas" ,libgnomecanvas)
873 ("libbonoboui" ,libbonoboui)
874 ("libgnomeui" ,libgnomeui)
875 ("libgnomeprintui" ,libgnomeprintui)
876 ("popt" ,popt)))
877 (native-inputs
878 `(("pkg-config" ,pkg-config)))
879 (home-page "http://www.gnu.org/software/gsegrafix/")
880 (synopsis "GNOME application to create scientific and engineering plots")
881 (description "GSEGrafix is an application which produces high-quality graphical
882 plots for science and engineering. Plots are specified via simple ASCII
883 parameter files and data files and are presented in an anti-aliased GNOME
884 canvas. The program supports rectangular two-dimensional plots, histograms,
885 polar-axis plots and three-dimensional plots. Plots can be printed or saved
886 to BMP, JPEG or PNG image formats.")
887 (license license:gpl3+)))
888
889 (define-public maxima
890 (package
891 (name "maxima")
892 (version "5.34.1")
893 (source
894 (origin
895 (method url-fetch)
896 (uri (string-append "mirror://sourceforge/maxima/Maxima-source/"
897 version "-source/" name "-" version ".tar.gz"))
898 (sha256
899 (base32
900 "1dw9vfzldpj7lv303xbw0wpyn6ra6i2yzwlrjbcx7j0jm5n43ji0"))))
901 (build-system gnu-build-system)
902 (inputs
903 `(("gcl" ,gcl)
904 ("gnuplot" ,gnuplot) ;for plots
905 ("tk" ,tk))) ;Tcl/Tk is used by 'xmaxima'
906 (native-inputs
907 `(("texinfo" ,texinfo)
908 ("perl" ,perl)))
909 (arguments
910 `(#:configure-flags
911 (list "--enable-gcl"
912 (string-append "--with-posix-shell="
913 (assoc-ref %build-inputs "bash")
914 "/bin/sh")
915 (string-append "--with-wish="
916 (assoc-ref %build-inputs "tk")
917 "/bin/wish"
918 (let ((v ,(package-version tk)))
919 (string-take v (string-index-right v #\.)))))
920 ;; By default Maxima attempts to write temporary files to
921 ;; '/tmp/nix-build-maxima-5.34.1', which doesn't exist. Work around
922 ;; that.
923 #:make-flags (list "TMPDIR=/tmp")
924 #:phases (alist-cons-before
925 'check 'pre-check
926 (lambda _
927 (chmod "src/maxima" #o555))
928 ;; Make sure the doc and emacs files are found in the
929 ;; standard location. Also configure maxima to find gnuplot
930 ;; without having it on the PATH.
931 (alist-cons-after
932 'install 'post-install
933 (lambda* (#:key outputs inputs #:allow-other-keys)
934 (let* ((gnuplot (assoc-ref inputs "gnuplot"))
935 (out (assoc-ref outputs "out"))
936 (datadir (string-append out "/share/maxima/" ,version)))
937 (with-directory-excursion out
938 (mkdir-p "share/emacs")
939 (mkdir-p "share/doc")
940 (symlink
941 (string-append datadir "/emacs/")
942 (string-append out "/share/emacs/site-lisp"))
943 (symlink
944 (string-append datadir "/doc/")
945 (string-append out "/share/doc/maxima"))
946 (with-atomic-file-replacement
947 (string-append datadir "/share/maxima-init.lisp")
948 (lambda (in out)
949 (format out "~a ~s~a~%"
950 "(setf $gnuplot_command "
951 (string-append gnuplot "/bin/gnuplot") ")")
952 (dump-port in out))))))
953 %standard-phases))))
954 (home-page "http://maxima.sourceforge.net")
955 (synopsis "Numeric and symbolic expression manipulation")
956 (description "Maxima is a system for the manipulation of symbolic and
957 numerical expressions. It yields high precision numeric results by using
958 exact fractions, arbitrary precision integers, and variable precision floating
959 point numbers")
960 ;; Some files are lgpl2.1+. Some are gpl2+. Some explicitly state gpl1+.
961 ;; Others simply say "GNU General Public License" without stating a
962 ;; version (which implicitly means gpl1+).
963 ;; At least one file (src/maxima.asd) says "version 2."
964 ;; GPLv2 only is therefore the smallest subset.
965 (license license:gpl2)))
966
967 (define-public atlas
968 (package
969 (name "atlas")
970 (version "3.10.2")
971 (source (origin
972 (method url-fetch)
973 (uri (string-append "mirror://sourceforge/math-atlas/atlas"
974 version ".tar.bz2"))
975 (sha256
976 (base32
977 "0bqh4bdnjdyww4mcpg6kn0x7338mfqbdgysn97dzrwwb26di7ars"))))
978 (build-system gnu-build-system)
979 (home-page "http://math-atlas.sourceforge.net/")
980 (inputs `(("gfortran" ,gfortran-4.8)
981 ("lapack-tar" ,(package-source lapack))))
982 (outputs '("out" "doc"))
983 ;; For the moment we drop support for MIPS at it fails to compile. See
984 ;; https://lists.gnu.org/archive/html/guix-devel/2014-11/msg00516.html
985 (supported-systems (delete "mips64el-linux" %supported-systems))
986 (arguments
987 `(#:parallel-build? #f
988 #:parallel-tests? #f
989
990 ;; ATLAS tunes itself for the machine it is built on, as explained at
991 ;; <http://lists.gnu.org/archive/html/guix-devel/2014-10/msg00305.html>.
992 ;; For this reason, we want users to build it locally instead of using
993 ;; substitutes.
994 #:substitutable? #f
995
996 #:modules ((srfi srfi-26)
997 (srfi srfi-1)
998 (guix build gnu-build-system)
999 (guix build utils))
1000 #:configure-flags
1001 `(;; Generate position independent code suitable for dynamic libraries
1002 ;; and use WALL timer to get more accurate timing.
1003 "-Fa" "alg" "-fPIC" "-D" "c" "-DWALL"
1004 ;; Set word width.
1005 "-b"
1006 ,,(if (string-match "64" (%current-system))
1007 "64"
1008 "32")
1009 ;; Disable parallel build as it gives errors: atlas_pthread.h is
1010 ;; needed to compile C files before it is generated.
1011 "-Ss" "pmake" "make -j 1"
1012 ;; Probe is failing for MIPS. We therefore define the system
1013 ;; architecture explicitly by setting (-A) MACHINETYPE = 49
1014 ;; 'MIPSR1xK' and (-V) ISA = 1 'none'.
1015 ,,@(if (string-prefix? "mips" (%current-system))
1016 (list "-A" "49" "-V" "1")
1017 (list))
1018 ;; Generate shared libraries.
1019 "--shared"
1020 ;; Build a full LAPACK library.
1021 ,(string-append "--with-netlib-lapack-tarfile="
1022 (assoc-ref %build-inputs "lapack-tar")))
1023 #:phases
1024 (alist-cons-after
1025 'install 'install-doc
1026 (lambda* (#:key outputs inputs #:allow-other-keys)
1027 (let ((doc (string-append (assoc-ref outputs "doc")
1028 "/share/doc/atlas")))
1029 (mkdir-p doc)
1030 (fold (lambda (file previous)
1031 (and previous (zero? (system* "cp" file doc))))
1032 #t (find-files "../ATLAS/doc" ".*"))))
1033 (alist-cons-after
1034 'check 'check-pt
1035 (lambda _ (zero? (system* "make" "ptcheck")))
1036 ;; Fix files required to run configure.
1037 (alist-cons-before
1038 'configure 'fix-/bin/sh
1039 (lambda _
1040 ;; Use `sh', not `/bin/sh'.
1041 (substitute* (find-files "." "Makefile|configure|SpewMakeInc\\.c")
1042 (("/bin/sh")
1043 "sh")))
1044 ;; Fix /bin/sh in generated make files.
1045 (alist-cons-after
1046 'configure 'fix-/bin/sh-in-generated-files
1047 (lambda _
1048 (substitute* (find-files "." "^[Mm]ake\\.inc.*")
1049 (("/bin/sh")
1050 "sh")))
1051 ;; ATLAS configure program does not accepts the default flags
1052 ;; passed by the 'gnu-build-system'.
1053 (alist-replace
1054 'configure
1055 (lambda* (#:key native-inputs inputs outputs
1056 (configure-flags '())
1057 #:allow-other-keys #:rest args)
1058 (let* ((prefix (assoc-ref outputs "out"))
1059 (bash (or (and=> (assoc-ref
1060 (or native-inputs inputs) "bash")
1061 (cut string-append <> "/bin/bash"))
1062 "/bin/sh"))
1063 (flags `(,(string-append "--prefix=" prefix)
1064 ,@configure-flags))
1065 (abs-srcdir (getcwd))
1066 (srcdir (string-append "../" (basename abs-srcdir))))
1067 (format #t "source directory: ~s (relative from build: ~s)~%"
1068 abs-srcdir srcdir)
1069 (mkdir "../build")
1070 (chdir "../build")
1071 (format #t "build directory: ~s~%" (getcwd))
1072 (format #t "configure flags: ~s~%" flags)
1073 (zero? (apply system* bash
1074 (string-append srcdir "/configure")
1075 flags))))
1076 %standard-phases)))))))
1077 (synopsis "Automatically Tuned Linear Algebra Software")
1078 (description
1079 "ATLAS is an automatically tuned linear algebra software library
1080 providing C and Fortran77 interfaces to a portably efficient BLAS
1081 implementation, as well as a few routines from LAPACK.
1082
1083 Optimization occurs at build time. For this reason, the library is built on
1084 the machine where it is installed, without resorting to pre-built substitutes.
1085
1086 Before building the library, CPU throttling should be disabled. This can be
1087 done in the BIOS, or, on GNU/Linux, with the following commands:
1088
1089 cpufreq-selector -g performance -c 0
1090 ...
1091 cpufreq-selector -g performance -c N-1
1092
1093 where N is the number of cores of your CPU. Failure to do so will result in a
1094 library with poor performance.")
1095 (license license:bsd-3)))