tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
zinnia: fix compilation on darwin, update sourceRoot logic
TomaSajt
9 months ago
c7b26ea2
ad50b616
+39
-8
2 changed files
expand all
collapse all
unified
split
pkgs
by-name
zi
zinnia
package.nix
remove-random-shuffle-usage.patch
+12
-8
pkgs/by-name/zi/zinnia/package.nix
···
4
4
fetchFromGitHub,
5
5
}:
6
6
7
7
-
stdenv.mkDerivation {
7
7
+
stdenv.mkDerivation (finalAttrs: {
8
8
pname = "zinnia";
9
9
version = "2016-08-28";
10
10
···
15
15
sha256 = "1izjy5qw6swg0rs2ym2i72zndb90mwrfbd1iv8xbpwckbm4899lg";
16
16
};
17
17
18
18
-
setSourceRoot = ''
19
19
-
sourceRoot=$(echo */zinnia)
20
20
-
'';
18
18
+
sourceRoot = "${finalAttrs.src.name}/zinnia";
21
19
22
22
-
meta = with lib; {
20
20
+
patches = [
21
21
+
# Fixes the following error on darwin:
22
22
+
# svm.cpp:50:10: error: no member named 'random_shuffle' in namespace 'std'
23
23
+
./remove-random-shuffle-usage.patch
24
24
+
];
25
25
+
26
26
+
meta = {
23
27
description = "Online hand recognition system with machine learning";
24
28
homepage = "http://taku910.github.io/zinnia/";
25
25
-
license = licenses.bsd2;
26
26
-
platforms = platforms.unix;
29
29
+
license = lib.licenses.bsd2;
30
30
+
platforms = lib.platforms.unix;
27
31
maintainers = [ ];
28
32
};
29
29
-
}
33
33
+
})
+27
pkgs/by-name/zi/zinnia/remove-random-shuffle-usage.patch
···
1
1
+
diff --git a/svm.cpp b/svm.cpp
2
2
+
index 3b7643e..2a34b42 100644
3
3
+
--- a/svm.cpp
4
4
+
+++ b/svm.cpp
5
5
+
@@ -10,6 +10,7 @@
6
6
+
#include <vector>
7
7
+
#include <cmath>
8
8
+
#include <algorithm>
9
9
+
+#include <random>
10
10
+
#include "feature.h"
11
11
+
12
12
+
namespace zinnia {
13
13
+
@@ -43,11 +44,13 @@ bool svm_train(size_t l,
14
14
+
}
15
15
+
}
16
16
+
17
17
+
+ std::random_device rand_device;
18
18
+
+ std::default_random_engine rand_engine(rand_device());
19
19
+
static const size_t kMaxIteration = 2000;
20
20
+
for (size_t iter = 0; iter < kMaxIteration; ++iter) {
21
21
+
double PGmax_new = -kINF;
22
22
+
double PGmin_new = kINF;
23
23
+
- std::random_shuffle(index.begin(), index.begin() + active_size);
24
24
+
+ std::shuffle(index.begin(), index.begin() + active_size, rand_engine);
25
25
+
26
26
+
for (size_t s = 0; s < active_size; ++s) {
27
27
+
const size_t i = index[s];