public class ISAACRandom extends BitsStreamGenerator implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
private int[] |
arr
Service variable.
|
private int |
count
Count through the results in rsl[]
|
private static int |
GLD_RATIO
The golden ratio
|
private static int |
H_SIZE
Half-size of rsl[] and mem[]
|
private int |
isaacA
Accumulator
|
private int |
isaacB
The last result
|
private int |
isaacC
Counter, guarantees cycle is at least 2^40
|
private int |
isaacI
Service variable.
|
private int |
isaacJ
Service variable.
|
private int |
isaacX
Service variable.
|
private static int |
MASK
For pseudo-random lookup
|
private int[] |
mem
The internal state
|
private int[] |
rsl
The results given to the user
|
private static long |
serialVersionUID
Serializable version identifier
|
private static int |
SIZE
Size of rsl[] and mem[]
|
private static int |
SIZE_L
Log of size of rsl[] and mem[]
|
Constructor and Description |
---|
ISAACRandom()
Creates a new ISAAC random number generator.
|
ISAACRandom(int[] seed)
Creates a new ISAAC random number generator using an int array seed.
|
ISAACRandom(long seed)
Creates a new ISAAC random number generator using a single long seed.
|
Modifier and Type | Method and Description |
---|---|
private void |
initState()
Initialize, or reinitialize, this instance of rand.
|
private void |
isaac()
Generate 256 results
|
private void |
isaac2()
Intermediate internal loop.
|
private void |
isaac3()
Lowest level internal loop.
|
protected int |
next(int bits)
Generate next pseudorandom number.
|
void |
setSeed(int seed)
Sets the seed of the underlying random number generator using an
int seed. |
void |
setSeed(int[] seed)
Sets the seed of the underlying random number generator using an
int array seed. |
void |
setSeed(long seed)
Sets the seed of the underlying random number generator using a
long seed. |
private void |
setState(int start)
Set the state by copying the internal arrays.
|
private void |
shuffle()
Shuffle array.
|
clear, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, nextLong
private static final long serialVersionUID
private static final int SIZE_L
private static final int SIZE
private static final int H_SIZE
private static final int MASK
private static final int GLD_RATIO
private final int[] rsl
private final int[] mem
private int count
private int isaacA
private int isaacB
private int isaacC
private final int[] arr
private int isaacX
private int isaacI
private int isaacJ
public ISAACRandom()
public ISAACRandom(long seed)
seed
- Initial seed.public ISAACRandom(int[] seed)
seed
- Initial seed. If null
, the seed will be related
to the current time.public void setSeed(int seed)
int
seed.
Sequences of values generated starting with the same seeds should be identical.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the seed valuepublic void setSeed(long seed)
long
seed.
Sequences of values generated starting with the same seeds should be identical.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the seed valuepublic void setSeed(int[] seed)
int
array seed.
Sequences of values generated starting with the same seeds should be identical.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the seed valueprotected int next(int bits)
This method is the core generation algorithm. It is used by all the
public generation methods for the various primitive types BitsStreamGenerator.nextBoolean()
, BitsStreamGenerator.nextBytes(byte[])
, BitsStreamGenerator.nextDouble()
,
BitsStreamGenerator.nextFloat()
, BitsStreamGenerator.nextGaussian()
, BitsStreamGenerator.nextInt()
,
BitsStreamGenerator.next(int)
and BitsStreamGenerator.nextLong()
.
next
in class BitsStreamGenerator
bits
- number of random bits to produceprivate void isaac()
private void isaac2()
private void isaac3()
private void initState()
private void shuffle()
private void setState(int start)
start
- First index into mem
array.