hungarian_algorithm_c 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/ext/hungarian_algorithm_c/hungarian_algorithm_c.c +1 -1
- data/lib/hungarian_algorithm_c/version.rb +1 -1
- data/spec/hungarian_algorithm_c_spec.rb +16 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf9bc75e8c20f1067c5bdc4aee13b650d96b90c
|
4
|
+
data.tar.gz: 2283bba92d3a9c8d96e006fde88ead8ae363e798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ddc4a8d3a594d644e50b1f6ca82d0baa692ea88f0c4ab034f4c1efb97e5de280e1830faf442a4b77c71806a31ec9c89bac2e00a15f88d1319b7b58ec59871da
|
7
|
+
data.tar.gz: 72176924f4375d2dc5e63d562a89befeb0aa6f4d4ec30a60f27b40ba6dca40cc1582dac2a4bdc8b424b1d7c0542af3d22ba01275959a2d00a60f5b2d412c9cdc
|
data/README.md
CHANGED
@@ -44,6 +44,8 @@ HungarianAlgorithmC.find_pairings(costs)
|
|
44
44
|
#=> [[0, 0], [1, 2], [2, 1]]
|
45
45
|
```
|
46
46
|
|
47
|
+
**Note**: Your cost matrix should not have `Float::INFINITY` or _very very large_ numbers as those will not be interpreted appropriately [here](ext/hungarian_algorithm_c/hungarian_algorithm_c.c#L56).
|
48
|
+
|
47
49
|
## Acknowledgements
|
48
50
|
|
49
51
|
The C code uses the implementation by [Cyrill Stachniss](ext/hungarian_algorithm_c/libhungarian).
|
@@ -53,7 +53,7 @@ VALUE pairs(VALUE self, VALUE flattened_array_ruby, VALUE row_size_val) {
|
|
53
53
|
|
54
54
|
int index;
|
55
55
|
for (index = 0; index < array_size; index++) {
|
56
|
-
long double element =
|
56
|
+
long double element = NUM2DBL(rb_ary_entry(flattened_array_ruby, index));
|
57
57
|
long long int rounded_element = element;
|
58
58
|
array_c[index] = rounded_element;
|
59
59
|
}
|
@@ -25,6 +25,17 @@ RSpec.describe HungarianAlgorithmC do
|
|
25
25
|
[0, 0]
|
26
26
|
])
|
27
27
|
end
|
28
|
+
|
29
|
+
context 'matrix contains Floa::INFINITY' do
|
30
|
+
let(:matrix_with_costs) { [
|
31
|
+
[4, 3],
|
32
|
+
[3, Float::INFINITY]
|
33
|
+
] }
|
34
|
+
|
35
|
+
it 'should not crash' do
|
36
|
+
should be_a Array
|
37
|
+
end
|
38
|
+
end
|
28
39
|
end
|
29
40
|
|
30
41
|
context '3x3 array' do
|
@@ -41,22 +52,6 @@ RSpec.describe HungarianAlgorithmC do
|
|
41
52
|
[2, 1]
|
42
53
|
])
|
43
54
|
end
|
44
|
-
|
45
|
-
context 'with very large numbers' do
|
46
|
-
let(:matrix_with_costs) { [
|
47
|
-
[4, 1, 7],
|
48
|
-
[Float::INFINITY, 3, 9],
|
49
|
-
[1, 2, 13]
|
50
|
-
] }
|
51
|
-
|
52
|
-
it 'should output minimum cost pairs' do
|
53
|
-
should match_array([
|
54
|
-
[0, 2],
|
55
|
-
[1, 0],
|
56
|
-
[2, 1]
|
57
|
-
])
|
58
|
-
end
|
59
|
-
end
|
60
55
|
end
|
61
56
|
|
62
57
|
context '4x4 array' do
|
@@ -76,12 +71,12 @@ RSpec.describe HungarianAlgorithmC do
|
|
76
71
|
])
|
77
72
|
end
|
78
73
|
|
79
|
-
context 'with
|
74
|
+
context 'with large numbers' do
|
80
75
|
let(:matrix_with_costs) { [
|
81
|
-
[
|
82
|
-
[
|
83
|
-
[
|
84
|
-
[
|
76
|
+
[1_000_000, 2_000_000, 3, 3_000_000],
|
77
|
+
[9_000_000, 1, 4_000_000, 5_000_000],
|
78
|
+
[2_000_000, 1_000_000, 1_000_000, 4],
|
79
|
+
[1, 8_000_000, 3_000_000, 44]
|
85
80
|
] }
|
86
81
|
|
87
82
|
it 'should output minimum cost pairs' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hungarian_algorithm_c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Syed Humza Shah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|