Problem with gmp_randinit_set

Pedro Gimeno gmpdiscuss at formauri.es
Fri Feb 17 23:42:07 UTC 2017


Niels Möller wrote, On 2017-02-17 20:01:
> nisse at lysator.liu.se (Niels Möller) writes:
> 
>> It shouldn't be too hard to rewrite randseed_mt to use mpn_powm, right?
>> Which probably didn't exist when the original version was written. 

I don't remember. I remember I used mpz_powm, and IIRC Kevin Ryde rewrote it to take advantage of the structure of the number.

> Or if we want to take advantage of the structure, we need an mpn
> function to reduce numbers modulo 2^19937 - 20023. The input seed is of
> arbitrary size, right?

Yes. Only seeds up to 2^19937-20028 inclusive are guaranteed to generate different sequences, though, and with the new seeding function, only up to 2^19936-1. I don't think it'd be a big deal to cut it out to 2^19936-1 now. Seeds bigger would generate different results, potentially breaking compatibility if these are used, but I don't think there's a big chance of that happening.

> How important is support for other limbsizes than 32 and 64 bits?

I'll leave that up to someone more acquainted with the architectures that GMP is ported to.

> We'd need special code to support artificially small limbs, where 20023
> doesn't fit in a limb.

I though you can't ever have limbs less than 16 bits. Are any of these in use?



More information about the gmp-bugs mailing list