hashing/std:less on mpz

Marc Glisse marc.glisse at normalesup.org
Thu Oct 8 11:30:13 CEST 2009


On Thu, 8 Oct 2009, Andrey Vul wrote:

> Is there a way to hash mpz types into a operator< -compatible way?
> I want to memoize the Ackermann function by using std::map<pr,mpz_class>, where
> struct pr { mpz_class x, y;
> bool operator<(pr& o) {

you are missing two "const" here.

> if (x==0.x)

s/0/o/

> return y < o.y;
> else
> return x < o.x;
> };
>
> Is there a gmp function for comparing mpz to mpz?

I don't understand what you are asking for. As you have seen, operator< 
can be used with mpz_class. Do you mean you want to replace your std::map 
(which should work fine) with a hash_map?

Using a hashing function on GMP types is a topic that comes regularly 
here, the archives immediatly show discussions in 2004 and 2005 at least.

-- 
Marc Glisse


More information about the gmp-discuss mailing list