Class Philox4x32

  • All Implemented Interfaces:
    org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider, RandomIntSource, org.apache.commons.rng.JumpableUniformRandomProvider, org.apache.commons.rng.LongJumpableUniformRandomProvider, org.apache.commons.rng.RestorableUniformRandomProvider, org.apache.commons.rng.UniformRandomProvider

    public final class Philox4x32
    extends IntProvider
    implements org.apache.commons.rng.LongJumpableUniformRandomProvider, org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
    This class implements the Philox4x32 128-bit counter-based generator with 10 rounds.

    This is a member of the Philox family of generators. Memory footprint is 192 bits and the period is 2130.

    Jumping in the sequence is essentially instantaneous. This generator provides both subsequences and arbitrary jumps for easy parallelization.

    References:

    1. Salmon, J.K. et al (2011) Parallel Random Numbers: As Easy as 1,2,3.
    Since:
    1.7
    • Constructor Detail

      • Philox4x32

        public Philox4x32​(int[] seed)
        Creates a new instance based on an array of int containing, key (first two ints) and the counter (next 4 ints, low bits = first int). The counter is not scrambled and may be used to create contiguous blocks with size a multiple of 4 ints. For example, setting seed[2] = 1 is equivalent to start with seed[2]=0 and calling next() 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

      • next

        public int next()
        Return the next random value.
        Specified by:
        next in interface RandomIntSource
        Returns:
        the next random value.
      • jump

        public org.apache.commons.rng.UniformRandomProvider jump()

        The jump size is the equivalent of 266 calls to nextInt(). It can provide up to 264 non-overlapping subsequences.

        Specified by:
        jump in interface org.apache.commons.rng.JumpableUniformRandomProvider
      • longJump

        public org.apache.commons.rng.JumpableUniformRandomProvider longJump()

        The jump size is the equivalent of 298 calls to nextLong(). It can provide up to 232 non-overlapping subsequences of length 298; each subsequence can provide up to 232 non-overlapping subsequences of length 266 using the jump() method.

        Specified by:
        longJump in interface org.apache.commons.rng.LongJumpableUniformRandomProvider
      • jump

        public org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider jump​(double distance)
        Specified by:
        jump in interface org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
      • jumpPowerOfTwo

        public org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider jumpPowerOfTwo​(int logDistance)
        Specified by:
        jumpPowerOfTwo in interface org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
      • jumps

        public Stream<org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider> jumps​(double distance)
        Specified by:
        jumps in interface org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider