Problem with gmp_randinit_set
gmpdiscuss at formauri.es
Wed Feb 15 02:07:28 UTC 2017
Torbjörn Granlund wrote, On 2017-02-15 00:45:
> Pedro Gimeno <gmpdiscuss at formauri.es> writes:
> Torbjörn Granlund wrote, On 2017-02-14 01:41:
> > One can change Mersenne_Twister_Generator_Noseed to
> > Mersenne_Twister_Generator to fix this (and move __gmp_randiset_mt to
> > randmts.c as mandated by Mersenne_Twister_Generator's scope), and then
> > your code supposedly runs without a crash. But I don't see why one ever
> > wants Mersenne_Twister_Generator_Noseed, which suggests my understanding
> > of this code is very poor indeed.
> It's been about 15 years ago, but my recollection is that the rationale behind the _Noseed version was to avoid a dependency on randmts.c, and it seems I neglected to consider this use case.
> I agree with your fix.
> I realised a serious flaw with that fix; it introduces a dependency from
> mpn_random* to mpz. That's not OK, I'm afraid.
Ah, yes, that was a problem that needed to be avoided. Thanks for looking into this.
One possible fix would be to resurrect my patch for a different seeding routine, which was based on the xxtea encryption algorithm. That one is faster and uses far less mpz code, and I think it wouldn't be difficult to get rid of mpz usage totally. It was written in or before 2006, I believe, and I rebased it in 2009, so merging it with current code might be troublesome. Fortunately, that part of the code doesn't seem to have changed a lot.
The problem is that it wouldn't be a good idea to apply that patch to stable versions, because it causes the sequences to be different.
I've attached the patch as it was in 2009 (against revision af3f365253c5).
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 23789 bytes
Desc: not available
More information about the gmp-bugs