Class Philox4x64
- java.lang.Object
-
- org.apache.commons.rng.core.BaseProvider
-
- org.apache.commons.rng.core.source64.LongProvider
-
- org.apache.commons.rng.core.source64.Philox4x64
-
- All Implemented Interfaces:
org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider,RandomLongSource,org.apache.commons.rng.JumpableUniformRandomProvider,org.apache.commons.rng.LongJumpableUniformRandomProvider,org.apache.commons.rng.RestorableUniformRandomProvider,org.apache.commons.rng.UniformRandomProvider
public final class Philox4x64 extends LongProvider implements org.apache.commons.rng.LongJumpableUniformRandomProvider, org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
This class implements the Philox4x64 256-bit counter-based generator with 10 rounds.This is a member of the Philox family of generators. Memory footprint is 384 bits and the period is 2258.
Jumping in the sequence is essentially instantaneous. This generator provides both subsequences and arbitrary jumps for easy parallelization.
References:
- Salmon, J.K. et al (2011) Parallel Random Numbers: As Easy as 1,2,3.
- Since:
- 1.7
-
-
Constructor Summary
Constructors Constructor Description Philox4x64(long[] seed)Creates a new instance given 6 long numbers containing, key (first two longs) and the counter (next 4 longs, low bits = first long).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]getStateInternal()Creates a snapshot of the RNG state.org.apache.commons.rng.UniformRandomProviderjump()org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProviderjump(double distance)org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProviderjumpPowerOfTwo(int logDistance)Stream<org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider>jumps(double distance)org.apache.commons.rng.JumpableUniformRandomProviderlongJump()longnext()Return the next random value.protected voidsetStateInternal(byte[] s)Resets the RNG to the givenstate.-
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, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
jumps
-
Methods inherited from interface org.apache.commons.rng.LongJumpableUniformRandomProvider
longJumps, longJumps
-
Methods inherited from interface org.apache.commons.rng.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
-
-
-
-
Constructor Detail
-
Philox4x64
public Philox4x64(long[] seed)
Creates a new instance given 6 long numbers containing, key (first two longs) and the counter (next 4 longs, low bits = first long). The counter is not scrambled and may be used to create contiguous blocks with size a multiple of 4 longs. For example, setting seed[2] = 1 is equivalent to start with seed[2]=0 and callingnext()4 times.- Parameters:
seed- Array of size 6 defining key0,key1,counter0,counter1,counter2,counter3. If the size is smaller, zero values are assumed.
-
-
Method Detail
-
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)
-
next
public long next()
Return the next random value.- Specified by:
nextin interfaceRandomLongSource- Returns:
- the next random value.
-
jump
public org.apache.commons.rng.UniformRandomProvider jump()
The jump size is the equivalent of 2130 calls to
nextLong(). It can provide up to 2128 non-overlapping subsequences.- Specified by:
jumpin interfaceorg.apache.commons.rng.JumpableUniformRandomProvider
-
longJump
public org.apache.commons.rng.JumpableUniformRandomProvider longJump()
The jump size is the equivalent of 2194 calls to
nextLong(). It can provide up to 264 non-overlapping subsequences of length 2194; each subsequence can provide up to 264 non-overlapping subsequences of length 2130 using thejump()method.- Specified by:
longJumpin interfaceorg.apache.commons.rng.LongJumpableUniformRandomProvider
-
jump
public org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider jump(double distance)
- Specified by:
jumpin interfaceorg.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
-
jumpPowerOfTwo
public org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider jumpPowerOfTwo(int logDistance)
- Specified by:
jumpPowerOfTwoin interfaceorg.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
-
-