hungarian_algorithm_c 0.0.1 → 0.0.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a54ee73466778776258aa0601cd5a7f8c0ff8ae6
|
4
|
+
data.tar.gz: 66cfd028102d917ef159e45fda5836a9128d4dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd8765887857a796dcedbf341058dd9630028762b37bafd3d5c16a3b3e0cf9edb605c1d3ee80374ef8971ec00c7c4df2fca70cc1a2cc7abf98a5020efa1d1381
|
7
|
+
data.tar.gz: fed0e9c37a870840477081d59beb4871cc0cb921decdc9bc025c7f92c3ccf530a00e8039adb894278e6d87e6764b9db12b97910626eea7e7e187dfb202dbadb1
|
@@ -53,8 +53,8 @@ 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
|
-
double element = 100 * NUM2DBL(rb_ary_entry(flattened_array_ruby, index));
|
57
|
-
int rounded_element = element;
|
56
|
+
long double element = 100 * NUM2DBL(rb_ary_entry(flattened_array_ruby, index));
|
57
|
+
long long int rounded_element = element;
|
58
58
|
array_c[index] = rounded_element;
|
59
59
|
}
|
60
60
|
|
@@ -41,6 +41,22 @@ RSpec.describe HungarianAlgorithmC do
|
|
41
41
|
[2, 1]
|
42
42
|
])
|
43
43
|
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
|
44
60
|
end
|
45
61
|
|
46
62
|
context '4x4 array' do
|
@@ -59,6 +75,24 @@ RSpec.describe HungarianAlgorithmC do
|
|
59
75
|
[3, 0]
|
60
76
|
])
|
61
77
|
end
|
78
|
+
|
79
|
+
context 'with very large numbers' do
|
80
|
+
let(:matrix_with_costs) { [
|
81
|
+
[Float::INFINITY, 3, 10000000000000000000000000000000000, 3],
|
82
|
+
[10, 2, Float::INFINITY, 6],
|
83
|
+
[10, 3, 34, Float::INFINITY],
|
84
|
+
[99999999999999999999999, 13, 15, 6000000000000000]
|
85
|
+
] }
|
86
|
+
|
87
|
+
it 'should output minimum cost pairs' do
|
88
|
+
should match_array([
|
89
|
+
[0, 2],
|
90
|
+
[1, 1],
|
91
|
+
[2, 3],
|
92
|
+
[3, 0]
|
93
|
+
])
|
94
|
+
end
|
95
|
+
end
|
62
96
|
end
|
63
97
|
end
|
64
98
|
end
|