Accept changes, Update documentation
This commit is contained in:
parent
229c36b661
commit
27a252b637
@ -11,16 +11,17 @@ import space.kscience.kmath.structures.DoubleBuffer
|
||||
import space.kscience.kmath.structures.indices
|
||||
|
||||
/**
|
||||
*
|
||||
* HyperSquareDomain class.
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
* A hyper-square (or hyper-cube) real-space domain. It is formed by a [Buffer] of [lower] boundaries
|
||||
* and a [Buffer] of upper boundaries. Upper should be greater or equals than lower.
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public class HyperSquareDomain(public val lower: Buffer<Double>, public val upper: Buffer<Double>) : DoubleDomain {
|
||||
init {
|
||||
require(lower.size == upper.size) {
|
||||
"Domain borders size mismatch. Lower borders size is ${lower.size}, but upper borders size is ${upper.size}"
|
||||
"Domain borders size mismatch. Lower borders size is ${lower.size}, but upper borders size is ${upper.size}."
|
||||
}
|
||||
require(lower.indices.all { lower[it] <= upper[it] }) {
|
||||
"Domain borders order mismatch. Lower borders must be less or equals than upper borders."
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class DoubleHistogramGroup(
|
||||
else -> floor((value - lower[axis]) / binSize[axis]).toInt()
|
||||
}
|
||||
|
||||
override fun getIndex(point: Buffer<Double>): IntArray = IntArray(dimension) {
|
||||
override fun getIndexOrNull(point: Buffer<Double>): IntArray = IntArray(dimension) {
|
||||
getIndex(it, point[it])
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public class DoubleHistogramGroup(
|
||||
override val defaultValue: Double get() = 1.0
|
||||
|
||||
override fun putValue(point: Point<out Double>, value: Double) {
|
||||
val index = getIndex(point)
|
||||
val index = getIndexOrNull(point)
|
||||
ndCounter[index].add(value)
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class IndexedHistogram<T : Comparable<T>, V : Any>(
|
||||
) : Histogram<T, V, DomainBin<T, V>> {
|
||||
|
||||
override fun get(point: Point<T>): DomainBin<T, V>? {
|
||||
val index = histogramGroup.getIndex(point) ?: return null
|
||||
val index = histogramGroup.getIndexOrNull(point) ?: return null
|
||||
return histogramGroup.produceBin(index, values[index])
|
||||
}
|
||||
|
||||
@ -54,9 +54,9 @@ public interface IndexedHistogramGroup<T : Comparable<T>, V : Any> : Group<Index
|
||||
public val histogramValueAlgebra: FieldND<V, *> //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape),
|
||||
|
||||
/**
|
||||
* Resolve index of the bin including given [point]
|
||||
* Resolve index of the bin including given [point]. Return null if point is outside histogram area
|
||||
*/
|
||||
public fun getIndex(point: Point<T>): IntArray?
|
||||
public fun getIndexOrNull(point: Point<T>): IntArray?
|
||||
|
||||
/**
|
||||
* Get a bin domain represented by given index
|
||||
|
Loading…
Reference in New Issue
Block a user