|
ADS
Algorithms and Data Structures
|
the hash code of an object of \( r \) parts of section 5.3.2 of Morin's book, \( h( x_0 , \ldots , x_{r-1} ) = ( ( z \sum_i z_i x_i ) \bmod 2^{2w} ) \operatorname{div} 2^w \) with \( w = 64 \), the \( z_i \) random words and \( z \) a random odd integer of \( 2 w \) bits: two distinct tuples collide with probability at most \( 3 / 2^w \) (Theorem 5.3 of Morin's book), where the XOR or the sum of the parts make large sets of tuples collide (exercises 5.7 to 5.9) More...
#include <ADS/dictionary/UniversalHashing.h>
Public member functions | |
| CompoundHash (std::size_t r, std::uint64_t seed=1) | |
| a function of tuples of \( r \) words, its multipliers from the seed | |
| std::uint64_t | operator() (std::span< const std::uint64_t > x) const |
| \( h( x_0 , \ldots , x_{r-1} ) \), in \( O( r ) \) time | |
| std::size_t | parts (void) const |
| the number \( r \) of parts | |
the hash code of an object of \( r \) parts of section 5.3.2 of Morin's book, \( h( x_0 , \ldots , x_{r-1} ) = ( ( z \sum_i z_i x_i ) \bmod 2^{2w} ) \operatorname{div} 2^w \) with \( w = 64 \), the \( z_i \) random words and \( z \) a random odd integer of \( 2 w \) bits: two distinct tuples collide with probability at most \( 3 / 2^w \) (Theorem 5.3 of Morin's book), where the XOR or the sum of the parts make large sets of tuples collide (exercises 5.7 to 5.9)
|
explicit |
a function of tuples of \( r \) words, its multipliers from the seed
|
nodiscard |
\( h( x_0 , \ldots , x_{r-1} ) \), in \( O( r ) \) time
In pseudocode (section 5.3.2 of Morin's book), on integers of \( 2 w \) bits:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ h( x_0 , \ldots , x_{r-1} ) \cr 2 & \quad s \gets 0 \cr 3 & \quad \textbf{for}\ i \gets 0\ \textbf{to}\ r - 1\ \textbf{do} \ s \gets ( s + z_i x_i ) \bmod 2^{2w} \cr 4 & \quad \textbf{return}\ ( z s \bmod 2^{2w} ) \operatorname{div} 2^w \end{array}} \]
|
inlinenodiscard |
the number \( r \) of parts