Package jsl.utilities.random.rng
Class RNStreamMakerBU
- java.lang.Object
-
- jsl.utilities.Identity
-
- jsl.utilities.random.rng.RNStreamMakerBU
-
- All Implemented Interfaces:
GetNameIfc
,IdentityIfc
public class RNStreamMakerBU extends Identity
An update (as of Jan-17-2021) of the MRG32k3a class from:https://github.com/umontreal-simul/ssj package umontreal.ssj.rng.MRG32k3a
This representation fits the stream architecture facilitated by the JSL and (importantly) allows multiple instances of the factory to be instantiated. This allows streams from different factories to produce the same streams and underlying random numbers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
RNStreamMakerBU.RNStream
Instances of RNStream are what is made by the factory.
-
Constructor Summary
Constructors Constructor Description RNStreamMakerBU()
Creates a factory with no nameRNStreamMakerBU(java.lang.String name)
Creates a factory with the provided name
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
advanceSeeds(int n)
Advances the seeds n times.static boolean
checkSeed(long[] seed)
Use to check seeds to see if they are valid for the factorystatic RNStreamMakerBU
getDefaultFactory()
Returns a reference to a "global" stream factorylong[]
getDefaultInitialFactorySeed()
Gets the default initial package seed: seed = {12345, 12345, 12345, 12345, 12345, 12345};long[]
getFactorySeed()
Returns the current factory seedRNStreamIfc
getStream()
Tells the factory to make and return a RNStreamRNStreamIfc
getStream(java.lang.String name)
Tells the provider to make and return a RNStream with the provided namestatic void
main(java.lang.String[] args)
RNStreamMakerBU
newInstance()
Returns a clone of the factory that will produce exactly the same streams.RNStreamMakerBU
newInstance(java.lang.String name)
Returns a new instance of the factory that will produce exactly the same streams The state of the returned factory will be exactly the same as the current factory.void
resetFactorySeed()
Resets the package seed to the default initial package seed: seed = {12345, 12345, 12345, 12345, 12345, 12345};static void
setDefaultFactory(RNStreamMakerBU f)
Sets the default factory to the supplied factoryvoid
setFactorySeed(long[] seed)
Sets the initial seed to the six integers in the vector seed[0..5].
-
-
-
Method Detail
-
checkSeed
public static boolean checkSeed(long[] seed)
Use to check seeds to see if they are valid for the factory- Parameters:
seed
- the seed to check- Returns:
- true if the supplied seed can be used, false otherwise
-
newInstance
public RNStreamMakerBU newInstance()
Returns a clone of the factory that will produce exactly the same streams. The state of the returned factory will be exactly the same as the current factory.- Returns:
- new instance of the factory
-
newInstance
public RNStreamMakerBU newInstance(java.lang.String name)
Returns a new instance of the factory that will produce exactly the same streams The state of the returned factory will be exactly the same as the current factory.- Parameters:
name
- the name for the factory, may be null- Returns:
- the new instance of the factory
-
getDefaultFactory
public static RNStreamMakerBU getDefaultFactory()
Returns a reference to a "global" stream factory- Returns:
- a reference to a "global" stream factory
-
setDefaultFactory
public static void setDefaultFactory(RNStreamMakerBU f)
Sets the default factory to the supplied factory- Parameters:
f
- must not be null
-
getDefaultInitialFactorySeed
public final long[] getDefaultInitialFactorySeed()
Gets the default initial package seed: seed = {12345, 12345, 12345, 12345, 12345, 12345};- Returns:
- an array holding the initial seed values
-
getFactorySeed
public final long[] getFactorySeed()
Returns the current factory seed- Returns:
- the array of seed values for the current state
-
setFactorySeed
public final void setFactorySeed(long[] seed)
Sets the initial seed to the six integers in the vector seed[0..5]. This will be the seed (initial state) of the first stream. By default, this seed is (12345, 12345, 12345, 12345, 12345, 12345).If it is called, the first 3 values of the seed must all be less than m1 = 4294967087, and not all 0; and the last 3 values must all be less than m2 = 4294944443, and not all 0. Throws illegal argument exception for invalid seeds
- Parameters:
seed
- the seeds
-
resetFactorySeed
public final void resetFactorySeed()
Resets the package seed to the default initial package seed: seed = {12345, 12345, 12345, 12345, 12345, 12345};
-
advanceSeeds
public final void advanceSeeds(int n)
Advances the seeds n times. Acts as if n streams were created, without actually creating the streams. The seeds will be advanced 2^127 steps- Parameters:
n
- the number of times to advance
-
getStream
public final RNStreamIfc getStream(java.lang.String name)
Tells the provider to make and return a RNStream with the provided name- Parameters:
name
- can be null- Returns:
- the made stream
-
getStream
public final RNStreamIfc getStream()
Tells the factory to make and return a RNStream- Returns:
- the made stream
-
main
public static void main(java.lang.String[] args)
-
-