Class AbstractPcgMcg6432

All Implemented Interfaces:
RandomIntSource, RestorableUniformRandomProvider, UniformRandomProvider
Direct Known Subclasses:
PcgMcgXshRr32, PcgMcgXshRs32

abstract class AbstractPcgMcg6432 extends IntProvider
This abstract class is a base for algorithms from the Permuted Congruential Generator (PCG) family that use an internal 64-bit Multiplicative Congruential Generator (MCG) and output 32-bits per cycle.
Since:
1.3
See Also:
  • Field Details

    • state

      private long state
      The state of the MCG.
  • Constructor Details

    • AbstractPcgMcg6432

      AbstractPcgMcg6432(Long seed)
      Creates a new instance.
      Parameters:
      seed - Initial seed.
  • Method Details

    • bump

      private static long bump(long input)
      Provides the next state of the MCG.
      Parameters:
      input - Current state.
      Returns:
      next state
    • next

      public int next()
      Return the next random value.
      Returns:
      the next random value.
    • transform

      protected abstract int transform(long x)
      Transform the 64-bit state of the generator to a 32-bit output. The transformation function shall vary with respect to different generators.
      Parameters:
      x - State.
      Returns:
      the output
    • getStateInternal

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

      protected void setStateInternal(byte[] s)
      Resets the RNG to the given state.
      Overrides:
      setStateInternal in class IntProvider
      Parameters:
      s - State (previously obtained by a call to BaseProvider.getStateInternal()).
      See Also: