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