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
public class TwoCmres extends LongProvider
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
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description protected byte[]getStateInternal()Creates a snapshot of the RNG state.longnext()static intnumberOfSubcycleGenerators()protected voidsetStateInternal(byte[] s)Resets the RNG to the givenstate.java.lang.StringtoString()Methods inherited from class org.apache.commons.rng.core.source64.LongProvider
nextBoolean, nextBytes, nextBytes, nextDouble, nextFloat, nextInt, nextLongMethods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, fillState, fillState, nextInt, nextLong, restoreState, saveState, splitStateInternal
-
Constructor Details
-
TwoCmres
public TwoCmres(java.lang.Integer seed)Creates a new instance.- Parameters:
seed- Seed.
-
TwoCmres
public TwoCmres(java.lang.Integer seed, int i, int j)Creates a new instance.- Parameters:
seed- Seed.i- Table entry for first subcycle generator.j- Table entry for second subcycle generator.- Throws:
java.lang.IllegalArgumentException- ifi == j.java.lang.IndexOutOfBoundsException- ifi < 0ori >= numberOfSubcycleGenerators().java.lang.IndexOutOfBoundsException- ifj < 0orj >= numberOfSubcycleGenerators().
-
-
Method Details
-
next
public long next()- Returns:
- the next random value.
-
toString
public java.lang.String toString()- Overrides:
toStringin classBaseProvider
-
numberOfSubcycleGenerators
public static int numberOfSubcycleGenerators()- 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:
BaseProvider.checkStateSize(byte[],int)
-