gmp_libgmp_randinit_lc_2exp Method |
Initialize state with a linear congruential algorithm X = (aX + c) mod 2^m2exp.
Namespace:
Math.Gmp.Native
Assembly:
Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax public static void gmp_randinit_lc_2exp(
gmp_randstate_t state,
mpz_t a,
uint c,
mp_bitcnt_t m2exp
)
Public Shared Sub gmp_randinit_lc_2exp (
state As gmp_randstate_t,
a As mpz_t,
c As UInteger,
m2exp As mp_bitcnt_t
)
public:
static void gmp_randinit_lc_2exp(
gmp_randstate_t^ state,
mpz_t^ a,
unsigned int c,
mp_bitcnt_t m2exp
)
static member gmp_randinit_lc_2exp :
state : gmp_randstate_t *
a : mpz_t *
c : uint32 *
m2exp : mp_bitcnt_t -> unit
Parameters
- state
- Type: Math.Gmp.Nativegmp_randstate_t
The state to initialize. - a
- Type: Math.Gmp.Nativempz_t
Parameter of the algorithm. - c
- Type: SystemUInt32
Parameter of the algorithm. - m2exp
- Type: Math.Gmp.Nativemp_bitcnt_t
Parameter of the algorithm.
Remarks
The low bits of X in this algorithm are not very random.
The least significant bit will have a period no more than 2, and the second bit
no more than 4, etc. For this reason only the high half of each X is actually used.
When a random number of more than m2exp / 2 bits is to be generated,
multiple iterations of the recurrence are used and the results concatenated.
Examples
gmp_randstate_t state = new gmp_randstate_t();
mpz_t a = new mpz_t();
gmp_lib.mpz_init_set_ui(a, 100000U);
gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300);
gmp_lib.gmp_randclear(state);
gmp_lib.mpz_clear(a);
Dim state As New gmp_randstate_t()
Dim a As New mpz_t()
gmp_lib.mpz_init_set_ui(a, 100000UI)
gmp_lib.gmp_randinit_lc_2exp(state, a, 13, 300)
gmp_lib.gmp_randclear(state)
gmp_lib.mpz_clear(a)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also