Class AbstractL64
java.lang.Object
org.apache.commons.rng.core.BaseProvider
org.apache.commons.rng.core.source64.LongProvider
org.apache.commons.rng.core.source64.AbstractL64
- All Implemented Interfaces:
RandomLongSource, JumpableUniformRandomProvider, LongJumpableUniformRandomProvider, RestorableUniformRandomProvider, UniformRandomProvider
- Direct Known Subclasses:
AbstractL64X128, L64X1024Mix, L64X256Mix
This abstract class is a base for algorithms from the LXM family of
generators with a 64-bit LCG sub-generator. The class implements
the jump functions.
- Since:
- 1.5
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractL64(long[] seed) Creates a new instance.AbstractL64(long seed0, long seed1) Creates a new instance using a 2 element seed.AbstractL64(AbstractL64 source) Creates a copy instance. -
Method Summary
Modifier and TypeMethodDescription(package private) abstract AbstractL64copy()Create a copy.protected byte[]Creates a snapshot of the RNG state.jump()Creates a copy of the UniformRandomProvider and then retreats the state of the current instance.longJump()Creates a copy of the UniformRandomProvider and then retreats the state of the current instance.private voidsetState(long[] state) Copies the state into the generator state.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, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface JumpableUniformRandomProvider
jumps, jumpsMethods inherited from interface LongJumpableUniformRandomProvider
longJumps, longJumpsMethods inherited from interface RandomLongSource
nextMethods inherited from interface UniformRandomProvider
doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, nextBoolean, nextBytes, nextBytes, nextDouble, nextDouble, nextDouble, nextFloat, nextFloat, nextFloat, nextInt, nextInt, nextInt, nextLong, nextLong, nextLong
-
Field Details
-
SEED_SIZE
private static final int SEED_SIZESize of the seed vector.- See Also:
-
la
protected long laPer-instance LCG additive parameter (must be odd). Cannot be final to support RestorableUniformRandomProvider. -
ls
protected long lsState of the LCG generator.
-
-
Constructor Details
-
AbstractL64
AbstractL64(long[] seed) Creates a new instance.- Parameters:
seed- Initial seed. If the length is larger than 2, only the first 2 elements will be used; if smaller, the remaining elements will be automatically set.The 1st element is used to set the LCG increment; the least significant bit is set to odd to ensure a full period LCG. The 2nd element is used to set the LCG state.
-
AbstractL64
AbstractL64(long seed0, long seed1) Creates a new instance using a 2 element seed.The 1st element is used to set the LCG increment; the least significant bit is set to odd to ensure a full period LCG. The 2nd element is used to set the LCG state.
- Parameters:
seed0- Initial seed element 0.seed1- Initial seed element 1.
-
AbstractL64
-
-
Method Details
-
setState
private void setState(long[] state) Copies the state into the generator state.- Parameters:
state- the new state
-
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:
-
jump
Creates a copy of the UniformRandomProvider and then retreats the state of the current instance. The copy is returned.The jump is performed by advancing the state of the LCG sub-generator by 1 cycle. The XBG state is unchanged.
- Specified by:
jumpin interfaceJumpableUniformRandomProvider- Returns:
- A copy of the current state.
-
longJump
Creates a copy of the UniformRandomProvider and then retreats the state of the current instance. The copy is returned.The jump is performed by advancing the state of the LCG sub-generator by 232 cycles. The XBG state is unchanged.
- Specified by:
longJumpin interfaceLongJumpableUniformRandomProvider- Returns:
- A copy of the current state.
-
copy
-