Class L128X1024Mix

    • Field Detail

      • XBG_STATE_SIZE

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

        private static final int LCG_STATE_SIZE
        Size of the LCG state vector.
        See Also:
        Constant Field Values
      • x

        private final long[] x
        State of the XBG.
      • index

        private int index
        Index in "state" array.
    • Constructor Detail

      • L128X1024Mix

        public L128X1024Mix​(long[] seed)
        Creates a new instance.
        Parameters:
        seed - Initial seed. If the length is larger than 20, only the first 20 elements will be used; if smaller, the remaining elements will be automatically set. A seed containing all zeros in the last 16 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.

      • L128X1024Mix

        protected L128X1024Mix​(L128X1024Mix 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()
        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 (21024 - 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 (21024 - 1) positions. It can provide up to 264 non-overlapping subsequences of length 264 (21024 - 1); each subsequence can provide up to 264 non-overlapping subsequences of length (21024 - 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.