Class AbstractWell
- java.lang.Object
-
- org.apache.commons.rng.core.BaseProvider
-
- org.apache.commons.rng.core.source32.IntProvider
-
- org.apache.commons.rng.core.source32.AbstractWell
-
- All Implemented Interfaces:
RandomIntSource
,RestorableUniformRandomProvider
,UniformRandomProvider
- Direct Known Subclasses:
Well1024a
,Well19937a
,Well44497a
,Well512a
public abstract class AbstractWell extends IntProvider
This abstract class implements the WELL class of pseudo-random number generator from François Panneton, Pierre L'Ecuyer and Makoto Matsumoto.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.
- Since:
- 1.0
- See Also:
- WELL Random number generator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractWell.IndexTable
Inner class used to store the indirection index table which is fixed for a given type of WELL class of pseudo-random number generator.
-
Field Summary
Fields Modifier and Type Field Description private static int
BLOCK_SIZE
Block size.protected int
index
Current index in the bytes pool.protected int[]
v
Bytes pool.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractWell(int k, int[] seed)
Creates an instance with the givenseed
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
calculateBlockCount(int k)
Calculate the number of 32-bits blocks.protected byte[]
getStateInternal()
Creates a snapshot of the RNG state.private void
setSeedInternal(int[] seed)
Initializes the generator with the givenseed
.protected void
setStateInternal(byte[] s)
Resets the RNG to the givenstate
.-
Methods inherited from class org.apache.commons.rng.core.source32.IntProvider
nextBoolean, nextBytes, nextBytes, nextBytesFill, nextDouble, nextInt, nextLong, resetCachedState
-
Methods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, extendSeed, extendSeed, fillState, fillState, restoreState, saveState, splitStateInternal, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.core.source32.RandomIntSource
next
-
-
-
-
Field Detail
-
BLOCK_SIZE
private static final int BLOCK_SIZE
Block size.- See Also:
- Constant Field Values
-
index
protected int index
Current index in the bytes pool.
-
v
protected final int[] v
Bytes pool.
-
-
Method Detail
-
getStateInternal
protected byte[] getStateInternal()
Creates a snapshot of the RNG state.- Overrides:
getStateInternal
in classIntProvider
- Returns:
- the internal state.
-
setStateInternal
protected void setStateInternal(byte[] s)
Resets the RNG to the givenstate
.- Overrides:
setStateInternal
in classIntProvider
- Parameters:
s
- State (previously obtained by a call toBaseProvider.getStateInternal()
).- See Also:
BaseProvider.checkStateSize(byte[],int)
-
setSeedInternal
private void setSeedInternal(int[] seed)
Initializes the generator with the givenseed
.- Parameters:
seed
- Seed. Cannot be null.
-
calculateBlockCount
private static int calculateBlockCount(int k)
Calculate the number of 32-bits blocks.- Parameters:
k
- Number of bits in the pool (not necessarily a multiple of 32).- Returns:
- the number of 32-bits blocks.
-
-