Hash functions

Kevin Ryde user42 at zip.com.au
Thu May 6 00:20:35 CEST 2004


Piotr Wyderski <wyderski at ii.uni.wroc.pl> writes:
>
> unsigned int mpX_hash(mpX_t p), where X is one of {z,f,q}.

A difficulty would be what algorithm to pick, it'd affect what sort of
values might hash together, and what would be certain of being
distinct.  Perhaps there should be a "modulus" to request a value in a
given range too.  Would also need to think whether results should be
the same on all systems (limb size independent) and whether to remain
fixed across gmp versions.

>         static inline unsigned int hash(const mpf_class& p) {

I guess you might want to work the exponent into it too.

>                 h ^= p.get_mpf_t()->_mp_d[i];

Don't forget a limb can be a long long.


More information about the gmp-discuss mailing list