Class DotyHumphreySmallFastCounting32
java.lang.Object
org.apache.commons.rng.core.BaseProvider
org.apache.commons.rng.core.source32.IntProvider
org.apache.commons.rng.core.source32.DotyHumphreySmallFastCounting32
- All Implemented Interfaces:
RandomIntSource
,RestorableUniformRandomProvider
,UniformRandomProvider
Implement the Small, Fast, Counting (SFC) 32-bit generator of Chris Doty-Humphrey.
The original source is the PractRand test suite by the same author.
The state size is 128-bits; the period is a minimum of 232 and an average of approximately 2127.
- Since:
- 1.3
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDotyHumphreySmallFastCounting32
(int[] seed) Creates an instance with the given seed. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
Creates a snapshot of the RNG state.final int
next()
Return the next random value.private void
setSeedInternal
(int[] seed) Seeds the RNG.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
-
Field Details
-
SEED_SIZE
private static final int SEED_SIZESize of the seed.- See Also:
-
a
private int aState a. -
b
private int bState b. -
c
private int cState c. -
counter
private int counterCounter.
-
-
Constructor Details
-
DotyHumphreySmallFastCounting32
public DotyHumphreySmallFastCounting32(int[] seed) Creates an instance with the given seed.- Parameters:
seed
- Initial seed. If the length is larger than 3, only the first 3 elements will be used; if smaller, the remaining elements will be automatically set.
-
-
Method Details
-
setSeedInternal
private void setSeedInternal(int[] seed) Seeds the RNG.- Parameters:
seed
- Seed.
-
next
public final int next()Return the next random value.- Returns:
- the next random value.
-
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:
-