reproducibility of GMP random functions vs limb size and GMP version

Torbjorn Granlund tg at gmplib.org
Wed Sep 15 17:15:04 CEST 2010


Paul Zimmermann <Paul.Zimmermann at loria.fr> writes:

  Sage uses GMP random functions in a way that enables the user to access the
  GMP random seed:
  
  sage: set_random_seed(17)
  sage: ZZ.random_element()
  -2
  sage: set_random_seed(42)
  sage: ZZ.random_element()
  -31
  sage: set_random_seed(17)
  sage: ZZ.random_element()
  -2
  
  The MPFR random functions use the GMP random seed. However to ensure the user
  he/she will get the same results (for a given seed) whatever the limb size
  and/or the GMP version, we assume that the GMP random functions do not depend
  on the limb size nor the GMP version. This seems to hold, but it is not
  documented.
  
  Thus my question: please could you document this fact?

There is a general principle behind GMP: Functions' semantics do not
depend on the underlying hardware (unless explicitly documented).

I'm not sure if there is a good place to reiterate this specifically for
the PRG functions.  Adding a sentence like "The result computed by this
function does not depend on the word size of the computer on which GMP
is run" would be clutter, IMHO.

The obsolete PRGs (e.g. mpz_random, mpz_random2) might be somewhat
system dependent.  That's one of the reasons they were replaced with
better functions.

-- 
Torbjörn


More information about the gmp-devel mailing list