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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
getStateInternal()
Creates a snapshot of the RNG state.long
next()
static int
numberOfSubcycleGenerators()
protected void
setStateInternal(byte[] s)
Resets the RNG to the givenstate
.String
toString()
-
Methods inherited from class org.apache.commons.rng.core.source64.LongProvider
nextBoolean, nextInt, nextLong, resetCachedState
-
Methods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, extendSeed, extendSeed, fillState, fillState, restoreState, saveState, splitStateInternal
-
-
-
-
Constructor Detail
-
TwoCmres
public TwoCmres(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:
IllegalArgumentException
- ifi == j
.IndexOutOfBoundsException
- ifi < 0
ori >= numberOfSubcycleGenerators()
.IndexOutOfBoundsException
- ifj < 0
orj >= numberOfSubcycleGenerators()
.
-
-
Method Detail
-
next
public long next()
- Returns:
- the next random value.
-
toString
public String toString()
- Overrides:
toString
in classBaseProvider
-
numberOfSubcycleGenerators
public static int numberOfSubcycleGenerators()
- Returns:
- the number of subcycle generators.
-
getStateInternal
protected byte[] getStateInternal()
Creates a snapshot of the RNG state.- Overrides:
getStateInternal
in classLongProvider
- Returns:
- the internal state.
-
setStateInternal
protected void setStateInternal(byte[] s)
Resets the RNG to the givenstate
.- Overrides:
setStateInternal
in classLongProvider
- Parameters:
s
- State (previously obtained by a call toBaseProvider.getStateInternal()
).- See Also:
BaseProvider.checkStateSize(byte[],int)
-
-