Skip to content

Commit

Permalink
Update beluga/include/beluga/algorithm/spatial_hash.hpp
Browse files Browse the repository at this point in the history
Co-authored-by: Nahuel Espinosa <[email protected]>
Signed-off-by: Gerardo Puga <[email protected]>
  • Loading branch information
glpuga and nahueespinosa authored Dec 28, 2023
1 parent f86206d commit bf7e723
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions beluga/include/beluga/algorithm/spatial_hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ constexpr std::size_t floor_and_fibo_hash(double value) {
// spread number information all through the 64 bits using the fibonacci hash
const auto div_hashed_value = kFib64 * unsigned_value;
// rotate bits to avoid aliasing between different values of I
const auto left_hash = (div_hashed_value << N * I);
if constexpr (N * I != 0) {
return left_hash | (div_hashed_value >> (64 - N * I));
const auto left_hash = (div_hashed_value << N * I);
const auto right_hash = (div_hashed_value >> (64 - N * I));
return left_hash | right_hash;
} else {
return left_hash;
return div_hashed_value;
}
}

Expand Down

0 comments on commit bf7e723

Please sign in to comment.