about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:36 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:47 +0000
commit36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch)
treeb3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/libraries/science
parent4e31070265257dc67d120c27e0f75c2344fdfa9a (diff)
parentabf060725d7614bd3b9f96764262dfbc2f9c2199 (diff)
downloadnixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs
git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a
git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science')
-rw-r--r--nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix28
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix32
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix23
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix37
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix42
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix25
-rw-r--r--nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix31
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix27
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix40
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/blas/default.nix68
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/brial/default.nix46
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix144
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch46
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch55
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix41
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix71
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix38
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix69
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix50
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix37
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix164
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/fenics/unicode.patch67
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix40
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix32
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix98
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/lcalc/makefile.patch113
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix34
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix35
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix42
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix17
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix27
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix30
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix39
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/magma/default.nix46
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/metis/default.nix20
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix79
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix24
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/nccl/generic.nix57
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix160
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix20
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix21
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix54
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/or-tools/gflags-include.patch12
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix33
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix50
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix40
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix28
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix82
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix48
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/scs/default.nix50
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix43
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix100
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix112
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch7
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix36
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/superlu/find-openblas-library.patch11
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix89
-rw-r--r--nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix75
-rw-r--r--nixpkgs/pkgs/development/libraries/science/networking/ns3/default.nix96
-rw-r--r--nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix24
63 files changed, 3195 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix b/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix
new file mode 100644
index 000000000000..f727728943bd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix
@@ -0,0 +1,30 @@
+{ stdenv
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+  version = "5.6.0";
+  name = "papi-${version}";
+
+  src = fetchurl {
+    url = "https://bitbucket.org/icl/papi/get/papi-5-6-0-t.tar.gz";
+    sha256 = "13mngf9kl0y2wfxqvkad0smdaag7k8fvw82b4312gx62nwhc1i6r";
+  };
+
+  buildInputs = [ stdenv ];
+
+  preConfigure = ''
+    cd src
+  '';
+
+  doCheck = true;
+  checkTarget = "test";
+
+  meta = with stdenv.lib; {
+    homepage = https://icl.utk.edu/papi/;
+    description = "PAPI provides the tool designer and application engineer with a consistent interface and methodology for use of the performance counter hardware found in most major microprocessors";
+    license = licenses.bsdOriginal;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix
new file mode 100644
index 000000000000..f4353f51d66c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, cmake, libminc }:
+
+stdenv.mkDerivation rec {
+  pname = "EBTKS";
+  name  = "${pname}-2017-09-23";
+
+  src = fetchFromGitHub {
+    owner  = "BIC-MNI";
+    repo   = pname;
+    rev    = "67e4e197d8a32d6462c9bdc7af44d64ebde4fb5c";
+    sha256 = "1a1qw6i47fs1izx60l1ysabpmyx9j5sjnbdv8b47wi2xcc9i3hpq";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/BIC-MNI/${pname}";
+    description = "Library for working with MINC files";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix
new file mode 100644
index 000000000000..3c9b8f8257ce
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, bicpl, freeglut, mesa_glu }:
+
+stdenv.mkDerivation rec {
+  pname = "bicgl";
+  name  = "${pname}-2017-09-10";
+
+  owner = "BIC-MNI";
+
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "b7f7e52d1039d6202a93d9055f516186033656cc";
+    sha256 = "0lzirdi1mf4yl8srq7vjn746sbydz7h0wjh7wy8gycy6hq04qrg4";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc bicpl freeglut mesa_glu ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib" "-DBICPL_DIR=${bicpl}/lib" ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Brain Imaging Centre graphics library";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix
new file mode 100644
index 000000000000..f763e8a4fcc0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, netpbm }:
+
+stdenv.mkDerivation rec {
+  pname = "bicpl";
+  name  = "${pname}-2017-09-10";
+
+  owner = "BIC-MNI";
+
+  # current master is significantly ahead of most recent release, so use Git version:
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "612a63e740fadb162fcf27ee00da6a18dec4d5a9";
+    sha256 = "1vv9gi184bkvp3f99v9xmmw1ly63ip5b09y7zdjn39g7kmwzrga7";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc netpbm ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib" "-DBUILD_TESTING=FALSE" ];
+
+  doCheck = false;
+  # internal_volume_io.h: No such file or directory
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Brain Imaging Centre programming library";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix
new file mode 100644
index 000000000000..5f4cbbaa5670
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, cmake, itk, python }:
+
+stdenv.mkDerivation rec {
+  pname    = "elastix";
+  pversion = "4.9.0";
+  name  = "${pname}-${pversion}";
+
+  src = fetchurl {
+    url    = "https://github.com/SuperElastix/${pname}/archive/${pversion}.tar.gz";
+    sha256 = "02pbln36nq98xxfyqwlxg7b6gmigdq4fgfqr9mym1qn58aj04shg";
+  };
+
+  nativeBuildInputs = [ cmake python ];
+  buildInputs = [ itk ];
+
+  meta = with stdenv.lib; {
+    homepage = http://elastix.isi.uu.nl/;
+    description = "Image registration toolkit based on ITK";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.linux;
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix
new file mode 100644
index 000000000000..2ee9144b316d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, zlib, bzip2, lzma, curl, perl }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "htslib";
+  version = "1.9";
+
+  src = fetchurl {
+    url = "https://github.com/samtools/htslib/releases/download/${version}/${name}.tar.bz2";
+    sha256 = "16ljv43sc3fxmv63w7b2ff8m1s7h89xhazwmbm1bicz8axq8fjz0";
+  };
+
+  # perl is only used during the check phase.
+  nativeBuildInputs = [ perl ];
+
+  buildInputs = [ zlib bzip2 lzma curl ];
+
+  configureFlags = [ "--enable-libcurl" ]; # optional but strongly recommended
+
+  installFlags = "prefix=$(out)";
+
+  preCheck = ''
+    patchShebangs test/
+  '';
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "A C library for reading/writing high-throughput sequencing data";
+    license = licenses.mit;
+    homepage = http://www.htslib.org/;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.mimadrid ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix
new file mode 100644
index 000000000000..ce2050e82e6d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix
@@ -0,0 +1,42 @@
+{ stdenv, lib, gtest, fetchFromGitHub, cmake, boost, eigen, python, vtk, zlib }:
+
+stdenv.mkDerivation rec {
+  version = "2.0.0";
+  name = "mirtk-${version}";
+
+  src = fetchFromGitHub {
+    owner = "BioMedIA";
+    repo = "MIRTK";
+    rev = "v${version}";
+    sha256 = "0i2v97m66ir5myvi5b123r7zcagwy551b73s984gk7lksl5yiqxk";
+    fetchSubmodules = true;
+  };
+
+  cmakeFlags = "-DWITH_VTK=ON -DBUILD_ALL_MODULES=ON -DBUILD_TESTING=ON";
+
+  doCheck = true;
+
+  checkPhase = ''
+    ctest -E '(Polynomial|ConvolutionFunction|Downsampling|EdgeTable|InterpolateExtrapolateImage)'
+  '';
+  # testPolynomial - segfaults for some reason
+  # testConvolutionFunction, testDownsampling - main not called correctly
+  # testEdgeTable, testInterpolateExtrapolateImageFunction - setup fails
+
+  postInstall = ''
+    install -Dm644 -t "$out/share/bash-completion/completions/mirtk" share/completion/bash/mirtk
+  '';
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ cmake gtest ];
+  buildInputs = [ boost eigen python vtk zlib ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/BioMedIA/MIRTK";
+    description = "Medical image registration library and tools";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.linux;
+    license = licenses.asl20;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix
new file mode 100644
index 000000000000..51eed36312dd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, cmake, zlib }:
+
+stdenv.mkDerivation rec {
+  pname    = "nifticlib";
+  pversion = "2.0.0";
+  name  = "${pname}-${pversion}";
+
+  src = fetchurl {
+    url    = "mirror://sourceforge/project/niftilib/${pname}/${pname}_2_0_0/${name}.tar.gz";
+    sha256 = "123z9bwzgin5y8gi5ni8j217k7n683whjsvg0lrpii9flgk8isd3";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib ];
+
+  doCheck = false; # fails 7 out of 293 tests
+
+  meta = with stdenv.lib; {
+    homepage = https://sourceforge.net/projects/niftilib;
+    description = "Medical imaging format C API";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.linux;
+    license = licenses.publicDomain;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix
new file mode 100644
index 000000000000..8755b7fd2eba
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, cmake, libminc, bicpl, arguments, pcre-cpp }:
+
+stdenv.mkDerivation rec {
+  pname = "oobicpl";
+  name  = "${pname}-2016-03-02";
+
+  owner = "BIC-MNI";
+
+  src = fetchFromGitHub {
+    inherit owner;
+    repo   = pname;
+    rev    = "bc062a65dead2e58461f5afb37abedfa6173f10c";
+    sha256 = "05l4ml9djw17bgdnrldhcxydrzkr2f2scqlyak52ph5azj5n4zsx";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ libminc bicpl arguments pcre-cpp ];
+
+  cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib"
+                 "-DBICPL_DIR=${bicpl}/lib"
+                 "-DARGUMENTS_DIR=${arguments}/lib"
+                 "-DOOBICPL_BUILD_SHARED_LIBS=TRUE" ];
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/${owner}/${pname}";
+    description = "Brain Imaging Centre object-oriented programming library (and tools)";
+    maintainers = with maintainers; [ bcdarwin ];
+    platforms = platforms.unix;
+    license   = licenses.free;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix
new file mode 100644
index 000000000000..4668839ebb9c
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+  name = "QuadProgpp-${version}";
+  version = "4b6bd65f09fbff99c172a86d6e96ca74449b323f";
+
+  src = fetchFromGitHub {
+    owner = "liuq";
+    repo = "QuadProgpp";
+    rev = version;
+    sha256 = "02r0dlk2yjpafknvm945vbgs4sl26w2i1gw3pllar9hi364y8hnx";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/liuq/QuadProgpp;
+    license = licenses.mit;
+    description = ''
+      A C++ library for Quadratic Programming which implements the
+      Goldfarb-Idnani active-set dual method.
+    '';
+    maintainers = with maintainers; [ fuuzetsu ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix
new file mode 100644
index 000000000000..2a6c4af43fc3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, autoconf, automake, gettext, libtool
+, gfortran, openblas }:
+
+with stdenv.lib;
+
+let
+  version = "3.6.3";
+in
+stdenv.mkDerivation {
+  name = "arpack-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/opencollab/arpack-ng/archive/${version}.tar.gz";
+    sha256 = "0lzlcsrjsi36pv5bnipwjnyg2fx3nrv31bw2klwrg11gb8g5bwv4";
+  };
+
+  nativeBuildInputs = [ autoconf automake gettext libtool ];
+  buildInputs = [ gfortran openblas ];
+
+  doCheck = true;
+
+  BLAS_LIBS = "-L${openblas}/lib -lopenblas";
+
+  INTERFACE64 = optional openblas.blas64 "1";
+
+  preConfigure = ''
+    ./bootstrap
+  '';
+
+  meta = {
+    homepage = https://github.com/opencollab/arpack-ng;
+    description = ''
+      A collection of Fortran77 subroutines to solve large scale eigenvalue
+      problems.
+    '';
+    license = stdenv.lib.licenses.bsd3;
+    maintainers = [ stdenv.lib.maintainers.ttuegel ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix
new file mode 100644
index 000000000000..286be260052b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix
@@ -0,0 +1,68 @@
+{ stdenv, fetchurl, gfortran }:
+
+stdenv.mkDerivation rec {
+  name = "blas-${version}";
+  version = "3.8.0";
+
+  src = fetchurl {
+    url = "http://www.netlib.org/blas/${name}.tgz";
+    sha256 = "1s24iry5197pskml4iygasw196bdhplj0jmbsb9jhabcjqj2mpsm";
+  };
+
+  buildInputs = [ gfortran ];
+
+  configurePhase = ''
+    echo >make.inc  "SHELL = ${stdenv.shell}"
+    echo >>make.inc "PLAT = _LINUX"
+    echo >>make.inc "FORTRAN = gfortran"
+    echo >>make.inc "OPTS = -O2 -fPIC"
+    echo >>make.inc "DRVOPTS = $$(OPTS)"
+    echo >>make.inc "NOOPT = -O0 -fPIC"
+    echo >>make.inc "LOADER = gfortran"
+    echo >>make.inc "LOADOPTS ="
+    echo >>make.inc "ARCH = gfortran"
+    echo >>make.inc "ARCHFLAGS = -shared -o"
+    echo >>make.inc "RANLIB = echo"
+    echo >>make.inc "BLASLIB = libblas.so.${version}"
+  '';
+
+  buildPhase = ''
+    make
+    echo >>make.inc "ARCHFLAGS = "
+    echo >>make.inc "BLASLIB = libblas.a"
+    echo >>make.inc "ARCH = ar rcs"
+    echo >>make.inc "RANLIB = ranlib"
+    make
+  '';
+
+  installPhase =
+    # FreeBSD's stdenv doesn't use Coreutils.
+    let dashD = if stdenv.isFreeBSD then "" else "-D"; in
+    (stdenv.lib.optionalString stdenv.isFreeBSD "mkdir -p $out/lib ;")
+    + ''
+    install ${dashD} -m755 libblas.a "$out/lib/libblas.a"
+    install ${dashD} -m755 libblas.so.${version} "$out/lib/libblas.so.${version}"
+    ln -s libblas.so.${version} "$out/lib/libblas.so.3"
+    ln -s libblas.so.${version} "$out/lib/libblas.so"
+  '';
+
+  preFixup = stdenv.lib.optionalString stdenv.isDarwin ''
+    for fn in $(find $out/lib -name "*.so*"); do
+      if [ -L "$fn" ]; then continue; fi
+      install_name_tool -id "$fn" "$fn"
+    done
+  '';
+
+  meta = {
+    description = "Basic Linear Algebra Subprograms";
+    license = stdenv.lib.licenses.publicDomain;
+    homepage = http://www.netlib.org/blas/;
+    platforms = stdenv.lib.platforms.unix;
+  };
+
+  # We use linkName to pass a different name to --with-blas-libs for
+  # fflas-ffpack and linbox, because we use blas on darwin but openblas
+  # elsewhere.
+  # See see https://github.com/NixOS/nixpkgs/pull/45013.
+  passthru.linkName = "blas";
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix b/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix
new file mode 100644
index 000000000000..38b77781867d
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix
@@ -0,0 +1,46 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+, pkgconfig
+, boost
+, m4ri
+, gd
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.2.4";
+  name = "brial-${version}";
+
+  src = fetchFromGitHub {
+    owner = "BRiAl";
+    repo = "BRiAl";
+    rev = version;
+    sha256 = "08skgmwz190mvpkh0ddx92ilva6bxidxwh1qg16ipi768x92193s";
+  };
+
+  # FIXME package boost-test and enable checks
+  doCheck = false;
+
+  configureFlags = [
+    "--with-boost-unit-test-framework=no"
+  ];
+
+  buildInputs = [
+    boost
+    m4ri
+    gd
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+    pkgconfig
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/BRiAl/BRiAl;
+    description = "Legacy version of PolyBoRi maintained by sagemath developers";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix b/nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix
new file mode 100644
index 000000000000..d568e9452021
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix
@@ -0,0 +1,144 @@
+{ stdenv, lib, config, fetchFromGitHub
+, cmake
+, glog, google-gflags, gtest
+, protobuf, snappy
+, python, future, six, python-protobuf, numpy, pydot
+, eigen
+, doxygen
+, useCuda ? (config.cudaSupport or false), cudatoolkit ? null
+, useCudnn ? (config.cudnnSupport or false), cudnn ? null
+, useOpenmp ? false, openmp ? null
+, useOpencv3 ? true, opencv3 ? null
+, useLeveldb ? false, leveldb ? null
+, useLmdb ? true, lmdb ? null
+, useRocksdb ? false, rocksdb ? null
+, useZeromq ? false, zeromq ? null
+, useMpi ? false, mpi ? null
+# TODO: distributed computations
+#, useGloo ? false
+#, useNccl ? false
+#, useNnpack ? false
+}:
+
+assert useCuda -> cudatoolkit != null;
+assert useCudnn -> (useCuda && cudnn != null);
+assert useOpencv3 -> opencv3 != null;
+assert useLeveldb -> leveldb != null;
+assert useLmdb -> lmdb != null;
+assert useRocksdb -> rocksdb != null;
+assert useZeromq -> zeromq != null;
+assert useMpi -> mpi != null;
+
+let
+  # Third party modules that caffe2 holds as git submodules.
+  # Download them and create symlinks from caffe2/third_party.
+  installExtraSrc = extra: ''
+    rmdir "third_party/${extra.dst}"
+    ln -s "${extra.src}" "third_party/${extra.dst}"
+  '';
+
+  cub = {
+    src = fetchFromGitHub rec {
+      owner  = "NVlabs";
+      repo   = "cub";
+      rev    = "v1.7.4";
+      sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66";
+    };
+    dst = "cub";
+  };
+
+  pybind11 = {
+    src = fetchFromGitHub {
+      owner  = "pybind";
+      repo   = "pybind11";
+      rev    = "86e2ad4f77442c3350f9a2476650da6bee253c52";
+      sha256 = "05gi58dirvc8fgm0avpydvidzsbh2zrzgfaq671ym09f6dz0bcgz";
+    };
+    dst = "pybind11";
+  };
+
+  ccVersion = (builtins.parseDrvName stdenv.cc.name).version;
+in
+
+stdenv.mkDerivation rec {
+  name = "caffe2-${version}";
+  version = "0.8.1";
+  src = fetchFromGitHub {
+    owner = "caffe2";
+    repo = "caffe2";
+    rev = "v${version}";
+    sha256 = "18y7zjc69j6n5642l9caddl641b0djf3pjn4wacdsc1wk1jiyqk8";
+  };
+
+  nativeBuildInputs = [ cmake doxygen gtest ];
+  outputs = [ "bin" "out" ];
+  propagatedBuildOutputs = [ ]; # otherwise propagates out -> bin cycle
+
+  buildInputs = [ glog google-gflags protobuf snappy eigen ]
+    ++ lib.optional useCuda cudatoolkit
+    ++ lib.optional useCudnn cudnn
+    ++ lib.optional useOpenmp openmp
+    ++ lib.optional useOpencv3 opencv3
+    ++ lib.optional useLeveldb leveldb
+    ++ lib.optional useLmdb lmdb
+    ++ lib.optional useRocksdb rocksdb
+    ++ lib.optional useZeromq zeromq
+  ;
+  propagatedBuildInputs = [ numpy future six python-protobuf pydot ];
+
+  patches = lib.optional (stdenv.cc.isGNU && lib.versionAtLeast ccVersion "7.0.0") [
+    ./fix_compilation_on_gcc7.patch
+  ] ++ lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ];
+
+  cmakeFlags = [ ''-DBUILD_TEST=OFF''
+                 ''-DBUILD_PYTHON=ON''
+                 ''-DUSE_CUDA=${if useCuda then ''ON''else ''OFF''}''
+                 ''-DUSE_OPENMP=${if useOpenmp then ''ON''else ''OFF''}''
+                 ''-DUSE_OPENCV=${if useOpencv3 then ''ON''else ''OFF''}''
+                 ''-DUSE_MPI=${if useMpi then ''ON''else ''OFF''}''
+                 ''-DUSE_LEVELDB=${if useLeveldb then ''ON''else ''OFF''}''
+                 ''-DUSE_LMDB=${if useLmdb then ''ON''else ''OFF''}''
+                 ''-DUSE_ROCKSDB=${if useRocksdb then ''ON''else ''OFF''}''
+                 ''-DUSE_ZMQ=${if useZeromq  then ''ON''else ''OFF''}''
+                 ''-DUSE_GLOO=OFF''
+                 ''-DUSE_NNPACK=OFF''
+                 ''-DUSE_NCCL=OFF''
+                 ''-DUSE_REDIS=OFF''
+                 ''-DUSE_FFMPEG=OFF''
+               ]
+               ++ lib.optional useCuda [
+                 ''-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit}''
+                 ''-DCUDA_FAST_MATH=ON''
+                 ''-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc''
+               ];
+
+  preConfigure = ''
+    ${installExtraSrc cub}
+    ${installExtraSrc pybind11}
+    # XXX hack
+    export NIX_CFLAGS_COMPILE="-I ${eigen}/include/eigen3/ $NIX_CFLAGS_COMPILE"
+  '';
+
+  postInstall = ''
+    moveToOutput "bin" "$bin"
+    mkdir -p $out/lib/${python.libPrefix}
+    ln -s $out/ $out/${python.sitePackages}
+  '';
+
+  doCheck = false;
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = https://caffe2.ai/;
+    description = "A new lightweight, modular, and scalable deep learning framework";
+    longDescription = ''
+      Caffe2 aims to provide an easy and straightforward way for you to experiment
+      with deep learning and leverage community contributions of new models and
+      algorithms. You can bring your creations to scale using the power of GPUs in the
+      cloud or to the masses on mobile with Caffe2's cross-platform libraries.
+    '';
+    platforms = with stdenv.lib.platforms; linux;
+    license = stdenv.lib.licenses.asl20;
+    maintainers = with stdenv.lib.maintainers; [ yuriaisaka ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch b/nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
new file mode 100644
index 000000000000..f319f20233a2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch
@@ -0,0 +1,46 @@
+diff --git a/caffe2/operators/recurrent_network_op.cc b/caffe2/operators/recurrent_network_op.cc
+index dd4fded..5995e8a 100644
+--- a/caffe2/operators/recurrent_network_op.cc
++++ b/caffe2/operators/recurrent_network_op.cc
+@@ -1,4 +1,4 @@
+-#include "recurrent_network_op.h"
++#include "caffe2/operators/recurrent_network_op.h"
+ #include "caffe2/core/workspace.h"
+ 
+ namespace caffe2 {
+diff --git a/caffe2/operators/recurrent_network_op.h b/caffe2/operators/recurrent_network_op.h
+index 55328e5..ea898bc 100644
+--- a/caffe2/operators/recurrent_network_op.h
++++ b/caffe2/operators/recurrent_network_op.h
+@@ -762,8 +762,8 @@ class AccumulateInputGradientOp : public Operator<Context> {
+   USE_OPERATOR_CONTEXT_FUNCTIONS;
+ 
+   bool RunOnDevice() override {
+-    const auto t =
+-        OperatorBase::Input<Tensor<CPUContext>>(0).template data<int32_t>()[0];
++    const auto& t0 = OperatorBase::Input<Tensor<CPUContext>>(0);
++    const auto t = t0.template data<int32_t>()[0];
+     auto& og = Input(1);
+     auto* g = Output(0);
+ 
+diff --git a/caffe2/queue/queue_ops.h b/caffe2/queue/queue_ops.h
+index f2c0a33..642343f 100644
+--- a/caffe2/queue/queue_ops.h
++++ b/caffe2/queue/queue_ops.h
+@@ -17,13 +17,10 @@ class CreateBlobsQueueOp final : public Operator<Context> {
+         name(operator_def.output().Get(0)) {}
+ 
+   bool RunOnDevice() override {
+-    const auto capacity =
+-        OperatorBase::template GetSingleArgument<int>("capacity", 1);
+-    const auto numBlobs =
+-        OperatorBase::template GetSingleArgument<int>("num_blobs", 1);
++    const auto capacity = GetSingleArgument("capacity", 1);
++    const auto numBlobs = GetSingleArgument("num_blobs", 1);
+     const auto enforceUniqueName =
+-        OperatorBase::template GetSingleArgument<int>(
+-            "enforce_unique_name", false);
++        GetSingleArgument("enforce_unique_name", false);
+     const auto fieldNames =
+         OperatorBase::template GetRepeatedArgument<std::string>("field_names");
+     CAFFE_ENFORCE_EQ(this->OutputSize(), 1);
diff --git a/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch b/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch
new file mode 100644
index 000000000000..d908cb6ba80b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch
@@ -0,0 +1,55 @@
+diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h
+index bd06681..00172b7 100644
+--- a/caffe2/perfkernels/cvtsh_ss_bugfix.h
++++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h
+@@ -1,10 +1,36 @@
++/**
++ * Copyright (c) 2016-present, Facebook, Inc.
++ *
++ * Licensed under the Apache License, Version 2.0 (the "License");
++ * you may not use this file except in compliance with the License.
++ * You may obtain a copy of the License at
++ *
++ *     http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
+ #pragma once
+ 
+-#if defined(__APPLE__) && (__clang_major__ < 8)
++// Apple clang was fixed in 8.1
++#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1)))
++#define __APPLE_NEED_FIX 1
++#endif
++
++// Regular clang was fixed in 3.9
++#if defined(__clang__) && (__clang_major__ < 4) && (__clang_minor__ < 9)
++#define __CLANG_NEED_FIX 1
++#endif
++
++#if __APPLE_NEED_FIX || __CLANG_NEED_FIX
+ 
+ #include <emmintrin.h>
+ 
+-// This version of apple clang has a bug that _cvtsh_ss is not defined, see
++// This version of clang has a bug that _cvtsh_ss is not defined, see
+ // https://reviews.llvm.org/D16177
+ static __inline float
+     __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
+@@ -15,7 +41,10 @@ _cvtsh_ss(unsigned short a)
+   return r[0];
+ }
+ 
+-#endif // defined(__APPLE__) && (__clang_major__ < 8)
++#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX
++
++#undef __APPLE_NEED_FIX
++#undef __CLANG_NEED_FIX
+ 
+ #ifdef _MSC_VER
+ 
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix
new file mode 100644
index 000000000000..537fcb93a87e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitHub, gfortran, suitesparse, openblas }:
+let
+  suitesparse_ = suitesparse;
+in let
+  # SuiteSparse must use the same openblas
+  suitesparse = suitesparse_.override { inherit openblas; };
+in stdenv.mkDerivation rec {
+
+  name = "${pname}-${version}";
+  pname = "cholmod-extra";
+  version = "1.2.0";
+
+  src = fetchFromGitHub {
+    repo = pname;
+    owner = "jluttine";
+    rev = version;
+    sha256 = "0hz1lfp0zaarvl0dv0zgp337hyd8np41kmdpz5rr3fc6yzw7vmkg";
+  };
+
+  buildInputs = [ suitesparse gfortran openblas ];
+
+  buildFlags = [
+    "BLAS=-lopenblas"
+  ];
+
+  installFlags = [
+    "INSTALL_LIB=$(out)/lib"
+    "INSTALL_INCLUDE=$(out)/include"
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/jluttine/cholmod-extra;
+    description = "A set of additional routines for SuiteSparse CHOLMOD Module";
+    license = with licenses; [ gpl2Plus ];
+    maintainers = with maintainers; [ jluttine ];
+    platforms = with platforms; unix;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix
new file mode 100644
index 000000000000..7a653a58eb2a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix
@@ -0,0 +1,71 @@
+{ stdenv
+, fetchFromGitHub
+, cmake
+, gfortran
+, blas
+, boost
+, python
+, ocl-icd
+, opencl-headers
+, Accelerate, CoreGraphics, CoreVideo, OpenCL
+, gtest
+}:
+
+stdenv.mkDerivation rec {
+  name = "clblas-${version}"; 
+  version = "2.12";
+
+  src = fetchFromGitHub {
+    owner = "clMathLibraries"; 
+    repo = "clBLAS";
+    rev = "v${version}";
+    sha256 = "154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs";
+  }; 
+
+  patches = [ ./platform.patch ]; 
+
+  postPatch = ''
+    sed -i -re 's/(set\(\s*Boost_USE_STATIC_LIBS\s+).*/\1OFF\ \)/g' src/CMakeLists.txt
+  '';
+
+  preConfigure = ''
+    cd src
+  '';
+
+  cmakeFlags = [
+    "-DUSE_SYSTEM_GTEST=ON"
+  ];
+
+  buildInputs = [
+    cmake
+    gfortran
+    blas
+    python
+    boost
+    gtest
+  ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
+    ocl-icd
+    opencl-headers
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    Accelerate
+    CoreGraphics
+    CoreVideo
+  ];
+  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin [
+    OpenCL
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = "https://github.com/clMathLibraries/clBLAS";
+    description = "A software library containing BLAS functions written in OpenCL";
+    longDescription = ''
+      This package contains a library of BLAS functions on top of OpenCL. 
+    '';
+    license = licenses.asl20;
+    maintainers = with maintainers; [ artuuge ];
+    platforms = platforms.unix;
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch b/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch
new file mode 100644
index 000000000000..87404a426a4b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch
@@ -0,0 +1,34 @@
+diff --git a/src/library/tools/ktest/config.cpp b/src/library/tools/ktest/config.cpp
+index 8b20128..faf9bde 100644
+--- a/src/library/tools/ktest/config.cpp
++++ b/src/library/tools/ktest/config.cpp
+@@ -24,8 +24,6 @@
+ 
+ using namespace clMath;
+ 
+-static const char DEFAULT_PLATFORM_NAME[] = "AMD Accelerated Parallel Processing";
+-
+ Config::Config() :
+     defaultConfig_(""),
+     cpp_("ktest.cpp"),
+@@ -35,7 +33,10 @@ Config::Config() :
+     hasFuncID_(false), hasSubdims_(false),
+     skipAccuracy_(false)
+ {
+-    setPlatform(DEFAULT_PLATFORM_NAME);
++    platform_ = NULL;
++    setPlatform("");
++
++    device_ = NULL;
+     setDevice("");
+ 
+     memset(&kargs_, 0, sizeof(kargs_));
+@@ -262,7 +263,7 @@ Config::setPlatform(const std::string& name)
+             continue;
+         }
+         if (name.empty()) {
+-            found = (strcmp(pname, DEFAULT_PLATFORM_NAME) == 0);
++	    found = true;
+         }
+         else {
+             found = (strcmp(pname, name.c_str()) == 0);
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix
new file mode 100644
index 000000000000..2441aff9fa30
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix
@@ -0,0 +1,38 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.21";
+  name = "cliquer-${version}";
+
+  # autotoolized version of the original cliquer
+  src = fetchFromGitHub {
+    owner = "dimpase";
+    repo = "autocliquer";
+    rev = "v${version}";
+    sha256 = "180i4qj1a25qfp75ig2d3144xfpb1dgcgpha0iqqghd7di4awg7z";
+  };
+
+  doCheck = true;
+
+  buildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://users.aalto.fi/~pat/cliquer.html;
+    downloadPage = src.meta.homepage; # autocliquer
+    description = "Routines for clique searching";
+    longDescription = ''
+      Cliquer is a set of C routines for finding cliques in an arbitrary weighted graph.
+      It uses an exact branch-and-bound algorithm developed by Patric Östergård.
+      It is designed with the aim of being efficient while still being flexible and
+      easy to use.
+    '';
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix
new file mode 100644
index 000000000000..b41469c215e2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix
@@ -0,0 +1,69 @@
+{ callPackage, cudatoolkit_7, cudatoolkit_7_5, cudatoolkit_8, cudatoolkit_9_0, cudatoolkit_9_1, cudatoolkit_9_2, cudatoolkit_10_0 }:
+
+let
+  generic = args: callPackage (import ./generic.nix (removeAttrs args ["cudatoolkit"])) {
+    inherit (args) cudatoolkit;
+  };
+
+in rec {
+  cudnn_cudatoolkit_7 = generic rec {
+    # Old URL is v4 instead of v4.0 for some reason...
+    version = "4";
+    cudatoolkit = cudatoolkit_7;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v4.0-prod.tgz";
+    sha256 = "01a4v5j4v9n2xjqcc4m28c3m67qrvsx87npvy7zhx7w8smiif2fd";
+  };
+
+  cudnn_cudatoolkit_7_5 = generic rec {
+    version = "6.0";
+    cudatoolkit = cudatoolkit_7_5;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v${version}.tgz";
+    sha256 = "0b68hv8pqcvh7z8xlgm4cxr9rfbjs0yvg1xj2n5ap4az1h3lp3an";
+  };
+
+  cudnn6_cudatoolkit_8 = generic rec {
+    version = "6.0";
+    cudatoolkit = cudatoolkit_8;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v${version}.tgz";
+    sha256 = "173zpgrk55ri8if7s5yngsc89ajd6hz4pss4cdxlv6lcyh5122cv";
+  };
+
+  cudnn_cudatoolkit_8 = generic rec {
+    version = "7.0.5";
+    cudatoolkit = cudatoolkit_8;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.tgz";
+    sha256 = "9e0b31735918fe33a79c4b3e612143d33f48f61c095a3b993023cdab46f6d66e";
+  };
+
+  cudnn_cudatoolkit_9_0 = generic rec {
+    version = "7.3.0";
+    cudatoolkit = cudatoolkit_9_0;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.3.0.29.tgz";
+    sha256 = "16z4vgbcmbayk4hppz0xshgs3g07blkp4j25cxcjqyrczx1r0gs0";
+  };
+
+  cudnn_cudatoolkit_9_1 = generic rec {
+    version = "7.1.3";
+    cudatoolkit = cudatoolkit_9_1;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.1.tgz";
+    sha256 = "0a0237gpr0p63s92njai0xvxmkbailzgfsvh7n9fnz0njhvnsqfx";
+  };
+
+  cudnn_cudatoolkit_9_2 = generic rec {
+    version = "7.2.1";
+    cudatoolkit = cudatoolkit_9_2;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.2.1.38.tgz";
+    sha256 = "1sf215wm6zgr17gs6sxfhw61b7a0qmcxiwhgy1b4nqdyxpqgay1y";
+  };
+
+  cudnn_cudatoolkit_9 = cudnn_cudatoolkit_9_2;
+
+  cudnn_cudatoolkit_10_0 = generic rec {
+    version = "7.3.1";
+    cudatoolkit = cudatoolkit_10_0;
+    srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.3.1.20.tgz";
+    sha256 = "1yp35mng4ym40g5rqp63dcpa6jg4q1pnjkspnhlakzzdy8is65af";
+  };
+
+  cudnn_cudatoolkit_10 = cudnn_cudatoolkit_10_0;
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix
new file mode 100644
index 000000000000..bb1258655b5b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix
@@ -0,0 +1,50 @@
+{ version
+, srcName
+, sha256
+}:
+
+{ stdenv
+, lib
+, cudatoolkit
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+  name = "cudatoolkit-${cudatoolkit.majorVersion}-cudnn-${version}";
+
+  inherit version;
+  src = fetchurl {
+    # URL from NVIDIA docker containers: https://gitlab.com/nvidia/cuda/blob/centos7/7.0/runtime/cudnn4/Dockerfile
+    url = "https://developer.download.nvidia.com/compute/redist/cudnn/v${version}/${srcName}";
+    inherit sha256;
+  };
+
+  installPhase = ''
+    function fixRunPath {
+      p=$(patchelf --print-rpath $1)
+      patchelf --set-rpath "$p:${lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
+    }
+    fixRunPath lib64/libcudnn.so
+
+    mkdir -p $out
+    cp -a include $out/include
+    cp -a lib64 $out/lib64
+  '';
+
+  propagatedBuildInputs = [
+    cudatoolkit
+  ];
+
+  passthru = {
+    inherit cudatoolkit;
+    majorVersion = lib.head (lib.splitString "." version);
+  };
+
+  meta = with stdenv.lib; {
+    description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
+    homepage = "https://developer.nvidia.com/cudnn";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ mdaiter ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix b/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix
new file mode 100644
index 000000000000..645a865eb955
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  name = "ecos-${version}";
+  version = "2.0.6";
+
+  src = fetchFromGitHub {
+    owner = "embotech";
+    repo = "ecos";
+    rev = "v${version}";
+    sha256 = "11v958j66wq30gxpjpkgl7n3rvla845lygz8fl39pgf1vk9sdyc7";
+  };
+
+  buildPhase = ''
+    make all shared
+  '';
+
+  doCheck = true;
+  checkPhase = ''
+    make test
+    ./runecos
+  '';
+
+  installPhase = ''
+    mkdir -p $out/lib
+    cp lib*.a lib*.so $out/lib
+    cp -r include $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A lightweight conic solver for second-order cone programming";
+    homepage = https://www.embotech.com/ECOS;
+    license = licenses.gpl3;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bhipple ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix b/nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix
new file mode 100644
index 000000000000..1825a6f1bb25
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix
@@ -0,0 +1,164 @@
+{ stdenv
+, fetchurl
+, boost
+, cmake
+, doxygen
+, eigen
+, numpy
+, pkgconfig
+, pytest
+, pythonPackages
+, six
+, sympy
+, gtest ? null
+, hdf5 ? null
+, mpi ? null
+, ply ? null
+, python ? null
+, sphinx ? null
+, suitesparse ? null
+, swig ? null
+, vtk ? null
+, zlib ? null
+, docs ? false
+, pythonBindings ? false
+, doCheck ? true }:
+
+assert pythonBindings -> python != null && ply != null && swig != null;
+
+let
+  version = "2017.1.0";
+
+  dijitso = pythonPackages.buildPythonPackage {
+    name = "dijitso-${version}";
+    src = fetchurl {
+      url = "https://bitbucket.org/fenics-project/dijitso/downloads/dijitso-${version}.tar.gz";
+      sha256 = "0mw6mynjmg6yl3l2k33yra2x84s4r6mh44ylhk9znjfk74jra8zg";
+    };
+    buildInputs = [ numpy pytest six ];
+    checkPhase = ''
+      export HOME=$PWD
+      py.test test/
+    '';
+    meta = {
+      description = "Distributed just-in-time shared library building";
+      homepage = http://fenicsproject.org/;
+      platforms = stdenv.lib.platforms.all;
+      license = stdenv.lib.licenses.lgpl3;
+    };
+  };
+
+  fiat = pythonPackages.buildPythonPackage {
+    name = "fiat-${version}";
+    src = fetchurl {
+      url = "https://bitbucket.org/fenics-project/fiat/downloads/fiat-${version}.tar.gz";
+      sha256 = "156ybz70n4n7p88q4pfkvbmg1xr2ll80inzr423mki0nml0q8a6l";
+    };
+    buildInputs = [ numpy pytest six sympy ];
+    checkPhase = ''
+      py.test test/unit/
+    '';
+    meta = {
+      description = "Automatic generation of finite element basis functions";
+      homepage = http://fenicsproject.org/;
+      platforms = stdenv.lib.platforms.all;
+      license = stdenv.lib.licenses.lgpl3;
+    };
+  };
+
+  ufl = pythonPackages.buildPythonPackage {
+    name = "ufl-${version}";
+    src = fetchurl {
+      url = "https://bitbucket.org/fenics-project/ufl/downloads/ufl-${version}.tar.gz";
+      sha256 = "13ysimmwad429fjjs07j1fw1gq196p021j7mv66hwrljyh8gm1xg";
+    };
+    buildInputs = [ numpy pytest six ];
+    checkPhase = ''
+      py.test test/
+    '';
+    meta = {
+      description = "A domain-specific language for finite element variational forms";
+      homepage = http://fenicsproject.org/;
+      platforms = stdenv.lib.platforms.all;
+      license = stdenv.lib.licenses.lgpl3;
+    };
+  };
+
+  ffc = pythonPackages.buildPythonPackage {
+    name = "ffc-${version}";
+    src = fetchurl {
+      url = "https://bitbucket.org/fenics-project/ffc/downloads/ffc-${version}.tar.gz";
+      sha256 = "1cw7zsrjms11xrfg7x9wjd90x3w4v5s1wdwa18xqlycqz7cc8wr0";
+    };
+    buildInputs = [ dijitso fiat numpy pytest six sympy ufl ];
+    checkPhase = ''
+      export HOME=$PWD
+      py.test test/unit/
+    '';
+    meta = {
+      description = "A compiler for finite element variational forms";
+      homepage = http://fenicsproject.org/;
+      platforms = stdenv.lib.platforms.all;
+      license = stdenv.lib.licenses.lgpl3;
+    };
+  };
+
+  instant = pythonPackages.buildPythonPackage {
+    name = "instant-${version}";
+    src = fetchurl {
+      url = "https://bitbucket.org/fenics-project/instant/downloads/instant-${version}.tar.gz";
+      sha256 = "1rsyh6n04w0na2zirfdcdjip8k8ikb8fc2x94fq8ylc3lpcnpx9q";
+    };
+    buildInputs = [ numpy six ];
+    meta = {
+      description = "Instant inlining of C and C++ code in Python";
+      homepage = http://fenicsproject.org/;
+      platforms = stdenv.lib.platforms.all;
+      license = stdenv.lib.licenses.lgpl3;
+    };
+  };
+
+in
+stdenv.mkDerivation {
+  name = "dolfin-${version}";
+  src = fetchurl {
+    url = "https://bitbucket.org/fenics-project/dolfin/downloads/dolfin-${version}.tar.gz";
+    sha256 = "14hfb5q6rz79zmy742s2fiqkb9j2cgh5bsg99v76apcr84nklyds";
+  };
+  propagatedBuildInputs = [ dijitso fiat numpy six ufl ];
+  buildInputs = [
+    boost cmake dijitso doxygen eigen ffc fiat gtest hdf5 instant mpi
+    numpy pkgconfig six sphinx suitesparse sympy ufl vtk zlib
+    ] ++ stdenv.lib.optionals pythonBindings [ ply python numpy swig ];
+  patches = [ ./unicode.patch ];
+  cmakeFlags = "-DDOLFIN_CXX_FLAGS=-std=c++11"
+    + " -DDOLFIN_AUTO_DETECT_MPI=OFF"
+    + " -DDOLFIN_ENABLE_CHOLMOD=" + (if suitesparse != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_DOCS=" + (if docs then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_GTEST=" + (if gtest != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_HDF5=" + (if hdf5 != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_MPI=" + (if mpi != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_PARMETIS=OFF"
+    + " -DDOLFIN_ENABLE_PETSC4PY=OFF"
+    + " -DDOLFIN_ENABLE_PETSC=OFF"
+    + " -DDOLFIN_ENABLE_PYTHON=" + (if pythonBindings then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_SCOTCH=OFF"
+    + " -DDOLFIN_ENABLE_SLEPC4PY=OFF"
+    + " -DDOLFIN_ENABLE_SLEPC=OFF"
+    + " -DDOLFIN_ENABLE_SPHINX=" + (if sphinx != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_TESTING=" + (if doCheck then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_TRILINOS=OFF"
+    + " -DDOLFIN_ENABLE_UMFPACK=" + (if suitesparse != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_VTK=" + (if vtk != null then "ON" else "OFF")
+    + " -DDOLFIN_ENABLE_ZLIB=" + (if zlib != null then "ON" else "OFF");
+  checkPhase = ''
+    make runtests
+  '';
+  postInstall = "source $out/share/dolfin/dolfin.conf";
+  meta = {
+    description = "The FEniCS Problem Solving Environment in Python and C++";
+    homepage = http://fenicsproject.org/;
+    platforms = stdenv.lib.platforms.darwin;
+    license = stdenv.lib.licenses.lgpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/fenics/unicode.patch b/nixpkgs/pkgs/development/libraries/science/math/fenics/unicode.patch
new file mode 100644
index 000000000000..2ef2709263ab
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/fenics/unicode.patch
@@ -0,0 +1,67 @@
+From 0cc9e68de1181d950d4185bf3a87b69a87e4358f Mon Sep 17 00:00:00 2001
+From: "James D. Trotter" <james@simula.no>
+Date: Mon, 14 Aug 2017 16:43:53 +0200
+Subject: [PATCH] Use a UTF-8 encoding to avoid errors with decoding non-ascii
+ characters
+
+---
+ cmake/scripts/generate-swig-interface.py |  6 +++---
+ utils/pylit/pylit.py                     | 10 +++++++---
+ 2 files changed, 10 insertions(+), 6 deletions(-)
+
+diff --git a/cmake/scripts/generate-swig-interface.py b/cmake/scripts/generate-swig-interface.py
+index 843a49229..7b85453d0 100644
+--- a/cmake/scripts/generate-swig-interface.py
++++ b/cmake/scripts/generate-swig-interface.py
+@@ -212,10 +212,10 @@ def extract_swig_modules_dependencies(module_to_submodules, submodule_info):
+                     continue
+ 
+                 # Read code
+-                with open(header_file) as f:
+-                    code = f.read()
+-
+                 try:
++                    with open(header_file, encoding='utf-8') as f:
++                        code = f.read()
++
+                     # Extract type info
+                     used_types, declared_types = parse_and_extract_type_info(code)
+                 except Exception as e:
+diff --git a/utils/pylit/pylit.py b/utils/pylit/pylit.py
+index bcd8ec5e0..8c2964fbd 100755
+--- a/utils/pylit/pylit.py
++++ b/utils/pylit/pylit.py
+@@ -1496,7 +1496,7 @@ def open_streams(infile = '-', outfile = '-', overwrite='update', **keyw):
+     if infile == '-':
+         in_stream = sys.stdin
+     else:
+-        in_stream = open(infile, 'r')
++        in_stream = open(infile, 'r', encoding='utf-8')
+ 
+     if outfile == '-':
+         out_stream = sys.stdout
+@@ -1505,7 +1505,7 @@ def open_streams(infile = '-', outfile = '-', overwrite='update', **keyw):
+     elif overwrite == 'update' and is_newer(outfile, infile):
+         raise IOError((1, "Output file is newer than input file!", outfile))
+     else:
+-        out_stream = open(outfile, 'w')
++        out_stream = open(outfile, 'w', encoding='utf-8')
+     return (in_stream, out_stream)
+ 
+ # is_newer
+@@ -1731,7 +1731,11 @@ def main(args=sys.argv[1:], **defaults):
+ 
+ # Convert and write to out_stream::
+ 
+-    out_stream.write(str(converter))
++    try:
++        out_stream.write(str(converter))
++    except Exception as e:
++        print("Failed to write extract to", out_stream.name)
++        raise
+ 
+     if out_stream is not sys.stdout:
+         print("extract written to", out_stream.name)
+-- 
+2.14.0
+
diff --git a/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix
new file mode 100644
index 000000000000..2891429c8578
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+, gmp
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.0";
+  pname = "flintqs";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "sagemath";
+    repo = "FlintQS";
+    rev = "v${version}";
+    sha256 = "1f0lnayz6j6qgasx8pbq61d2fqam0wwhsmh6h15l4vq58l1vvbwj";
+  };
+
+  preAutoreconf = ''
+    touch ChangeLog
+  '';
+
+  buildInputs = [
+    gmp
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/sagemath/FlintQS;
+    description = "Highly optimized multi-polynomial quadratic sieve for integer factorization";
+    license = with licenses; [ gpl2 ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix b/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix
new file mode 100644
index 000000000000..7e58a4c7c982
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, unzip, openblas, gfortran }:
+
+stdenv.mkDerivation rec {
+  name = "ipopt-${version}";
+  version = "3.12.11";
+
+  src = fetchurl {
+    url = "https://www.coin-or.org/download/source/Ipopt/Ipopt-${version}.zip";
+    sha256 = "1qihlwwqsqpbwpp6zqfa7nrmb55dndppzmdy98897aiknaa2650h";
+  };
+
+  CXXDEFS = [ "-DHAVE_RAND" "-DHAVE_CSTRING" "-DHAVE_CSTDIO" ];
+
+  configureFlags = [
+    "--with-blas-lib=-lopenblas"
+    "--with-lapack-lib=-lopenblas"
+  ];
+
+  nativeBuildInputs = [ unzip ];
+
+  buildInputs = [ gfortran openblas ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "A software package for large-scale nonlinear optimization";
+    homepage = https://projects.coin-or.org/Ipopt;
+    license = licenses.epl10;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix
new file mode 100644
index 000000000000..51fbd9f14cb4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix
@@ -0,0 +1,98 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, pari
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.23";
+  pname = "lcalc";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    # original at http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/CODE/L-${version}.tar.gz, no longer available
+    # "newer" version at google code https://code.google.com/archive/p/l-calc/source/default/source
+    url = "mirror://sageupstream/lcalc/lcalc-${version}.tar.bz2";
+    sha256 = "1c6dsdshgxhqppjxvxhp8yhpxaqvnz3d1mlh26r571gkq8z2bm43";
+  };
+
+  preConfigure = "cd src";
+
+  buildInputs = [
+    pari
+  ];
+
+  patches = [
+    # Port to newer pari
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/pari-2.7.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1x3aslldm8njjm7p9g9s9w2c91kphnci2vpkxkrcxfihw3ayss6c";
+    })
+
+    # Uncomment the definition of lcalc_to_double(const long double& x).
+    # (Necessary for GCC >= 4.6.0, cf. https://trac.sagemath.org/ticket/10892)
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/Lcommon.h.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0g4ybvsrcv48rmlh1xjnkms19jp25k58azv6ds1f2cm34hxs8fdx";
+    })
+
+    # Include also <time.h> in Lcommandline_numbertheory.h (at least required
+    # on Cygwin, cf. https://trac.sagemath.org/ticket/9845)
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/time.h.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1brf04n11kkc43ylagf8dm32j5r2g9zv51dp5wag1mpm4p04l7cl";
+    })
+
+    # Fix for gcc >4.6
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/lcalc-1.23_default_parameters_1.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0i2yvxm5fx4z0v6m4srgh8rj98kijmlvyirlxf1ky0bp2si6bpka";
+    })
+
+    # gcc 5.1
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/lcalc-1.23_default_parameters_2.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0dqwmxpm9wb53qbypsyfkgsvk2f8nf67sydphd4dkc2vw4yz6vlh";
+    })
+
+    # based on gentoos makefile patch -- fix paths, adhere to flags
+    ./makefile.patch
+
+    # (fetchpatch {
+    #   name = "default-double.patch";
+    #   url = "https://github.com/dimpase/lcalc/pull/1/commits/0500c67b6aa1f492715591669f6647c8f7a3ea59.patch";
+    #   sha256 = "0dqwmxpm9wb53qbypsyfkgsvk2f8nf67sydphd4dkc2vw4yz6vla";
+    # })
+
+    (fetchpatch {
+      name = "c++11.patch";
+      url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/lcalc-c++11.patch?h=packages/lcalc&id=3607b97df5a8c231191115b0cb5c62426b339e71";
+      sha256 = "1ccrl61lv2vvx8ggldq54m5d0n1iy6mym7qz0i8nj6yj0dshnpk3";
+    })
+  ] ++ stdenv.lib.optional stdenv.isDarwin
+  (fetchpatch {
+    url = "https://git.sagemath.org/sage.git/plain/build/pkgs/lcalc/patches/clang.patch";
+    sha256 = "0bb7656z6cp6i4p2qj745cmq0lhh52v2akl9whi760dynfdxbl18";
+  });
+
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace src/Makefile --replace g++ c++
+  '';
+
+  installFlags = [
+    "DESTDIR=$(out)"
+  ];
+
+  makeFlags = [
+    "PARI_DEFINE=-DINCLUDE_PARI"
+    "PARI_PREFIX=${pari}"
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://oto.math.uwaterloo.ca/~mrubinst/L_function_public/L.html;
+    description = "A program for calculating with L-functions";
+    license = with licenses; [ gpl2 ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/lcalc/makefile.patch b/nixpkgs/pkgs/development/libraries/science/math/lcalc/makefile.patch
new file mode 100644
index 000000000000..f55bbe3f24fa
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/lcalc/makefile.patch
@@ -0,0 +1,113 @@
+diff --git a/src/Makefile b/src/Makefile
+index 84e4e88..56ca676 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -58,7 +58,7 @@ ifeq ($(G5),TRUE)
+    #MACHINE_SPECIFIC_FLAGS = -mpowerpc -mpowerpc64 -m64
+ endif
+ 
+-CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
++CCFLAGS = $(CXXFLAGS) $(OPENMP_FLAG) $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS)
+ #CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG)  $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
+ #CCFLAGS =  -Wa,-W -O2 -fno-exceptions -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MACHINE_SPECIFIC_FLAGS) $(EXTRA)
+ 
+@@ -68,12 +68,12 @@ CCFLAGS =  -Wa,-W -O3 $(OPENMP_FLAG) -Wno-deprecated $(PREPROCESSOR_DEFINE) $(MA
+ 
+ ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
+     #location of pari.h.
+-    LOCATION_PARI_H = /usr/local/include/pari #usual location
++    LOCATION_PARI_H = $(PARI_PREFIX)/include/pari #usual location
+ 
+     #location of libpari.a or of libpari.so
+     #depending on whether static or dynamic libraries are being used.
+     #On mac os x it's the former, on linux I think usually the latter.
+-    LOCATION_PARI_LIBRARY = /usr/local/lib #usual location
++    LOCATION_PARI_LIBRARY = $(PARI_PREFIX)/lib #usual location
+ else
+     #supplied as a dummy so as to avoid more ifeq's below
+     LOCATION_PARI_H = .
+@@ -89,24 +89,24 @@ INCLUDEFILES= -I../include
+ 
+ ifeq ($(OS_NAME),Darwin)
+     LDFLAGS2 =
+-    DYN_OPTION=dynamiclib
++    DYN_OPTION=-dynamiclib
+ else
+-    LDFLAGS1 = -Xlinker -export-dynamic #not sure why pari calls these when linking but on the web I found
++    LDFLAGS1 = #not sure why pari calls these when linking but on the web I found
+     #'Libtool provides the `-export-dynamic' link flag (see section Link mode), which does this declaration.
+     #You need to use this flag if you are linking a shared library that will be dlopened'
+     #see notes below
+     #ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
+-       LDFLAGS2 = $(LDFLAGS1) -Xlinker -rpath -Xlinker $(LOCATION_PARI_LIBRARY)
++       LDFLAGS2 = $(LDFLAGS)
+     #else
+     #    LDFLAGS2 = $(LDFLAGS1)
+     #endif
+-    DYN_OPTION=shared
++    DYN_OPTION=$(LDFLAGS) -shared -Wl,-soname,libLfunction.so
+ endif
+ 
+ ifeq ($(PARI_DEFINE),-DINCLUDE_PARI)
+-    LDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
++    MYLDFLAGS = $(LDFLAGS2) -L$(LOCATION_PARI_LIBRARY) -lpari
+ else
+-    LDFLAGS = $(LDFLAGS2)
++    MYLDFLAGS = $(LDFLAGS2)
+ endif
+ 
+ 
+@@ -129,7 +129,8 @@ endif
+ #become clear which libraries the computer can find.
+ 
+ 
+-INSTALL_DIR= /usr/local
++INSTALL_DIR= $(DESTDIR)
++LIB_DIR ?=lib
+ 
+ #object files for the libLfunction library
+ OBJ_L = Lglobals.o Lgamma.o Lriemannsiegel.o Lriemannsiegel_blfi.o Ldokchitser.o
+@@ -141,9 +142,8 @@ OBJECTS = $(OBJ3)
+ 
+ all:
+ #	make print_vars
+-	make libLfunction.so
+-	make lcalc
+-	make examples
++	${MAKE} libLfunction.so
++	${MAKE} lcalc
+ #	make find_L
+ #	make test
+ 
+@@ -151,7 +151,7 @@ print_vars:
+ 	@echo OS_NAME = $(OS_NAME)
+ 
+ lcalc: $(OBJECTS)
+-	$(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(LDFLAGS) -o lcalc $(GMP_FLAGS)
++	$(CC) $(CCFLAGS) $(INCLUDEFILES) $(OBJECTS) $(MYLDFLAGS) -o lcalc $(GMP_FLAGS)
+ 
+ examples:
+ 	$(CC) $(CCFLAGS) $(INCLUDEFILES) example_programs/example.cc libLfunction.so -o example_programs/example $(GMP_FLAGS)
+@@ -262,15 +262,18 @@ Lcommandline.o: ../include/Lcommandline_values_zeros.h
+ 
+ 
+ libLfunction.so: $(OBJ_L)
+-	g++ -$(DYN_OPTION)  -o libLfunction.so $(OBJ_L)
++	g++ $(DYN_OPTION) -o libLfunction.so $(OBJ_L)
+ 
+ clean:
+ 	rm -f *.o lcalc libLfunction.so example_programs/example
+ 
+ install:
+-	cp -f lcalc $(INSTALL_DIR)/bin/.
+-	cp -f libLfunction.so $(INSTALL_DIR)/lib/.
+-	cp -rf ../include $(INSTALL_DIR)/include/Lfunction
++	install -d $(INSTALL_DIR)/bin
++	install -d $(INSTALL_DIR)/$(LIB_DIR)
++	install -d $(INSTALL_DIR)/include/libLfunction
++	install lcalc $(INSTALL_DIR)/bin
++	install libLfunction.so $(INSTALL_DIR)/$(LIB_DIR)
++	install -m 644 -t $(INSTALL_DIR)/include/libLfunction ../include/*.h
+ 
+ 
+ SRCS = Lcommandline.cc Lcommandline_elliptic.cc Lcommandline_globals.cc Lcommandline_misc.cc Lcommandline_numbertheory.cc Lcommandline_twist.cc Lcommandline_values_zeros.cc Lgamma.cc Lglobals.cc Lmisc.cc Lriemannsiegel.cc Lriemannsiegel_blfi.cc cmdline.c
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix
new file mode 100644
index 000000000000..be650f3c3ce8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix
@@ -0,0 +1,34 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.0";
+  name = "libbraiding-${version}";
+
+  src = fetchFromGitHub {
+    owner = "miguelmarco";
+    repo = "libbraiding";
+    rev = version;
+    sha256 = "0l68rikfr7k2l547gb3pp3g8cj5zzxwipm79xrb5r8ffj466ydxg";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  # no tests included for now (2018-08-05), but can't hurt to activate
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/miguelmarco/libbraiding/;
+    description = "C++ library for computations on braid groups";
+    longDescription = ''
+      A library to compute several properties of braids, including centralizer and conjugacy check.
+    '';
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix
new file mode 100644
index 000000000000..e96ee475d7d2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix
@@ -0,0 +1,35 @@
+{ stdenv
+, fetchFromGitHub
+, autoreconfHook
+, boehmgc
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.02r5";
+  name = "llibhomfly-${version}";
+
+  src = fetchFromGitHub {
+    owner = "miguelmarco";
+    repo = "libhomfly";
+    rev = version;
+    sha256 = "1szv8iwlhvmy3saigi15xz8vgch92p2lbsm6440v5s8vxj455bvd";
+  };
+
+  buildInputs = [
+    boehmgc
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/miguelmarco/libhomfly/;
+    description = "Library to compute the homfly polynomial of knots and links";
+    license = licenses.unlicense;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix
new file mode 100644
index 000000000000..c26e9c575ab2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix
@@ -0,0 +1,42 @@
+{
+  stdenv,
+  fetchurl,
+  gfortran,
+  cmake,
+  python2,
+  shared ? false
+}:
+let
+  usedLibExtension = if shared then ".so" else ".a";
+  inherit (stdenv.lib) optional optionals;
+  version = "3.8.0";
+in
+
+stdenv.mkDerivation rec {
+  name = "liblapack-${version}";
+  src = fetchurl {
+    url = "http://www.netlib.org/lapack/lapack-${version}.tar.gz";
+    sha256 = "1xmwi2mqmipvg950gb0rhgprcps8gy8sjm8ic9rgy2qjlv22rcny";
+  };
+
+  buildInputs = [ gfortran cmake ];
+  nativeBuildInputs = [ python2 ];
+
+  cmakeFlags = [
+    "-DUSE_OPTIMIZED_BLAS=ON"
+    "-DCMAKE_Fortran_FLAGS=-fPIC"
+  ]
+  ++ (optional shared "-DBUILD_SHARED_LIBS=ON");
+
+  doCheck = ! shared;
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    inherit version;
+    description = "Linear Algebra PACKage";
+    homepage = http://www.netlib.org/lapack/;
+    license = licenses.bsd3;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix
new file mode 100644
index 000000000000..33e8baada834
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix
@@ -0,0 +1,17 @@
+{ stdenv, fetchurl }:
+stdenv.mkDerivation {
+  name = "liblbfgs-1.10";
+
+  configureFlags = [ "--enable-sse2" ];
+  src = fetchurl {
+    url = https://github.com/downloads/chokkan/liblbfgs/liblbfgs-1.10.tar.gz;
+    sha256 = "1kv8d289rbz38wrpswx5dkhr2yh4fg4h6sszkp3fawxm09sann21";
+  };
+
+  meta = {
+    description = "Library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS)";
+    homepage = http://www.chokkan.org/software/liblbfgs/;
+    license = stdenv.lib.licenses.mit;
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix
new file mode 100644
index 000000000000..3cf5c3619a9e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix
@@ -0,0 +1,27 @@
+{stdenv, fetchurl, gmp}:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "lrs";
+  version = "7.0";
+
+  src = fetchurl {
+    url = "http://cgm.cs.mcgill.ca/~avis/C/lrslib/archive/lrslib-070.tar.gz";
+    sha256 = "1zjdmkjracz695k73c2pvipc0skpyn1wzagkhilsvcw9pqljpwg9";
+  };
+
+  buildInputs = [ gmp ];
+
+  preBuild = ''
+    export makeFlags="$makeFlags prefix=$out";
+  '';
+
+  meta = {
+    inherit version;
+    description = "Implementation of the reverse search algorithm for vertex enumeration/convex hull problems";
+    license = stdenv.lib.licenses.gpl2 ;
+    maintainers = [stdenv.lib.maintainers.raskin];
+    platforms = stdenv.lib.platforms.linux;
+    homepage = "http://cgm.cs.mcgill.ca/~avis/C/lrs.html";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix b/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix
new file mode 100644
index 000000000000..b9ee1e2a10d7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix
@@ -0,0 +1,30 @@
+{ stdenv
+, fetchFromBitbucket
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "20140914";
+  name = "m4ri-${version}";
+
+  src = fetchFromBitbucket {
+    owner = "malb";
+    repo = "m4ri";
+    rev = "release-${version}";
+    sha256 = "0xfg6pffbn8r1s0y7bn9b8i55l00d41dkmhrpf7pwk53qa3achd3";
+  };
+
+  doCheck = true;
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://malb.bitbucket.io/m4ri/;
+    description = "Library to do fast arithmetic with dense matrices over F_2";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix b/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix
new file mode 100644
index 000000000000..23fc03655cf3
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix
@@ -0,0 +1,39 @@
+{ stdenv
+, fetchFromBitbucket
+, autoreconfHook
+, m4ri
+}:
+
+stdenv.mkDerivation rec {
+  version = "20150908";
+  name = "m4rie-${version}";
+
+  src = fetchFromBitbucket {
+    owner = "malb";
+    repo = "m4rie";
+    rev = "release-${version}";
+    sha256 = "0r8lv46qx5mkz5kp3ay2jnsp0mbhlqr5z2z220wdk73wdshcznss";
+  };
+
+  doCheck = true;
+
+  buildInputs = [
+    m4ri
+  ];
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://malb.bitbucket.io/m4rie/;
+    description = "Library for matrix multiplication, reduction and inversion over GF(2^k) for 2 <= k <= 10";
+    longDescription = ''
+      M4RIE is a library for fast arithmetic with dense matrices over small finite fields of even characteristic.
+      It uses the M4RI library, implementing the same operations over the finite field F2.
+    '';
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
new file mode 100644
index 000000000000..8444d88809af
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, fetchurl, cmake, gfortran, cudatoolkit, libpthreadstubs, liblapack }:
+
+with stdenv.lib;
+
+let version = "2.0.2";
+
+in stdenv.mkDerivation {
+  name = "magma-${version}";
+  src = fetchurl {
+    url = "https://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${version}.tar.gz";
+    sha256 = "0w3z6k1npfh0d3r8kpw873f1m7lny29sz2bvvfxzk596d4h083lk";
+    name = "magma-${version}.tar.gz";
+  };
+
+  buildInputs = [ gfortran cudatoolkit libpthreadstubs liblapack cmake ];
+
+  doCheck = false;
+  #checkTarget = "tests";
+
+  enableParallelBuilding=true;
+
+  # MAGMA's default CMake setup does not care about installation. So we copy files directly.
+  installPhase = ''
+    mkdir -p $out
+    mkdir -p $out/include
+    mkdir -p $out/lib
+    mkdir -p $out/lib/pkgconfig
+    cp -a ../include/*.h $out/include
+    #cp -a sparse-iter/include/*.h $out/include
+    cp -a lib/*.a $out/lib
+    cat ../lib/pkgconfig/magma.pc.in                   | \
+    sed -e s:@INSTALL_PREFIX@:"$out":          | \
+    sed -e s:@CFLAGS@:"-I$out/include":    | \
+    sed -e s:@LIBS@:"-L$out/lib -lmagma -lmagma_sparse": | \
+    sed -e s:@MAGMA_REQUIRED@::                       \
+        > $out/lib/pkgconfig/magma.pc
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Matrix Algebra on GPU and Multicore Architectures";
+    license = licenses.bsd3;
+    homepage = http://icl.cs.utk.edu/magma/index.html;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ ianwookim ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix
new file mode 100644
index 000000000000..3ce94f28ac2a
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, unzip, cmake }:
+
+stdenv.mkDerivation {
+  name = "metis-5.1.0";
+
+  src = fetchurl {
+    url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz";
+    sha256 = "1cjxgh41r8k6j029yxs8msp3z6lcnpm16g5pvckk35kc7zhfpykn";
+  };
+
+  cmakeFlags = [ "-DGKLIB_PATH=../GKlib" ];
+  buildInputs = [ unzip cmake ];
+
+  meta = {
+    description = "Serial graph partitioning and fill-reducing matrix ordering";
+    homepage = http://glaros.dtc.umn.edu/gkhome/metis/metis/overview;
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix
new file mode 100644
index 000000000000..0801238fb121
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix
@@ -0,0 +1,79 @@
+{ stdenvNoCC, writeText, fetchurl, rpmextract, undmg }:
+/*
+  For details on using mkl as a blas provider for python packages such as numpy,
+  numexpr, scipy, etc., see the Python section of the NixPkgs manual.
+*/
+stdenvNoCC.mkDerivation rec {
+  name = "mkl-${version}";
+  version = "${date}.${rel}";
+  date = "2019.0";
+  rel = "117";
+
+  src = if stdenvNoCC.isDarwin
+    then
+      (fetchurl {
+        url = "http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/13565/m_mkl_${version}.dmg";
+        sha256 = "1f1jppac7vqwn00hkws0p4njx38ajh0n25bsjyb5d7jcacwfvm02";
+      })
+    else
+      (fetchurl {
+        url = "http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/13575/l_mkl_${version}.tgz";
+        sha256 = "1bf7i54iqlf7x7fn8kqwmi06g30sxr6nq3ac0r871i6g0p3y47sf";
+      });
+
+  buildInputs = if stdenvNoCC.isDarwin then [ undmg ] else [ rpmextract ];
+
+  buildPhase = if stdenvNoCC.isDarwin then ''
+      for f in Contents/Resources/pkg/*.tgz; do
+          tar xzvf $f
+      done
+  '' else ''
+    rpmextract rpm/intel-mkl-common-c-${date}-${rel}-${date}-${rel}.noarch.rpm
+    rpmextract rpm/intel-mkl-core-rt-${date}-${rel}-${date}-${rel}.x86_64.rpm
+    rpmextract rpm/intel-openmp-19.0.0-${rel}-19.0.0-${rel}.x86_64.rpm
+  '';
+
+  installPhase = if stdenvNoCC.isDarwin then ''
+      mkdir -p $out/lib
+
+      cp -r compilers_and_libraries_${version}/mac/mkl/include $out/
+
+      cp -r compilers_and_libraries_${version}/licensing/mkl/en/license.txt $out/lib/
+      cp -r compilers_and_libraries_${version}/mac/compiler/lib/* $out/lib/
+      cp -r compilers_and_libraries_${version}/mac/mkl/lib/* $out/lib/
+  '' else ''
+      mkdir -p $out/lib
+
+      cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/include $out/
+
+      cp -r opt/intel/compilers_and_libraries_${version}/linux/compiler/lib/intel64_lin/* $out/lib/
+      cp -r opt/intel/compilers_and_libraries_${version}/linux/mkl/lib/intel64_lin/* $out/lib/
+      cp license.txt $out/lib/
+  '';
+
+  # Per license agreement, do not modify the binary
+  dontStrip = true;
+  dontPatchELF = true;
+
+  # Since these are unmodified binaries from Intel, they do not depend on stdenv
+  # and we can make them fixed-output derivations for cache efficiency.
+  outputHashAlgo = "sha256";
+  outputHashMode = "recursive";
+  outputHash = if stdenvNoCC.isDarwin
+    then "00d49ls9vcjan1ngq2wx2q4p6lnm05zwh67hsmj7bnq43ykrfibw"
+    else "1amagcaan0hk3x9v7gg03gkw02n066v4kmjb32yyzsy5rfrivb1a";
+
+  meta = with stdenvNoCC.lib; {
+    description = "Intel Math Kernel Library";
+    longDescription = ''
+      Intel Math Kernel Library (Intel MKL) optimizes code with minimal effort
+      for future generations of Intel processors. It is compatible with your
+      choice of compilers, languages, operating systems, and linking and
+      threading models.
+    '';
+    homepage = https://software.intel.com/en-us/mkl;
+    license = licenses.issl;
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+    maintainers = [ maintainers.bhipple ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix
new file mode 100644
index 000000000000..d3c20258425b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix
@@ -0,0 +1,24 @@
+{ callPackage, cudatoolkit_8, cudatoolkit_9 }:
+
+let
+  generic = args: callPackage (import ./generic.nix (removeAttrs args ["cudatoolkit"])) {
+    inherit (args) cudatoolkit;
+  };
+
+in
+
+{
+  nccl_cudatoolkit_8 = generic rec {
+    version = "2.1.4";
+    cudatoolkit = cudatoolkit_8;
+    srcName = "nccl_${version}-1+cuda${cudatoolkit.majorVersion}_x86_64.txz";
+    sha256 = "1lwwm8kdhna5m318yg304kl2gsz1jwhv4zv4gn8av2m57zh848zi";
+  };
+
+  nccl_cudatoolkit_9 = generic rec {
+    version = "2.1.4";
+    cudatoolkit = cudatoolkit_9;
+    srcName = "nccl_${version}-1+cuda${cudatoolkit.majorVersion}_x86_64.txz";
+    sha256 = "0pajmqzkacpszs63jh2hw2qqc49kj75kcf7r0ky8hdh560q8xn0p";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/nccl/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/nccl/generic.nix
new file mode 100644
index 000000000000..609a7df51e58
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/nccl/generic.nix
@@ -0,0 +1,57 @@
+{ version
+, srcName
+, sha256
+}:
+
+{ stdenv
+, lib
+, requireFile
+, cudatoolkit
+}:
+
+stdenv.mkDerivation rec {
+  name = "cudatoolkit-${cudatoolkit.majorVersion}-nccl-${version}";
+
+  inherit version;
+
+  src = requireFile rec {
+    name = srcName;
+    inherit sha256;
+    message = ''
+      This nix expression requires that ${name} is already part of the store.
+      Register yourself to NVIDIA Accelerated Computing Developer Program, retrieve the NCCL library
+      at https://developer.nvidia.com/nccl, and run the following command in the download directory:
+      nix-prefetch-url file://\$PWD/${name}
+    '';
+  };
+
+  unpackCmd = "tar xJf $src";
+
+  installPhase = ''
+    function fixRunPath {
+      p=$(patchelf --print-rpath $1)
+      patchelf --set-rpath "$p:${lib.makeLibraryPath [ stdenv.cc.cc ]}" $1
+    }
+    fixRunPath lib/libnccl.so
+
+    mkdir -p $out
+    cp -a include $out/include
+    cp -a lib $out/lib
+  '';
+
+  propagatedBuildInputs = [
+    cudatoolkit
+  ];
+
+  passthru = {
+    inherit cudatoolkit;
+  };
+
+  meta = with stdenv.lib; {
+    description = "Multi-GPU and multi-node collective communication primitives that are performance optimized for NVIDIA GPUs";
+    homepage = https://developer.nvidia.com/nccl;
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ mdaiter ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix
new file mode 100644
index 000000000000..120fa25090a4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix
@@ -0,0 +1,160 @@
+{ stdenv, fetchFromGitHub, fetchpatch, gfortran, perl, which, config, coreutils
+# Most packages depending on openblas expect integer width to match
+# pointer width, but some expect to use 32-bit integers always
+# (for compatibility with reference BLAS).
+, blas64 ? null
+}:
+
+with stdenv.lib;
+
+let blas64_ = blas64; in
+
+let
+  # To add support for a new platform, add an element to this set.
+  configs = {
+    armv6l-linux = {
+      BINARY = "32";
+      TARGET = "ARMV6";
+      DYNAMIC_ARCH = "0";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+
+    armv7l-linux = {
+      BINARY = "32";
+      TARGET = "ARMV7";
+      DYNAMIC_ARCH = "0";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+
+    aarch64-linux = {
+      BINARY = "64";
+      TARGET = "ARMV8";
+      DYNAMIC_ARCH = "1";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+
+    i686-linux = {
+      BINARY = "32";
+      TARGET = "P2";
+      DYNAMIC_ARCH = "1";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+
+    x86_64-darwin = {
+      BINARY = "64";
+      TARGET = "ATHLON";
+      DYNAMIC_ARCH = "1";
+      # Note that clang is available through the stdenv on OSX and
+      # thus is not an explicit dependency.
+      CC = "clang";
+      USE_OPENMP = "0";
+      MACOSX_DEPLOYMENT_TARGET = "10.7";
+    };
+
+    x86_64-linux = {
+      BINARY = "64";
+      TARGET = "ATHLON";
+      DYNAMIC_ARCH = "1";
+      CC = "gcc";
+      USE_OPENMP = "1";
+    };
+  };
+in
+
+let
+  config =
+    configs.${stdenv.hostPlatform.system}
+    or (throw "unsupported system: ${stdenv.hostPlatform.system}");
+in
+
+let
+  blas64 =
+    if blas64_ != null
+      then blas64_
+      else hasPrefix "x86_64" stdenv.hostPlatform.system;
+in
+stdenv.mkDerivation rec {
+  name = "openblas-${version}";
+  version = "0.3.4";
+  src = fetchFromGitHub {
+    owner = "xianyi";
+    repo = "OpenBLAS";
+    rev = "v${version}";
+    sha256 = "1jdq4msfyg13pdmwwfqpixf4fshss68qzls820lmn0i6y7h4aix3";
+  };
+
+  inherit blas64;
+
+  patches = [
+    # Fixes build on x86_64-darwin. See:
+    # https://github.com/xianyi/OpenBLAS/issues/1926
+    (fetchpatch {
+      url = https://github.com/xianyi/OpenBLAS/commit/701ea88347461e4c5d896765438dc870281b3834.patch;
+      sha256 = "18rcfgkjsijl9d2510jn961wqvz7zdlz2fgy1yjmax29kvv8fqd9";
+    })
+  ];
+
+  # Some hardening features are disabled due to sporadic failures in
+  # OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but
+  # with how these flags interact with hardening measures used downstream.
+  # In either case, OpenBLAS must only be used by trusted code--it is
+  # inherently unsuitable for security-conscious applications--so there should
+  # be no objection to disabling these hardening measures.
+  hardeningDisable = [
+    # don't modify or move the stack
+    "stackprotector" "pic"
+    # don't alter index arithmetic
+    "strictoverflow"
+    # don't interfere with dynamic target detection
+    "relro" "bindnow"
+  ];
+
+  nativeBuildInputs =
+    [gfortran perl which]
+    ++ optionals stdenv.isDarwin [coreutils];
+
+  makeFlags =
+    [
+      "FC=gfortran"
+      ''PREFIX="''$(out)"''
+      "NUM_THREADS=64"
+      "INTERFACE64=${if blas64 then "1" else "0"}"
+      "NO_STATIC=1"
+    ] ++ stdenv.lib.optional (stdenv.hostPlatform.libc == "musl") "NO_AFFINITY=1"
+    ++ mapAttrsToList (var: val: var + "=" + val) config;
+
+  doCheck = true;
+  checkTarget = "tests";
+
+  postInstall = ''
+    # Write pkgconfig aliases. Upstream report:
+    # https://github.com/xianyi/OpenBLAS/issues/1740
+    for alias in blas cblas lapack; do
+      cat <<EOF > $out/lib/pkgconfig/$alias.pc
+Name: $alias
+Version: ${version}
+Description: $alias provided by the OpenBLAS package.
+Cflags: -I$out/include
+Libs: -L$out/lib -lopenblas
+EOF
+    done
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Basic Linear Algebra Subprograms";
+    license = licenses.bsd3;
+    homepage = https://github.com/xianyi/OpenBLAS;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ ttuegel ];
+  };
+
+  # We use linkName to pass a different name to --with-blas-libs for
+  # fflas-ffpack and linbox, because we use blas on darwin but openblas
+  # elsewhere.
+  # See see https://github.com/NixOS/nixpkgs/pull/45013.
+  passthru.linkName = "openblas";
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix
new file mode 100644
index 000000000000..3e8524b40140
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "openlibm-${version}";
+  version = "0.6.0";
+  src = fetchurl {
+    url = "https://github.com/JuliaLang/openlibm/archive/v${version}.tar.gz";
+    sha256 = "0a5fpm8nra5ldhjk0cqd2rx1qh32wiarkxmcqcm5xl8z7l4kjm6l";
+  };
+
+  makeFlags = [ "prefix=$(out)" ];
+
+  meta = {
+    description = "High quality system independent, portable, open source libm implementation";
+    homepage = http://www.openlibm.org/;
+    license = stdenv.lib.licenses.mit;
+    maintainers = [ stdenv.lib.maintainers.ttuegel ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix
new file mode 100644
index 000000000000..3a4c5a784385
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, gfortran }:
+
+stdenv.mkDerivation {
+  name = "openspecfun-0.5.3";
+  src = fetchurl {
+    url = "https://github.com/JuliaLang/openspecfun/archive/v0.5.3.tar.gz";
+    sha256 = "1rs1bv8jq751fv9vq79890wqf9xlbjc7lvz3ighzyfczbyjcf18m";
+  };
+
+  makeFlags = [ "prefix=$(out)" ];
+
+  nativeBuildInputs = [ gfortran ];
+
+  meta = {
+    description = "A collection of special mathematical functions";
+    homepage = https://github.com/JuliaLang/openspecfun;
+    license = stdenv.lib.licenses.mit;
+    maintainers = [ stdenv.lib.maintainers.ttuegel ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
new file mode 100644
index 000000000000..415e57e5d3cf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix
@@ -0,0 +1,54 @@
+{ stdenv, fetchFromGitHub, cmake, google-gflags, which
+, lsb-release, glog, protobuf, cbc, zlib, python3 }:
+
+stdenv.mkDerivation rec {
+  name = "or-tools-${version}";
+  version = "v6.10";
+
+  src = fetchFromGitHub {
+    owner = "google";
+    repo = "or-tools";
+    rev = version;
+    sha256 = "11k3671rpv968dsglc6bgarr9yi8ijaaqm2wq3m0rn4wy8fj7za2";
+  };
+
+  # The original build system uses cmake which does things like pull
+  # in dependencies through git and Makefile creation time. We
+  # obviously don't want to do this so instead we provide the
+  # dependencies straight from nixpkgs and use the make build method.
+  configurePhase = ''
+    cat <<EOF > Makefile.local
+    UNIX_GFLAGS_DIR=${google-gflags}
+    UNIX_GLOG_DIR=${glog}
+    UNIX_PROTOBUF_DIR=${protobuf}
+    UNIX_CBC_DIR=${cbc}
+    EOF
+  '';
+
+  makeFlags = [ "prefix=${placeholder "out"}" ];
+  buildFlags = [ "cc" ];
+
+  checkTarget = "test_cc";
+  doCheck = true;
+
+  installTargets = [ "install_cc" ];
+
+  nativeBuildInputs = [
+    cmake lsb-release which zlib python3
+  ];
+  propagatedBuildInputs = [
+    google-gflags glog protobuf cbc
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/google/or-tools;
+    license = licenses.asl20;
+    description = ''
+      Google's software suite for combinatorial optimization.
+    '';
+    maintainers = with maintainers; [ fuuzetsu ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/gflags-include.patch b/nixpkgs/pkgs/development/libraries/science/math/or-tools/gflags-include.patch
new file mode 100644
index 000000000000..08f76180638b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/gflags-include.patch
@@ -0,0 +1,12 @@
+diff --git a/ortools/data/jobshop_scheduling_parser.cc b/ortools/data/jobshop_scheduling_parser.cc
+index cb0a360b..c2f055eb 100644
+--- a/ortools/data/jobshop_scheduling_parser.cc
++++ b/ortools/data/jobshop_scheduling_parser.cc
+@@ -14,6 +14,7 @@
+ #include "ortools/data/jobshop_scheduling_parser.h"
+ 
+ #include <cmath>
++#include <gflags/gflags.h>
+ 
+ #include "google/protobuf/wrappers.pb.h"
+ #include "ortools/base/filelineiter.h"
diff --git a/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix
new file mode 100644
index 000000000000..ca35ce2f4134
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix
@@ -0,0 +1,33 @@
+{ stdenv
+, fetchurl
+, cmake
+, mpi
+}:
+
+stdenv.mkDerivation rec {
+  name = "parmetis-${version}";
+  version = "4.0.3";
+
+  src = fetchurl {
+    url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/parmetis-${version}.tar.gz";
+    sha256 = "0pvfpvb36djvqlcc3lq7si0c5xpb2cqndjg8wvzg35ygnwqs5ngj";
+  };
+
+  buildInputs = [ cmake mpi ];
+
+  # metis and GKlib are packaged with distribution
+  # AUR https://aur.archlinux.org/packages/parmetis/ has reported that
+  # it easier to build with the included packages as opposed to using the metis
+  # package. Compilation time is short.
+  configurePhase = ''
+    make config metis_path=$PWD/metis gklib_path=$PWD/metis/GKlib prefix=$out
+  '';
+
+  meta = with stdenv.lib; {
+    description = "ParMETIS is an MPI-based parallel library that implements a variety of algorithms for partitioning unstructured graphs, meshes, and for computing fill-reducing orderings of sparse matrices";
+    homepage = http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview;
+    platforms = platforms.all;
+    license = licenses.unfree;
+    maintainers = [ maintainers.costrouc ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix
new file mode 100644
index 000000000000..ac8129c9032f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix
@@ -0,0 +1,50 @@
+{ stdenv
+, fetchurl
+, blas
+, gfortran
+, liblapack
+, python }:
+
+stdenv.mkDerivation rec {
+  name = "petsc-${version}";
+  version = "3.8.4";
+
+  src = fetchurl {
+    url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz";
+    sha256 = "1iy49gagxncx09d88kxnwkj876p35683mpfk33x37165si6xqy4z";
+  };
+
+  nativeBuildInputs = [ blas gfortran.cc.lib liblapack python ];
+
+  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace config/install.py \
+      --replace /usr/bin/install_name_tool install_name_tool
+  '';
+
+  preConfigure = ''
+    patchShebangs .
+    configureFlagsArray=(
+      $configureFlagsArray
+      "--CC=$CC"
+      "--with-cxx=0"
+      "--with-fc=0"
+      "--with-mpi=0"
+      "--with-blas-lib=[${blas}/lib/libblas.a,${gfortran.cc.lib}/lib/libgfortran.a]"
+      "--with-lapack-lib=[${liblapack}/lib/liblapack.a,${gfortran.cc.lib}/lib/libgfortran.a]"
+    )
+  '';
+
+  postInstall = ''
+    rm $out/bin/petscmpiexec
+    rm $out/bin/popup
+    rm $out/bin/uncrustify.cfg
+    rm -rf $out/bin/win32fe
+  '';
+
+  meta = {
+    description = "Library of linear algebra algorithms for solving partial differential equations";
+    homepage = https://www.mcs.anl.gov/petsc/index.html;
+    platforms = stdenv.lib.platforms.all;
+    license = stdenv.lib.licenses.bsd2;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix b/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix
new file mode 100644
index 000000000000..7394fb9e1b41
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix
@@ -0,0 +1,40 @@
+{ stdenv
+, fetchFromGitHub
+, fetchpatch
+, autoreconfHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "planarity";
+  version = "3.0.0.5";
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "graph-algorithms";
+    repo = "edge-addition-planarity-suite";
+    rev = "Version_${version}";
+    sha256 = "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8";
+  };
+
+  nativeBuildInputs = [
+    autoreconfHook
+  ];
+
+  doCheck = true;
+
+  patches = [
+    # declare variables declared in headers as extern, not yet merged upstream
+    (fetchpatch {
+      url = "https://github.com/graph-algorithms/edge-addition-planarity-suite/pull/3.patch";
+      sha256 = "1nqjc4clr326imz4jxqxcxv2hgh1sjgzll27k5cwkdin8lnmmil8";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/graph-algorithms/edge-addition-planarity-suite;
+    description = "A library for implementing graph algorithms";
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix b/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix
new file mode 100644
index 000000000000..fda54fe44ab1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix
@@ -0,0 +1,28 @@
+{ stdenv
+, fetchurl
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rankwidth";
+  version = "0.7";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sageupstream/rw/rw-${version}.tar.gz";
+    sha256 = "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0";
+  };
+
+  configureFlags = [
+    "--enable-executable=no" # no igraph dependency
+  ];
+
+  # check phase is empty for now (as of version 0.7)
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "Calculates rank-width and rank-decompositions";
+    license = with licenses; [ gpl2Plus ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix b/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix
new file mode 100644
index 000000000000..624885c501aa
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix
@@ -0,0 +1,82 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, coreutils
+}:
+
+stdenv.mkDerivation rec {
+  pname = "rubiks";
+  version = "20070912";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "mirror://sageupstream/rubiks/rubiks-${version}.tar.bz2";
+    sha256 = "0zdmkb0j1kyspdpsszzb2k3279xij79jkx0dxd9f3ix1yyyg3yfq";
+  };
+
+  preConfigure = ''
+    export INSTALL="${coreutils}/bin/install"
+  '';
+
+  # everything is done in `make install`
+  buildPhase = "true";
+
+  installFlags = [
+    "PREFIX=$(out)"
+  ];
+
+  patches = [
+    # Fix makefiles which use all the variables in all the wrong ways and
+    # hardcode values for some variables.
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-cu2-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1ry3w1mk9q4jqd91zlaa1bdiiplld4hpfjaldbhlmzlgrrc99qmq";
+    })
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-mcube-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0zsbh6k3kqdg82fv0kzghr1x7pafisv943gmssqscp107bhg77bz";
+    })
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-solver-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "0vhw70ylnmydgjhwx8jjlb2slccj4pfqn6vzirkyz1wp8apsmfhp";
+    })
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/reid-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1r311sn012xs135s0d21qwsig2kld7rdcq19nm0zbnklviid57df";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = https://wiki.sagemath.org/spkg/rubiks;
+    description = "Several programs for working with Rubik's cubes";
+    # The individual websites are no longer available
+    longDescription = ''
+      There are several programs for working with Rubik's cubes, by three
+      different people. Look inside the directories under /src to see
+      specific info and licensing. In summary the three contributers are:
+
+
+      Michael Reid (GPL) http://www.math.ucf.edu/~reid/Rubik/optimal_solver.html
+          optimal - uses many pre-computed tables to find an optimal
+                    solution to the 3x3x3 Rubik's cube
+
+
+      Dik T. Winter (MIT License)
+          cube    - uses Kociemba's algorithm to iteratively find a short
+                    solution to the 3x3x3 Rubik's cube
+          size222 - solves a 2x2x2 Rubik's cube
+
+
+      Eric Dietz (GPL) http://www.wrongway.org/?rubiksource
+          cu2   - A fast, non-optimal 2x2x2 solver
+          cubex - A fast, non-optimal 3x3x3 solver
+          mcube - A fast, non-optimal 4x4x4 solver
+    '';
+    license = with licenses; [
+      gpl2 # Michael Reid's and Eric Dietz software
+      mit # Dik T. Winter's software
+    ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
new file mode 100644
index 000000000000..3f37bf49de38
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchurl, cmake, openssh
+, gfortran, mpi, openblasCompat
+} :
+
+
+stdenv.mkDerivation rec {
+  name = "scalapack-${version}";
+  version = "2.0.2";
+
+  src = fetchurl {
+    url = "http://www.netlib.org/scalapack/scalapack-${version}.tgz";
+    sha256 = "0p1r61ss1fq0bs8ynnx7xq4wwsdvs32ljvwjnx6yxr8gd6pawx0c";
+  };
+
+  nativeBuildInputs = [ cmake openssh ];
+  buildInputs = [ mpi gfortran openblasCompat ];
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  preConfigure = ''
+    cmakeFlagsArray+=(
+      -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF
+      -DLAPACK_LIBRARIES="-lopenblas"
+      -DBLAS_LIBRARIES="-lopenblas"
+      )
+  '';
+
+  preCheck = ''
+    # make sure the test starts even if we have less than 4 cores
+    export OMPI_MCA_rmaps_base_oversubscribe=1
+
+    # Run single threaded
+    export OMP_NUM_THREADS=1
+
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://www.netlib.org/scalapack/;
+    description = "Library of high-performance linear algebra routines for parallel distributed memory machines";
+    license = licenses.bsd3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.costrouc ];
+  };
+
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix
new file mode 100644
index 000000000000..f9d1a84b1f03
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchFromGitHub, blas, liblapack, gfortran, fixDarwinDylibNames }:
+
+stdenv.mkDerivation rec {
+  name = "scs-${version}";
+  version = "2.0.2";
+
+  src = fetchFromGitHub {
+    owner = "cvxgrp";
+    repo = "scs";
+    rev = "v${version}";
+    sha256 = "17lbcmcsniqlyzgbzmjipfd0rrk25a8hzh7l5wl2wp1iwsd8c3a9";
+  };
+
+  # Actually link and add libgfortran to the rpath
+  postPatch = ''
+    substituteInPlace scs.mk \
+      --replace "#-lgfortran" "-lgfortran" \
+      --replace "gcc" "cc"
+  '';
+
+  nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  buildInputs = [ blas liblapack gfortran.cc.lib ];
+
+  doCheck = true;
+
+  # Test demo requires passing data and seed; numbers chosen arbitrarily.
+  postCheck = ''
+    ./out/demo_socp_indirect 42 0.42 0.42 42
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/lib
+    cp -r include $out/
+    cp out/*.a out/*.so out/*.dylib $out/lib/
+    runHook postInstall
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Splitting Conic Solver";
+    longDescription = ''
+      Numerical optimization package for solving large-scale convex cone problems
+    '';
+    homepage = https://github.com/cvxgrp/scs;
+    license = licenses.mit;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bhipple ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix
new file mode 100644
index 000000000000..7e71eafef697
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, gfortran, openblas }:
+
+let
+  int_t = if openblas.blas64 then "int64_t" else "int32_t";
+in
+stdenv.mkDerivation rec {
+  version = "4.2.1";
+  name = "suitesparse-${version}";
+  src = fetchurl {
+    url = "http://www.cise.ufl.edu/research/sparse/SuiteSparse/SuiteSparse-${version}.tar.gz" ;
+    sha256 = "1ga69637x7kdkiy3w3lq9dvva7220bdangv2lch2wx1hpi83h0p8";
+  };
+
+  nativeBuildInputs = [ gfortran ];
+  buildInputs = [ openblas ];
+
+  preConfigure = ''
+    mkdir -p $out/lib
+    mkdir -p $out/include
+
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/METIS .*$/METIS =/' \
+        -e 's/METIS_PATH .*$/METIS_PATH =/' \
+        -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION -DLONGBLAS=${int_t}/' \
+        -e '/UMFPACK_CONFIG/ s/$/-DLONGBLAS=${int_t}/'
+  '';
+
+  makeFlags = [
+    "PREFIX=\"$(out)\""
+    "INSTALL_LIB=$(out)/lib"
+    "INSTALL_INCLUDE=$(out)/include"
+    "BLAS=-lopenblas"
+    "LAPACK="
+  ];
+
+  meta = with stdenv.lib; {
+    homepage = http://faculty.cse.tamu.edu/davis/suitesparse.html;
+    description = "A suite of sparse matrix algorithms";
+    license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ];
+    maintainers = with maintainers; [ ttuegel ];
+    platforms = with platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix
new file mode 100644
index 000000000000..1ce56d1e49f7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix
@@ -0,0 +1,100 @@
+{ stdenv, fetchurl, gfortran, openblas
+, enableCuda  ? false, cudatoolkit
+}:
+
+let
+  version = "4.4.4";
+  name = "suitesparse-${version}";
+
+  int_t = if openblas.blas64 then "int64_t" else "int32_t";
+  SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary;
+in
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${version}.tar.gz";
+    sha256 = "1zdn1y0ij6amj7smmcslkqgbqv9yy5cwmbyzqc9v6drzdzllgbpj";
+  };
+
+  preConfigure = ''
+    mkdir -p $out/lib
+    mkdir -p $out/include
+
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/METIS .*$/METIS =/' \
+        -e 's/METIS_PATH .*$/METIS_PATH =/' \
+        -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION -DLONGBLAS=${int_t}/' \
+        -e '/UMFPACK_CONFIG/ s/$/-DLONGBLAS=${int_t}/'
+  ''
+  + stdenv.lib.optionalString stdenv.isDarwin ''
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/^[[:space:]]*\(LIB = -lm\) -lrt/\1/'
+  ''
+  + stdenv.lib.optionalString enableCuda ''
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's|^[[:space:]]*\(CUDA_ROOT     =\)|CUDA_ROOT = ${cudatoolkit}|' \
+        -e 's|^[[:space:]]*\(GPU_BLAS_PATH =\)|GPU_BLAS_PATH = $(CUDA_ROOT)|' \
+        -e 's|^[[:space:]]*\(GPU_CONFIG    =\)|GPU_CONFIG = -I$(CUDA_ROOT)/include -DGPU_BLAS -DCHOLMOD_OMP_NUM_THREADS=$(NIX_BUILD_CORES) |' \
+        -e 's|^[[:space:]]*\(CUDA_PATH     =\)|CUDA_PATH = $(CUDA_ROOT)|' \
+        -e 's|^[[:space:]]*\(CUDART_LIB    =\)|CUDART_LIB = $(CUDA_ROOT)/lib64/libcudart.so|' \
+        -e 's|^[[:space:]]*\(CUBLAS_LIB    =\)|CUBLAS_LIB = $(CUDA_ROOT)/lib64/libcublas.so|' \
+        -e 's|^[[:space:]]*\(CUDA_INC_PATH =\)|CUDA_INC_PATH = $(CUDA_ROOT)/include/|' \
+        -e 's|^[[:space:]]*\(NV20          =\)|NV20 = -arch=sm_20 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NV30          =\)|NV30 = -arch=sm_30 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NV35          =\)|NV35 = -arch=sm_35 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NVCC          =\) echo|NVCC = $(CUDA_ROOT)/bin/nvcc|' \
+        -e 's|^[[:space:]]*\(NVCCFLAGS     =\)|NVCCFLAGS = $(NV20) -O3 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_60,code=sm_60|'
+  '';
+
+  makeFlags = [
+    "PREFIX=\"$(out)\""
+    "INSTALL_LIB=$(out)/lib"
+    "INSTALL_INCLUDE=$(out)/include"
+    "BLAS=-lopenblas"
+    "LAPACK="
+  ];
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin " -DNTIMER";
+
+  postInstall = ''
+    # Build and install shared library
+    (
+        cd "$(mktemp -d)"
+        for i in "$out"/lib/lib*.a; do
+          ar -x $i
+        done
+        ${if enableCuda then cudatoolkit else stdenv.cc.outPath}/bin/${if enableCuda then "nvcc" else "cc"} *.o ${if stdenv.isDarwin then "-dynamiclib" else "--shared"} -o "$out/lib/libsuitesparse${SHLIB_EXT}" -lopenblas ${stdenv.lib.optionalString enableCuda "-lcublas"}
+    )
+    for i in umfpack cholmod amd camd colamd spqr; do
+      ln -s libsuitesparse${SHLIB_EXT} "$out"/lib/lib$i${SHLIB_EXT}
+    done
+
+    # Install documentation
+    outdoc=$out/share/doc/${name}
+    mkdir -p $outdoc
+    cp -r AMD/Doc $outdoc/amd
+    cp -r BTF/Doc $outdoc/bft
+    cp -r CAMD/Doc $outdoc/camd
+    cp -r CCOLAMD/Doc $outdoc/ccolamd
+    cp -r CHOLMOD/Doc $outdoc/cholmod
+    cp -r COLAMD/Doc $outdoc/colamd
+    cp -r CXSparse/Doc $outdoc/cxsparse
+    cp -r KLU/Doc $outdoc/klu
+    cp -r LDL/Doc $outdoc/ldl
+    cp -r RBio/Doc $outdoc/rbio
+    cp -r SPQR/Doc $outdoc/spqr
+    cp -r UMFPACK/Doc $outdoc/umfpack
+  '';
+
+  nativeBuildInputs = [ gfortran ];
+  buildInputs = [ openblas ];
+
+  meta = with stdenv.lib; {
+    homepage = http://faculty.cse.tamu.edu/davis/suitesparse.html;
+    description = "A suite of sparse matrix algorithms";
+    license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ];
+    maintainers = with maintainers; [ ttuegel ];
+    platforms = with platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix
new file mode 100644
index 000000000000..528fe5ed0739
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix
@@ -0,0 +1,112 @@
+{ stdenv, fetchurl, gfortran, openblas, cmake, fixDarwinDylibNames
+, enableCuda  ? false, cudatoolkit
+}:
+
+let
+  version = "5.3.0";
+  name = "suitesparse-${version}";
+
+  SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary;
+in
+stdenv.mkDerivation rec {
+  inherit name;
+
+  src = fetchurl {
+    url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${version}.tar.gz";
+    sha256 = "0gcn1xj3z87wpp26gxn11k8073bxv6jswfd8jmddlm64v09rgrlh";
+  };
+
+  dontUseCmakeConfigure = true;
+
+  preConfigure = ''
+    mkdir -p $out/lib
+    mkdir -p $out/include
+    mkdir -p $out/share/doc/${name}
+
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/METIS .*$/METIS =/' \
+        -e 's/METIS_PATH .*$/METIS_PATH =/' \
+        -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION/'
+  ''
+  + stdenv.lib.optionalString stdenv.isDarwin ''
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's/^[[:space:]]*\(LIB = -lm\) -lrt/\1/'
+  ''
+  + stdenv.lib.optionalString enableCuda ''
+    sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
+        -e 's|^[[:space:]]*\(CUDA_ROOT     =\)|CUDA_ROOT = ${cudatoolkit}|' \
+        -e 's|^[[:space:]]*\(GPU_BLAS_PATH =\)|GPU_BLAS_PATH = $(CUDA_ROOT)|' \
+        -e 's|^[[:space:]]*\(GPU_CONFIG    =\)|GPU_CONFIG = -I$(CUDA_ROOT)/include -DGPU_BLAS -DCHOLMOD_OMP_NUM_THREADS=$(NIX_BUILD_CORES) |' \
+        -e 's|^[[:space:]]*\(CUDA_PATH     =\)|CUDA_PATH = $(CUDA_ROOT)|' \
+        -e 's|^[[:space:]]*\(CUDART_LIB    =\)|CUDART_LIB = $(CUDA_ROOT)/lib64/libcudart.so|' \
+        -e 's|^[[:space:]]*\(CUBLAS_LIB    =\)|CUBLAS_LIB = $(CUDA_ROOT)/lib64/libcublas.so|' \
+        -e 's|^[[:space:]]*\(CUDA_INC_PATH =\)|CUDA_INC_PATH = $(CUDA_ROOT)/include/|' \
+        -e 's|^[[:space:]]*\(NV20          =\)|NV20 = -arch=sm_20 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NV30          =\)|NV30 = -arch=sm_30 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NV35          =\)|NV35 = -arch=sm_35 -Xcompiler -fPIC|' \
+        -e 's|^[[:space:]]*\(NVCC          =\) echo|NVCC = $(CUDA_ROOT)/bin/nvcc|' \
+        -e 's|^[[:space:]]*\(NVCCFLAGS     =\)|NVCCFLAGS = $(NV20) -O3 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_60,code=sm_60|'
+  '';
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin " -DNTIMER";
+
+  buildPhase = ''
+    runHook preBuild
+
+    # Build individual shared libraries
+    make library        \
+        BLAS=-lopenblas \
+        LAPACK=""       \
+        ${stdenv.lib.optionalString openblas.blas64 "CFLAGS=-DBLAS64"}
+
+    # Build libsuitesparse.so which bundles all the individual libraries.
+    # Bundling is done by building the static libraries, extracting objects from
+    # them and combining the objects into one shared library.
+    mkdir -p static
+    make static AR_TARGET=$(pwd)/static/'$(LIBRARY).a'
+    (
+        cd static
+        for i in lib*.a; do
+          ar -x $i
+        done
+    )
+    ${if enableCuda then "${cudatoolkit}/bin/nvcc" else "${stdenv.cc.outPath}/bin/cc"} \
+        static/*.o                                                                     \
+        ${if stdenv.isDarwin then "-dynamiclib" else "--shared"}                       \
+        -o "lib/libsuitesparse${SHLIB_EXT}"                                            \
+        -lopenblas                                                                     \
+        ${stdenv.lib.optionalString enableCuda "-lcublas"}
+
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -r lib $out/
+    cp -r include $out/
+    cp -r share $out/
+
+    # Fix rpaths
+    cd $out
+    find -name \*.so\* -type f -exec \
+      patchelf --set-rpath "$out/lib:${stdenv.lib.makeLibraryPath buildInputs}" {} \;
+
+    runHook postInstall
+  '';
+
+  nativeBuildInputs = [ cmake ]
+    ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  buildInputs = [ openblas gfortran.cc.lib ]
+    ++ stdenv.lib.optional enableCuda cudatoolkit;
+
+  meta = with stdenv.lib; {
+    homepage = http://faculty.cse.tamu.edu/davis/suitesparse.html;
+    description = "A suite of sparse matrix algorithms";
+    license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ];
+    maintainers = with maintainers; [ ttuegel ];
+    platforms = with platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch b/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch
new file mode 100644
index 000000000000..29d86238af08
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch
@@ -0,0 +1,7 @@
+--- a/TESTING/MATGEN/CMakeLists.txt
++++ b/TESTING/MATGEN/CMakeLists.txt
+@@ -97,3 +97,4 @@ if(enable_complex16)
+ endif()
+ 
+ add_library(matgen ${sources})
++target_link_libraries(matgen superlu)
diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix b/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix
new file mode 100644
index 000000000000..9938a3096a02
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchurl, cmake,
+  gfortran, openblasCompat}:
+
+stdenv.mkDerivation rec {
+  version = "5.2.1";
+  name = "superlu-${version}";
+
+  src = fetchurl {
+    url = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_${version}.tar.gz";
+    sha256 = "0qzlb7cd608q62kyppd0a8c65l03vrwqql6gsm465rky23b6dyr8";
+  };
+
+  buildInputs = [ cmake gfortran ];
+
+  propagatedBuildInputs = [ openblasCompat ];
+
+  cmakeFlags = [
+    "-DBUILD_SHARED_LIBS=true"
+    "-DUSE_XSDK_DEFAULTS=true"
+  ];
+
+  patches = [
+    ./find-openblas-library.patch
+    ./add-superlu-lib-as-dependency-for-the-unit-tests.patch
+  ];
+
+  doCheck = true;
+  checkTarget = "test";
+
+  meta = {
+    homepage = http://crd-legacy.lbl.gov/~xiaoye/SuperLU/;
+    license = http://crd-legacy.lbl.gov/~xiaoye/SuperLU/License.txt;
+    description = "A library for the solution of large, sparse, nonsymmetric systems of linear equations";
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/find-openblas-library.patch b/nixpkgs/pkgs/development/libraries/science/math/superlu/find-openblas-library.patch
new file mode 100644
index 000000000000..ce7bc6974c95
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/find-openblas-library.patch
@@ -0,0 +1,11 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -75,6 +75,8 @@ set(CMAKE_C_FLAGS_RELEASE "-O3" CACHE STRING "")
+ ######################################################################
+ #
+ #--------------------- BLAS ---------------------
++find_package(OpenBLAS)
++set(TPL_BLAS_LIBRARIES ${OpenBLAS_LIBRARIES})
+ if(NOT enable_blaslib)
+   if (TPL_BLAS_LIBRARIES)
+     set(BLAS_FOUND TRUE)
diff --git a/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix b/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix
new file mode 100644
index 000000000000..f421755b6182
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix
@@ -0,0 +1,89 @@
+{ stdenv
+, fetchurl
+, fetchpatch
+, makeWrapper
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.018.1";
+  name = "sympow-${version}";
+
+  src = fetchurl {
+    # Original website no longer reachable
+    url = "mirror://sageupstream/sympow/sympow-${version}.tar.bz2";
+    sha256 = "0hphs7ia1wr5mydf288zvwj4svrymfpadcg3pi6w80km2yg5bm3c";
+  };
+
+  nativeBuildInputs = [
+    makeWrapper
+  ];
+
+  configurePhase = ''
+    runHook preConfigure
+    ./Configure # doesn't take any options
+    runHook postConfigure
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    install -D datafiles/* --target-directory "$out/share/sympow/datafiles/"
+    install *.gp "$out/share/sympow/"
+    install -Dm755 sympow "$out/share/sympow/sympow"
+    install -D new_data "$out/bin/new_data"
+
+    makeWrapper "$out/share/sympow/sympow" "$out/bin/sympow" \
+      --run 'export SYMPOW_LOCAL="$HOME/.local/share/sympow"' \
+      --run 'if [ ! -d "$SYMPOW_LOCAL" ]; then
+        mkdir -p "$SYMPOW_LOCAL" 
+        cp -r ${placeholder "out"}/share/sympow/* "$SYMPOW_LOCAL"
+        chmod -R +xw "$SYMPOW_LOCAL"
+    fi' \
+      --run 'cd "$SYMPOW_LOCAL"'
+    runHook postInstall
+  '';
+
+  patches = [
+    # don't hardcode paths
+    (fetchpatch {
+      name = "do_not_hardcode_paths.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/Configure.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "1611p8ra8zkxvmxn3gm2l64bd4ma4m6r4vd6vwswcic91k1fci04";
+    })
+
+    # bug on some platforms in combination with a newer gcc:
+    # https://trac.sagemath.org/ticket/11920
+    (fetchpatch {
+      name = "fix_newer_gcc1.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/fpu.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "14gfa56w3ddfmd4d5ir9a40y2zi43cj1i4d2l2ij9l0qlqdy9jyx";
+    })
+    (fetchpatch {
+      name = "fix_newer_gcc2.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/execlp.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "190gqhgz9wgw4lqwz0nwb1izc9zffx34bazsiw2a2sz94bmgb54v";
+    })
+
+    # fix pointer initialization bug (https://trac.sagemath.org/ticket/22862)
+    (fetchpatch {
+      name = "fix_pointer_initialization1.patch";
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/sympow/patches/initialize-tacks.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
+      sha256 = "02341vdbbidfs39s26vi4n5wigz619sw8fdbl0h9qsmwwhscgf85";
+    })
+    (fetchpatch {
+      name = "fix_pointer_initialization2.patch";
+      url = "https://git.archlinux.org/svntogit/community.git/plain/trunk/sympow-datafiles.patch?h=packages/sympow";
+      sha256 = "1m0vz048layb47r1jjf7fplw650ccc9x0w3l322iqmppzmv3022a";
+    })
+  ];
+
+  meta = with stdenv.lib; {
+    description = "A package to compute special values of symmetric power elliptic curve L-functions";
+    license = {
+      shortName = "sympow";
+      fullName = "Custom, BSD-like. See COPYING file.";
+      free = true;
+    };
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix b/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix
new file mode 100644
index 000000000000..ad4d4c017376
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix
@@ -0,0 +1,75 @@
+{ stdenv
+, lib
+, fetchFromGitLab
+, fetchpatch
+, gmp
+, python2
+, tune ? false # tune to hardware, impure
+}:
+
+stdenv.mkDerivation rec {
+  version = "0.9.1";
+  pname = "zn_poly";
+  name = "${pname}-${version}";
+
+  # sage has picked up the maintenance (bug fixes and building, not development)
+  # from the original, now unmaintained project which can be found at
+  # http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/
+  src = fetchFromGitLab {
+    owner = "sagemath";
+    repo = "zn_poly";
+    rev = version;
+    sha256 = "0ra5vy585bqq7g3317iw6fp44iqgqvds3j0l1va6mswimypq4vxb";
+  };
+
+  buildInputs = [
+    gmp
+  ];
+
+  nativeBuildInputs = [
+    python2 # needed by ./configure to create the makefile
+  ];
+
+  # name of library file ("libzn_poly.so")
+  libbasename = "libzn_poly";
+  libext = "${stdenv.targetPlatform.extensions.sharedLibrary}";
+
+  makeFlags = [ "CC=cc" ];
+
+  # Tuning (either autotuning or with hand-written paramters) is possible
+  # but not implemented here.
+  # It seems buggy anyways (see homepage).
+  buildFlags = [ "all" "${libbasename}${libext}" ];
+
+  configureFlags = lib.optionals (!tune) [
+    "--disable-tuning"
+  ];
+
+  patches = [
+    # fix format-security by not passing variables directly to printf
+    # https://gitlab.com/sagemath/zn_poly/merge_requests/1
+    (fetchpatch {
+      name = "format-security.patch";
+      url = "https://gitlab.com/timokau/zn_poly/commit/1950900a80ec898d342b8bcafa148c8027649766.patch";
+      sha256 = "1gks9chvsfpc6sg5h3nqqfia4cgvph7jmj9dw67k7dk7kv9y0rk1";
+    })
+  ];
+
+  # `make install` fails to install some header files and the lib file.
+  installPhase = ''
+    mkdir -p "$out/include/zn_poly"
+    mkdir -p "$out/lib"
+    cp "${libbasename}"*"${libext}" "$out/lib"
+    cp include/*.h "$out/include/zn_poly"
+  '';
+
+  doCheck = true;
+
+  meta = with lib; {
+    homepage = http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/;
+    description = "Polynomial arithmetic over Z/nZ";
+    license = with licenses; [ gpl3 ];
+    maintainers = with maintainers; [ timokau ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/networking/ns3/default.nix b/nixpkgs/pkgs/development/libraries/science/networking/ns3/default.nix
new file mode 100644
index 000000000000..d5c3ca2457aa
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/networking/ns3/default.nix
@@ -0,0 +1,96 @@
+{ stdenv
+, fetchFromGitHub
+, python
+, wafHook
+
+# for binding generation
+, castxml ? null
+
+# can take a long time, generates > 30000 images/graphs
+, enableDoxygen ? false
+
+# e.g. "optimized" or "debug". If not set, use default one
+, build_profile ? null
+
+# --enable-examples
+, withExamples ? false
+
+# very long
+, withManual ? false, doxygen ? null, graphviz ? null, imagemagick ? null
+# for manual, tetex is used to get the eps2pdf binary
+# texlive to get latexmk. building manual still fails though
+, dia, tetex ? null, ghostscript ? null, texlive ? null
+
+# generates python bindings
+, generateBindings ? false, ncurses ? null
+
+# All modules can be enabled by choosing 'all_modules'.
+# we include here the DCE mandatory ones
+, modules ? [ "core" "network" "internet" "point-to-point" "fd-net-device" "netanim"]
+, gcc6
+, lib
+}:
+
+let
+  pythonEnv = python.withPackages(ps:
+    stdenv.lib.optional withManual ps.sphinx
+    ++ stdenv.lib.optionals generateBindings (with ps;[ pybindgen pygccxml ])
+  );
+in
+stdenv.mkDerivation rec {
+
+  name = "ns-3.${version}";
+  version = "28";
+
+  # the all in one https://www.nsnam.org/release/ns-allinone-3.27.tar.bz2;
+  # fetches everything (netanim, etc), this package focuses on ns3-core
+  src = fetchFromGitHub {
+    owner  = "nsnam";
+    repo   = "ns-3-dev-git";
+    rev    = name;
+    sha256 = "17kzfjpgw2mvyx1c9bxccnvw67jpk09fxmcnlkqx9xisk10qnhng";
+  };
+
+  nativeBuildInputs = [ wafHook ];
+  # ncurses is a hidden dependency of waf when checking python
+  buildInputs = lib.optionals generateBindings [ castxml ncurses ]
+    ++ stdenv.lib.optional enableDoxygen [ doxygen graphviz imagemagick ]
+    ++ stdenv.lib.optional withManual [ dia tetex ghostscript texlive.combined.scheme-medium ];
+
+  propagatedBuildInputs = [ gcc6 pythonEnv ];
+
+  postPatch = ''
+    patchShebangs doc/ns3_html_theme/get_version.sh
+  '';
+
+  configureFlags = with stdenv.lib; [
+      "--enable-modules=${stdenv.lib.concatStringsSep "," modules}"
+      "--with-python=${pythonEnv.interpreter}"
+  ]
+  ++ optional (build_profile != null) "--build-profile=${build_profile}"
+  ++ optional generateBindings [  ]
+  ++ optional withExamples " --enable-examples "
+  ++ optional doCheck " --enable-tests "
+  ;
+
+  buildTargets = "build"
+    + lib.optionalString enableDoxygen " doxygen"
+    + lib.optionalString withManual "sphinx";
+
+  doCheck = true;
+
+  # we need to specify the proper interpreter else ns3 can check against a
+  # different version even though we
+  checkPhase =  ''
+    ${pythonEnv.interpreter} ./test.py
+  '';
+
+  hardeningDisable = [ "fortify" ];
+
+  meta = {
+    homepage = http://www.nsnam.org;
+    license = stdenv.lib.licenses.gpl3;
+    description = "A discrete time event network simulator";
+    platforms = with stdenv.lib.platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix b/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix
new file mode 100644
index 000000000000..5f2263d821d0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, cmake, boost
+}:
+
+stdenv.mkDerivation rec {
+  name = "ispike-${version}";
+  version = "2.1.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ispike/${name}.tar.gz";
+    sha256 = "0khrxp43bi5kisr8j4lp9fl4r5marzf7b4inys62ac108sfb28lp";
+  };
+
+  buildInputs = [ cmake boost ];
+
+  meta = {
+    description = "Spiking neural interface between iCub and a spiking neural simulator";
+    homepage = https://sourceforge.net/projects/ispike/;
+    license = stdenv.lib.licenses.lgpl3;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.nico202 ];
+  };
+
+  
+}