Class DotyHumphreySmallFastCounting64
java.lang.Object
org.apache.commons.rng.core.BaseProvider
org.apache.commons.rng.core.source64.LongProvider
org.apache.commons.rng.core.source64.DotyHumphreySmallFastCounting64
- All Implemented Interfaces:
RandomLongSource, RestorableUniformRandomProvider, UniformRandomProvider
Implement the Small, Fast, Counting (SFC) 64-bit generator of Chris Doty-Humphrey.
The original source is the PractRand test suite by the same author.
The state size is 256-bits; the period is a minimum of 264 and an average of approximately 2255.
- Since:
- 1.3
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDotyHumphreySmallFastCounting64(long[] seed) Creates an instance with the given seed. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Creates a snapshot of the RNG state.final longnext()Return the next random value.private voidsetSeedInternal(long[] seed) Seeds the RNG.protected voidsetStateInternal(byte[] s) Resets the RNG to the givenstate.Methods inherited from class LongProvider
nextBoolean, nextInt, nextLong, resetCachedStateMethods inherited from class 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 long aState a. -
b
private long bState b. -
c
private long cState c. -
counter
private long counterCounter.
-
-
Constructor Details
-
DotyHumphreySmallFastCounting64
public DotyHumphreySmallFastCounting64(long[] 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(long[] seed) Seeds the RNG.- Parameters:
seed- Seed.
-
next
public final long next()Return the next random value.- Returns:
- the next random value.
-
getStateInternal
protected byte[] getStateInternal()Creates a snapshot of the RNG state.- Overrides:
getStateInternalin classLongProvider- Returns:
- the internal state.
-
setStateInternal
protected void setStateInternal(byte[] s) Resets the RNG to the givenstate.- Overrides:
setStateInternalin classLongProvider- Parameters:
s- State (previously obtained by a call toBaseProvider.getStateInternal()).- See Also:
-