public class RandState
extends java.lang.Object
A RandState object wraps a gmp_randstate_t
GMP object, i.e.,
a state for pseudo-random number generation functions.
The state defines an algorithm and a current value state (that should be
seeded).
Constructor and Description |
---|
RandState()
Creates a random state with the default algorithm.
|
RandState(boolean b)
Creates a random state for a Mersenne Twister algorithm.
|
RandState(int size)
Creates a random state for a congruential algorithm.
|
RandState(Mpz a,
int c,
int m2exp)
Creates a random state for a congruential algorithm.
|
RandState(RandState op)
Creates a copy of the random state op.
|
Modifier and Type | Method and Description |
---|---|
protected void |
finalize()
Deallocates the GMP gmp_randstate_t object.
|
int |
randomBits(int n)
Returns an uniformly distributed random number of n bits
(i.e., in 0..2^n-1).
|
int |
randomInt(int n)
Returns an uniformly distributed random number in 0..n-1.
|
void |
Seed(int seed)
Sets an initial seed value for the state.
|
void |
Seed(Mpz seed)
Sets an initial seed value for the state.
|
public RandState()
public RandState(boolean b)
The boolean argument is not actually used. It is used to differentiate from the default algorithm constructor.
public RandState(Mpz a, int c, int m2exp)
X=(aX+c) mod 2^m2exp.
public RandState(int size)
The multiplicand and modulo are selected from a table to ensure that at least size bits of each value is used.
The maximum size currently supported is 128.
public RandState(RandState op)
protected void finalize()
finalize
in class java.lang.Object
public void Seed(Mpz seed)
public void Seed(int seed)
public int randomBits(int n)
n must be positive.
public int randomInt(int n)
n must be positive.