Package jsl.utilities.random.rng
Class RNGStreamManager
- java.lang.Object
-
- jsl.utilities.random.rng.RNGStreamManager
-
- All Implemented Interfaces:
RandomStreamManagerIfc,RNStreamControlIfc
public class RNGStreamManager extends java.lang.Object implements RandomStreamManagerIfc
A wrapper for holding a list of streams so that all streams can be managed together The methods of the RandomStreamIfc are applied to all contained random number streams
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<RNStreamIfc>myStreamsHolds the streams
-
Constructor Summary
Constructors Constructor Description RNGStreamManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, RNStreamIfc element)Adds the stream to the managerbooleanadd(RNStreamIfc e)Adds the stream to the managerRNStreamIfcaddNewRNStream()Adds a stream from RNStreamFactory.getDefaultFactory()RNStreamIfcaddNewRNStream(RNStreamFactory f)Creates a new stream from the supplied factory and adds it to the list of managed streamsvoidadvanceToNextSubstream()Positions the RNG at the beginning of its next substreamvoidadvanceToNextSubstream(int n)Causes all managed streams to advance their to the next nth substreamvoidclear()booleancontains(RNStreamIfc o)Checks if the manager contains the supplied streamRNStreamIfcget(int index)Gets the stream at the supplied indexbooleangetAntitheticOption()intindexOf(RNStreamIfc o)Returns the index of the streambooleanisEmpty()Checks if the manager is empty (has no streams)java.util.Iterator<RNStreamIfc>iterator()static RNGStreamManagermakeRngStreams(int numStreams)Makes a stream manager and fills it with streams from RNStreamFactory.getDefaultFactory()static RNGStreamManagermakeRngStreams(int numStreams, RNStreamFactory f)Makes RNStreams and fills a RNGStreamManagerRNStreamIfcremove(int index)booleanremove(RNStreamIfc o)voidresetStartStream()The resetStartStream method will position the RNG at the beginning of its stream.voidresetStartSubstream()Resets the position of the RNG at the start of the current substreamRNStreamIfcset(int index, RNStreamIfc element)Sets the stream at the indexvoidsetAntitheticOption(boolean flag)Tells the stream to start producing antithetic variatesintsize()Returns the number of streams being managed
-
-
-
Field Detail
-
myStreams
protected java.util.List<RNStreamIfc> myStreams
Holds the streams
-
-
Method Detail
-
makeRngStreams
public static RNGStreamManager makeRngStreams(int numStreams)
Makes a stream manager and fills it with streams from RNStreamFactory.getDefaultFactory()- Parameters:
numStreams- , must be > 0- Returns:
-
makeRngStreams
public static RNGStreamManager makeRngStreams(int numStreams, RNStreamFactory f)
Makes RNStreams and fills a RNGStreamManager- Parameters:
numStreams- , must be > 0f- the factory- Returns:
- the manager
-
resetStartStream
public void resetStartStream()
Description copied from interface:RNStreamControlIfcThe resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.- Specified by:
resetStartStreamin interfaceRNStreamControlIfc
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RNStreamControlIfcResets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstreamin interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfcPositions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstreamin interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream(int n)
Causes all managed streams to advance their to the next nth substream- Parameters:
n-
-
setAntitheticOption
public void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfcTells the stream to start producing antithetic variates- Specified by:
setAntitheticOptionin interfaceRNStreamControlIfc- Parameters:
flag- true means that it produces antithetic variates.
-
getAntitheticOption
public boolean getAntitheticOption()
- Specified by:
getAntitheticOptionin interfaceRNStreamControlIfc- Returns:
- true means on
-
size
public int size()
Description copied from interface:RandomStreamManagerIfcReturns the number of streams being managed- Specified by:
sizein interfaceRandomStreamManagerIfc- Returns:
-
set
public RNStreamIfc set(int index, RNStreamIfc element)
Sets the stream at the index- Parameters:
index- , must be a valid indexelement- , must not be null- Returns:
- the RandomStreamIfc
-
remove
public RNStreamIfc remove(int index)
- Parameters:
index- must be a valid index- Returns:
- RandomStreamIfc
-
remove
public boolean remove(RNStreamIfc o)
-
iterator
public java.util.Iterator<RNStreamIfc> iterator()
-
isEmpty
public boolean isEmpty()
Description copied from interface:RandomStreamManagerIfcChecks if the manager is empty (has no streams)- Specified by:
isEmptyin interfaceRandomStreamManagerIfc- Returns:
-
indexOf
public int indexOf(RNStreamIfc o)
Description copied from interface:RandomStreamManagerIfcReturns the index of the stream- Specified by:
indexOfin interfaceRandomStreamManagerIfc- Returns:
-
get
public RNStreamIfc get(int index)
Description copied from interface:RandomStreamManagerIfcGets the stream at the supplied index- Specified by:
getin interfaceRandomStreamManagerIfc- Parameters:
index- must be a valid index- Returns:
- RandomStreamIfc
-
contains
public boolean contains(RNStreamIfc o)
Description copied from interface:RandomStreamManagerIfcChecks if the manager contains the supplied stream- Specified by:
containsin interfaceRandomStreamManagerIfc- Returns:
-
clear
public void clear()
-
add
public void add(int index, RNStreamIfc element)Adds the stream to the manager- Parameters:
index- , must be a valid indexelement- , must not be null
-
add
public boolean add(RNStreamIfc e)
Adds the stream to the manager- Parameters:
e- must not be null- Returns:
- true if added
-
addNewRNStream
public RNStreamIfc addNewRNStream()
Adds a stream from RNStreamFactory.getDefaultFactory()- Returns:
- the added RNStream
-
addNewRNStream
public RNStreamIfc addNewRNStream(RNStreamFactory f)
Creates a new stream from the supplied factory and adds it to the list of managed streams- Parameters:
f- , must not be null- Returns:
- the created stream
-
-