This commit is contained in:
Alexander Nozik 2021-01-28 20:04:33 +03:00
parent 8a2f1586e2
commit 228c0b3886
4 changed files with 22 additions and 11 deletions

View File

@ -68,11 +68,12 @@ benchmark {
targets.register("benchmarks")
// This one matches sourceSet name above
configurations.register("fast") {
configurations.register("dot") {
warmups = 1 // number of warmup iterations
iterations = 3 // number of iterations
iterationTime = 500 // time in seconds per iteration
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
include("DotBenchmark")
}
}

View File

@ -1,8 +1,18 @@
plugins { id("ru.mipt.npm.mpp") }
kotlin.sourceSets.commonMain {
dependencies {
api(project(":kmath-core"))
api(project(":kmath-for-real"))
kotlin.sourceSets {
commonMain {
dependencies {
api(project(":kmath-core"))
}
}
commonTest{
dependencies{
implementation(project(":kmath-for-real"))
}
}
}
readme {
this.maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
}

View File

@ -5,7 +5,6 @@ import kscience.kmath.histogram.fill
import kscience.kmath.histogram.put
import kscience.kmath.real.RealVector
import kscience.kmath.real.invoke
import kscience.kmath.structures.Buffer
import kotlin.random.Random
import kotlin.test.*

View File

@ -1,6 +1,6 @@
package kscience.kmath.histogram
import kscience.kmath.real.RealVector
import kscience.kmath.linear.Point
import kscience.kmath.structures.Buffer
import kscience.kmath.structures.asBuffer
import java.util.*
@ -11,12 +11,12 @@ import kotlin.math.floor
public class UnivariateBin(
public val position: Double,
public val size: Double,
public val counter: LongCounter = LongCounter()
public val counter: LongCounter = LongCounter(),
) : Bin<Double> {
//TODO add weighting
public override val value: Number get() = counter.sum()
public override val center: RealVector get() = doubleArrayOf(position).asBuffer()
public override val center: Point<Double> get() = doubleArrayOf(position).asBuffer()
public override val dimension: Int get() = 1
public operator fun contains(value: Double): Boolean = value in (position - size / 2)..(position + size / 2)
@ -27,8 +27,9 @@ public class UnivariateBin(
/**
* Univariate histogram with log(n) bin search speed
*/
public class UnivariateHistogram private constructor(private val factory: (Double) -> UnivariateBin) :
MutableHistogram<Double, UnivariateBin> {
public class UnivariateHistogram private constructor(
private val factory: (Double) -> UnivariateBin,
) : MutableHistogram<Double, UnivariateBin> {
private val bins: TreeMap<Double, UnivariateBin> = TreeMap()