public abstract class AbstractWell extends BitsStreamGenerator implements Serializable
This generator is described in a paper by François Panneton, Pierre L'Ecuyer and Makoto Matsumoto Improved Long-Period Generators Based on Linear Recurrences Modulo 2 ACM Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper are in wellrng-errata.txt.
Modifier and Type | Field and Description |
---|---|
protected int[] |
i1
Index indirection table giving for each index the value index + m1 taking table size into account.
|
protected int[] |
i2
Index indirection table giving for each index the value index + m2 taking table size into account.
|
protected int[] |
i3
Index indirection table giving for each index the value index + m3 taking table size into account.
|
protected int |
index
Current index in the bytes pool.
|
protected int[] |
iRm1
Index indirection table giving for each index its predecessor taking table size into account.
|
protected int[] |
iRm2
Index indirection table giving for each index its second predecessor taking table size into account.
|
protected int[] |
v
Bytes pool.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractWell(int k,
int m1,
int m2,
int m3)
Creates a new random number generator.
|
protected |
AbstractWell(int k,
int m1,
int m2,
int m3,
int seed)
Creates a new random number generator using a single int seed.
|
protected |
AbstractWell(int k,
int m1,
int m2,
int m3,
int[] seed)
Creates a new random number generator using an int array seed.
|
protected |
AbstractWell(int k,
int m1,
int m2,
int m3,
long seed)
Creates a new random number generator using a single long seed.
|
Modifier and Type | Method and Description |
---|---|
protected abstract int |
next(int bits)
Generate next pseudorandom number.
|
void |
setSeed(int seed)
Reinitialize the generator as if just built with the given int seed.
|
void |
setSeed(int[] seed)
Reinitialize the generator as if just built with the given int array seed.
|
void |
setSeed(long seed)
Reinitialize the generator as if just built with the given long seed.
|
clear, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong
protected int index
protected final int[] v
protected final int[] iRm1
protected final int[] iRm2
protected final int[] i1
protected final int[] i2
protected final int[] i3
protected AbstractWell(int k, int m1, int m2, int m3)
The instance is initialized using the current time plus the system identity hash code of this instance as the seed.
k
- number of bits in the pool (not necessarily a multiple of 32)m1
- first parameter of the algorithmm2
- second parameter of the algorithmm3
- third parameter of the algorithmprotected AbstractWell(int k, int m1, int m2, int m3, int seed)
k
- number of bits in the pool (not necessarily a multiple of 32)m1
- first parameter of the algorithmm2
- second parameter of the algorithmm3
- third parameter of the algorithmseed
- the initial seed (32 bits integer)protected AbstractWell(int k, int m1, int m2, int m3, int[] seed)
k
- number of bits in the pool (not necessarily a multiple of 32)m1
- first parameter of the algorithmm2
- second parameter of the algorithmm3
- third parameter of the algorithmseed
- the initial seed (32 bits integers array), if null
the seed of the generator will be related to the current timeprotected AbstractWell(int k, int m1, int m2, int m3, long seed)
k
- number of bits in the pool (not necessarily a multiple of 32)m1
- first parameter of the algorithmm2
- second parameter of the algorithmm3
- third parameter of the algorithmseed
- the initial seed (64 bits integer)public void setSeed(int seed)
The state of the generator is exactly the same as a new generator built with the same seed.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the initial seed (32 bits integer)public void setSeed(int[] seed)
The state of the generator is exactly the same as a new generator built with the same seed.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the initial seed (32 bits integers array). If null
the seed of the generator will be the system time plus the system identity
hash code of the instance.public void setSeed(long seed)
The state of the generator is exactly the same as a new generator built with the same seed.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the initial seed (64 bits integer)protected abstract int next(int bits)
This method is the core generation algorithm. It is used by all the public generation methods for the various
primitive types BitsStreamGenerator.nextBoolean()
, BitsStreamGenerator.nextBytes(byte[])
, BitsStreamGenerator.nextDouble()
, BitsStreamGenerator.nextFloat()
,
BitsStreamGenerator.nextGaussian()
, BitsStreamGenerator.nextInt()
, BitsStreamGenerator.next(int)
and BitsStreamGenerator.nextLong()
.
next
in class BitsStreamGenerator
bits
- number of random bits to produceCopyright © 2019 CNES. All Rights Reserved.