Xoroshiro128PlusPlus implements
interfaces RandomGenerator and LeapableGenerator,
and therefore supports methods for producing pseudorandomly chosen
numbers of type int, long, float, and double
as well as creating new Xoroshiro128PlusPlus objects
by "jumping" or "leaping".
The class Xoroshiro128PlusPlus uses the xoroshiro128 algorithm
(parameters 49, 21, 28) with the "++" scrambler that computes
Long.rotateLeft(s0 + s1, 17) + s0.
(See David Blackman and Sebastiano Vigna, "Scrambled Linear Pseudorandom
Number Generators," ACM Transactions on Mathematical Software, 2021.)
Its state consists of two long fields x0 and x1,
which can take on any values provided that they are not both zero.
The period of this generator is 2128-1.
The 64-bit values produced by the nextLong() method are equidistributed.
To be precise, over the course of the cycle of length 2128-1,
each nonzero long value is generated 264 times,
but the value 0 is generated only 264-1 times.
The values produced by the nextInt(), nextFloat(), and nextDouble()
methods are likewise equidistributed.
Instances Xoroshiro128PlusPlus are not thread-safe.
They are designed to be used so that each thread as its own instance.
The methods jump and leap and jumps and leaps
can be used to construct new instances of Xoroshiro128PlusPlus that traverse
other parts of the state cycle.
Instances of Xoroshiro128PlusPlus are not cryptographically
secure. Consider instead using java.
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.
| Modifier and Type | Field and Description |
|---|---|
| private static final AtomicLong | defaultGen
The seed generator for default constructors. |
| private static final String | GROUP
Group name. |
| private static final long[] | |
| private static final long[] | |
| private long | x0
The per-instance state. |
| private long | x1
The per-instance state. |
| Access | Constructor and Description |
|---|---|
| public | Xoroshiro128PlusPlus(long
first word of the initial state x0, long second word of the initial state x1)Basic constructor that initializes all fields from parameters. |
| public | Xoroshiro128PlusPlus(long
the initial seed seed)Creates a new instance of |
| public | Xoroshiro128PlusPlus()
Creates a new instance of |
| public | Xoroshiro128PlusPlus(byte[]
the initial seed seed)Creates a new instance of |
| Modifier and Type | Method and Description |
|---|---|
| public Xoroshiro128PlusPlus | copy()
Implements java. Returns a new generator whose internal state is an exact copy of this generator (therefore their future behavior should be identical if subjected to the same series of operations). |
| public void | jump()
Implements java. Alter the state of this pseudorandom number generator so as to jump forward a large, fixed distance (typically 264 or more) within its state cycle. |
| private void | |
| public double | jumpDistance()
Implements java. Returns the distance by which the
|
| public void | leap()
Implements java. Alter the state of this pseudorandom number generator so as to leap forward a large, fixed distance (typically 296 or more) within its state cycle. |
| public double | leapDistance()
Implements java. Returns the distance by which the
|
| public long | nextLong()
Implements java. Returns a pseudorandomly chosen |
| defaultGen | back to summary |
|---|---|
| private static final AtomicLong defaultGen The seed generator for default constructors. | |
| GROUP | back to summary |
|---|---|
| private static final String GROUP Group name. | |
| JUMP_TABLE | back to summary |
|---|---|
| private static final long[] JUMP_TABLE | |
| LEAP_TABLE | back to summary |
|---|---|
| private static final long[] LEAP_TABLE | |
| x0 | back to summary |
|---|---|
| private long x0 The per-instance state. At least one of the two fields x0 and x1 must be nonzero. | |
| x1 | back to summary |
|---|---|
| private long x1 The per-instance state. At least one of the two fields x0 and x1 must be nonzero. | |
| Xoroshiro128PlusPlus | back to summary |
|---|---|
| public Xoroshiro128PlusPlus(long x0, long x1) 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.
| |
| Xoroshiro128PlusPlus | back to summary |
|---|---|
| public Xoroshiro128PlusPlus(long seed) Creates a new instance of
| |
| Xoroshiro128PlusPlus | back to summary |
|---|---|
| public Xoroshiro128PlusPlus() Creates a new instance of | |
| Xoroshiro128PlusPlus | back to summary |
|---|---|
| public Xoroshiro128PlusPlus(byte[] seed) Creates a new instance of
| |
| copy | back to summary |
|---|---|
| public Xoroshiro128PlusPlus copy() Implements java. Doc from java. Returns a new generator whose internal state is an exact copy of this generator (therefore their future behavior should be identical if subjected to the same series of operations). | |
| jump | back to summary |
|---|---|
| public void jump() Implements java. Doc from java. Alter the state of this pseudorandom number generator so as to jump forward a large, fixed distance (typically 264 or more) within its state cycle.
| |
| jumpAlgorithm | back to summary |
|---|---|
| private void jumpAlgorithm(long[] table) | |
| jumpDistance | back to summary |
|---|---|
| public double jumpDistance() Implements java. Doc from java. Returns the distance by which the
| |
| leap | back to summary |
|---|---|
| public void leap() Implements java. Doc from java. Alter the state of this pseudorandom number generator so as to leap forward a large, fixed distance (typically 296 or more) within its state cycle.
| |
| leapDistance | back to summary |
|---|---|
| public double leapDistance() Implements java. Doc from java. Returns the distance by which the
| |
| nextLong | back to summary |
|---|---|
| public long nextLong() Implements java. Doc from java. Returns a pseudorandomly chosen
| |