From 5de179de48bdee4da10b8afe9510fccba7404f78 Mon Sep 17 00:00:00 2001 From: Nikolaus Demmel Date: Tue, 23 Jun 2020 16:59:15 +0200 Subject: [PATCH] hash_combine moved to headers and tbb_hash left-overs --- include/basalt/hash_bow/hash_bow.h | 2 +- include/basalt/optimization/accumulator.h | 7 ++--- include/basalt/utils/common_types.h | 31 ++++++++--------------- thirdparty/basalt-headers | 2 +- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/include/basalt/hash_bow/hash_bow.h b/include/basalt/hash_bow/hash_bow.h index f2faab3..c034edd 100644 --- a/include/basalt/hash_bow/hash_bow.h +++ b/include/basalt/hash_bow/hash_bow.h @@ -72,7 +72,7 @@ class HashBow { const int64_t* max_t_ns = nullptr) const { results.clear(); - std::unordered_map> scores; + std::unordered_map scores; for (const auto& kv : bow_vector) { const auto range_it = inverted_index.find(kv.first); diff --git a/include/basalt/optimization/accumulator.h b/include/basalt/optimization/accumulator.h index 420cc66..94d90b6 100644 --- a/include/basalt/optimization/accumulator.h +++ b/include/basalt/optimization/accumulator.h @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #if defined(BASALT_USE_CHOLMOD) @@ -256,14 +257,10 @@ class SparseHashAccumulator { inline size_t operator()(const KeyT& c) const { size_t seed = 0; for (int i = 0; i < 4; i++) { - hash_combine(seed, std::hash()(c[i])); + hash_combine(seed, c[i]); } return seed; } - - inline void hash_combine(std::size_t& seed, std::size_t value) const { - seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2); - } }; std::unordered_map hash_map; diff --git a/include/basalt/utils/common_types.h b/include/basalt/utils/common_types.h index cc0c07e..48678c0 100644 --- a/include/basalt/utils/common_types.h +++ b/include/basalt/utils/common_types.h @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include namespace basalt { @@ -268,6 +269,7 @@ using ImageProjections = std::map; /// inlier projections indexed per track using TrackProjections = std::unordered_map>; + } // namespace basalt namespace cereal { @@ -286,20 +288,17 @@ template void serialize(Archive& ar, basalt::MatchData& c) { ar(c.T_i_j, c.matches, c.inliers); } + } // namespace cereal namespace std { -inline void hash_combine(std::size_t& seed, std::size_t value) { - seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2); -} - template <> struct hash { size_t operator()(const basalt::TimeCamId& x) const { size_t seed = 0; - hash_combine(seed, std::hash()(x.frame_id)); - hash_combine(seed, std::hash()(x.cam_id)); + basalt::hash_combine(seed, x.frame_id); + basalt::hash_combine(seed, x.cam_id); return seed; } }; @@ -309,22 +308,12 @@ struct hash> { size_t operator()( const std::pair& x) const { size_t seed = 0; - hash_combine(seed, std::hash()(x.first.frame_id)); - hash_combine(seed, std::hash()(x.first.cam_id)); - hash_combine(seed, std::hash()(x.second.frame_id)); - hash_combine(seed, std::hash()(x.second.cam_id)); + basalt::hash_combine(seed, x.first.frame_id); + basalt::hash_combine(seed, x.first.cam_id); + basalt::hash_combine(seed, x.second.frame_id); + basalt::hash_combine(seed, x.second.cam_id); return seed; } }; + } // namespace std - -namespace tbb { - -template <> -struct tbb_hash : public std::hash {}; - -template <> -struct tbb_hash> - : public std::hash> {}; - -} // namespace tbb diff --git a/thirdparty/basalt-headers b/thirdparty/basalt-headers index b068d7a..d6a1bc2 160000 --- a/thirdparty/basalt-headers +++ b/thirdparty/basalt-headers @@ -1 +1 @@ -Subproject commit b068d7a967af52fb3c8e261829b16a2403845ef8 +Subproject commit d6a1bc24376a67b11bd13e44cf75c1e4351f359a