Class AbstractWell

All Implemented Interfaces:
RandomIntSource, RestorableUniformRandomProvider, UniformRandomProvider
Direct Known Subclasses:
Well1024a, Well19937a, Well44497a, Well512a

public abstract class AbstractWell extends IntProvider
This abstract class implements the WELL class of pseudo-random number generator from François Panneton, Pierre L'Ecuyer and Makoto Matsumoto.

This generator is described in a paper by François Panneton, Pierre L'Ecuyer and Makoto Matsumoto Improved Long-Period Generators Based on Linear Recurrences Modulo 2 ACM Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper are in wellrng-errata.txt.

Since:
1.0
See Also:
  • Field Details

    • BLOCK_SIZE

      private static final int BLOCK_SIZE
      Block size.
      See Also:
    • index

      protected int index
      Current index in the bytes pool.
    • v

      protected final int[] v
      Bytes pool.
  • Constructor Details

    • AbstractWell

      protected AbstractWell(int k, int[] seed)
      Creates an instance with the given seed.
      Parameters:
      k - Number of bits in the pool (not necessarily a multiple of 32).
      seed - Initial seed.
  • Method Details

    • 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:
    • setSeedInternal

      private void setSeedInternal(int[] seed)
      Initializes the generator with the given seed.
      Parameters:
      seed - Seed. Cannot be null.
    • calculateBlockCount

      private static int calculateBlockCount(int k)
      Calculate the number of 32-bits blocks.
      Parameters:
      k - Number of bits in the pool (not necessarily a multiple of 32).
      Returns:
      the number of 32-bits blocks.