Class ConcurrentCachedRVG
java.lang.Object
dev.nm.stat.random.rng.concurrent.cache.ConcurrentCachedRVG
- All Implemented Interfaces:
RandomVectorGenerator
,Seedable
This is a fast thread-safe wrapper for random vector generators. This class
is backed by
ConcurrentCachedGenerator
.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance which wraps the given random vector generator and uses a cache which has 8 entries per available core.ConcurrentCachedRVG
(RandomVectorGenerator rvg, int cacheSize) Constructs a new instance which wraps the given random vector generator and uses a cache of the specified size. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
Gets the next random vector.void
seed
(long... seeds) Delegate to the underlying random vector generator.
-
Constructor Details
-
ConcurrentCachedRVG
Constructs a new instance which wraps the given random vector generator and uses a cache of the specified size. A larger cache will make the simulation slightly faster at the expense of increased memory usage, but can lead to the computation of unnecessary values at the tail.- Parameters:
rvg
- the underlying generatorcacheSize
- the cache size- See Also:
-
ConcurrentCachedRVG
Constructs a new instance which wraps the given random vector generator and uses a cache which has 8 entries per available core.- Parameters:
rvg
- the underlying generator
-
-
Method Details
-
nextVector
public double[] nextVector()Description copied from interface:RandomVectorGenerator
Gets the next random vector.- Specified by:
nextVector
in interfaceRandomVectorGenerator
- Returns:
- the next random vector
-
seed
public void seed(long... seeds) Delegate to the underlying random vector generator. Note: this method is NOT thread-safe.
-