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 by ConcurrentCachedGenerator.
  • Constructor Details

    • 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 generator
      cacheSize - the cache size
      See Also:
    • 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 Details

    • nextVector

      public double[] nextVector()
      Description copied from interface: RandomVectorGenerator
      Gets the next random vector.
      Specified by:
      nextVector in interface RandomVectorGenerator
      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.
      Specified by:
      seed in interface Seedable
      Parameters:
      seeds - the seeds