Histograms evicted from core
This commit is contained in:
parent
123e0176b8
commit
9e2d6125f1
@ -1 +0,0 @@
|
|||||||
@file:DependsOn("scientifik:kmath-core-jvm:0.0.3-dev")
|
|
34
kmath-histograms/build.gradle.kts
Normal file
34
kmath-histograms/build.gradle.kts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm()
|
||||||
|
js()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
|
||||||
|
val commonMain by getting {
|
||||||
|
dependencies {
|
||||||
|
api(project(":kmath-core"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val commonTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jvmTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test"))
|
||||||
|
implementation(kotlin("test-junit"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jsTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -118,7 +118,10 @@ class FastHistogram(
|
|||||||
*```
|
*```
|
||||||
*/
|
*/
|
||||||
fun fromRanges(vararg ranges: ClosedFloatingPointRange<Double>): FastHistogram {
|
fun fromRanges(vararg ranges: ClosedFloatingPointRange<Double>): FastHistogram {
|
||||||
return FastHistogram(ranges.map { it.start }.toVector(), ranges.map { it.endInclusive }.toVector())
|
return FastHistogram(
|
||||||
|
ranges.map { it.start }.toVector(),
|
||||||
|
ranges.map { it.endInclusive }.toVector()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -42,7 +42,8 @@ interface Histogram<T : Any, out B : Bin<T>> : Iterable<B> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MutableHistogram<T : Any, out B : Bin<T>> : Histogram<T, B> {
|
interface MutableHistogram<T : Any, out B : Bin<T>> :
|
||||||
|
Histogram<T, B> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment appropriate bin
|
* Increment appropriate bin
|
@ -27,7 +27,8 @@ interface HistogramSpace<T : Any, B : Bin<T>, H : Histogram<T, B>> : Space<H> {
|
|||||||
val binSpace: Space<Bin<T>>
|
val binSpace: Space<Bin<T>>
|
||||||
}
|
}
|
||||||
|
|
||||||
class PhantomBin<T : Comparable<T>>(val template: BinTemplate<T>, override val value: Number) : Bin<T> {
|
class PhantomBin<T : Comparable<T>>(val template: BinTemplate<T>, override val value: Number) :
|
||||||
|
Bin<T> {
|
||||||
|
|
||||||
override fun contains(vector: Point<out T>): Boolean = template.contains(vector)
|
override fun contains(vector: Point<out T>): Boolean = template.contains(vector)
|
||||||
|
|
@ -1,5 +1,8 @@
|
|||||||
package scientifik.kmath.histogram
|
package scietifik.kmath.histogram
|
||||||
|
|
||||||
|
import scientifik.kmath.histogram.FastHistogram
|
||||||
|
import scientifik.kmath.histogram.fill
|
||||||
|
import scientifik.kmath.histogram.put
|
||||||
import scientifik.kmath.linear.Vector
|
import scientifik.kmath.linear.Vector
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
@ -76,8 +76,14 @@ class UnivariateHistogram private constructor(private val factory: (Double) -> U
|
|||||||
val sorted = borders.sortedArray()
|
val sorted = borders.sortedArray()
|
||||||
return UnivariateHistogram { value ->
|
return UnivariateHistogram { value ->
|
||||||
when {
|
when {
|
||||||
value < sorted.first() -> UnivariateBin(Double.NEGATIVE_INFINITY, Double.MAX_VALUE)
|
value < sorted.first() -> UnivariateBin(
|
||||||
value > sorted.last() -> UnivariateBin(Double.POSITIVE_INFINITY, Double.MAX_VALUE)
|
Double.NEGATIVE_INFINITY,
|
||||||
|
Double.MAX_VALUE
|
||||||
|
)
|
||||||
|
value > sorted.last() -> UnivariateBin(
|
||||||
|
Double.POSITIVE_INFINITY,
|
||||||
|
Double.MAX_VALUE
|
||||||
|
)
|
||||||
else -> {
|
else -> {
|
||||||
val index = (0 until sorted.size).first { value > sorted[it] }
|
val index = (0 until sorted.size).first { value > sorted[it] }
|
||||||
val left = sorted[index]
|
val left = sorted[index]
|
@ -22,6 +22,7 @@ include(
|
|||||||
":kmath-core",
|
":kmath-core",
|
||||||
// ":kmath-io",
|
// ":kmath-io",
|
||||||
":kmath-coroutines",
|
":kmath-coroutines",
|
||||||
|
":kmath-histograms",
|
||||||
":kmath-commons",
|
":kmath-commons",
|
||||||
":kmath-koma",
|
":kmath-koma",
|
||||||
":kmath-sequential",
|
":kmath-sequential",
|
||||||
|
Loading…
Reference in New Issue
Block a user