APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.random

public final Class L128X256MixRandom

extends AbstractSplittableWithBrineGenerator
Class Inheritance
Imports
java.util.concurrent.atomic.AtomicLong, java.util.random.RandomGenerator, jdk.internal.util.random.RandomSupport, .RandomSupport.AbstractSplittableWithBrineGenerator

A "splittable" pseudorandom number generator (PRNG) whose period is roughly 2384. Class L128X256MixRandom implements interfaces RandomGenerator and SplittableGenerator, and therefore supports methods for producing pseudorandomly chosen values of type int, long, float, double, and boolean (and for producing streams of pseudorandomly chosen numbers of type int, long, and double), as well as methods for creating new split-off L128X256MixRandom objects or streams of such objects.

The L128X256MixRandom algorithm is a specific member of the LXM family of algorithms for pseudorandom number generators; for more information, see the documentation for package jdk.random. Each instance of L128X256MixRandom has 384 bits of state plus one 128-bit instance-specific parameter.

If two instances of L128X256MixRandom are created with the same seed within the same program execution, and the same sequence of method calls is made for each, they will generate and return identical sequences of values.

As with java.util.SplittableRandom, instances of L128X256MixRandom are not thread-safe. They are designed to be split, not shared, across threads (see the split method). For example, a java.util.concurrent.ForkJoinTask fork/join-style computation using random numbers might include a construction of the form new Subtask(someL128X256MixRandom.split()).fork().

This class provides additional methods for generating random streams, that employ the above techniques when used in stream.parallel() mode.

Instances of L128X256MixRandom are not cryptographically secure. Consider instead using java.security.SecureRandom in security-sensitive applications. Additionally, default-constructed instances do not use a cryptographically random seed unless the system property java.util.secureRandomSeed is set to true.

Since
17

Field Summary

Modifier and TypeField and Description
private final long
ah

The parameter that is used as an additive constant for the LCG.

private final long
al

The parameter that is used as an additive constant for the LCG.

private static final AtomicLong
defaultGen

The seed generator for default constructors.

private static final int
private static final long
private long
sh

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG.

private long
sl

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG.

private long
x0

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG.

private long
x1

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG.

private long
x2

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG.

private long
x3

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG.

Constructor Summary

AccessConstructor and Description
public
L128X256MixRandom(long
high half of the additive parameter for the LCG
ah
,
long
low half of the additive parameter for the LCG
al
,
long
high half of the initial state for the LCG
sh
,
long
low half of the initial state for the LCG
sl
,
long
first word of the initial state for the XBG
x0
,
long
second word of the initial state for the XBG
x1
,
long
third word of the initial state for the XBG
x2
,
long
fourth word of the initial state for the XBG
x3
)

Basic constructor that initializes all fields from parameters.

public
L128X256MixRandom(long
the initial seed
seed
)

Creates a new instance of L128X256MixRandom using the specified long value as the initial seed.

public
L128X256MixRandom()

Creates a new instance of L128X256MixRandom that is likely to generate sequences of values that are statistically independent of those of any other instances in the current program execution, but may, and typically does, vary across program invocations.

public
L128X256MixRandom(byte[]
the initial seed
seed
)

Creates a new instance of L128X256MixRandom using the specified array of initial seed bytes.

Method Summary

Modifier and TypeMethod and Description
public long
nextLong()

Implements java.util.random.RandomGenerator.nextLong.

Returns a pseudorandomly chosen long value.

public RandomGenerator.SplittableGenerator
Inherited from jdk.internal.util.random.RandomSupport.AbstractSplittableWithBrineGenerator:
splitsplit

Field Detail

ahback to summary
private final long ah

The parameter that is used as an additive constant for the LCG. Must be odd (therefore al must be odd).

alback to summary
private final long al

The parameter that is used as an additive constant for the LCG. Must be odd (therefore al must be odd).

defaultGenback to summary
private static final AtomicLong defaultGen

The seed generator for default constructors.

EQUIDISTRIBUTIONback to summary
private static final int EQUIDISTRIBUTION
MLback to summary
private static final long ML
shback to summary
private long sh

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG. At least one of the four fields x0, x1, x2, and x3 must be nonzero.

slback to summary
private long sl

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG. At least one of the four fields x0, x1, x2, and x3 must be nonzero.

x0back to summary
private long x0

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG. At least one of the four fields x0, x1, x2, and x3 must be nonzero.

x1back to summary
private long x1

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG. At least one of the four fields x0, x1, x2, and x3 must be nonzero.

x2back to summary
private long x2

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG. At least one of the four fields x0, x1, x2, and x3 must be nonzero.

x3back to summary
private long x3

The per-instance state: sh and sl for the LCG; x0, x1, x2, and x3 for the XBG. At least one of the four fields x0, x1, x2, and x3 must be nonzero.

Constructor Detail

L128X256MixRandomback to summary
public L128X256MixRandom(long ah, long al, long sh, long sl, long x0, long x1, long x2, long x3)

Basic constructor that initializes all fields from parameters. It then adjusts the field values if necessary to ensure that all constraints on the values of fields are met.

Parameters
ah:long

high half of the additive parameter for the LCG

al:long

low half of the additive parameter for the LCG

sh:long

high half of the initial state for the LCG

sl:long

low half of the initial state for the LCG

x0:long

first word of the initial state for the XBG

x1:long

second word of the initial state for the XBG

x2:long

third word of the initial state for the XBG

x3:long

fourth word of the initial state for the XBG

L128X256MixRandomback to summary
public L128X256MixRandom(long seed)

Creates a new instance of L128X256MixRandom using the specified long value as the initial seed. Instances of L128X256MixRandom created with the same seed in the same program generate identical sequences of values.

Parameters
seed:long

the initial seed

L128X256MixRandomback to summary
public L128X256MixRandom()

Creates a new instance of L128X256MixRandom that is likely to generate sequences of values that are statistically independent of those of any other instances in the current program execution, but may, and typically does, vary across program invocations.

L128X256MixRandomback to summary
public L128X256MixRandom(byte[] seed)

Creates a new instance of L128X256MixRandom using the specified array of initial seed bytes. Instances of L128X256MixRandom created with the same seed array in the same program execution generate identical sequences of values.

Parameters
seed:byte[]

the initial seed

Method Detail

nextLongback to summary
public long nextLong()

Implements java.util.random.RandomGenerator.nextLong.

Doc from java.util.random.RandomGenerator.nextLong.

Returns a pseudorandomly chosen long value.

Annotations
@Override
splitback to summary
public RandomGenerator.SplittableGenerator split(RandomGenerator.SplittableGenerator source, long brine)

Implements abstract jdk.internal.util.random.RandomSupport.AbstractSplittableWithBrineGenerator.split.

Annotations
@Override