From 9f513b355c767c2c0536c5e4d7ad8df7dc6c2691 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Sun, 20 Jun 2021 01:16:08 +0700 Subject: [PATCH] Update CMRandomGeneratorWrapper --- .../kmath/commons/random/CMRandomGeneratorWrapper.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt index 16a6967e2..4e2fbf980 100644 --- a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt +++ b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt @@ -5,7 +5,11 @@ package space.kscience.kmath.commons.random +import kotlinx.coroutines.runBlocking +import space.kscience.kmath.misc.PerformancePitfall +import space.kscience.kmath.samplers.GaussianSampler import space.kscience.kmath.stat.RandomGenerator +import space.kscience.kmath.stat.next public class CMRandomGeneratorWrapper( public val factory: (IntArray) -> RandomGenerator, @@ -33,7 +37,10 @@ public class CMRandomGeneratorWrapper( public override fun nextInt(): Int = generator.nextInt() public override fun nextInt(n: Int): Int = generator.nextInt(n) - public override fun nextGaussian(): Double = TODO() + + @PerformancePitfall + public override fun nextGaussian(): Double = runBlocking { GaussianSampler(0.0, 1.0).next(generator) } + public override fun nextDouble(): Double = generator.nextDouble() public override fun nextLong(): Long = generator.nextLong() }