All Downloads are FREE. Search and download functionalities are using the official Maven repository.

breeze.stats.distributions.ThreadLocalRandomGenerator.scala Maven / Gradle / Ivy

There is a newer version: 1.0
Show newest version
package breeze.stats.distributions

import org.apache.commons.math3.random.RandomGenerator

/**
 * TODO
 *
 * @author dlwh
 **/
class ThreadLocalRandomGenerator(genThunk: =>RandomGenerator) extends RandomGenerator{
  private val genTL = new ThreadLocal[RandomGenerator] {
    override def initialValue(): RandomGenerator = genThunk
  }
  def nextBytes(bytes: Array[Byte]) = genTL.get().nextBytes(bytes)

  def setSeed(seed: Long) = genTL.get().setSeed(seed)

  def setSeed(seed: Array[Int]) = genTL.get().setSeed(seed)

  def setSeed(seed: Int) = genTL.get().setSeed(seed)

  def nextInt(): Int = genTL.get().nextInt()

  def nextInt(n: Int): Int = genTL.get().nextInt(n)

  def nextLong(): Long = genTL.get().nextLong()

  def nextBoolean(): Boolean = genTL.get().nextBoolean()

  def nextFloat(): Float = genTL.get().nextFloat()

  def nextDouble(): Double = genTL.get().nextDouble()

  def nextGaussian(): Double = genTL.get().nextGaussian()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy