Class L128X256Mix

    • Field Detail

      • XBG_STATE_SIZE

        private static final int XBG_STATE_SIZE
        Size of the XBG state vector.
        See Also:
        Constant Field Values
      • x0

        private long x0
        State 0 of the XBG.
      • x1

        private long x1
        State 1 of the XBG.
      • x2

        private long x2
        State 2 of the XBG.
      • x3

        private long x3
        State 3 of the XBG.
    • Constructor Detail

      • L128X256Mix

        public L128X256Mix​(long[] seed)
        Creates a new instance.
        Parameters:
        seed - Initial seed. If the length is larger than 8, only the first 8 elements will be used; if smaller, the remaining elements will be automatically set. A seed containing all zeros in the last four elements will create a non-functional XBG sub-generator and a low quality output with a period of 2128.

        The 1st and 2nd elements are used to set the LCG increment; the least significant bit is set to odd to ensure a full period LCG. The 3rd and 4th elements are used to set the LCG state.

      • L128X256Mix

        public L128X256Mix​(long seed0,
                           long seed1,
                           long seed2,
                           long seed3,
                           long seed4,
                           long seed5,
                           long seed6,
                           long seed7)
        Creates a new instance using an 8 element seed. A seed containing all zeros in the last four elements will create a non-functional XBG sub-generator and a low quality output with a period of 2128.

        The 1st and 2nd elements are used to set the LCG increment; the least significant bit is set to odd to ensure a full period LCG. The 3rd and 4th elements are used to set the LCG state.

        Parameters:
        seed0 - Initial seed element 0.
        seed1 - Initial seed element 1.
        seed2 - Initial seed element 2.
        seed3 - Initial seed element 3.
        seed4 - Initial seed element 4.
        seed5 - Initial seed element 5.
        seed6 - Initial seed element 6.
        seed7 - Initial seed element 7.
      • L128X256Mix

        protected L128X256Mix​(L128X256Mix source)
        Creates a copy instance.
        Parameters:
        source - Source to copy.
    • Method Detail

      • getStateInternal

        protected byte[] getStateInternal()
        Creates a snapshot of the RNG state.
        Overrides:
        getStateInternal in class AbstractL128
        Returns:
        the internal state.
      • next

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

        public UniformRandomProvider 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.

        The jump size is the equivalent of moving the state backwards by (2256 - 1) positions. It can provide up to 2128 non-overlapping subsequences.

        Specified by:
        jump in interface JumpableUniformRandomProvider
        Overrides:
        jump in class AbstractL128
        Returns:
        A copy of the current state.
      • longJump

        public JumpableUniformRandomProvider 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 264 cycles. The XBG state is unchanged.

        The jump size is the equivalent of moving the state backwards by 264 (2256 - 1) positions. It can provide up to 264 non-overlapping subsequences of length 264 (2256 - 1); each subsequence can provide up to 264 non-overlapping subsequences of length (2256 - 1) using the jump() method.

        Specified by:
        longJump in interface LongJumpableUniformRandomProvider
        Overrides:
        longJump in class AbstractL128
        Returns:
        A copy of the current state.
      • splits

        public java.util.stream.Stream<SplittableUniformRandomProvider> splits​(long streamSize,
                                                                               SplittableUniformRandomProvider source)
        Returns a stream producing the given streamSize number of new random generators, each of which implements the SplittableUniformRandomProvider interface.
        Specified by:
        splits in interface SplittableUniformRandomProvider
        Parameters:
        streamSize - Number of objects to generate.
        source - A source of randomness used to initialise the new instances; this may be split to provide a source of randomness across a parallel stream.
        Returns:
        a stream of random generators; the stream is limited to the given streamSize.
      • create

        private static SplittableUniformRandomProvider create​(long seed,
                                                              UniformRandomProvider source)
        Create a new instance using the given seed and source of randomness to initialise the instance.
        Parameters:
        seed - Seed used to initialise the instance.
        source - Source of randomness used to initialise the instance.
        Returns:
        A new instance.