hungarian_algorithm_c 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3131f481cd59f14347ab0881138cebeee3e426df
4
- data.tar.gz: 8d5f3506ffe58e10ccb2bb5b550aaec1d3296a18
3
+ metadata.gz: a54ee73466778776258aa0601cd5a7f8c0ff8ae6
4
+ data.tar.gz: 66cfd028102d917ef159e45fda5836a9128d4dfa
5
5
  SHA512:
6
- metadata.gz: 3f41e80045ae12207881e794037d078e890e60bae9045c363cd86c3716f148318204ed06bdd67b2f0ef0630ede36cf83cc3a048a7edcb7cf1a83dbd8b0f5a957
7
- data.tar.gz: ea61a05071cab151bb5e867e535b6127351889f610671800e8c800996ad432fbb20151e2a86333a5bb9179457f33c47c2a46133b29b6815db03ad4010f9892cc
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
 
@@ -1,3 +1,3 @@
1
1
  module HungarianAlgorithmC
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'hungarian_algorithm_c.so'
1
+ require_relative './hungarian_algorithm_c.so'
2
2
 
3
3
  module HungarianAlgorithmC
4
4
  class << self
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hungarian_algorithm_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Syed Humza Shah