From faa6a256c8801243a8b7e688f8006a01ece8d9e2 Mon Sep 17 00:00:00 2001 From: Ye Huanjie <330411311@qq.com> Date: Mon, 20 Jan 2025 23:00:10 +0800 Subject: [PATCH 1/2] speed_up_ppf_hash_search --- .../include/pcl/registration/ppf_registration.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/registration/include/pcl/registration/ppf_registration.h b/registration/include/pcl/registration/ppf_registration.h index fbb5ed39f93..6879eb672e5 100644 --- a/registration/include/pcl/registration/ppf_registration.h +++ b/registration/include/pcl/registration/ppf_registration.h @@ -67,11 +67,18 @@ class PCL_EXPORTS PPFHashMapSearch { std::size_t operator()(const HashKeyStruct& s) const noexcept { - const std::size_t h1 = std::hash{}(s.first); - const std::size_t h2 = std::hash{}(s.second.first); - const std::size_t h3 = std::hash{}(s.second.second.first); - const std::size_t h4 = std::hash{}(s.second.second.second); - return h1 ^ (h2 << 1) ^ (h3 << 2) ^ (h4 << 3); + /// RS hash function https://www.partow.net/programming/hashfunctions/index.html + std::size_t b_ = 378551; + std::size_t a_ = 63689; + std::size_t hash = 0; + hash = hash * a_ + s.first; + a_ = a_ * b_; + hash = hash * a_ + s.second.first; + a_ = a_ * b_; + hash = hash * a_ + s.second.second.first; + a_ = a_ * b_; + hash = hash * a_ + s.second.second.second; + return hash; } }; using FeatureHashMapType = From 9753648f223a43b99014fdcac532afa6ab0fe8ad Mon Sep 17 00:00:00 2001 From: YeHuanjie <41501835+YeHuanjie@users.noreply.github.com> Date: Mon, 20 Jan 2025 23:14:41 +0800 Subject: [PATCH 2/2] Update ppf_registration.h --- .../include/pcl/registration/ppf_registration.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/registration/include/pcl/registration/ppf_registration.h b/registration/include/pcl/registration/ppf_registration.h index 6879eb672e5..7962d0368b5 100644 --- a/registration/include/pcl/registration/ppf_registration.h +++ b/registration/include/pcl/registration/ppf_registration.h @@ -68,15 +68,15 @@ class PCL_EXPORTS PPFHashMapSearch { operator()(const HashKeyStruct& s) const noexcept { /// RS hash function https://www.partow.net/programming/hashfunctions/index.html - std::size_t b_ = 378551; - std::size_t a_ = 63689; + std::size_t b_ = 378551; + std::size_t a_ = 63689; std::size_t hash = 0; hash = hash * a_ + s.first; - a_ = a_ * b_; + a_ = a_ * b_; hash = hash * a_ + s.second.first; - a_ = a_ * b_; + a_ = a_ * b_; hash = hash * a_ + s.second.second.first; - a_ = a_ * b_; + a_ = a_ * b_; hash = hash * a_ + s.second.second.second; return hash; }