umontreal.iro.lecuyer.rng
Class BasicRandomStreamFactory
- java.lang.Object
-
- umontreal.iro.lecuyer.rng.BasicRandomStreamFactory
-
- All Implemented Interfaces:
- RandomStreamFactory
public class BasicRandomStreamFactory extends java.lang.Object implements RandomStreamFactory
Represents a basic random stream factory that can constructs new instances of a givenRandomStreamimplementation via thenewInstancemethod. The class name of the implementation to be used must be passed to the constructor as a String, which must be the name of a nullary constructor of aRandomStreamobject (i.e., a constructor that has no parameters). The streams are constructed by the factory by reflection from this String.
-
-
Constructor Summary
Constructors Constructor and Description BasicRandomStreamFactory(java.lang.Class rsClass)Constructs a new basic random stream factory with random stream class rsClass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.ClassgetRandomStreamClass()Returns the random stream class associated with this object.RandomStreamnewInstance()Constructs and returns a new random stream.voidsetRandomStreamClass(java.lang.Class rsClass)Sets the associated random stream class to rsClass.java.lang.StringtoString()
-
-
-
Constructor Detail
-
BasicRandomStreamFactory
public BasicRandomStreamFactory(java.lang.Class rsClass)
Constructs a new basic random stream factory with random stream class rsClass. The supplied class object must represent an implementation ofRandomStreamand must provide a nullary constructor. For example, to construct a factory producingMRG32k3arandom streams, this constructor must be called with MRG33k3a.class.- Parameters:
rsClass- the random stream class being used.- Throws:
java.lang.NullPointerException- if rsClass is null.java.lang.IllegalArgumentException- if rsClass does not represent an implementation ofRandomStream, or does not provide a nullary constructor.
-
-
Method Detail
-
getRandomStreamClass
public java.lang.Class getRandomStreamClass()
Returns the random stream class associated with this object.- Returns:
- the associated random stream class.
-
setRandomStreamClass
public void setRandomStreamClass(java.lang.Class rsClass)
Sets the associated random stream class to rsClass. The supplied class object must represent an implementation ofRandomStreamand must provide a nullary constructor.- Parameters:
rsClass- the random stream class being used.- Throws:
java.lang.NullPointerException- if rsClass is null.java.lang.IllegalArgumentException- if rsClass does not represent an implementation ofRandomStream, or does not provide a nullary constructor.
-
newInstance
public RandomStream newInstance()
Description copied from interface:RandomStreamFactoryConstructs and returns a new random stream. If the instantiation of the random stream fails, this method throws aRandomStreamInstantiationException.- Specified by:
newInstancein interfaceRandomStreamFactory- Returns:
- the newly-constructed random stream.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG