See section Random Number Functions for a discussion on how to choose the initial seed value passed to these functions.
alg denotes what algorithm to use for random number generation. Use one of
gmp_randinit
functions.
If alg is 0 or GMP_RAND_ALG_DEFAULT, the default algorithm is used. The default algorithm is typically a fast algorithm like the linear congruential and requires a third size argument (see GMP_RAND_ALG_LC).
When you're done with a state variable, call gmp_randclear
to deallocate any memory allocated by this function.
gmp_randinit
may set the following bits in gmp_errno:
Initialize random state variable state with given linear congruential scheme.
Parameters a, c, and m2exp are the multiplier, adder, and modulus for the linear congruential scheme to use, respectively. The modulus is expressed as a power of 2, so that @ifnottex m = 2^m2exp.
The least significant bits of a random number generated by the linear congruential algorithm where the modulus is a power of two are not very random. Therefore, the lower half of a random number generated by an LC scheme initialized with this function is discarded. Thus, the size of a random number is m2exp / 2 (rounded upwards) bits when this function has been used for initializing the random state.
When you're done with a state variable, call gmp_randclear
to deallocate any memory allocated by this function.
Set the initial seed value.
Parameter seed is the initial random seed. The function
gmp_randseed_ui
takes the seed as an unsigned long int rather
than as an mpz_t.
gmp_randstate_t
variables when you are done with
them.
Go to the first, previous, next, last section, table of contents.