summary refs log tree commit diff
path: root/pkgs/applications/science/math
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/math')
-rw-r--r--pkgs/applications/science/math/caffe/darwin.patch47
-rw-r--r--pkgs/applications/science/math/caffe/default.nix51
-rw-r--r--pkgs/applications/science/math/cplex/default.nix82
-rw-r--r--pkgs/applications/science/math/gfan/default.nix11
-rw-r--r--pkgs/applications/science/math/qalculate-gtk/default.nix4
-rw-r--r--pkgs/applications/science/math/ratpoints/default.nix26
-rw-r--r--pkgs/applications/science/math/symmetrica/default.nix34
7 files changed, 227 insertions, 28 deletions
diff --git a/pkgs/applications/science/math/caffe/darwin.patch b/pkgs/applications/science/math/caffe/darwin.patch
new file mode 100644
index 000000000000..e8fa6a683f73
--- /dev/null
+++ b/pkgs/applications/science/math/caffe/darwin.patch
@@ -0,0 +1,47 @@
+diff --git a/Makefile b/Makefile
+index c823f66e..65b90c5e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -32,9 +32,9 @@ SRC_DIRS := $(shell find * -type d -exec bash -c "find {} -maxdepth 1 \
+ LIBRARY_NAME := $(PROJECT)
+ LIB_BUILD_DIR := $(BUILD_DIR)/lib
+ STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
+-DYNAMIC_VERSION_MAJOR 		:= 1
+-DYNAMIC_VERSION_MINOR 		:= 0
+-DYNAMIC_VERSION_REVISION 	:= 0
++DYNAMIC_VERSION_MAJOR		:= 1
++DYNAMIC_VERSION_MINOR		:= 0
++DYNAMIC_VERSION_REVISION	:= 0
+ DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
+ #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
+ DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
+diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
+index c48255c8..cf4c580e 100644
+--- a/cmake/Dependencies.cmake
++++ b/cmake/Dependencies.cmake
+@@ -105,7 +105,6 @@ if(USE_OPENCV)
+ endif()
+ 
+ # ---[ BLAS
+-if(NOT APPLE)
+   set(BLAS "Atlas" CACHE STRING "Selected BLAS library")
+   set_property(CACHE BLAS PROPERTY STRINGS "Atlas;Open;MKL")
+ 
+@@ -123,17 +122,6 @@ if(NOT APPLE)
+     list(APPEND Caffe_LINKER_LIBS PUBLIC ${MKL_LIBRARIES})
+     list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_MKL)
+   endif()
+-elseif(APPLE)
+-  find_package(vecLib REQUIRED)
+-  list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${vecLib_INCLUDE_DIR})
+-  list(APPEND Caffe_LINKER_LIBS PUBLIC ${vecLib_LINKER_LIBS})
+-
+-  if(VECLIB_FOUND)
+-    if(NOT vecLib_INCLUDE_DIR MATCHES "^/System/Library/Frameworks/vecLib.framework.*")
+-      list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_ACCELERATE)
+-    endif()
+-  endif()
+-endif()
+ 
+ # ---[ Python
+ if(BUILD_python)
diff --git a/pkgs/applications/science/math/caffe/default.nix b/pkgs/applications/science/math/caffe/default.nix
index d7357c5048d5..e56c63e01bf0 100644
--- a/pkgs/applications/science/math/caffe/default.nix
+++ b/pkgs/applications/science/math/caffe/default.nix
@@ -1,27 +1,39 @@
-{ stdenv, lib
+{ stdenv, lib, runCommand
 , fetchFromGitHub
+, fetchurl
 , cmake
 , boost
 , google-gflags
 , glog
 , hdf5-cpp
-, leveldb
-, lmdb
 , opencv3
 , protobuf
-, snappy
 , doxygen
 , openblas
-, cudaSupport ? true, cudatoolkit
+, Accelerate, CoreGraphics, CoreVideo
+, lmdbSupport ? true, lmdb
+, leveldbSupport ? true, leveldb, snappy
+, cudaSupport ? stdenv.isLinux, cudatoolkit
 , cudnnSupport ? false, cudnn ? null
 , ncclSupport ? false, nccl ? null
 , pythonSupport ? false, python ? null, numpy ? null
 }:
 
+assert leveldbSupport -> (leveldb != null && snappy != null);
 assert cudnnSupport -> cudaSupport;
 assert ncclSupport -> cudaSupport;
 assert pythonSupport -> (python != null && numpy != null);
 
+let
+  toggle = bool: if bool then "ON" else "OFF";
+
+  test_model_weights = fetchurl {
+    url = "http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel";
+    sha256 = "472d4a06035497b180636d8a82667129960371375bd10fcb6df5c6c7631f25e0";
+  };
+
+in
+
 stdenv.mkDerivation rec {
   name = "caffe-${version}";
   version = "1.0";
@@ -44,19 +56,27 @@ stdenv.mkDerivation rec {
            "-DCUDA_ARCH_NAME=All"
            "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
          ] else [ "-DCPU_ONLY=ON" ])
-      ++ lib.optional ncclSupport "-DUSE_NCCL=ON";
+      ++ ["-DUSE_NCCL=${toggle ncclSupport}"]
+      ++ ["-DUSE_LEVELDB=${toggle leveldbSupport}"]
+      ++ ["-DUSE_LMDB=${toggle lmdbSupport}"];
 
-  buildInputs = [ boost google-gflags glog protobuf hdf5-cpp lmdb leveldb snappy opencv3 openblas ]
+  buildInputs = [ boost google-gflags glog protobuf hdf5-cpp opencv3 openblas ]
                 ++ lib.optional cudaSupport cudatoolkit
                 ++ lib.optional cudnnSupport cudnn
+                ++ lib.optional lmdbSupport lmdb
                 ++ lib.optional ncclSupport nccl
-                ++ lib.optionals pythonSupport [ python numpy ];
+                ++ lib.optionals leveldbSupport [ leveldb snappy ]
+                ++ lib.optionals pythonSupport [ python numpy ]
+                ++ lib.optionals stdenv.isDarwin [ Accelerate CoreGraphics CoreVideo ]
+                ;
 
   propagatedBuildInputs = lib.optional pythonSupport python.pkgs.protobuf;
 
   outputs = [ "bin" "out"];
   propagatedBuildOutputs = []; # otherwise propagates out -> bin cycle
 
+  patches = [ ./darwin.patch ];
+
   preConfigure = lib.optionalString (cudaSupport && lib.versionAtLeast cudatoolkit.version "9.0") ''
     # CUDA 9.0 doesn't support sm_20
     sed -i 's,20 21(20) ,,' cmake/Cuda.cmake
@@ -71,6 +91,9 @@ stdenv.mkDerivation rec {
     # Internal static library.
     rm $out/lib/libproto.a
 
+    # Install models
+    cp -a ../models $out/share/Caffe/models
+
     moveToOutput "bin" "$bin"
   '' + lib.optionalString pythonSupport ''
     mkdir -p $out/${python.sitePackages}
@@ -78,6 +101,16 @@ stdenv.mkDerivation rec {
     rm -rf $out/python
   '';
 
+  doInstallCheck = false; # build takes more than 30 min otherwise
+  installCheckPhase = ''
+    model=bvlc_reference_caffenet
+    m_path="$out/share/Caffe/models/$model"
+    $bin/bin/caffe test \
+      -model "$m_path/deploy.prototxt" \
+      -solver "$m_path/solver.prototxt" \
+      -weights "${test_model_weights}"
+  '';
+
   meta = with stdenv.lib; {
     description = "Deep learning framework";
     longDescription = ''
@@ -88,6 +121,6 @@ stdenv.mkDerivation rec {
     homepage = http://caffe.berkeleyvision.org/;
     maintainers = with maintainers; [ jb55 ];
     license = licenses.bsd2;
-    platforms = platforms.linux;
+    platforms = platforms.linux ++ platforms.darwin;
   };
 }
diff --git a/pkgs/applications/science/math/cplex/default.nix b/pkgs/applications/science/math/cplex/default.nix
new file mode 100644
index 000000000000..fe3913648f87
--- /dev/null
+++ b/pkgs/applications/science/math/cplex/default.nix
@@ -0,0 +1,82 @@
+{ stdenv, makeWrapper, openjdk, gtk2, xorg, glibcLocales, releasePath }:
+
+# To use this package, you need to download your own cplex installer from IBM
+# and override the releasePath attribute to point to the location of the file.  
+#
+# Note: cplex creates an individual build for each license which screws
+# somewhat with the use of functions like requireFile as the hash will be
+# different for every user.
+
+stdenv.mkDerivation rec {
+  name = "cplex-${version}";
+  version = "128";
+  
+  src =
+    if builtins.isNull releasePath then
+      throw ''
+        This nix expression requires that the cplex installer is already
+        downloaded to your machine. Get it from IBM: 
+        https://developer.ibm.com/docloud/blog/2017/12/20/cplex-optimization-studio-12-8-now-available/ 
+
+        Set `cplex.releasePath = /path/to/download;` in your
+        ~/.config/nixpkgs/config.nix for `nix-*` commands, or
+        `config.cplex.releasePath = /path/to/download;` in your
+        `configuration.nix` for NixOS.
+      ''
+    else
+      releasePath;
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ openjdk gtk2 xorg.libXtst glibcLocales ];
+
+  unpackPhase = "cp $src $name";
+
+  patchPhase = ''
+    sed -i -e 's|/usr/bin/tr"|tr"         |' $name
+  '';
+
+  buildPhase = ''
+    sh $name -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=$out
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    ln -s $out/opl/bin/x86-64_linux/oplrun\
+      $out/opl/bin/x86-64_linux/oplrunjava\
+      $out/opl/oplide/oplide\
+      $out/cplex/bin/x86-64_linux/cplex\
+      $out/cpoptimizer/bin/x86-64_linux/cpoptimizer\
+      $out/bin
+  '';
+
+  fixupPhase = 
+  let 
+    libraryPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc gtk2 xorg.libXtst ];
+  in ''
+    interpreter=${stdenv.glibc}/lib/ld-linux-x86-64.so.2
+
+    for pgm in $out/opl/bin/x86-64_linux/oplrun $out/opl/bin/x86-64_linux/oplrunjava $out/opl/oplide/oplide;
+    do
+      patchelf --set-interpreter "$interpreter" $pgm;
+      wrapProgram $pgm \
+        --prefix LD_LIBRARY_PATH : $out/opl/bin/x86-64_linux:${libraryPath} \
+        --set LOCALE_ARCHIVE ${glibcLocales}/lib/locale/locale-archive;
+    done
+
+    for pgm in $out/cplex/bin/x86-64_linux/cplex $out/cpoptimizer/bin/x86-64_linux/cpoptimizer $out/opl/oplide/jre/bin/*; 
+    do
+      if grep ELF $pgm > /dev/null;
+      then
+        patchelf --set-interpreter "$interpreter" $pgm;
+      fi
+    done
+  '';
+  
+  meta = with stdenv.lib; {
+    description = "Optimization solver for mathematical programming";
+    homepage = "https://www.ibm.com/be-en/marketplace/ibm-ilog-cplex";
+    license = licenses.unfree;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ bfortz ];
+  };
+}
diff --git a/pkgs/applications/science/math/gfan/default.nix b/pkgs/applications/science/math/gfan/default.nix
index 65d551f39a71..d2d1ddb65846 100644
--- a/pkgs/applications/science/math/gfan/default.nix
+++ b/pkgs/applications/science/math/gfan/default.nix
@@ -9,15 +9,20 @@ stdenv.mkDerivation rec {
     sha256 = "02pihqb1lb76a0xbfwjzs1cd6ay3ldfxsm8dvsbl6qs3vkjxax56";
   };
 
-  makeFlags = ''PREFIX=$(out) CC=cc CXX=c++ cddnoprefix=1'';
-  buildInputs = [gmp mpir cddlib];
+  patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
+    substituteInPlace Makefile --replace "-fno-guess-branch-probability" ""
+  '';
+
+  buildFlags = [ "CC=cc" "CXX=c++" "cddnoprefix=1" ];
+  installFlags = [ ''PREFIX=$(out)'' ];
+  buildInputs = [ gmp mpir cddlib ];
 
   meta = {
     inherit version;
     description = ''A software package for computing Gröbner fans and tropical varieties'';
     license = stdenv.lib.licenses.gpl2 ;
     maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
     homepage = http://home.math.au.dk/jensen/software/gfan/gfan.html;
   };
 }
diff --git a/pkgs/applications/science/math/qalculate-gtk/default.nix b/pkgs/applications/science/math/qalculate-gtk/default.nix
index 7990088ffbe9..59dbfdb509dc 100644
--- a/pkgs/applications/science/math/qalculate-gtk/default.nix
+++ b/pkgs/applications/science/math/qalculate-gtk/default.nix
@@ -2,13 +2,13 @@
 
 stdenv.mkDerivation rec {
   name = "qalculate-gtk-${version}";
-  version = "2.6.1";
+  version = "2.6.2";
 
   src = fetchFromGitHub {
     owner = "qalculate";
     repo = "qalculate-gtk";
     rev = "v${version}";
-    sha256 = "19jw1w29x0r1qq5r8gmqrqr00ml2pfi2w433723vjzxpfg2pp70r";
+    sha256 = "1yzw6avhka7bbi071z9d8cipcghyjq2bg9x3arv1cf395xlnrmb9";
   };
 
   patchPhase = ''
diff --git a/pkgs/applications/science/math/ratpoints/default.nix b/pkgs/applications/science/math/ratpoints/default.nix
index 82a6836bd623..2dd4778234df 100644
--- a/pkgs/applications/science/math/ratpoints/default.nix
+++ b/pkgs/applications/science/math/ratpoints/default.nix
@@ -1,20 +1,36 @@
-{stdenv, fetchurl, gmp}:
+{ stdenv, fetchurl, fetchpatch, gmp }:
 stdenv.mkDerivation rec {
   name = "ratpoints-${version}";
-  version = "2.1.3";
+  version = "2.1.3.p4";
+
   src = fetchurl {
     url = "http://www.mathe2.uni-bayreuth.de/stoll/programs/ratpoints-${version}.tar.gz";
     sha256 = "0zhad84sfds7izyksbqjmwpfw4rvyqk63yzdjd3ysd32zss5bgf4";
   };
-  buildInputs = [gmp];
-  makeFlags = "INSTALL_DIR=$(out)";
+
+  enableParallelBuilding = true;
+
+  patches = [
+    (fetchpatch {
+      url = "https://git.sagemath.org/sage.git/plain/build/pkgs/ratpoints/patches/sturm_and_rp_private.patch?id=1615f58890e8f9881c4228c78a6b39b9aab1303a";
+      sha256 = "0q3wajncyfr3gahd8gwk9x7g56zw54lpywrl63lqk7drkf60mrcl";
+    })
+  ];
+
+  buildInputs = [ gmp ];
+
+  makeFlags = [ "CC=cc" ];
+  buildFlags = stdenv.lib.optional stdenv.isDarwin ["CCFLAGS2=-lgmp -lc -lm" "CCFLAGS=-UUSE_SSE"];
+  installFlags = [ "INSTALL_DIR=$(out)" ];
+
   preInstall = ''mkdir -p "$out"/{bin,share,lib,include}'';
+
   meta = {
     inherit version;
     description = ''A program to find rational points on hyperelliptic curves'';
     license = stdenv.lib.licenses.gpl2Plus;
     maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
     homepage = http://www.mathe2.uni-bayreuth.de/stoll/programs/;
     updateWalker = true;
   };
diff --git a/pkgs/applications/science/math/symmetrica/default.nix b/pkgs/applications/science/math/symmetrica/default.nix
index 6123fd7306d9..a641993b393b 100644
--- a/pkgs/applications/science/math/symmetrica/default.nix
+++ b/pkgs/applications/science/math/symmetrica/default.nix
@@ -5,20 +5,15 @@
 stdenv.mkDerivation rec {
   name = "symmetrica-${version}";
   version = "2.0";
+
   src = fetchurl {
     url = "http://www.algorithm.uni-bayreuth.de/en/research/SYMMETRICA/SYM2_0_tar.gz";
     sha256 = "1qhfrbd5ybb0sinl9pad64rscr08qvlfzrzmi4p4hk61xn6phlmz";
     name = "symmetrica-2.0.tar.gz";
   };
+
   sourceRoot = ".";
-  installPhase = ''
-    mkdir -p "$out"/{lib,share/doc/symmetrica,include/symmetrica}
-    ar crs libsymmetrica.a *.o
-    ranlib libsymmetrica.a
-    cp libsymmetrica.a "$out/lib"
-    cp *.h "$out/include/symmetrica"
-    cp README *.doc "$out/share/doc/symmetrica"
-  '';
+
   patches = [
       # don't show banner ("SYMMETRICA VERSION X - STARTING)
       # it doesn't contain very much helpful information and a banner is not ideal for a library
@@ -34,13 +29,34 @@ stdenv.mkDerivation rec {
         url = "https://git.sagemath.org/sage.git/plain/build/pkgs/symmetrica/patches/int32.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba";
         sha256 = "0p33c85ck4kd453z687ni4bdcqr1pqx2756j7aq11bf63vjz4cyz";
       })
+
+      (fetchpatch {
+        url = "https://git.sagemath.org/sage.git/plain/build/pkgs/symmetrica/patches/return_values.patch?id=1615f58890e8f9881c4228c78a6b39b9aab1303a";
+        sha256 = "0dmczkicwl50sivc07w3wm3jpfk78wm576dr25999jdj2ipsb7nk";
+      })
   ];
+
+  postPatch = ''
+    substituteInPlace makefile --replace gcc cc
+  '';
+
+  enableParallelBuilding = true;
+
+  installPhase = ''
+    mkdir -p "$out"/{lib,share/doc/symmetrica,include/symmetrica}
+    ar crs libsymmetrica.a *.o
+    ranlib libsymmetrica.a
+    cp libsymmetrica.a "$out/lib"
+    cp *.h "$out/include/symmetrica"
+    cp README *.doc "$out/share/doc/symmetrica"
+  '';
+
   meta = {
     inherit version;
     description = ''A collection of routines for representation theory and combinatorics'';
     license = stdenv.lib.licenses.publicDomain;
     maintainers = [stdenv.lib.maintainers.raskin];
-    platforms = stdenv.lib.platforms.linux;
+    platforms = stdenv.lib.platforms.unix;
     homepage = http://www.symmetrica.de/;
   };
 }