Class LXMSupport


  • final class LXMSupport
    extends java.lang.Object
    Utility support for the LXM family of generators. The LXM family is described in further detail in:
    Steele and Vigna (2021) LXM: better splittable pseudorandom number generators (and almost as fast). Proceedings of the ACM on Programming Languages, Volume 5, Article 148, pp 1–31.

    Constants are provided to advance the state of an LCG by a power of 2 in a single multiply operation to support jump operations.

    Since:
    1.5
    See Also:
    Steele & Vigna (2021) Proc. ACM Programming Languages 5, 1-31
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static int C32P
      Jump constant precursor for c' for an advance of the 32-bit LCG by 2^16.
      (package private) static int GOLDEN_RATIO_32
      The fractional part of the golden ratio, phi, scaled to 32-bits and rounded to odd.
      (package private) static int M32
      32-bit LCG multiplier.
      (package private) static int M32P
      Jump constant m' for an advance of the 32-bit LCG by 2^16.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LXMSupport()
      No instances.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static int lea32​(int x)
      Perform a 32-bit mixing function using Doug Lea's 32-bit mix constants and shifts.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • M32P

        static final int M32P
        Jump constant m' for an advance of the 32-bit LCG by 2^16. Computed as: m' = m^(2^16) (mod 2^32).
        See Also:
        Constant Field Values
      • C32P

        static final int C32P
        Jump constant precursor for c' for an advance of the 32-bit LCG by 2^16. Computed as:
         product_{i=0}^{15} { M^(2^i) + 1 } (mod 2^32)
         

        The jump is computed for the LCG with an update step of s = m * s + c as:

         s = m' * s + c' * c
         
        See Also:
        Constant Field Values
      • GOLDEN_RATIO_32

        static final int GOLDEN_RATIO_32
        The fractional part of the golden ratio, phi, scaled to 32-bits and rounded to odd.
         phi = (sqrt(5) - 1) / 2) * 2^32
         
        See Also:
        Golden ratio, Constant Field Values
    • Constructor Detail

      • LXMSupport

        private LXMSupport()
        No instances.
    • Method Detail

      • lea32

        static int lea32​(int x)
        Perform a 32-bit mixing function using Doug Lea's 32-bit mix constants and shifts.

        This is based on the original 32-bit mix function of Austin Appleby's MurmurHash3 modified to use a single mix constant and 16-bit shifts, which may have a performance advantage on some processors.

        The code was kindly provided by Guy Steele as a printing constraint led to its omission from Steele and Vigna's paper.

        Note from Guy Steele:

        The constant 0xd36d884b was chosen by Doug Lea by taking the (two’s-complement) negation of the decimal constant 747796405, which appears in Table 5 of L’Ecuyer’s classic paper “Tables of Linear Congruential Generators of Different Sizes and Good Lattice Structure” (January 1999); the constant in lea64 was chosen in a similar manner. These choices were based on his engineering intuition and then validated by testing.
        Parameters:
        x - the input value
        Returns:
        the output value