GNU Info

Info Node: (gmp.info)Integer Random Numbers

(gmp.info)Integer Random Numbers


Next: Miscellaneous Integer Functions Prev: I/O of Integers Up: Integer Functions
Enter node , (file) or (file)node

Random Number Functions
=======================

   The random number functions of GMP come in two groups; older function
that rely on a global state, and newer functions that accept a state
parameter that is read and modified.  Please see the Note: Random
Number Functions for more information on how to use and not to use
random number functions.

 - Function: void mpz_urandomb (mpz_t ROP, gmp_randstate_t STATE,
          unsigned long int N)
     Generate a uniformly distributed random integer in the range 0 to
     2^N-1, inclusive.

     The variable STATE must be initialized by calling one of the
     `gmp_randinit' functions (Note: Random State Initialization)
     before invoking this function.

 - Function: void mpz_urandomm (mpz_t ROP, gmp_randstate_t STATE, mpz_t
          N)
     Generate a uniform random integer in the range 0 to N-1, inclusive.

     The variable STATE must be initialized by calling one of the
     `gmp_randinit' functions (Note: Random State Initialization)
     before invoking this function.

 - Function: void mpz_rrandomb (mpz_t ROP, gmp_randstate_t STATE,
          unsigned long int N)
     Generate a random integer with long strings of zeros and ones in
     the binary representation.  Useful for testing functions and
     algorithms, since this kind of random numbers have proven to be
     more likely to trigger corner-case bugs.  The random number will
     be in the range 0 to 2^N-1, inclusive.

     The variable STATE must be initialized by calling one of the
     `gmp_randinit' functions (Note: Random State Initialization)
     before invoking this function.

 - Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE)
     Generate a random integer of at most MAX_SIZE limbs.  The generated
     random number doesn't satisfy any particular requirements of
     randomness.  Negative random numbers are generated when MAX_SIZE
     is negative.

     This function is obsolete.  Use `mpz_urandomb' or `mpz_urandomm'
     instead.

 - Function: void mpz_random2 (mpz_t ROP, mp_size_t MAX_SIZE)
     Generate a random integer of at most MAX_SIZE limbs, with long
     strings of zeros and ones in the binary representation.  Useful
     for testing functions and algorithms, since this kind of random
     numbers have proven to be more likely to trigger corner-case bugs.
     Negative random numbers are generated when MAX_SIZE is negative.

     This function is obsolete.  Use `mpz_rrandomb' instead.


automatically generated by info2www version 1.2.2.9