Hash function for mpz_class.

Vincent Diepeveen diep at xs4all.nl
Sat Jul 19 11:05:24 UTC 2014

Take a look at Zobrist type hashfunction, used widely in game tree search 
because of its high speed..

Make an array with random numbers, somehow lookup your classes element 
into the array and lookup every element uniquely into the array. All those 
resulting random numbers you just XOR resulting in 1 hash.

Very fast and incremental manner of hashing. Note that you CAN get 
collissions and you will need to deal with that yourself.

Important is to store really good random numbers. Many RNG's are not good 
enough as they just rotate and shift a little themselves giving quickly 
multilineair relationships causing more collissions.

The perfect solution to that is to wait for one specific morning at 3 AM, to randomly 
modify by hand the outputted RNG data a little. Then you have 
reasonable random numbers.


On Fri, 18 Jul 2014, Fernando Alberione wrote:

> Hello,
>   writing this mail because I need information on how to build a hash
> function for:
> std::unordered_set<mpz_class> set;
> Thanks!
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-discuss

More information about the gmp-discuss mailing list