Class ConcurrentCachedRVG
- java.lang.Object
-
- dev.nm.stat.random.rng.concurrent.cache.ConcurrentCachedRVG
-
- All Implemented Interfaces:
RandomVectorGenerator,Seedable
public class ConcurrentCachedRVG extends Object implements RandomVectorGenerator
This is a fast thread-safe wrapper for random vector generators. This class is backed byConcurrentCachedGenerator.
-
-
Constructor Summary
Constructors Constructor Description ConcurrentCachedRVG(RandomVectorGenerator rvg)Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]nextVector()Gets the next random vector.voidseed(long... seeds)Delegate to the underlying random vector generator.
-
-
-
Constructor Detail
-
ConcurrentCachedRVG
public ConcurrentCachedRVG(RandomVectorGenerator rvg, int cacheSize)
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:
ConcurrentCachedGenerator(dev.nm.stat.random.rng.concurrent.cache.ConcurrentCachedGenerator.Generator, int)
-
ConcurrentCachedRVG
public ConcurrentCachedRVG(RandomVectorGenerator rvg)
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 Detail
-
nextVector
public double[] nextVector()
Description copied from interface:RandomVectorGeneratorGets the next random vector.- Specified by:
nextVectorin interfaceRandomVectorGenerator- Returns:
- the next random vector
-
-