84 [[nodiscard]]
static uint64_t
hash64(
const T & val)
noexcept
86 if constexpr (
sizeof(size_t) >= 8)
87 return static_cast<uint64_t
>(
murmur3hash(val, 0x9e3779b9UL));
90 static_cast<uint64_t
>(
murmur3hash(val, 0x9e3779b9UL)) & 0xffffffffULL;
92 static_cast<uint64_t
>(
murmur3hash(val, 0x85ebca6bUL)) & 0xffffffffULL;
93 return (hi << 32) | lo;
107 void update(
const T & val,
const double weight = 1.0)
109 const uint64_t hash =
hash64(val);
128 template <
typename Itor>
133 update((*beg).first, (*beg).second);
141 uint64_t fingerprint = 0;
144 fingerprint |= (
static_cast<uint64_t
>(1) << i);
152 [[nodiscard]]
static double similarity(
const uint64_t f1,
const uint64_t f2)
noexcept
154 const int distance = std::popcount(f1 ^ f2);
155 return 1.0 - (
static_cast<double>(distance) /
static_cast<double>(
FINGERPRINT_SIZE));
Exception handling system with formatted messages for Aleph-w.
Simple dynamic array with automatic resizing and functional operations.
SimHash fingerprint generator.
static constexpr size_t FINGERPRINT_SIZE
Number of bits in the SimHash fingerprint (always 64).
static uint64_t hash64(const T &val) noexcept
Compute a 64-bit hash value from a feature.
SimHash()
Construct SimHash accumulator.
void update(const T &val, const double weight=1.0)
Add a feature to the set.
void update(Itor beg, const Itor &end)
Add all features in a range to the SimHash accumulator.
static double similarity(const uint64_t f1, const uint64_t f2) noexcept
Estimate similarity with another fingerprint.
void clear()
Reset the accumulator.
Array< double > v_
Accumulator vector for each bit.
uint64_t get_fingerprint() const noexcept
Returns the fingerprint.
Standard hash functions for Aleph types.
Main namespace for Aleph-w library functions.
std::decay_t< typename HeadC::Item_Type > T
size_t murmur3hash(const Key &key, std::uint32_t seed)
Dynamic array container with automatic resizing.