Class TwoCmres
java.lang.Object
org.apache.commons.rng.core.BaseProvider
org.apache.commons.rng.core.source64.LongProvider
org.apache.commons.rng.core.source64.TwoCmres
- All Implemented Interfaces:
RandomLongSource,RestorableUniformRandomProvider,UniformRandomProvider
Random number generator designed by Mark D. Overton.
It is one of the many generators described by the author in the following article series:
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classSubcycle generator. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final TwoCmres.Cmres.FactoryFactory of instances of this class.private static final StringError message.private static final byteA small positive integer.private final TwoCmres.CmresFirst subcycle generator.private longState of first subcycle generator.private final TwoCmres.CmresSecond subcycle generator.private longState of second subcycle generator. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTwoCmres(int seed, TwoCmres.Cmres x, TwoCmres.Cmres y) Creates a new instance.Creates a new instance.Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Creates a snapshot of the RNG state.longnext()Return the next random value.static intGet the number of subcycle generators.private voidsetSeedInternal(int seed) protected voidsetStateInternal(byte[] s) Resets the RNG to the givenstate.toString()Methods inherited from class org.apache.commons.rng.core.source64.LongProvider
nextBoolean, nextInt, nextLong, resetCachedStateMethods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, extendSeed, extendSeed, fillState, fillState, restoreState, saveState, splitStateInternal
-
Field Details
-
INTERNAL_ERROR_MSG
Error message.- See Also:
-
SEED_GUARD
private static final byte SEED_GUARDA small positive integer.- See Also:
-
FACTORY
Factory of instances of this class. Singleton. -
x
First subcycle generator. -
y
Second subcycle generator. -
xx
private long xxState of first subcycle generator. -
yy
private long yyState of second subcycle generator.
-
-
Constructor Details
-
TwoCmres
Creates a new instance.- Parameters:
seed- Initial seed.x- First subcycle generator.y- Second subcycle generator.
-
TwoCmres
Creates a new instance.- Parameters:
seed- Seed.
-
TwoCmres
Creates a new instance.- Parameters:
seed- Seed.i- Table entry for first subcycle generator.j- Table entry for second subcycle generator.- Throws:
IllegalArgumentException- ifi == j.IndexOutOfBoundsException- ifi < 0ori >= numberOfSubcycleGenerators().IndexOutOfBoundsException- ifj < 0orj >= numberOfSubcycleGenerators().
-
-
Method Details
-
next
public long next()Return the next random value.- Returns:
- the next random value.
-
toString
- Overrides:
toStringin classBaseProvider
-
numberOfSubcycleGenerators
public static int numberOfSubcycleGenerators()Get the number of subcycle generators.- Returns:
- the number of subcycle generators.
-
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:
-
setSeedInternal
private void setSeedInternal(int seed) - Parameters:
seed- Seed.
-