Class LXMSupport
java.lang.Object
org.apache.commons.rng.core.source32.LXMSupport
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:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
Jump constant precursor forc'
for an advance of the 32-bit LCG by 2^16.(package private) static final int
The fractional part of the golden ratio, phi, scaled to 32-bits and rounded to odd.(package private) static final int
32-bit LCG multiplier.(package private) static final int
Jump constantm'
for an advance of the 32-bit LCG by 2^16. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static int
lea32
(int x) Perform a 32-bit mixing function using Doug Lea's 32-bit mix constants and shifts.
-
Field Details
-
M32
static final int M3232-bit LCG multiplier. Note: (M % 8) = 5.- See Also:
-
M32P
static final int M32PJump constantm'
for an advance of the 32-bit LCG by 2^16. Computed as:m' = m^(2^16) (mod 2^32)
.- See Also:
-
C32P
static final int C32PJump constant precursor forc'
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:
-
GOLDEN_RATIO_32
static final int GOLDEN_RATIO_32The fractional part of the golden ratio, phi, scaled to 32-bits and rounded to odd.phi = (sqrt(5) - 1) / 2) * 2^32
- See Also:
-
-
Constructor Details
-
LXMSupport
private LXMSupport()No instances.
-
-
Method Details
-
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
-