Commit 7ae702a4 authored by Davis King's avatar Davis King

Changed how murmur hash was used in find_max_factor_graph_nmplp to avoid a

violation of the strict aliasing rule.  This fixes a bug which caused
find_max_factor_graph_nmplp() to not work properly on some compilers.
parent 453fee62
...@@ -40,8 +40,7 @@ namespace dlib ...@@ -40,8 +40,7 @@ namespace dlib
- #(*this)(a,b) == value - #(*this)(a,b) == value
!*/ !*/
{ {
const unsigned long block[2] = {a,b}; const uint32 h = murmur_hash3_2(a,b)%(data.size()-scan_dist);
const uint32 h = murmur_hash3(&block[0], sizeof(block))%(data.size()-scan_dist);
const unsigned long empty_bucket = std::numeric_limits<unsigned long>::max(); const unsigned long empty_bucket = std::numeric_limits<unsigned long>::max();
...@@ -85,8 +84,7 @@ namespace dlib ...@@ -85,8 +84,7 @@ namespace dlib
DLIB_ASSERT(a != b, "An invalid map_problem was given to find_max_factor_graph_nmplp()." DLIB_ASSERT(a != b, "An invalid map_problem was given to find_max_factor_graph_nmplp()."
<< "\nNode " << a << " is listed as being a neighbor with itself, which is illegal."); << "\nNode " << a << " is listed as being a neighbor with itself, which is illegal.");
const unsigned long block[2] = {a,b}; uint32 h = murmur_hash3_2(a,b)%(data.size()-scan_dist);
uint32 h = murmur_hash3(&block[0], sizeof(block))%(data.size()-scan_dist);
for (unsigned long i = 0; i < scan_dist; ++i) for (unsigned long i = 0; i < scan_dist; ++i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment