From 39640498fc93f4ca5adc4c439c641d5aeb4510cb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 19 Mar 2022 09:20:32 +0300 Subject: [PATCH 01/26] Another histogram refactor --- build.gradle.kts | 2 +- buildSrc/gradle.properties | 2 +- .../kmath/domains/HyperSquareDomain.kt | 11 ++++- .../kmath/histogram/DoubleHistogramSpace.kt | 46 +++++++++++-------- .../kmath/histogram/IndexedHistogramSpace.kt | 20 ++++---- .../kmath/histogram/UnivariateHistogram.kt | 20 -------- .../kmath/histogram/TreeHistogramSpace.kt | 22 ++++++++- .../kmath/histogram/TreeHistogramTest.kt | 2 +- 8 files changed, 71 insertions(+), 54 deletions(-) rename kmath-histograms/src/{jvmMain => commonMain}/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt (71%) diff --git a/build.gradle.kts b/build.gradle.kts index 3372d505d..ee77f32df 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ allprojects { } group = "space.kscience" - version = "0.3.0-dev-20" + version = "0.3.0-dev-21" } subprojects { diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 05486d4f6..713f9bcd9 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -5,4 +5,4 @@ kotlin.code.style=official -toolsVersion=0.11.1-kotlin-1.6.10 +toolsVersion=0.11.2-kotlin-1.6.10 diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt index bd5514623..2fac442e7 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt @@ -7,6 +7,7 @@ package space.kscience.kmath.domains import space.kscience.kmath.linear.Point import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.structures.Buffer +import space.kscience.kmath.structures.DoubleBuffer import space.kscience.kmath.structures.indices /** @@ -16,9 +17,17 @@ import space.kscience.kmath.structures.indices * @author Alexander Nozik */ @UnstableKMathAPI -public class HyperSquareDomain(private val lower: Buffer, private val upper: Buffer) : DoubleDomain { +public class HyperSquareDomain(public val lower: Buffer, public val upper: Buffer) : DoubleDomain { + init { + require(lower.size == upper.size) { + "Domain borders size mismatch. Lower borders size is ${lower.size}, but upper borders size is ${upper.size}" + } + } + override val dimension: Int get() = lower.size + public val center: DoubleBuffer get() = DoubleBuffer(dimension) { (lower[it] + upper[it]) / 2.0 } + override operator fun contains(point: Point): Boolean = point.indices.all { i -> point[i] in lower[i]..upper[i] } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt index 61d0b9f33..27f04d60b 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt @@ -5,7 +5,6 @@ package space.kscience.kmath.histogram -import space.kscience.kmath.domains.Domain import space.kscience.kmath.domains.HyperSquareDomain import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.nd.* @@ -13,6 +12,9 @@ import space.kscience.kmath.operations.DoubleField import space.kscience.kmath.structures.* import kotlin.math.floor +/** + * Multivariate histogram space for hyper-square real-field bins. + */ public class DoubleHistogramSpace( private val lower: Buffer, private val upper: Buffer, @@ -47,7 +49,7 @@ public class DoubleHistogramSpace( } @OptIn(UnstableKMathAPI::class) - override fun getDomain(index: IntArray): Domain { + override fun getDomain(index: IntArray): HyperSquareDomain { val lowerBoundary = index.mapIndexed { axis, i -> when (i) { 0 -> Double.NEGATIVE_INFINITY @@ -67,8 +69,13 @@ public class DoubleHistogramSpace( return HyperSquareDomain(lowerBoundary, upperBoundary) } + @OptIn(UnstableKMathAPI::class) + public val Bin.domain: HyperSquareDomain + get() = (this as? DomainBin)?.domain as? HyperSquareDomain + ?: error("Im a teapot. This is not my bin") - override fun produceBin(index: IntArray, value: Double): Bin { + @OptIn(UnstableKMathAPI::class) + override fun produceBin(index: IntArray, value: Double): DomainBin { val domain = getDomain(index) return DomainBin(domain, value) } @@ -96,7 +103,9 @@ public class DoubleHistogramSpace( *) *``` */ - public fun fromRanges(vararg ranges: ClosedFloatingPointRange): DoubleHistogramSpace = DoubleHistogramSpace( + public fun fromRanges( + vararg ranges: ClosedFloatingPointRange, + ): DoubleHistogramSpace = DoubleHistogramSpace( ranges.map(ClosedFloatingPointRange::start).asBuffer(), ranges.map(ClosedFloatingPointRange::endInclusive).asBuffer() ) @@ -110,21 +119,22 @@ public class DoubleHistogramSpace( *) *``` */ - public fun fromRanges(vararg ranges: Pair, Int>): DoubleHistogramSpace = - DoubleHistogramSpace( - ListBuffer( - ranges - .map(Pair, Int>::first) - .map(ClosedFloatingPointRange::start) - ), + public fun fromRanges( + vararg ranges: Pair, Int>, + ): DoubleHistogramSpace = DoubleHistogramSpace( + ListBuffer( + ranges + .map(Pair, Int>::first) + .map(ClosedFloatingPointRange::start) + ), - ListBuffer( - ranges - .map(Pair, Int>::first) - .map(ClosedFloatingPointRange::endInclusive) - ), + ListBuffer( + ranges + .map(Pair, Int>::first) + .map(ClosedFloatingPointRange::endInclusive) + ), - ranges.map(Pair, Int>::second).toIntArray() - ) + ranges.map(Pair, Int>::second).toIntArray() + ) } } \ No newline at end of file diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt index 9275c1c5e..bfacebb43 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt @@ -7,7 +7,6 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.Domain import space.kscience.kmath.linear.Point -import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.nd.DefaultStrides import space.kscience.kmath.nd.FieldND import space.kscience.kmath.nd.Shape @@ -24,22 +23,21 @@ public data class DomainBin>( override val value: Number, ) : Bin, Domain by domain -@OptIn(UnstableKMathAPI::class) public class IndexedHistogram, V : Any>( - public val context: IndexedHistogramSpace, + public val histogramSpace: IndexedHistogramSpace, public val values: StructureND, ) : Histogram> { override fun get(point: Point): Bin? { - val index = context.getIndex(point) ?: return null - return context.produceBin(index, values[index]) + val index = histogramSpace.getIndex(point) ?: return null + return histogramSpace.produceBin(index, values[index]) } - override val dimension: Int get() = context.shape.size + override val dimension: Int get() = histogramSpace.shape.size override val bins: Iterable> - get() = DefaultStrides(context.shape).asSequence().map { - context.produceBin(it, values[it]) + get() = DefaultStrides(histogramSpace.shape).asSequence().map { + histogramSpace.produceBin(it, values[it]) }.asIterable() } @@ -67,13 +65,13 @@ public interface IndexedHistogramSpace, V : Any> public fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram override fun add(left: IndexedHistogram, right: IndexedHistogram): IndexedHistogram { - require(left.context == this) { "Can't operate on a histogram produced by external space" } - require(right.context == this) { "Can't operate on a histogram produced by external space" } + require(left.histogramSpace == this) { "Can't operate on a histogram produced by external space" } + require(right.histogramSpace == this) { "Can't operate on a histogram produced by external space" } return IndexedHistogram(this, histogramValueSpace { left.values + right.values }) } override fun scale(a: IndexedHistogram, value: Double): IndexedHistogram { - require(a.context == this) { "Can't operate on a histogram produced by external space" } + require(a.histogramSpace == this) { "Can't operate on a histogram produced by external space" } return IndexedHistogram(this, histogramValueSpace { a.values * value }) } diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt similarity index 71% rename from kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt rename to kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt index ac0576a8e..69ea83ae3 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt @@ -37,26 +37,6 @@ public class UnivariateBin( public interface UnivariateHistogram : Histogram { public operator fun get(value: Double): UnivariateBin? override operator fun get(point: Buffer): UnivariateBin? = get(point[0]) - - public companion object { - /** - * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. - */ - public inline fun uniform( - binSize: Double, - start: Double = 0.0, - builder: UnivariateHistogramBuilder.() -> Unit, - ): UnivariateHistogram = TreeHistogramSpace.uniform(binSize, start).fill(builder) - - /** - * Build and fill a histogram with custom borders. Returns a read-only histogram. - */ - public inline fun custom( - borders: DoubleArray, - builder: UnivariateHistogramBuilder.() -> Unit, - ): UnivariateHistogram = TreeHistogramSpace.custom(borders).fill(builder) - - } } @UnstableKMathAPI diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt index 0853615e6..1ab49003c 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt @@ -49,7 +49,9 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> UnivariateDomain fun createBin(value: Double): BinCounter { val binDefinition = binFactory(value) val newBin = BinCounter(binDefinition) - synchronized(this) { bins[binDefinition.center] = newBin } + synchronized(this) { + bins[binDefinition.center] = newBin + } return newBin } @@ -131,6 +133,24 @@ public class TreeHistogramSpace( override val zero: UnivariateHistogram by lazy { fill { } } public companion object { + /** + * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. + */ + public inline fun uniform( + binSize: Double, + start: Double = 0.0, + builder: UnivariateHistogramBuilder.() -> Unit, + ): UnivariateHistogram = uniform(binSize, start).fill(builder) + + /** + * Build and fill a histogram with custom borders. Returns a read-only histogram. + */ + public inline fun custom( + borders: DoubleArray, + builder: UnivariateHistogramBuilder.() -> Unit, + ): UnivariateHistogram = custom(borders).fill(builder) + + /** * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. */ diff --git a/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt b/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt index 28a1b03cb..f1a8f953b 100644 --- a/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt +++ b/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt @@ -13,7 +13,7 @@ class TreeHistogramTest { @Test fun normalFill() { - val histogram = UnivariateHistogram.uniform(0.1) { + val histogram = TreeHistogramSpace.uniform(0.1) { repeat(100_000) { putValue(Random.nextDouble()) } From 29369cd6d7ef4a0b127df5551953e0b7239ffdec Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 22 Mar 2022 22:17:20 +0300 Subject: [PATCH 02/26] [WIP] Another histogram refactor --- .../{UnivariateDomain.kt => Domain1D.kt} | 15 +++- .../kmath/histogram/DoubleHistogramSpace.kt | 22 +++--- .../kscience/kmath/histogram/Histogram.kt | 33 +++++---- .../kscience/kmath/histogram/Histogram1D.kt | 56 +++++++++++++++ .../kmath/histogram/IndexedHistogramSpace.kt | 27 +++---- .../histogram/UniformDoubleHistogram1D.kt | 9 +++ .../kmath/histogram/UnivariateHistogram.kt | 59 --------------- .../kmath/histogram/TreeHistogramSpace.kt | 71 +++++++++---------- 8 files changed, 159 insertions(+), 133 deletions(-) rename kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/{UnivariateDomain.kt => Domain1D.kt} (57%) create mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt create mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt delete mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/UnivariateDomain.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt similarity index 57% rename from kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/UnivariateDomain.kt rename to kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt index 9020ef8cb..f50f16c11 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/UnivariateDomain.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt @@ -9,16 +9,21 @@ import space.kscience.kmath.linear.Point import space.kscience.kmath.misc.UnstableKMathAPI @UnstableKMathAPI -public class UnivariateDomain(public val range: ClosedFloatingPointRange) : DoubleDomain { +public abstract class Domain1D>(public val range: ClosedRange) : Domain { override val dimension: Int get() = 1 - public operator fun contains(d: Double): Boolean = range.contains(d) + public operator fun contains(value: T): Boolean = range.contains(value) - override operator fun contains(point: Point): Boolean { + override operator fun contains(point: Point): Boolean { require(point.size == 0) return contains(point[0]) } +} +@UnstableKMathAPI +public class DoubleDomain1D( + @Suppress("CanBeParameter") public val doubleRange: ClosedFloatingPointRange, +) : Domain1D(doubleRange), DoubleDomain { override fun getLowerBound(num: Int): Double { require(num == 0) return range.start @@ -31,3 +36,7 @@ public class UnivariateDomain(public val range: ClosedFloatingPointRange override fun volume(): Double = range.endInclusive - range.start } + +@UnstableKMathAPI +public val DoubleDomain1D.center: Double + get() = (range.endInclusive + range.start) / 2 diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt index 27f04d60b..c0df8c2cc 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt @@ -6,6 +6,7 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.HyperSquareDomain +import space.kscience.kmath.linear.Point import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.nd.* import space.kscience.kmath.operations.DoubleField @@ -31,7 +32,7 @@ public class DoubleHistogramSpace( public val dimension: Int get() = lower.size override val shape: IntArray = IntArray(binNums.size) { binNums[it] + 2 } - override val histogramValueSpace: DoubleFieldND = DoubleField.ndAlgebra(*shape) + override val histogramValueAlgebra: DoubleFieldND = DoubleField.ndAlgebra(*shape) private val binSize = DoubleBuffer(dimension) { (upper[it] - lower[it]) / binNums[it] } @@ -70,21 +71,20 @@ public class DoubleHistogramSpace( } @OptIn(UnstableKMathAPI::class) - public val Bin.domain: HyperSquareDomain - get() = (this as? DomainBin)?.domain as? HyperSquareDomain - ?: error("Im a teapot. This is not my bin") - - @OptIn(UnstableKMathAPI::class) - override fun produceBin(index: IntArray, value: Double): DomainBin { + override fun produceBin(index: IntArray, value: Double): DomainBin { val domain = getDomain(index) return DomainBin(domain, value) } - override fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram { + override fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram { val ndCounter = StructureND.auto(shape) { Counter.double() } - val hBuilder = HistogramBuilder { point, value -> - val index = getIndex(point) - ndCounter[index].add(value.toDouble()) + val hBuilder = object : HistogramBuilder { + override val defaultValue: Double get() = 1.0 + + override fun putValue(point: Point, value: Double) { + val index = getIndex(point) + ndCounter[index].add(value) + } } hBuilder.apply(builder) val values: BufferND = ndCounter.mapToBuffer { it.value } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt index 4e803fc63..64c031c7a 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt @@ -13,14 +13,14 @@ import space.kscience.kmath.structures.asBuffer /** * The binned data element. Could be a histogram bin with a number of counts or an artificial construct. */ -public interface Bin : Domain { +public interface Bin : Domain { /** * The value of this bin. */ - public val value: Number + public val value: V } -public interface Histogram> { +public interface Histogram> { /** * Find existing bin, corresponding to given coordinates */ @@ -32,29 +32,38 @@ public interface Histogram> { public val dimension: Int public val bins: Iterable + + public companion object { + //A discoverability root + } } -public fun interface HistogramBuilder { +public interface HistogramBuilder { /** - * Increment appropriate bin + * The default value increment for a bin */ - public fun putValue(point: Point, value: Number) + public val defaultValue: V + + /** + * Increment appropriate bin with given value + */ + public fun putValue(point: Point, value: V = defaultValue) } -public fun > HistogramBuilder.put(point: Point): Unit = putValue(point, 1.0) +public fun HistogramBuilder.put(point: Point): Unit = putValue(point) -public fun HistogramBuilder.put(vararg point: T): Unit = put(point.asBuffer()) +public fun HistogramBuilder.put(vararg point: T): Unit = put(point.asBuffer()) -public fun HistogramBuilder.put(vararg point: Number): Unit = +public fun HistogramBuilder.put(vararg point: Number): Unit = put(DoubleBuffer(point.map { it.toDouble() }.toDoubleArray())) -public fun HistogramBuilder.put(vararg point: Double): Unit = put(DoubleBuffer(point)) -public fun HistogramBuilder.fill(sequence: Iterable>): Unit = sequence.forEach { put(it) } +public fun HistogramBuilder.put(vararg point: Double): Unit = put(DoubleBuffer(point)) +public fun HistogramBuilder.fill(sequence: Iterable>): Unit = sequence.forEach { put(it) } /** * Pass a sequence builder into histogram */ -public fun HistogramBuilder.fill(block: suspend SequenceScope>.() -> Unit): Unit = +public fun HistogramBuilder.fill(block: suspend SequenceScope>.() -> Unit): Unit = fill(sequence(block).asIterable()) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt new file mode 100644 index 000000000..e9c62b141 --- /dev/null +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.histogram + +import space.kscience.kmath.domains.Domain1D +import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.operations.asSequence +import space.kscience.kmath.structures.Buffer + + +/** + * A univariate bin based on a range + * + * @property value The value of histogram including weighting + * @property standardDeviation Standard deviation of the bin value. Zero or negative if not applicable + */ +@UnstableKMathAPI +public class Bin1D, out V>( + public val domain: Domain1D, + override val value: V, +) : Bin, ClosedRange by domain.range { + + override val dimension: Int get() = 1 + + override fun contains(point: Buffer): Boolean = point.size == 1 && contains(point[0]) +} + +@OptIn(UnstableKMathAPI::class) +public interface Histogram1D, V> : Histogram> { + override val dimension: Int get() = 1 + public operator fun get(value: T): Bin1D? + override operator fun get(point: Buffer): Bin1D? = get(point[0]) +} + +@UnstableKMathAPI +public interface Histogram1DBuilder : HistogramBuilder { + /** + * Thread safe put operation + */ + public fun putValue(at: T, value: V = defaultValue) +} + +@UnstableKMathAPI +public fun Histogram1DBuilder.fill(items: Iterable): Unit = + items.forEach(this::putValue) + +@UnstableKMathAPI +public fun Histogram1DBuilder.fill(array: DoubleArray): Unit = + array.forEach(this::putValue) + +@UnstableKMathAPI +public fun Histogram1DBuilder.fill(buffer: Buffer): Unit = + buffer.asSequence().forEach(this::putValue) \ No newline at end of file diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt index bfacebb43..a2623b1a1 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt @@ -18,24 +18,28 @@ import space.kscience.kmath.operations.invoke /** * A simple histogram bin based on domain */ -public data class DomainBin>( +public data class DomainBin, out V>( public val domain: Domain, - override val value: Number, -) : Bin, Domain by domain + override val value: V, +) : Bin, Domain by domain +/** + * @param T the type of the argument space + * @param V the type of bin value + */ public class IndexedHistogram, V : Any>( public val histogramSpace: IndexedHistogramSpace, public val values: StructureND, -) : Histogram> { +) : Histogram> { - override fun get(point: Point): Bin? { + override fun get(point: Point): DomainBin? { val index = histogramSpace.getIndex(point) ?: return null return histogramSpace.produceBin(index, values[index]) } override val dimension: Int get() = histogramSpace.shape.size - override val bins: Iterable> + override val bins: Iterable> get() = DefaultStrides(histogramSpace.shape).asSequence().map { histogramSpace.produceBin(it, values[it]) }.asIterable() @@ -46,9 +50,8 @@ public class IndexedHistogram, V : Any>( */ public interface IndexedHistogramSpace, V : Any> : Group>, ScaleOperations> { - //public val valueSpace: Space public val shape: Shape - public val histogramValueSpace: FieldND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), + public val histogramValueAlgebra: FieldND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), /** * Resolve index of the bin including given [point] @@ -60,19 +63,19 @@ public interface IndexedHistogramSpace, V : Any> */ public fun getDomain(index: IntArray): Domain? - public fun produceBin(index: IntArray, value: V): Bin + public fun produceBin(index: IntArray, value: V): DomainBin - public fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram + public fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram override fun add(left: IndexedHistogram, right: IndexedHistogram): IndexedHistogram { require(left.histogramSpace == this) { "Can't operate on a histogram produced by external space" } require(right.histogramSpace == this) { "Can't operate on a histogram produced by external space" } - return IndexedHistogram(this, histogramValueSpace { left.values + right.values }) + return IndexedHistogram(this, histogramValueAlgebra { left.values + right.values }) } override fun scale(a: IndexedHistogram, value: Double): IndexedHistogram { require(a.histogramSpace == this) { "Can't operate on a histogram produced by external space" } - return IndexedHistogram(this, histogramValueSpace { a.values * value }) + return IndexedHistogram(this, histogramValueAlgebra { a.values * value }) } override val zero: IndexedHistogram get() = produce { } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt new file mode 100644 index 000000000..856cd8592 --- /dev/null +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt @@ -0,0 +1,9 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.histogram + +//class UniformDoubleHistogram1D: DoubleHistogram1D { +//} \ No newline at end of file diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt deleted file mode 100644 index 69ea83ae3..000000000 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2018-2021 KMath contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package space.kscience.kmath.histogram - -import space.kscience.kmath.domains.UnivariateDomain -import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.operations.asSequence -import space.kscience.kmath.structures.Buffer - - -@UnstableKMathAPI -public val UnivariateDomain.center: Double - get() = (range.endInclusive + range.start) / 2 - -/** - * A univariate bin based on a range - * - * @property value The value of histogram including weighting - * @property standardDeviation Standard deviation of the bin value. Zero or negative if not applicable - */ -@UnstableKMathAPI -public class UnivariateBin( - public val domain: UnivariateDomain, - override val value: Double, - public val standardDeviation: Double, -) : Bin, ClosedFloatingPointRange by domain.range { - - override val dimension: Int get() = 1 - - override fun contains(point: Buffer): Boolean = point.size == 1 && contains(point[0]) -} - -@OptIn(UnstableKMathAPI::class) -public interface UnivariateHistogram : Histogram { - public operator fun get(value: Double): UnivariateBin? - override operator fun get(point: Buffer): UnivariateBin? = get(point[0]) -} - -@UnstableKMathAPI -public interface UnivariateHistogramBuilder : HistogramBuilder { - /** - * Thread safe put operation - */ - public fun putValue(at: Double, value: Double = 1.0) - - override fun putValue(point: Buffer, value: Number) -} - -@UnstableKMathAPI -public fun UnivariateHistogramBuilder.fill(items: Iterable): Unit = items.forEach(this::putValue) - -@UnstableKMathAPI -public fun UnivariateHistogramBuilder.fill(array: DoubleArray): Unit = array.forEach(this::putValue) - -@UnstableKMathAPI -public fun UnivariateHistogramBuilder.fill(buffer: Buffer): Unit = buffer.asSequence().forEach(this::putValue) \ No newline at end of file diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt index 1ab49003c..9d07d5014 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt @@ -5,7 +5,7 @@ package space.kscience.kmath.histogram -import space.kscience.kmath.domains.UnivariateDomain +import space.kscience.kmath.domains.DoubleDomain1D import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations @@ -15,7 +15,7 @@ import kotlin.math.abs import kotlin.math.floor import kotlin.math.sqrt -private fun > TreeMap.getBin(value: Double): B? { +private fun > TreeMap.getBin(value: Double): B? { // check ceiling entry and return it if it is what needed val ceil = ceilingEntry(value)?.value if (ceil != null && value in ceil) return ceil @@ -28,19 +28,18 @@ private fun > TreeMap.getBin(val @UnstableKMathAPI public class TreeHistogram( - private val binMap: TreeMap, -) : UnivariateHistogram { - override fun get(value: Double): UnivariateBin? = binMap.getBin(value) - override val dimension: Int get() = 1 - override val bins: Collection get() = binMap.values + private val binMap: TreeMap>, +) : Histogram1D { + override fun get(value: Double): Bin1D? = binMap.getBin(value) + override val bins: Collection> get() = binMap.values } @OptIn(UnstableKMathAPI::class) @PublishedApi -internal class TreeHistogramBuilder(val binFactory: (Double) -> UnivariateDomain) : UnivariateHistogramBuilder { +internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) : Histogram1DBuilder { - internal class BinCounter(val domain: UnivariateDomain, val counter: Counter = Counter.double()) : - ClosedFloatingPointRange by domain.range + internal class BinCounter(val domain: DoubleDomain1D, val counter: Counter = Counter.double()) : + ClosedRange by domain.range private val bins: TreeMap = TreeMap() @@ -64,15 +63,15 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> UnivariateDomain } } - override fun putValue(point: Buffer, value: Number) { + override fun putValue(point: Buffer, value: Double) { require(point.size == 1) { "Only points with single value could be used in univariate histogram" } putValue(point[0], value.toDouble()) } fun build(): TreeHistogram { - val map = bins.mapValuesTo(TreeMap()) { (_, binCounter) -> + val map = bins.mapValuesTo(TreeMap>()) { (_, binCounter) -> val count = binCounter.counter.value - UnivariateBin(binCounter.domain, count, sqrt(count)) + Bin1D(binCounter.domain, count, sqrt(count)) } return TreeHistogram(map) } @@ -83,23 +82,23 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> UnivariateDomain */ @UnstableKMathAPI public class TreeHistogramSpace( - @PublishedApi internal val binFactory: (Double) -> UnivariateDomain, -) : Group, ScaleOperations { + @PublishedApi internal val binFactory: (Double) -> DoubleDomain1D, +) : Group>, ScaleOperations> { - public inline fun fill(block: UnivariateHistogramBuilder.() -> Unit): UnivariateHistogram = + public inline fun fill(block: Histogram1DBuilder.() -> Unit): Histogram1D = TreeHistogramBuilder(binFactory).apply(block).build() override fun add( - left: UnivariateHistogram, - right: UnivariateHistogram, - ): UnivariateHistogram { + left: Histogram1D, + right: Histogram1D, + ): Histogram1D { // require(a.context == this) { "Histogram $a does not belong to this context" } // require(b.context == this) { "Histogram $b does not belong to this context" } - val bins = TreeMap().apply { + val bins = TreeMap>().apply { (left.bins.map { it.domain } union right.bins.map { it.domain }).forEach { def -> put( def.center, - UnivariateBin( + Bin1D( def, value = (left[def.center]?.value ?: 0.0) + (right[def.center]?.value ?: 0.0), standardDeviation = (left[def.center]?.standardDeviation @@ -111,12 +110,12 @@ public class TreeHistogramSpace( return TreeHistogram(bins) } - override fun scale(a: UnivariateHistogram, value: Double): UnivariateHistogram { - val bins = TreeMap().apply { + override fun scale(a: Histogram1D, value: Double): Histogram1D { + val bins = TreeMap>().apply { a.bins.forEach { bin -> put( bin.domain.center, - UnivariateBin( + Bin1D( bin.domain, value = bin.value * value, standardDeviation = abs(bin.standardDeviation * value) @@ -128,38 +127,38 @@ public class TreeHistogramSpace( return TreeHistogram(bins) } - override fun UnivariateHistogram.unaryMinus(): UnivariateHistogram = this * (-1) + override fun Histogram1D.unaryMinus(): Histogram1D = this * (-1) - override val zero: UnivariateHistogram by lazy { fill { } } + override val zero: Histogram1D by lazy { fill { } } public companion object { /** - * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. + * Build and fill a [DoubleHistogram1D]. Returns a read-only histogram. */ public inline fun uniform( binSize: Double, start: Double = 0.0, - builder: UnivariateHistogramBuilder.() -> Unit, - ): UnivariateHistogram = uniform(binSize, start).fill(builder) + builder: Histogram1DBuilder.() -> Unit, + ): Histogram1D = uniform(binSize, start).fill(builder) /** * Build and fill a histogram with custom borders. Returns a read-only histogram. */ public inline fun custom( borders: DoubleArray, - builder: UnivariateHistogramBuilder.() -> Unit, - ): UnivariateHistogram = custom(borders).fill(builder) + builder: Histogram1DBuilder.() -> Unit, + ): Histogram1D = custom(borders).fill(builder) /** - * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. + * Build and fill a [DoubleHistogram1D]. Returns a read-only histogram. */ public fun uniform( binSize: Double, start: Double = 0.0, ): TreeHistogramSpace = TreeHistogramSpace { value -> val center = start + binSize * floor((value - start) / binSize + 0.5) - UnivariateDomain((center - binSize / 2)..(center + binSize / 2)) + DoubleDomain1D((center - binSize / 2)..(center + binSize / 2)) } /** @@ -170,11 +169,11 @@ public class TreeHistogramSpace( return TreeHistogramSpace { value -> when { - value < sorted.first() -> UnivariateDomain( + value < sorted.first() -> DoubleDomain1D( Double.NEGATIVE_INFINITY..sorted.first() ) - value > sorted.last() -> UnivariateDomain( + value > sorted.last() -> DoubleDomain1D( sorted.last()..Double.POSITIVE_INFINITY ) @@ -182,7 +181,7 @@ public class TreeHistogramSpace( val index = sorted.indices.first { value > sorted[it] } val left = sorted[index] val right = sorted[index + 1] - UnivariateDomain(left..right) + DoubleDomain1D(left..right) } } } From 3a3a5bd77f02b8a1fc43c399c53a5086a7891d5c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 23 Mar 2022 14:07:24 +0300 Subject: [PATCH 03/26] Histogram API refactor --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../space/kscience/kmath/domains/Domain1D.kt | 2 +- .../kscience/kmath/histogram/Histogram.kt | 2 +- .../kscience/kmath/histogram/Histogram1D.kt | 4 +- .../kmath/histogram/IndexedHistogramSpace.kt | 2 +- .../histogram/MultivariateHistogramTest.kt | 6 +- .../kmath/histogram/TreeHistogramSpace.kt | 70 +++++++++++-------- 7 files changed, 49 insertions(+), 39 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e5897b..00e33edef 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt index f50f16c11..ccd1c3edb 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt @@ -38,5 +38,5 @@ public class DoubleDomain1D( } @UnstableKMathAPI -public val DoubleDomain1D.center: Double +public val Domain1D.center: Double get() = (range.endInclusive + range.start) / 2 diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt index 64c031c7a..f9550df17 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt @@ -17,7 +17,7 @@ public interface Bin : Domain { /** * The value of this bin. */ - public val value: V + public val binValue: V } public interface Histogram> { diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt index e9c62b141..4f193f943 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt @@ -14,13 +14,13 @@ import space.kscience.kmath.structures.Buffer /** * A univariate bin based on a range * - * @property value The value of histogram including weighting + * @property binValue The value of histogram including weighting * @property standardDeviation Standard deviation of the bin value. Zero or negative if not applicable */ @UnstableKMathAPI public class Bin1D, out V>( public val domain: Domain1D, - override val value: V, + override val binValue: V, ) : Bin, ClosedRange by domain.range { override val dimension: Int get() = 1 diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt index a2623b1a1..3e4b07984 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt @@ -20,7 +20,7 @@ import space.kscience.kmath.operations.invoke */ public data class DomainBin, out V>( public val domain: Domain, - override val value: V, + override val binValue: V, ) : Bin, Domain by domain /** diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt index 923cc98de..31a29676c 100644 --- a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt @@ -21,7 +21,7 @@ internal class MultivariateHistogramTest { val histogram = hSpace.produce { put(0.55, 0.55) } - val bin = histogram.bins.find { it.value.toInt() > 0 } ?: fail() + val bin = histogram.bins.find { it.binValue.toInt() > 0 } ?: fail() assertTrue { bin.contains(DoubleVector(0.55, 0.55)) } assertTrue { bin.contains(DoubleVector(0.6, 0.5)) } assertFalse { bin.contains(DoubleVector(-0.55, 0.55)) } @@ -44,7 +44,7 @@ internal class MultivariateHistogramTest { put(nextDouble(), nextDouble(), nextDouble()) } } - assertEquals(n, histogram.bins.sumOf { it.value.toInt() }) + assertEquals(n, histogram.bins.sumOf { it.binValue.toInt() }) } @Test @@ -77,7 +77,7 @@ internal class MultivariateHistogramTest { assertTrue { res.bins.count() >= histogram1.bins.count() } - assertEquals(0.0, res.bins.sumOf { it.value.toDouble() }) + assertEquals(0.0, res.bins.sumOf { it.binValue.toDouble() }) } } } \ No newline at end of file diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt index 9d07d5014..38e533db0 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt @@ -6,6 +6,7 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.DoubleDomain1D +import space.kscience.kmath.domains.center import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations @@ -26,18 +27,24 @@ private fun > TreeMap.getBin(value: Double): return null } +public data class ValueAndError(val value: Double, val error: Double) + +public typealias WeightedBin1D = Bin1D + @UnstableKMathAPI public class TreeHistogram( - private val binMap: TreeMap>, -) : Histogram1D { - override fun get(value: Double): Bin1D? = binMap.getBin(value) - override val bins: Collection> get() = binMap.values + private val binMap: TreeMap, +) : Histogram1D { + override fun get(value: Double): WeightedBin1D? = binMap.getBin(value) + override val bins: Collection get() = binMap.values } @OptIn(UnstableKMathAPI::class) @PublishedApi internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) : Histogram1DBuilder { + override val defaultValue: Double get() = 1.0 + internal class BinCounter(val domain: DoubleDomain1D, val counter: Counter = Counter.double()) : ClosedRange by domain.range @@ -46,7 +53,7 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) fun get(value: Double): BinCounter? = bins.getBin(value) fun createBin(value: Double): BinCounter { - val binDefinition = binFactory(value) + val binDefinition: DoubleDomain1D = binFactory(value) val newBin = BinCounter(binDefinition) synchronized(this) { bins[binDefinition.center] = newBin @@ -69,9 +76,9 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) } fun build(): TreeHistogram { - val map = bins.mapValuesTo(TreeMap>()) { (_, binCounter) -> - val count = binCounter.counter.value - Bin1D(binCounter.domain, count, sqrt(count)) + val map = bins.mapValuesTo(TreeMap()) { (_, binCounter) -> + val count: Double = binCounter.counter.value + WeightedBin1D(binCounter.domain, ValueAndError(count, sqrt(count))) } return TreeHistogram(map) } @@ -83,26 +90,27 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) @UnstableKMathAPI public class TreeHistogramSpace( @PublishedApi internal val binFactory: (Double) -> DoubleDomain1D, -) : Group>, ScaleOperations> { +) : Group, ScaleOperations { - public inline fun fill(block: Histogram1DBuilder.() -> Unit): Histogram1D = + public inline fun fill(block: Histogram1DBuilder.() -> Unit): TreeHistogram = TreeHistogramBuilder(binFactory).apply(block).build() override fun add( - left: Histogram1D, - right: Histogram1D, - ): Histogram1D { + left: TreeHistogram, + right: TreeHistogram, + ): TreeHistogram { // require(a.context == this) { "Histogram $a does not belong to this context" } // require(b.context == this) { "Histogram $b does not belong to this context" } - val bins = TreeMap>().apply { + val bins = TreeMap().apply { (left.bins.map { it.domain } union right.bins.map { it.domain }).forEach { def -> put( def.center, - Bin1D( + WeightedBin1D( def, - value = (left[def.center]?.value ?: 0.0) + (right[def.center]?.value ?: 0.0), - standardDeviation = (left[def.center]?.standardDeviation - ?: 0.0) + (right[def.center]?.standardDeviation ?: 0.0) + ValueAndError( + (left[def.center]?.binValue?.value ?: 0.0) + (right[def.center]?.binValue?.value ?: 0.0), + (left[def.center]?.binValue?.error ?: 0.0) + (right[def.center]?.binValue?.error ?: 0.0) + ) ) ) } @@ -110,15 +118,17 @@ public class TreeHistogramSpace( return TreeHistogram(bins) } - override fun scale(a: Histogram1D, value: Double): Histogram1D { - val bins = TreeMap>().apply { + override fun scale(a: TreeHistogram, value: Double): TreeHistogram { + val bins = TreeMap().apply { a.bins.forEach { bin -> put( bin.domain.center, - Bin1D( + WeightedBin1D( bin.domain, - value = bin.value * value, - standardDeviation = abs(bin.standardDeviation * value) + ValueAndError( + bin.binValue.value * value, + abs(bin.binValue.error * value) + ) ) ) } @@ -127,27 +137,27 @@ public class TreeHistogramSpace( return TreeHistogram(bins) } - override fun Histogram1D.unaryMinus(): Histogram1D = this * (-1) + override fun TreeHistogram.unaryMinus(): TreeHistogram = this * (-1) - override val zero: Histogram1D by lazy { fill { } } + override val zero: TreeHistogram by lazy { fill { } } public companion object { /** - * Build and fill a [DoubleHistogram1D]. Returns a read-only histogram. + * Build and fill a [TreeHistogram]. Returns a read-only histogram. */ public inline fun uniform( binSize: Double, start: Double = 0.0, - builder: Histogram1DBuilder.() -> Unit, - ): Histogram1D = uniform(binSize, start).fill(builder) + builder: Histogram1DBuilder.() -> Unit, + ): TreeHistogram = uniform(binSize, start).fill(builder) /** * Build and fill a histogram with custom borders. Returns a read-only histogram. */ public inline fun custom( borders: DoubleArray, - builder: Histogram1DBuilder.() -> Unit, - ): Histogram1D = custom(borders).fill(builder) + builder: Histogram1DBuilder.() -> Unit, + ): TreeHistogram = custom(borders).fill(builder) /** From ce82d2d07633240f8df932fb9b8ac185e0e8c9d6 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 23 Mar 2022 15:51:08 +0300 Subject: [PATCH 04/26] Histogram API refactor --- .../{UniformDoubleHistogram1D.kt => UniformHistogram1D.kt} | 5 ++++- .../space/kscience/kmath/histogram/TreeHistogramSpace.kt | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) rename kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/{UniformDoubleHistogram1D.kt => UniformHistogram1D.kt} (58%) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt similarity index 58% rename from kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt rename to kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index 856cd8592..ed8b2e29d 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformDoubleHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -5,5 +5,8 @@ package space.kscience.kmath.histogram -//class UniformDoubleHistogram1D: DoubleHistogram1D { +//class UniformHistogram1D( +// public val borders: Buffer, +// public val values: Buffer, +//) : Histogram1D { //} \ No newline at end of file diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt index 38e533db0..e85bb0a3c 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt @@ -3,6 +3,8 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +@file:OptIn(UnstableKMathAPI::class) + package space.kscience.kmath.histogram import space.kscience.kmath.domains.DoubleDomain1D @@ -31,7 +33,6 @@ public data class ValueAndError(val value: Double, val error: Double) public typealias WeightedBin1D = Bin1D -@UnstableKMathAPI public class TreeHistogram( private val binMap: TreeMap, ) : Histogram1D { @@ -39,7 +40,6 @@ public class TreeHistogram( override val bins: Collection get() = binMap.values } -@OptIn(UnstableKMathAPI::class) @PublishedApi internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) : Histogram1DBuilder { @@ -87,7 +87,6 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) /** * A space for univariate histograms with variable bin borders based on a tree map */ -@UnstableKMathAPI public class TreeHistogramSpace( @PublishedApi internal val binFactory: (Double) -> DoubleDomain1D, ) : Group, ScaleOperations { From 92cffd78d935e8d834ec14887680ccffdaf89586 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Fri, 1 Apr 2022 02:23:34 +0700 Subject: [PATCH 05/26] Upgrade gradle tools --- .github/workflows/build.yml | 11 ++-- .github/workflows/pages.yml | 7 +- .github/workflows/publish.yml | 17 ++--- README.md | 80 ++++++++--------------- benchmarks/README.md | 4 ++ buildSrc/gradle.properties | 3 +- buildSrc/settings.gradle.kts | 3 +- docs/templates/README-TEMPLATE.md | 2 +- examples/README.md | 4 ++ gradle.properties | 7 +- gradle/wrapper/gradle-wrapper.jar | Bin 59536 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- kmath-ast/README.md | 55 +++++++++++----- kmath-commons/README.md | 32 +++++++++ kmath-complex/README.md | 10 +-- kmath-core/README.md | 10 +-- kmath-coroutines/README.md | 32 +++++++++ kmath-dimensions/README.md | 32 +++++++++ kmath-ejml/README.md | 10 +-- kmath-for-real/README.md | 10 +-- kmath-functions/README.md | 10 +-- kmath-geometry/README.md | 32 +++++++++ kmath-histograms/README.md | 32 +++++++++ kmath-jafama/README.md | 10 +-- kmath-jupyter/README.md | 32 +++++++++ kmath-kotlingrad/README.md | 10 +-- kmath-memory/README.md | 32 +++++++++ kmath-multik/README.md | 32 +++++++++ kmath-nd4j/README.md | 10 +-- kmath-optimization/README.md | 32 +++++++++ kmath-stat/README.md | 32 +++++++++ kmath-symja/README.md | 32 +++++++++ kmath-tensorflow/README.md | 32 +++++++++ kmath-tensors/README.md | 10 +-- kmath-viktor/README.md | 32 +++++++++ settings.gradle.kts | 2 - 36 files changed, 556 insertions(+), 147 deletions(-) create mode 100644 benchmarks/README.md create mode 100644 examples/README.md create mode 100644 kmath-commons/README.md create mode 100644 kmath-coroutines/README.md create mode 100644 kmath-dimensions/README.md create mode 100644 kmath-geometry/README.md create mode 100644 kmath-histograms/README.md create mode 100644 kmath-jupyter/README.md create mode 100644 kmath-memory/README.md create mode 100644 kmath-multik/README.md create mode 100644 kmath-optimization/README.md create mode 100644 kmath-stat/README.md create mode 100644 kmath-symja/README.md create mode 100644 kmath-tensorflow/README.md create mode 100644 kmath-viktor/README.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2c76a354..455e0dd2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,14 +13,11 @@ jobs: runs-on: ${{matrix.os}} timeout-minutes: 40 steps: - - name: Checkout the repo - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: DeLaGuardo/setup-graalvm@4.0 + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2.5.0 with: - graalvm: 21.2.0 - java: java11 - arch: amd64 + java-version: 11 + distribution: liberica - name: Cache gradle uses: actions/cache@v2 with: diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 23ed54357..e7f5300c7 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -10,11 +10,10 @@ jobs: timeout-minutes: 40 steps: - uses: actions/checkout@v2 - - uses: DeLaGuardo/setup-graalvm@4.0 + - uses: actions/setup-java@v2.5.0 with: - graalvm: 21.2.0 - java: java11 - arch: amd64 + java-version: 11 + distribution: liberica - uses: actions/cache@v2 with: path: ~/.gradle/caches diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fa3cb700c..17adc5655 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,14 +14,11 @@ jobs: os: [ macOS-latest, windows-latest ] runs-on: ${{matrix.os}} steps: - - name: Checkout the repo - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: DeLaGuardo/setup-graalvm@4.0 + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2.5.0 with: - graalvm: 21.2.0 - java: java11 - arch: amd64 + java-version: 11 + distribution: liberica - name: Cache gradle uses: actions/cache@v2 with: @@ -44,12 +41,12 @@ jobs: if: matrix.os == 'windows-latest' shell: cmd run: > - ./gradlew release --no-daemon --build-cache -Ppublishing.enabled=true + ./gradlew releaseAll --no-daemon --build-cache -Ppublishing.enabled=true -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} - name: Publish Mac Artifacts if: matrix.os == 'macOS-latest' run: > - ./gradlew release --no-daemon --build-cache -Ppublishing.enabled=true -Ppublishing.platform=macosX64 - -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} + ./gradlew releaseMacosX64 releaseIosArm64 releaseIosX64 release --no-daemon --build-cache + -Ppublishing.enabled=true -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} diff --git a/README.md b/README.md index 99dd6d00f..aea94f529 100644 --- a/README.md +++ b/README.md @@ -52,21 +52,18 @@ module definitions below. The module stability could have the following levels: ## Modules -
-* ### [benchmarks](benchmarks) +### [benchmarks](benchmarks) > > > **Maturity**: EXPERIMENTAL -
-* ### [examples](examples) +### [examples](examples) > > > **Maturity**: EXPERIMENTAL -
-* ### [kmath-ast](kmath-ast) +### [kmath-ast](kmath-ast) > > > **Maturity**: EXPERIMENTAL @@ -77,15 +74,13 @@ module definitions below. The module stability could have the following levels: > - [mst-js-codegen](kmath-ast/src/jsMain/kotlin/space/kscience/kmath/estree/estree.kt) : Dynamic MST to JS compiler > - [rendering](kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/MathRenderer.kt) : Extendable MST rendering -
-* ### [kmath-commons](kmath-commons) +### [kmath-commons](kmath-commons) > > > **Maturity**: EXPERIMENTAL -
-* ### [kmath-complex](kmath-complex) +### [kmath-complex](kmath-complex) > Complex numbers and quaternions. > > **Maturity**: PROTOTYPE @@ -94,9 +89,8 @@ module definitions below. The module stability could have the following levels: > - [complex](kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/Complex.kt) : Complex Numbers > - [quaternion](kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/Quaternion.kt) : Quaternions -
-* ### [kmath-core](kmath-core) +### [kmath-core](kmath-core) > Core classes, algebra definitions, basic linear algebra > > **Maturity**: DEVELOPMENT @@ -112,21 +106,18 @@ performance calculations to code generation. > - [domains](kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains) : Domains > - [autodiff](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/SimpleAutoDiff.kt) : Automatic differentiation -
-* ### [kmath-coroutines](kmath-coroutines) +### [kmath-coroutines](kmath-coroutines) > > > **Maturity**: EXPERIMENTAL -
-* ### [kmath-dimensions](kmath-dimensions) +### [kmath-dimensions](kmath-dimensions) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-ejml](kmath-ejml) +### [kmath-ejml](kmath-ejml) > > > **Maturity**: PROTOTYPE @@ -136,9 +127,8 @@ performance calculations to code generation. > - [ejml-matrix](kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt) : Matrix implementation. > - [ejml-linear-space](kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt) : LinearSpace implementations. -
-* ### [kmath-for-real](kmath-for-real) +### [kmath-for-real](kmath-for-real) > Extension module that should be used to achieve numpy-like behavior. All operations are specialized to work with `Double` numbers without declaring algebraic contexts. One can still use generic algebras though. @@ -150,9 +140,8 @@ One can still use generic algebras though. > - [DoubleMatrix](kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/DoubleMatrix.kt) : Numpy-like operations for 2d real structures > - [grids](kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/structures/grids.kt) : Uniform grid generators -
-* ### [kmath-functions](kmath-functions) +### [kmath-functions](kmath-functions) > > > **Maturity**: EXPERIMENTAL @@ -164,21 +153,18 @@ One can still use generic algebras though. > - [spline interpolation](kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator. > - [integration](kmath-functions/#) : Univariate and multivariate quadratures -
-* ### [kmath-geometry](kmath-geometry) +### [kmath-geometry](kmath-geometry) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-histograms](kmath-histograms) +### [kmath-histograms](kmath-histograms) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-jafama](kmath-jafama) +### [kmath-jafama](kmath-jafama) > > > **Maturity**: PROTOTYPE @@ -186,15 +172,13 @@ One can still use generic algebras though. > **Features:** > - [jafama-double](kmath-jafama/src/main/kotlin/space/kscience/kmath/jafama/) : Double ExtendedField implementations based on Jafama -
-* ### [kmath-jupyter](kmath-jupyter) +### [kmath-jupyter](kmath-jupyter) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-kotlingrad](kmath-kotlingrad) +### [kmath-kotlingrad](kmath-kotlingrad) > > > **Maturity**: EXPERIMENTAL @@ -203,21 +187,18 @@ One can still use generic algebras though. > - [differentiable-mst-expression](kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt) : MST based DifferentiableExpression. > - [scalars-adapters](kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt) : Conversions between Kotlin∇'s SFun and MST -
-* ### [kmath-memory](kmath-memory) +### [kmath-memory](kmath-memory) > An API and basic implementation for arranging objects in a continuous memory block. > > **Maturity**: DEVELOPMENT -
-* ### [kmath-multik](kmath-multik) +### [kmath-multik](kmath-multik) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-nd4j](kmath-nd4j) +### [kmath-nd4j](kmath-nd4j) > > > **Maturity**: EXPERIMENTAL @@ -227,33 +208,28 @@ One can still use generic algebras though. > - [nd4jarrayrings](kmath-nd4j/#) : Rings over Nd4jArrayStructure of Int and Long > - [nd4jarrayfields](kmath-nd4j/#) : Fields over Nd4jArrayStructure of Float and Double -
-* ### [kmath-optimization](kmath-optimization) +### [kmath-optimization](kmath-optimization) > > > **Maturity**: EXPERIMENTAL -
-* ### [kmath-stat](kmath-stat) +### [kmath-stat](kmath-stat) > > > **Maturity**: EXPERIMENTAL -
-* ### [kmath-symja](kmath-symja) +### [kmath-symja](kmath-symja) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-tensorflow](kmath-tensorflow) +### [kmath-tensorflow](kmath-tensorflow) > > > **Maturity**: PROTOTYPE -
-* ### [kmath-tensors](kmath-tensors) +### [kmath-tensors](kmath-tensors) > > > **Maturity**: PROTOTYPE @@ -263,13 +239,11 @@ One can still use generic algebras though. > - [tensor algebra with broadcasting](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/BroadcastDoubleTensorAlgebra.kt) : Basic linear algebra operations implemented with broadcasting. > - [linear algebra operations](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Advanced linear algebra operations like LU decomposition, SVD, etc. -
-* ### [kmath-viktor](kmath-viktor) +### [kmath-viktor](kmath-viktor) > > > **Maturity**: DEVELOPMENT -
## Multi-platform support @@ -308,8 +282,8 @@ repositories { } dependencies { - api("space.kscience:kmath-core:0.3.0-dev-17") - // api("space.kscience:kmath-core-jvm:0.3.0-dev-17") for jvm-specific version + api("space.kscience:kmath-core:$version") + // api("space.kscience:kmath-core-jvm:$version") for jvm-specific version } ``` diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 000000000..cd8fbafd3 --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,4 @@ +# Module benchmarks + + + diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 05486d4f6..a0b05e812 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -4,5 +4,4 @@ # kotlin.code.style=official - -toolsVersion=0.11.1-kotlin-1.6.10 +toolsVersion=0.11.2-kotlin-1.6.10 diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 9c5550602..bc530ac03 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -7,7 +7,6 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("VERSION_CATALOGS") dependencyResolutionManagement { - val toolsVersion: String by extra repositories { @@ -22,4 +21,4 @@ dependencyResolutionManagement { from("ru.mipt.npm:version-catalog:$toolsVersion") } } -} \ No newline at end of file +} diff --git a/docs/templates/README-TEMPLATE.md b/docs/templates/README-TEMPLATE.md index b0c418697..4ffa9e75f 100644 --- a/docs/templates/README-TEMPLATE.md +++ b/docs/templates/README-TEMPLATE.md @@ -52,7 +52,7 @@ module definitions below. The module stability could have the following levels: ## Modules -$modules +${modules} ## Multi-platform support diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..d4e1c5289 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,4 @@ +# Module examples + + + diff --git a/gradle.properties b/gradle.properties index 7d9628621..a7cd2f876 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,13 +2,10 @@ # Copyright 2018-2021 KMath contributors. # Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. # - kotlin.code.style=official +kotlin.jupyter.add.scanner=false kotlin.mpp.stability.nowarn=true kotlin.native.ignoreDisabledTargets=true - -kotlin.jupyter.add.scanner=false - org.gradle.configureondemand=true -org.gradle.parallel=true org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G +org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2ae8848c63b8b4dea2cb829da983f2fa..41d9927a4d4fb3f96a785543079b8df6723c946b 100644 GIT binary patch delta 8958 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 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e5897b..aa991fcea 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/kmath-ast/README.md b/kmath-ast/README.md index bedf17486..4872a3a26 100644 --- a/kmath-ast/README.md +++ b/kmath-ast/README.md @@ -10,17 +10,17 @@ Extensions to MST API: transformations, dynamic compilation and visualization. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-ast:0.3.0-dev-17' + implementation 'space.kscience:kmath-ast:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation("space.kscience:kmath-ast:0.3.0-dev-17") + implementation("space.kscience:kmath-ast:0.3.0-dev-20") } ``` @@ -66,20 +66,19 @@ For example, the following code: ```kotlin import space.kscience.kmath.asm.compileToExpression -import space.kscience.kmath.complex.ComplexField +import space.kscience.kmath.operations.DoubleField -"x+2".parseMath().compileToExpression(ComplexField) +"x^3-x+3".parseMath().compileToExpression(DoubleField) ``` … leads to generation of bytecode, which can be decompiled to the following Java class: ```java -import java.util.Map; -import kotlin.jvm.functions.Function2; -import space.kscience.kmath.asm.internal.MapIntrinsics; -import space.kscience.kmath.complex.Complex; -import space.kscience.kmath.expressions.Expression; -import space.kscience.kmath.expressions.Symbol; +import java.util.*; +import kotlin.jvm.functions.*; +import space.kscience.kmath.asm.internal.*; +import space.kscience.kmath.complex.*; +import space.kscience.kmath.expressions.*; public final class CompiledExpression_45045_0 implements Expression { private final Object[] constants; @@ -91,6 +90,32 @@ public final class CompiledExpression_45045_0 implements Expression { } ``` +For `LongRing`, `IntRing`, and `DoubleField` specialization is supported for better performance: + +```java +import java.util.*; +import space.kscience.kmath.asm.internal.*; +import space.kscience.kmath.expressions.*; + +public final class CompiledExpression_-386104628_0 implements DoubleExpression { + private final SymbolIndexer indexer; + + public SymbolIndexer getIndexer() { + return this.indexer; + } + + public double invoke(double[] arguments) { + double var2 = arguments[0]; + return Math.pow(var2, 3.0D) - var2 + 3.0D; + } + + public final Double invoke(Map arguments) { + double var2 = ((Double)MapIntrinsics.getOrFail(arguments, "x")).doubleValue(); + return Math.pow(var2, 3.0D) - var2 + 3.0D; + } +} +``` + Setting JVM system property `space.kscience.kmath.ast.dump.generated.classes` to `1` makes the translator dump class files to program's working directory, so they can be reviewed manually. #### Limitations @@ -134,9 +159,9 @@ MstField { x + 2 }.compileToExpression(DoubleField) An example of emitted Wasm IR in the form of WAT: ```lisp -(func $executable (param $0 f64) (result f64) +(func \$executable (param \$0 f64) (result f64) (f64.add - (local.get $0) + (local.get \$0) (f64.const 2) ) ) diff --git a/kmath-commons/README.md b/kmath-commons/README.md new file mode 100644 index 000000000..a17a39205 --- /dev/null +++ b/kmath-commons/README.md @@ -0,0 +1,32 @@ +# Module kmath-commons + +Commons math binding for kmath + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-commons:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-commons:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-commons:0.3.0-dev-20") +} +``` diff --git a/kmath-complex/README.md b/kmath-complex/README.md index 92f2435ba..b55ce0fea 100644 --- a/kmath-complex/README.md +++ b/kmath-complex/README.md @@ -8,17 +8,17 @@ Complex and hypercomplex number systems in KMath. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-complex:0.3.0-dev-17' + implementation 'space.kscience:kmath-complex:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -29,6 +29,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-complex:0.3.0-dev-17") + implementation("space.kscience:kmath-complex:0.3.0-dev-20") } ``` diff --git a/kmath-core/README.md b/kmath-core/README.md index e765ad50c..31965ef92 100644 --- a/kmath-core/README.md +++ b/kmath-core/README.md @@ -15,17 +15,17 @@ performance calculations to code generation. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-core:0.3.0-dev-17' + implementation 'space.kscience:kmath-core:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -36,6 +36,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-core:0.3.0-dev-17") + implementation("space.kscience:kmath-core:0.3.0-dev-20") } ``` diff --git a/kmath-coroutines/README.md b/kmath-coroutines/README.md new file mode 100644 index 000000000..0d83a6c60 --- /dev/null +++ b/kmath-coroutines/README.md @@ -0,0 +1,32 @@ +# Module kmath-coroutines + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-coroutines:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-coroutines:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-coroutines:0.3.0-dev-20") +} +``` diff --git a/kmath-dimensions/README.md b/kmath-dimensions/README.md new file mode 100644 index 000000000..52097cf40 --- /dev/null +++ b/kmath-dimensions/README.md @@ -0,0 +1,32 @@ +# Module kmath-dimensions + +A proof of concept module for adding type-safe dimensions to structures + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-dimensions:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-dimensions:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-dimensions:0.3.0-dev-20") +} +``` diff --git a/kmath-ejml/README.md b/kmath-ejml/README.md index fcd092bf1..3fe6d9e1a 100644 --- a/kmath-ejml/README.md +++ b/kmath-ejml/README.md @@ -9,17 +9,17 @@ EJML based linear algebra implementation. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-ejml:0.3.0-dev-17' + implementation 'space.kscience:kmath-ejml:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -30,6 +30,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-ejml:0.3.0-dev-17") + implementation("space.kscience:kmath-ejml:0.3.0-dev-20") } ``` diff --git a/kmath-for-real/README.md b/kmath-for-real/README.md index 938327612..197190dcd 100644 --- a/kmath-for-real/README.md +++ b/kmath-for-real/README.md @@ -9,17 +9,17 @@ Specialization of KMath APIs for Double numbers. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-for-real:0.3.0-dev-17' + implementation 'space.kscience:kmath-for-real:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -30,6 +30,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-for-real:0.3.0-dev-17") + implementation("space.kscience:kmath-for-real:0.3.0-dev-20") } ``` diff --git a/kmath-functions/README.md b/kmath-functions/README.md index 3d4beee47..6379ad0b5 100644 --- a/kmath-functions/README.md +++ b/kmath-functions/README.md @@ -11,17 +11,17 @@ Functions and interpolations. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-functions:0.3.0-dev-17' + implementation 'space.kscience:kmath-functions:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -32,6 +32,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-functions:0.3.0-dev-17") + implementation("space.kscience:kmath-functions:0.3.0-dev-20") } ``` diff --git a/kmath-geometry/README.md b/kmath-geometry/README.md new file mode 100644 index 000000000..6b8fb25a0 --- /dev/null +++ b/kmath-geometry/README.md @@ -0,0 +1,32 @@ +# Module kmath-geometry + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-geometry:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-geometry:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-geometry:0.3.0-dev-20") +} +``` diff --git a/kmath-histograms/README.md b/kmath-histograms/README.md new file mode 100644 index 000000000..0b8a632d6 --- /dev/null +++ b/kmath-histograms/README.md @@ -0,0 +1,32 @@ +# Module kmath-histograms + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-histograms:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-histograms:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-histograms:0.3.0-dev-20") +} +``` diff --git a/kmath-jafama/README.md b/kmath-jafama/README.md index 760244751..a274b3d88 100644 --- a/kmath-jafama/README.md +++ b/kmath-jafama/README.md @@ -7,17 +7,17 @@ Integration with [Jafama](https://github.com/jeffhain/jafama). ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-jafama:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-jafama:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-jafama:0.3.0-dev-17' + implementation 'space.kscience:kmath-jafama:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -28,7 +28,7 @@ repositories { } dependencies { - implementation("space.kscience:kmath-jafama:0.3.0-dev-17") + implementation("space.kscience:kmath-jafama:0.3.0-dev-20") } ``` diff --git a/kmath-jupyter/README.md b/kmath-jupyter/README.md new file mode 100644 index 000000000..8014b969d --- /dev/null +++ b/kmath-jupyter/README.md @@ -0,0 +1,32 @@ +# Module kmath-jupyter + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-jupyter:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-jupyter:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-jupyter:0.3.0-dev-20") +} +``` diff --git a/kmath-kotlingrad/README.md b/kmath-kotlingrad/README.md index 588ccb9b4..08c913090 100644 --- a/kmath-kotlingrad/README.md +++ b/kmath-kotlingrad/README.md @@ -8,17 +8,17 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-17' + implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -29,6 +29,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-17") + implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-20") } ``` diff --git a/kmath-memory/README.md b/kmath-memory/README.md new file mode 100644 index 000000000..d37087a66 --- /dev/null +++ b/kmath-memory/README.md @@ -0,0 +1,32 @@ +# Module kmath-memory + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-memory:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-memory:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-memory:0.3.0-dev-20") +} +``` diff --git a/kmath-multik/README.md b/kmath-multik/README.md new file mode 100644 index 000000000..167445f52 --- /dev/null +++ b/kmath-multik/README.md @@ -0,0 +1,32 @@ +# Module kmath-multik + +JetBrains Multik connector + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-multik:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-multik:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-multik:0.3.0-dev-20") +} +``` diff --git a/kmath-nd4j/README.md b/kmath-nd4j/README.md index 7ca9cd4fd..225de18e9 100644 --- a/kmath-nd4j/README.md +++ b/kmath-nd4j/README.md @@ -9,17 +9,17 @@ ND4J based implementations of KMath abstractions. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-nd4j:0.3.0-dev-17' + implementation 'space.kscience:kmath-nd4j:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -30,7 +30,7 @@ repositories { } dependencies { - implementation("space.kscience:kmath-nd4j:0.3.0-dev-17") + implementation("space.kscience:kmath-nd4j:0.3.0-dev-20") } ``` diff --git a/kmath-optimization/README.md b/kmath-optimization/README.md new file mode 100644 index 000000000..137975c90 --- /dev/null +++ b/kmath-optimization/README.md @@ -0,0 +1,32 @@ +# Module kmath-optimization + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-optimization:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-optimization:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-optimization:0.3.0-dev-20") +} +``` diff --git a/kmath-stat/README.md b/kmath-stat/README.md new file mode 100644 index 000000000..762e61237 --- /dev/null +++ b/kmath-stat/README.md @@ -0,0 +1,32 @@ +# Module kmath-stat + + + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-stat:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-stat:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-stat:0.3.0-dev-20") +} +``` diff --git a/kmath-symja/README.md b/kmath-symja/README.md new file mode 100644 index 000000000..e3c717cff --- /dev/null +++ b/kmath-symja/README.md @@ -0,0 +1,32 @@ +# Module kmath-symja + +Symja integration module + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-symja:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-symja:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-symja:0.3.0-dev-20") +} +``` diff --git a/kmath-tensorflow/README.md b/kmath-tensorflow/README.md new file mode 100644 index 000000000..f1dfa0202 --- /dev/null +++ b/kmath-tensorflow/README.md @@ -0,0 +1,32 @@ +# Module kmath-tensorflow + +Google tensorflow connector + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-tensorflow:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-tensorflow:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-tensorflow:0.3.0-dev-20") +} +``` diff --git a/kmath-tensors/README.md b/kmath-tensors/README.md index 42ce91336..3d7dfd1fb 100644 --- a/kmath-tensors/README.md +++ b/kmath-tensors/README.md @@ -9,17 +9,17 @@ Common linear algebra operations on tensors. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-17`. +The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-20`. -**Gradle:** -```gradle +**Gradle Groovy:** +```groovy repositories { maven { url 'https://repo.kotlin.link' } mavenCentral() } dependencies { - implementation 'space.kscience:kmath-tensors:0.3.0-dev-17' + implementation 'space.kscience:kmath-tensors:0.3.0-dev-20' } ``` **Gradle Kotlin DSL:** @@ -30,6 +30,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-tensors:0.3.0-dev-17") + implementation("space.kscience:kmath-tensors:0.3.0-dev-20") } ``` diff --git a/kmath-viktor/README.md b/kmath-viktor/README.md new file mode 100644 index 000000000..229d4dcd4 --- /dev/null +++ b/kmath-viktor/README.md @@ -0,0 +1,32 @@ +# Module kmath-viktor + +Binding for https://github.com/JetBrains-Research/viktor + +## Usage + +## Artifact: + +The Maven coordinates of this project are `space.kscience:kmath-viktor:0.3.0-dev-20`. + +**Gradle Groovy:** +```groovy +repositories { + maven { url 'https://repo.kotlin.link' } + mavenCentral() +} + +dependencies { + implementation 'space.kscience:kmath-viktor:0.3.0-dev-20' +} +``` +**Gradle Kotlin DSL:** +```kotlin +repositories { + maven("https://repo.kotlin.link") + mavenCentral() +} + +dependencies { + implementation("space.kscience:kmath-viktor:0.3.0-dev-20") +} +``` diff --git a/settings.gradle.kts b/settings.gradle.kts index a8b473fee..b3c275810 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,8 +1,6 @@ rootProject.name = "kmath" enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -enableFeaturePreview("VERSION_CATALOGS") - include( ":kmath-memory", ":kmath-complex", From 13fb49e48c84217dd07b7f3343ba2c0f08962081 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Fri, 1 Apr 2022 02:27:50 +0700 Subject: [PATCH 06/26] Rename version catalog --- buildSrc/build.gradle.kts | 8 ++++---- buildSrc/settings.gradle.kts | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index b69ebe6cd..fa5142538 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,7 +1,7 @@ plugins { `kotlin-dsl` `version-catalog` - alias(npmlibs.plugins.kotlin.plugin.serialization) + alias(miptNpmLibs.plugins.kotlin.plugin.serialization) } java.targetCompatibility = JavaVersion.VERSION_11 @@ -14,8 +14,8 @@ repositories { } val toolsVersion: String by extra -val kotlinVersion = npmlibs.versions.kotlin.asProvider().get() -val benchmarksVersion = npmlibs.versions.kotlinx.benchmark.get() +val kotlinVersion = miptNpmLibs.versions.kotlin.asProvider().get() +val benchmarksVersion = miptNpmLibs.versions.kotlinx.benchmark.get() dependencies { api("ru.mipt.npm:gradle-tools:$toolsVersion") @@ -23,7 +23,7 @@ dependencies { api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:$benchmarksVersion") api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion") //to be used inside build-script only - implementation(npmlibs.kotlinx.serialization.json) + implementation(miptNpmLibs.kotlinx.serialization.json) } kotlin.sourceSets.all { diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index bc530ac03..7c1df133d 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -4,7 +4,6 @@ */ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") -enableFeaturePreview("VERSION_CATALOGS") dependencyResolutionManagement { val toolsVersion: String by extra @@ -17,7 +16,7 @@ dependencyResolutionManagement { } versionCatalogs { - create("npmlibs") { + create("miptNpmLibs") { from("ru.mipt.npm:version-catalog:$toolsVersion") } } From 38fd3e24c8261eb4da302d499c13d0d063d93712 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Fri, 1 Apr 2022 02:37:14 +0700 Subject: [PATCH 07/26] Use correct class name for kotlin JVM compilation --- benchmarks/build.gradle.kts | 2 +- examples/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index f8d39b9c5..22712816d 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -155,7 +155,7 @@ kotlin.sourceSets.all { } } -tasks.withType { +tasks.withType { kotlinOptions { jvmTarget = "11" freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" + "-Xlambdas=indy" diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 36715cd78..60f8f5aed 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -58,7 +58,7 @@ kotlin.sourceSets.all { } } -tasks.withType { +tasks.withType { kotlinOptions { jvmTarget = "11" freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" + "-Xopt-in=kotlin.RequiresOptIn" + "-Xlambdas=indy" From 3277a99ed3bb3668160de14d3e4e23ad9b587600 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Fri, 1 Apr 2022 02:58:12 +0700 Subject: [PATCH 08/26] Never use GitHub Packages to publish project with --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3372d505d..445976853 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,7 +56,7 @@ subprojects { readme.readmeTemplate = file("docs/templates/README-TEMPLATE.md") ksciencePublish { - github("kmath") + github("kmath", addToRelease = false) space() sonatype() } From bae465fe865b0b8288861b78b62c04f4b5eef8c3 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Fri, 1 Apr 2022 03:06:07 +0700 Subject: [PATCH 09/26] Update GitHub actions --- .github/workflows/build.yml | 8 ++++---- .github/workflows/pages.yml | 20 +++++++++++++++----- .github/workflows/publish.yml | 11 +++++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 455e0dd2d..0834c2656 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,13 +13,13 @@ jobs: runs-on: ${{matrix.os}} timeout-minutes: 40 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2.5.0 + - uses: actions/checkout@v3.0.0 + - uses: actions/setup-java@v3.0.0 with: java-version: 11 distribution: liberica - name: Cache gradle - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: | ~/.gradle/caches @@ -28,7 +28,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Cache konan - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: ~/.konan key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index e7f5300c7..0158c82ac 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -9,19 +9,29 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 40 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2.5.0 + - uses: actions/checkout@v3.0.0 + - uses: actions/setup-java@v3.0.0 with: java-version: 11 distribution: liberica - - uses: actions/cache@v2 + - name: Cache gradle + uses: actions/cache@v3.0.1 with: - path: ~/.gradle/caches + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache konan + uses: actions/cache@v3.0.1 + with: + path: ~/.konan key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} restore-keys: | ${{ runner.os }}-gradle- - run: ./gradlew dokkaHtmlMultiModule --build-cache --no-daemon --no-parallel --stacktrace - - uses: JamesIves/github-pages-deploy-action@4.1.0 + - uses: JamesIves/github-pages-deploy-action@4.2.5 with: branch: gh-pages folder: build/dokka/htmlMultiModule diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 17adc5655..83755793a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,13 +14,13 @@ jobs: os: [ macOS-latest, windows-latest ] runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2.5.0 + - uses: actions/checkout@v3.0.0 + - uses: actions/setup-java@v3.0.0 with: java-version: 11 distribution: liberica - name: Cache gradle - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: | ~/.gradle/caches @@ -29,14 +29,13 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Cache konan - uses: actions/cache@v2 + uses: actions/cache@v3.0.1 with: path: ~/.konan key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} restore-keys: | ${{ runner.os }}-gradle- - - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1.0.4 + - uses: gradle/wrapper-validation-action@v1.0.4 - name: Publish Windows Artifacts if: matrix.os == 'windows-latest' shell: cmd From 97a320c9ef8cd3cdbb73256499200a23be51b84d Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Fri, 1 Apr 2022 14:02:03 +0700 Subject: [PATCH 10/26] Use gradle-build-action --- .github/workflows/build.yml | 14 +++----------- .github/workflows/pages.yml | 13 +++---------- .github/workflows/publish.yml | 34 ++++++++++++++++------------------ 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0834c2656..cffef64b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,15 +18,6 @@ jobs: with: java-version: 11 distribution: liberica - - name: Cache gradle - uses: actions/cache@v3.0.1 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle- - name: Cache konan uses: actions/cache@v3.0.1 with: @@ -36,5 +27,6 @@ jobs: ${{ runner.os }}-gradle- - name: Gradle Wrapper Validation uses: gradle/wrapper-validation-action@v1.0.4 - - name: Build - run: ./gradlew build --build-cache --no-daemon --stacktrace + - uses: gradle/gradle-build-action@v2.1.5 + with: + arguments: build diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 0158c82ac..9b76fd16e 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -14,15 +14,6 @@ jobs: with: java-version: 11 distribution: liberica - - name: Cache gradle - uses: actions/cache@v3.0.1 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle- - name: Cache konan uses: actions/cache@v3.0.1 with: @@ -30,7 +21,9 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} restore-keys: | ${{ runner.os }}-gradle- - - run: ./gradlew dokkaHtmlMultiModule --build-cache --no-daemon --no-parallel --stacktrace + - uses: gradle/gradle-build-action@v2.1.5 + with: + arguments: dokkaHtmlMultiModule --no-parallel - uses: JamesIves/github-pages-deploy-action@4.2.5 with: branch: gh-pages diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 83755793a..8e9b98dcb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,15 +19,6 @@ jobs: with: java-version: 11 distribution: liberica - - name: Cache gradle - uses: actions/cache@v3.0.1 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle- - name: Cache konan uses: actions/cache@v3.0.1 with: @@ -38,14 +29,21 @@ jobs: - uses: gradle/wrapper-validation-action@v1.0.4 - name: Publish Windows Artifacts if: matrix.os == 'windows-latest' - shell: cmd - run: > - ./gradlew releaseAll --no-daemon --build-cache -Ppublishing.enabled=true - -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} - -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} + uses: gradle/gradle-build-action@v2.1.5 + with: + arguments: | + releaseAll + -Ppublishing.enabled=true + -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} + -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} - name: Publish Mac Artifacts if: matrix.os == 'macOS-latest' - run: > - ./gradlew releaseMacosX64 releaseIosArm64 releaseIosX64 release --no-daemon --build-cache - -Ppublishing.enabled=true -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} - -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} + uses: gradle/gradle-build-action@v2.1.5 + with: + arguments: | + releaseMacosX64 + releaseIosArm64 + releaseIosX64 + -Ppublishing.enabled=true + -Ppublishing.space.user=${{ secrets.SPACE_APP_ID }} + -Ppublishing.space.token=${{ secrets.SPACE_APP_SECRET }} From 73f72f12bca21554764e2b24dcb5fd4e22a64983 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 5 Apr 2022 23:23:29 +0300 Subject: [PATCH 11/26] [WIP] Another histogram refactor --- CHANGELOG.md | 1 + .../space/kscience/kmath/domains/Domain1D.kt | 17 ++++ .../space/kscience/kmath/misc/sorting.kt | 75 +++++++++++---- .../space/kscience/kmath/misc/PermSortTest.kt | 25 +++-- kmath-for-real/build.gradle.kts | 15 +-- kmath-histograms/build.gradle.kts | 2 + ...togramSpace.kt => DoubleHistogramGroup.kt} | 8 +- .../kscience/kmath/histogram/Histogram1D.kt | 10 +- ...ogramSpace.kt => IndexedHistogramGroup.kt} | 6 +- .../kmath/histogram/UniformHistogram1D.kt | 94 ++++++++++++++++++- .../histogram/MultivariateHistogramTest.kt | 6 +- .../kmath/histogram/UniformHistogram1DTest.kt | 34 +++++++ .../kmath/distributions/Distribution.kt | 4 +- .../kmath/distributions/NormalDistribution.kt | 15 +-- .../space/kscience/kmath/stat/Sampler.kt | 9 ++ .../kmath/stat/UniformDistribution.kt | 4 +- 16 files changed, 258 insertions(+), 67 deletions(-) rename kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/{DoubleHistogramSpace.kt => DoubleHistogramGroup.kt} (96%) rename kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/{IndexedHistogramSpace.kt => IndexedHistogramGroup.kt} (93%) create mode 100644 kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a19b1f467..d710c330b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - Operations -> Ops - Default Buffer and ND algebras are now Ops and lack neutral elements (0, 1) as well as algebra-level shapes. - Tensor algebra takes read-only structures as input and inherits AlgebraND +- `UnivariateDistribution` renamed to `Distribution1D` ### Deprecated - Specialized `DoubleBufferAlgebra` diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt index ccd1c3edb..3d531349c 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/Domain1D.kt @@ -35,6 +35,23 @@ public class DoubleDomain1D( } override fun volume(): Double = range.endInclusive - range.start + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || this::class != other::class) return false + + other as DoubleDomain1D + + if (doubleRange != other.doubleRange) return false + + return true + } + + override fun hashCode(): Int = doubleRange.hashCode() + + override fun toString(): String = doubleRange.toString() + + } @UnstableKMathAPI diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/sorting.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/sorting.kt index a144e49b4..dc5421136 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/sorting.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/sorting.kt @@ -3,43 +3,71 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ + package space.kscience.kmath.misc -import kotlin.comparisons.* import space.kscience.kmath.structures.Buffer +import space.kscience.kmath.structures.VirtualBuffer /** - * Return a new list filled with buffer indices. Indice order is defined by sorting associated buffer value. - * This feature allows to sort buffer values without reordering its content. + * Return a new array filled with buffer indices. Indices order is defined by sorting associated buffer value. + * This feature allows sorting buffer values without reordering its content. * - * @return List of buffer indices, sorted by associated value. + * @return Buffer indices, sorted by associated value. */ -@PerformancePitfall @UnstableKMathAPI -public fun > Buffer.permSort() : IntArray = _permSortWith(compareBy { get(it) }) +public fun > Buffer.indicesSorted(): IntArray = permSortIndicesWith(compareBy { get(it) }) + +/** + * Create a zero-copy virtual buffer that contains the same elements but in ascending order + */ +@OptIn(UnstableKMathAPI::class) +public fun > Buffer.sorted(): Buffer { + val permutations = indicesSorted() + return VirtualBuffer(size) { this[permutations[it]] } +} -@PerformancePitfall @UnstableKMathAPI -public fun > Buffer.permSortDescending() : IntArray = _permSortWith(compareByDescending { get(it) }) +public fun > Buffer.indicesSortedDescending(): IntArray = + permSortIndicesWith(compareByDescending { get(it) }) + +/** + * Create a zero-copy virtual buffer that contains the same elements but in descending order + */ +@OptIn(UnstableKMathAPI::class) +public fun > Buffer.sortedDescending(): Buffer { + val permutations = indicesSortedDescending() + return VirtualBuffer(size) { this[permutations[it]] } +} -@PerformancePitfall @UnstableKMathAPI -public fun > Buffer.permSortBy(selector: (V) -> C) : IntArray = _permSortWith(compareBy { selector(get(it)) }) +public fun > Buffer.indicesSortedBy(selector: (V) -> C): IntArray = + permSortIndicesWith(compareBy { selector(get(it)) }) + +@OptIn(UnstableKMathAPI::class) +public fun > Buffer.sortedBy(selector: (V) -> C): Buffer { + val permutations = indicesSortedBy(selector) + return VirtualBuffer(size) { this[permutations[it]] } +} -@PerformancePitfall @UnstableKMathAPI -public fun > Buffer.permSortByDescending(selector: (V) -> C) : IntArray = _permSortWith(compareByDescending { selector(get(it)) }) +public fun > Buffer.indicesSortedByDescending(selector: (V) -> C): IntArray = + permSortIndicesWith(compareByDescending { selector(get(it)) }) + +@OptIn(UnstableKMathAPI::class) +public fun > Buffer.sortedByDescending(selector: (V) -> C): Buffer { + val permutations = indicesSortedByDescending(selector) + return VirtualBuffer(size) { this[permutations[it]] } +} -@PerformancePitfall @UnstableKMathAPI -public fun Buffer.permSortWith(comparator : Comparator) : IntArray = _permSortWith { i1, i2 -> comparator.compare(get(i1), get(i2)) } +public fun Buffer.indicesSortedWith(comparator: Comparator): IntArray = + permSortIndicesWith { i1, i2 -> comparator.compare(get(i1), get(i2)) } -@PerformancePitfall -@UnstableKMathAPI -private fun Buffer._permSortWith(comparator : Comparator) : IntArray { - if (size < 2) return IntArray(size) +private fun Buffer.permSortIndicesWith(comparator: Comparator): IntArray { + if (size < 2) return IntArray(size) { 0 } - /* TODO: optimisation : keep a constant big array of indices (Ex: from 0 to 4096), then create indice + /* TODO: optimisation : keep a constant big array of indices (Ex: from 0 to 4096), then create indices * arrays more efficiently by copying subpart of cached one. For bigger needs, we could copy entire * cached array, then fill remaining indices manually. Not done for now, because: * 1. doing it right would require some statistics about common used buffer sizes. @@ -53,3 +81,12 @@ private fun Buffer._permSortWith(comparator : Comparator) : IntArray */ return packedIndices.sortedWith(comparator).toIntArray() } + +/** + * Checks that the [Buffer] is sorted (ascending) and throws [IllegalArgumentException] if it is not. + */ +public fun > Buffer.requireSorted() { + for (i in 0..(size - 2)) { + require(get(i + 1) >= get(i)) { "The buffer is not sorted at index $i" } + } +} diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/misc/PermSortTest.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/misc/PermSortTest.kt index 0a2bb9138..4a724ac5f 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/misc/PermSortTest.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/misc/PermSortTest.kt @@ -6,14 +6,13 @@ package space.kscience.kmath.misc import space.kscience.kmath.misc.PermSortTest.Platform.* -import kotlin.random.Random -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - import space.kscience.kmath.structures.IntBuffer import space.kscience.kmath.structures.asBuffer +import kotlin.random.Random +import kotlin.test.Test import kotlin.test.assertContentEquals +import kotlin.test.assertEquals +import kotlin.test.assertTrue class PermSortTest { @@ -29,9 +28,9 @@ class PermSortTest { @Test fun testOnEmptyBuffer() { val emptyBuffer = IntBuffer(0) {it} - var permutations = emptyBuffer.permSort() + var permutations = emptyBuffer.indicesSorted() assertTrue(permutations.isEmpty(), "permutation on an empty buffer should return an empty result") - permutations = emptyBuffer.permSortDescending() + permutations = emptyBuffer.indicesSortedDescending() assertTrue(permutations.isEmpty(), "permutation on an empty buffer should return an empty result") } @@ -47,25 +46,25 @@ class PermSortTest { @Test fun testPermSortBy() { - val permutations = platforms.permSortBy { it.name } + val permutations = platforms.indicesSortedBy { it.name } val expected = listOf(ANDROID, JS, JVM, NATIVE, WASM) assertContentEquals(expected, permutations.map { platforms[it] }, "Ascending PermSort by name") } @Test fun testPermSortByDescending() { - val permutations = platforms.permSortByDescending { it.name } + val permutations = platforms.indicesSortedByDescending { it.name } val expected = listOf(WASM, NATIVE, JVM, JS, ANDROID) assertContentEquals(expected, permutations.map { platforms[it] }, "Descending PermSort by name") } @Test fun testPermSortWith() { - var permutations = platforms.permSortWith { p1, p2 -> p1.name.length.compareTo(p2.name.length) } + var permutations = platforms.indicesSortedWith { p1, p2 -> p1.name.length.compareTo(p2.name.length) } val expected = listOf(JS, JVM, WASM, NATIVE, ANDROID) assertContentEquals(expected, permutations.map { platforms[it] }, "PermSort using custom ascending comparator") - permutations = platforms.permSortWith(compareByDescending { it.name.length }) + permutations = platforms.indicesSortedWith(compareByDescending { it.name.length }) assertContentEquals(expected.reversed(), permutations.map { platforms[it] }, "PermSort using custom descending comparator") } @@ -75,7 +74,7 @@ class PermSortTest { println("Test randomization seed: $seed") val buffer = Random(seed).buffer(bufferSize) - val indices = buffer.permSort() + val indices = buffer.indicesSorted() assertEquals(bufferSize, indices.size) // Ensure no doublon is present in indices @@ -87,7 +86,7 @@ class PermSortTest { assertTrue(current <= next, "Permutation indices not properly sorted") } - val descIndices = buffer.permSortDescending() + val descIndices = buffer.indicesSortedDescending() assertEquals(bufferSize, descIndices.size) // Ensure no doublon is present in indices assertEquals(descIndices.toSet().size, descIndices.size) diff --git a/kmath-for-real/build.gradle.kts b/kmath-for-real/build.gradle.kts index 4cccaef5c..18c2c50ad 100644 --- a/kmath-for-real/build.gradle.kts +++ b/kmath-for-real/build.gradle.kts @@ -21,19 +21,22 @@ readme { feature( id = "DoubleVector", - description = "Numpy-like operations for Buffers/Points", ref = "src/commonMain/kotlin/space/kscience/kmath/real/DoubleVector.kt" - ) + ){ + "Numpy-like operations for Buffers/Points" + } feature( id = "DoubleMatrix", - description = "Numpy-like operations for 2d real structures", ref = "src/commonMain/kotlin/space/kscience/kmath/real/DoubleMatrix.kt" - ) + ){ + "Numpy-like operations for 2d real structures" + } feature( id = "grids", - description = "Uniform grid generators", ref = "src/commonMain/kotlin/space/kscience/kmath/structures/grids.kt" - ) + ){ + "Uniform grid generators" + } } diff --git a/kmath-histograms/build.gradle.kts b/kmath-histograms/build.gradle.kts index 7e511faa0..51271bb0a 100644 --- a/kmath-histograms/build.gradle.kts +++ b/kmath-histograms/build.gradle.kts @@ -17,6 +17,8 @@ kotlin.sourceSets { commonTest { dependencies { implementation(project(":kmath-for-real")) + implementation(projects.kmath.kmathStat) + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0") } } } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt similarity index 96% rename from kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt rename to kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt index c0df8c2cc..a80ed119c 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt @@ -16,11 +16,11 @@ import kotlin.math.floor /** * Multivariate histogram space for hyper-square real-field bins. */ -public class DoubleHistogramSpace( +public class DoubleHistogramGroup( private val lower: Buffer, private val upper: Buffer, private val binNums: IntArray = IntArray(lower.size) { 20 }, -) : IndexedHistogramSpace { +) : IndexedHistogramGroup { init { // argument checks @@ -105,7 +105,7 @@ public class DoubleHistogramSpace( */ public fun fromRanges( vararg ranges: ClosedFloatingPointRange, - ): DoubleHistogramSpace = DoubleHistogramSpace( + ): DoubleHistogramGroup = DoubleHistogramGroup( ranges.map(ClosedFloatingPointRange::start).asBuffer(), ranges.map(ClosedFloatingPointRange::endInclusive).asBuffer() ) @@ -121,7 +121,7 @@ public class DoubleHistogramSpace( */ public fun fromRanges( vararg ranges: Pair, Int>, - ): DoubleHistogramSpace = DoubleHistogramSpace( + ): DoubleHistogramGroup = DoubleHistogramGroup( ListBuffer( ranges .map(Pair, Int>::first) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt index 4f193f943..237bd87b9 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt @@ -6,6 +6,7 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.Domain1D +import space.kscience.kmath.linear.Point import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.asSequence import space.kscience.kmath.structures.Buffer @@ -18,7 +19,7 @@ import space.kscience.kmath.structures.Buffer * @property standardDeviation Standard deviation of the bin value. Zero or negative if not applicable */ @UnstableKMathAPI -public class Bin1D, out V>( +public data class Bin1D, out V>( public val domain: Domain1D, override val binValue: V, ) : Bin, ClosedRange by domain.range { @@ -35,12 +36,15 @@ public interface Histogram1D, V> : Histogram override operator fun get(point: Buffer): Bin1D? = get(point[0]) } -@UnstableKMathAPI public interface Histogram1DBuilder : HistogramBuilder { /** * Thread safe put operation */ public fun putValue(at: T, value: V = defaultValue) + + override fun putValue(point: Point, value: V) { + putValue(point[0], value) + } } @UnstableKMathAPI @@ -52,5 +56,5 @@ public fun Histogram1DBuilder.fill(array: DoubleArray): Unit = array.forEach(this::putValue) @UnstableKMathAPI -public fun Histogram1DBuilder.fill(buffer: Buffer): Unit = +public fun Histogram1DBuilder.fill(buffer: Buffer): Unit = buffer.asSequence().forEach(this::putValue) \ No newline at end of file diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt similarity index 93% rename from kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt rename to kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt index 3e4b07984..9749f8403 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt @@ -28,7 +28,7 @@ public data class DomainBin, out V>( * @param V the type of bin value */ public class IndexedHistogram, V : Any>( - public val histogramSpace: IndexedHistogramSpace, + public val histogramSpace: IndexedHistogramGroup, public val values: StructureND, ) : Histogram> { @@ -48,8 +48,8 @@ public class IndexedHistogram, V : Any>( /** * A space for producing histograms with values in a NDStructure */ -public interface IndexedHistogramSpace, V : Any> - : Group>, ScaleOperations> { +public interface IndexedHistogramGroup, V : Any> : Group>, + ScaleOperations> { public val shape: Shape public val histogramValueAlgebra: FieldND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index ed8b2e29d..44638c29b 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -5,8 +5,92 @@ package space.kscience.kmath.histogram -//class UniformHistogram1D( -// public val borders: Buffer, -// public val values: Buffer, -//) : Histogram1D { -//} \ No newline at end of file +import space.kscience.kmath.domains.DoubleDomain1D +import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.operations.Group +import space.kscience.kmath.operations.Ring +import space.kscience.kmath.operations.ScaleOperations +import space.kscience.kmath.operations.invoke +import space.kscience.kmath.structures.Buffer +import kotlin.math.floor + +@OptIn(UnstableKMathAPI::class) +public class UniformHistogram1D( + public val group: UniformHistogram1DGroup, + public val values: Map, +) : Histogram1D { + + private val startPoint get() = group.startPoint + private val binSize get() = group.binSize + + private fun produceBin(index: Int, value: V): Bin1D { + val domain = DoubleDomain1D((startPoint + index * binSize)..(startPoint + (index + 1) * binSize)) + return Bin1D(domain, value) + } + + override val bins: Iterable> get() = values.map { produceBin(it.key, it.value) } + + override fun get(value: Double): Bin1D? { + val index: Int = group.getIndex(value) + val v = values[index] + return v?.let { produceBin(index, it) } + } +} + +public class UniformHistogram1DGroup( + public val valueAlgebra: A, + public val binSize: Double, + public val startPoint: Double = 0.0, +) : Group>, ScaleOperations> where A : Ring, A : ScaleOperations { + override val zero: UniformHistogram1D by lazy { UniformHistogram1D(this, emptyMap()) } + + public fun getIndex(at: Double): Int = floor((at - startPoint) / binSize).toInt() + + override fun add(left: UniformHistogram1D, right: UniformHistogram1D): UniformHistogram1D = valueAlgebra { + require(left.group == this@UniformHistogram1DGroup) + require(right.group == this@UniformHistogram1DGroup) + val keys = left.values.keys + right.values.keys + UniformHistogram1D( + this@UniformHistogram1DGroup, + keys.associateWith { (left.values[it] ?: valueAlgebra.zero) + (right.values[it] ?: valueAlgebra.zero) } + ) + } + + override fun UniformHistogram1D.unaryMinus(): UniformHistogram1D = valueAlgebra { + UniformHistogram1D(this@UniformHistogram1DGroup, values.mapValues { -it.value }) + } + + override fun scale( + a: UniformHistogram1D, + value: Double, + ): UniformHistogram1D = UniformHistogram1D( + this@UniformHistogram1DGroup, + a.values.mapValues { valueAlgebra.scale(it.value, value) } + ) + + public inline fun produce(block: Histogram1DBuilder.() -> Unit): UniformHistogram1D { + val map = HashMap() + val builder = object : Histogram1DBuilder { + override val defaultValue: V get() = valueAlgebra.zero + + override fun putValue(at: Double, value: V) { + val index = getIndex(at) + map[index] = with(valueAlgebra) { (map[index] ?: zero) + one } + } + } + builder.block() + return UniformHistogram1D(this, map) + } +} + +public fun Histogram.Companion.uniform1D( + algebra: A, + binSize: Double, + startPoint: Double = 0.0, +): UniformHistogram1DGroup where A : Ring, A : ScaleOperations = + UniformHistogram1DGroup(algebra, binSize, startPoint) + +@UnstableKMathAPI +public fun UniformHistogram1DGroup.produce( + buffer: Buffer, +): UniformHistogram1D = produce { fill(buffer) } \ No newline at end of file diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt index 31a29676c..1426b35fa 100644 --- a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt @@ -14,7 +14,7 @@ import kotlin.test.* internal class MultivariateHistogramTest { @Test fun testSinglePutHistogram() { - val hSpace = DoubleHistogramSpace.fromRanges( + val hSpace = DoubleHistogramGroup.fromRanges( (-1.0..1.0), (-1.0..1.0) ) @@ -29,7 +29,7 @@ internal class MultivariateHistogramTest { @Test fun testSequentialPut() { - val hSpace = DoubleHistogramSpace.fromRanges( + val hSpace = DoubleHistogramGroup.fromRanges( (-1.0..1.0), (-1.0..1.0), (-1.0..1.0) @@ -49,7 +49,7 @@ internal class MultivariateHistogramTest { @Test fun testHistogramAlgebra() { - DoubleHistogramSpace.fromRanges( + DoubleHistogramGroup.fromRanges( (-1.0..1.0), (-1.0..1.0), (-1.0..1.0) diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt new file mode 100644 index 000000000..d23afdb8b --- /dev/null +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.histogram + +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.runTest +import space.kscience.kmath.distributions.NormalDistribution +import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.operations.DoubleField +import space.kscience.kmath.stat.RandomGenerator +import space.kscience.kmath.stat.nextBuffer +import kotlin.test.Test +import kotlin.test.assertEquals + +@OptIn(ExperimentalCoroutinesApi::class, UnstableKMathAPI::class) +internal class UniformHistogram1DTest { + @Test + fun normal() = runTest { + val generator = RandomGenerator.default(123) + val distribution = NormalDistribution(0.0, 1.0) + with(Histogram.uniform1D(DoubleField, 0.1)) { + val h1 = produce(distribution.nextBuffer(generator, 10000)) + + val h2 = produce(distribution.nextBuffer(generator, 50000)) + + val h3 = h1 + h2 + + assertEquals(60000, h3.bins.sumOf { it.binValue }.toInt()) + } + } +} \ No newline at end of file diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt index 3d3f95f8f..8dbcb3367 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt @@ -27,7 +27,7 @@ public interface Distribution : Sampler { public companion object } -public interface UnivariateDistribution> : Distribution { +public interface Distribution1D> : Distribution { /** * Cumulative distribution for ordered parameter (CDF) */ @@ -37,7 +37,7 @@ public interface UnivariateDistribution> : Distribution { /** * Compute probability integral in an interval */ -public fun > UnivariateDistribution.integral(from: T, to: T): Double { +public fun > Distribution1D.integral(from: T, to: T): Double { require(to > from) return cumulative(to) - cumulative(from) } diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/NormalDistribution.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/NormalDistribution.kt index 66e041f05..cfc6eba04 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/NormalDistribution.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/NormalDistribution.kt @@ -14,14 +14,9 @@ import space.kscience.kmath.stat.RandomGenerator import kotlin.math.* /** - * Implements [UnivariateDistribution] for the normal (gaussian) distribution. + * Implements [Distribution1D] for the normal (gaussian) distribution. */ -public class NormalDistribution(public val sampler: GaussianSampler) : UnivariateDistribution { - public constructor( - mean: Double, - standardDeviation: Double, - normalized: NormalizedGaussianSampler = ZigguratNormalizedGaussianSampler, - ) : this(GaussianSampler(mean, standardDeviation, normalized)) +public class NormalDistribution(public val sampler: GaussianSampler) : Distribution1D { override fun probability(arg: Double): Double { val x1 = (arg - sampler.mean) / sampler.standardDeviation @@ -43,3 +38,9 @@ public class NormalDistribution(public val sampler: GaussianSampler) : Univariat private val SQRT2 = sqrt(2.0) } } + +public fun NormalDistribution( + mean: Double, + standardDeviation: Double, + normalized: NormalizedGaussianSampler = ZigguratNormalizedGaussianSampler, +): NormalDistribution = NormalDistribution(GaussianSampler(mean, standardDeviation, normalized)) diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Sampler.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Sampler.kt index 0dd121f3b..c96ecdc8c 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Sampler.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Sampler.kt @@ -67,3 +67,12 @@ public fun Sampler.sampleBuffer(generator: RandomGenerator, size: Int): @JvmName("sampleIntBuffer") public fun Sampler.sampleBuffer(generator: RandomGenerator, size: Int): Chain> = sampleBuffer(generator, size, ::IntBuffer) + + +/** + * Samples a [Buffer] of values from this [Sampler]. + */ +public suspend fun Sampler.nextBuffer(generator: RandomGenerator, size: Int): Buffer = + sampleBuffer(generator, size).first() + +//TODO add `context(RandomGenerator) Sampler.nextBuffer \ No newline at end of file diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/UniformDistribution.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/UniformDistribution.kt index 970a3aab5..20cc0e802 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/UniformDistribution.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/UniformDistribution.kt @@ -8,9 +8,9 @@ package space.kscience.kmath.stat import space.kscience.kmath.chains.Chain import space.kscience.kmath.chains.SimpleChain import space.kscience.kmath.distributions.Distribution -import space.kscience.kmath.distributions.UnivariateDistribution +import space.kscience.kmath.distributions.Distribution1D -public class UniformDistribution(public val range: ClosedFloatingPointRange) : UnivariateDistribution { +public class UniformDistribution(public val range: ClosedFloatingPointRange) : Distribution1D { private val length: Double = range.endInclusive - range.start override fun probability(arg: Double): Double = if (arg in range) 1.0 / length else 0.0 From a2c0bc8a1012b437b1e91edd09e00327467e01f0 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 8 Apr 2022 19:41:41 +0300 Subject: [PATCH 12/26] Another histogram refactor --- .../kmath/histogram/UniformHistogram1D.kt | 24 +++++++++++++++++++ .../kmath/histogram/UniformHistogram1DTest.kt | 16 ++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index 44638c29b..e2811602c 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -81,6 +81,30 @@ public class UniformHistogram1DGroup( builder.block() return UniformHistogram1D(this, map) } + + /** + * Re-bin given histogram to be compatible if exiting bin fully falls inside existing bin, this bin value + * is increased by one. If not, all bins including values from this bin are increased by fraction + * (conserving the norming). + */ + @UnstableKMathAPI + public fun produceFrom(histogram: Histogram1D): UniformHistogram1D = + if ((histogram as? UniformHistogram1D)?.group == this) histogram + else { + val map = HashMap() + histogram.bins.forEach { bin -> + val range = bin.domain.range + val indexOfLeft = getIndex(range.start) + val indexOfRight = getIndex(range.endInclusive) + val numBins = indexOfRight - indexOfLeft + 1 + for (i in indexOfLeft..indexOfRight) { + map[indexOfLeft] = with(valueAlgebra) { + (map[indexOfLeft] ?: zero) + bin.binValue / numBins + } + } + } + UniformHistogram1D(this, map) + } } public fun Histogram.Companion.uniform1D( diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt index d23afdb8b..8d5cb8fb1 100644 --- a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt @@ -12,14 +12,15 @@ import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.DoubleField import space.kscience.kmath.stat.RandomGenerator import space.kscience.kmath.stat.nextBuffer +import kotlin.native.concurrent.ThreadLocal import kotlin.test.Test import kotlin.test.assertEquals @OptIn(ExperimentalCoroutinesApi::class, UnstableKMathAPI::class) internal class UniformHistogram1DTest { + @Test fun normal() = runTest { - val generator = RandomGenerator.default(123) val distribution = NormalDistribution(0.0, 1.0) with(Histogram.uniform1D(DoubleField, 0.1)) { val h1 = produce(distribution.nextBuffer(generator, 10000)) @@ -31,4 +32,17 @@ internal class UniformHistogram1DTest { assertEquals(60000, h3.bins.sumOf { it.binValue }.toInt()) } } + + @Test + fun rebin() = runTest { + val h1 = Histogram.uniform1D(DoubleField, 0.1).produce(generator.nextDoubleBuffer(10000)) + val h2 = Histogram.uniform1D(DoubleField,0.3).produceFrom(h1) + + assertEquals(10000, h2.bins.sumOf { it.binValue }.toInt()) + } + + @ThreadLocal + companion object{ + private val generator = RandomGenerator.default(123) + } } \ No newline at end of file From 3a2faa7da480cee97d2ddb682721ee85f4a57366 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 9 Apr 2022 10:18:18 +0300 Subject: [PATCH 13/26] Generalize UniformHistogram1D --- .../kmath/histogram/UniformHistogram1D.kt | 40 +++++++++++++------ .../kmath/histogram/UniformHistogram1DTest.kt | 14 +++++-- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index e2811602c..758e7969a 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -37,37 +37,53 @@ public class UniformHistogram1D( } } +/** + * An algebra for uniform histograms in 1D real space + */ public class UniformHistogram1DGroup( public val valueAlgebra: A, public val binSize: Double, public val startPoint: Double = 0.0, -) : Group>, ScaleOperations> where A : Ring, A : ScaleOperations { +) : Group>, ScaleOperations> where A : Ring, A : ScaleOperations { + override val zero: UniformHistogram1D by lazy { UniformHistogram1D(this, emptyMap()) } - public fun getIndex(at: Double): Int = floor((at - startPoint) / binSize).toInt() + /** + * Get index of a bin + */ + @PublishedApi + internal fun getIndex(at: Double): Int = floor((at - startPoint) / binSize).toInt() - override fun add(left: UniformHistogram1D, right: UniformHistogram1D): UniformHistogram1D = valueAlgebra { - require(left.group == this@UniformHistogram1DGroup) - require(right.group == this@UniformHistogram1DGroup) - val keys = left.values.keys + right.values.keys + override fun add( + left: Histogram1D, + right: Histogram1D, + ): UniformHistogram1D = valueAlgebra { + val leftUniform = produceFrom(left) + val rightUniform = produceFrom(right) + val keys = leftUniform.values.keys + rightUniform.values.keys UniformHistogram1D( this@UniformHistogram1DGroup, - keys.associateWith { (left.values[it] ?: valueAlgebra.zero) + (right.values[it] ?: valueAlgebra.zero) } + keys.associateWith { + (leftUniform.values[it] ?: valueAlgebra.zero) + (rightUniform.values[it] ?: valueAlgebra.zero) + } ) } - override fun UniformHistogram1D.unaryMinus(): UniformHistogram1D = valueAlgebra { - UniformHistogram1D(this@UniformHistogram1DGroup, values.mapValues { -it.value }) + override fun Histogram1D.unaryMinus(): UniformHistogram1D = valueAlgebra { + UniformHistogram1D(this@UniformHistogram1DGroup, produceFrom(this@unaryMinus).values.mapValues { -it.value }) } override fun scale( - a: UniformHistogram1D, + a: Histogram1D, value: Double, ): UniformHistogram1D = UniformHistogram1D( this@UniformHistogram1DGroup, - a.values.mapValues { valueAlgebra.scale(it.value, value) } + produceFrom(a).values.mapValues { valueAlgebra.scale(it.value, value) } ) + /** + * + */ public inline fun produce(block: Histogram1DBuilder.() -> Unit): UniformHistogram1D { val map = HashMap() val builder = object : Histogram1DBuilder { @@ -87,7 +103,7 @@ public class UniformHistogram1DGroup( * is increased by one. If not, all bins including values from this bin are increased by fraction * (conserving the norming). */ - @UnstableKMathAPI + @OptIn(UnstableKMathAPI::class) public fun produceFrom(histogram: Histogram1D): UniformHistogram1D = if ((histogram as? UniformHistogram1D)?.group == this) histogram else { diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt index 8d5cb8fb1..09bf3939d 100644 --- a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/UniformHistogram1DTest.kt @@ -34,9 +34,17 @@ internal class UniformHistogram1DTest { } @Test - fun rebin() = runTest { - val h1 = Histogram.uniform1D(DoubleField, 0.1).produce(generator.nextDoubleBuffer(10000)) - val h2 = Histogram.uniform1D(DoubleField,0.3).produceFrom(h1) + fun rebinDown() = runTest { + val h1 = Histogram.uniform1D(DoubleField, 0.01).produce(generator.nextDoubleBuffer(10000)) + val h2 = Histogram.uniform1D(DoubleField,0.03).produceFrom(h1) + + assertEquals(10000, h2.bins.sumOf { it.binValue }.toInt()) + } + + @Test + fun rebinUp() = runTest { + val h1 = Histogram.uniform1D(DoubleField, 0.03).produce(generator.nextDoubleBuffer(10000)) + val h2 = Histogram.uniform1D(DoubleField,0.01).produceFrom(h1) assertEquals(10000, h2.bins.sumOf { it.binValue }.toInt()) } From eba3a2526e0ca604947e71b5125565f57497623a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 09:48:55 +0300 Subject: [PATCH 14/26] [final] Generalize UniformHistogram1D --- .../kscience/kmath/histogram/Histogram1D.kt | 9 ++-- .../kmath/histogram/UniformHistogram1D.kt | 54 +++++++++++++------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt index 237bd87b9..0c9352e76 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt @@ -6,6 +6,7 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.Domain1D +import space.kscience.kmath.domains.center import space.kscience.kmath.linear.Point import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.operations.asSequence @@ -16,7 +17,6 @@ import space.kscience.kmath.structures.Buffer * A univariate bin based on a range * * @property binValue The value of histogram including weighting - * @property standardDeviation Standard deviation of the bin value. Zero or negative if not applicable */ @UnstableKMathAPI public data class Bin1D, out V>( @@ -56,5 +56,8 @@ public fun Histogram1DBuilder.fill(array: DoubleArray): Unit = array.forEach(this::putValue) @UnstableKMathAPI -public fun Histogram1DBuilder.fill(buffer: Buffer): Unit = - buffer.asSequence().forEach(this::putValue) \ No newline at end of file +public fun Histogram1DBuilder.fill(buffer: Buffer): Unit = + buffer.asSequence().forEach(this::putValue) + +@OptIn(UnstableKMathAPI::class) +public val Bin1D.center: Double get() = domain.center \ No newline at end of file diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index 758e7969a..93eca192f 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -17,7 +17,7 @@ import kotlin.math.floor @OptIn(UnstableKMathAPI::class) public class UniformHistogram1D( public val group: UniformHistogram1DGroup, - public val values: Map, + internal val values: Map, ) : Histogram1D { private val startPoint get() = group.startPoint @@ -82,7 +82,7 @@ public class UniformHistogram1DGroup( ) /** - * + * Fill histogram. */ public inline fun produce(block: Histogram1DBuilder.() -> Unit): UniformHistogram1D { val map = HashMap() @@ -104,23 +104,25 @@ public class UniformHistogram1DGroup( * (conserving the norming). */ @OptIn(UnstableKMathAPI::class) - public fun produceFrom(histogram: Histogram1D): UniformHistogram1D = - if ((histogram as? UniformHistogram1D)?.group == this) histogram - else { - val map = HashMap() - histogram.bins.forEach { bin -> - val range = bin.domain.range - val indexOfLeft = getIndex(range.start) - val indexOfRight = getIndex(range.endInclusive) - val numBins = indexOfRight - indexOfLeft + 1 - for (i in indexOfLeft..indexOfRight) { - map[indexOfLeft] = with(valueAlgebra) { - (map[indexOfLeft] ?: zero) + bin.binValue / numBins - } + public fun produceFrom( + histogram: Histogram1D, + ): UniformHistogram1D = if ((histogram as? UniformHistogram1D)?.group == this) { + histogram + } else { + val map = HashMap() + histogram.bins.forEach { bin -> + val range = bin.domain.range + val indexOfLeft = getIndex(range.start) + val indexOfRight = getIndex(range.endInclusive) + val numBins = indexOfRight - indexOfLeft + 1 + for (i in indexOfLeft..indexOfRight) { + map[indexOfLeft] = with(valueAlgebra) { + (map[indexOfLeft] ?: zero) + bin.binValue / numBins } } - UniformHistogram1D(this, map) } + UniformHistogram1D(this, map) + } } public fun Histogram.Companion.uniform1D( @@ -133,4 +135,22 @@ public fun Histogram.Companion.uniform1D( @UnstableKMathAPI public fun UniformHistogram1DGroup.produce( buffer: Buffer, -): UniformHistogram1D = produce { fill(buffer) } \ No newline at end of file +): UniformHistogram1D = produce { fill(buffer) } + +/** + * Map of bin centers to bin values + */ +@OptIn(UnstableKMathAPI::class) +public val UniformHistogram1D.binValues: Map + get() = bins.associate { it.center to it.binValue } + + +//TODO add normalized values inside Field-based histogram spaces with context receivers +///** +// * Map of bin centers to normalized bin values (bin size as normalization) +// */ +//@OptIn(UnstableKMathAPI::class) +//public val UniformHistogram1D.binValuesNormalized: Map +// get() = group.valueAlgebra { +// bins.associate { it.center to it.binValue / group.binSize } +// } \ No newline at end of file From 86d89f89f904c8dd7bd70f5f596c78d63560a82f Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 10:29:44 +0300 Subject: [PATCH 15/26] Update kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt Co-authored-by: Iaroslav Postovalov <38042667+CommanderTvis@users.noreply.github.com> --- .../space/kscience/kmath/histogram/IndexedHistogramGroup.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt index 9749f8403..b1d317a15 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt @@ -68,8 +68,9 @@ public interface IndexedHistogramGroup, V : Any> : Group.() -> Unit): IndexedHistogram override fun add(left: IndexedHistogram, right: IndexedHistogram): IndexedHistogram { - require(left.histogramSpace == this) { "Can't operate on a histogram produced by external space" } - require(right.histogramSpace == this) { "Can't operate on a histogram produced by external space" } + require(left.histogramSpace == this && right.histogramSpace == this) { + "A histogram belonging to a different group cannot be operated." + } return IndexedHistogram(this, histogramValueAlgebra { left.values + right.values }) } From 40b088149bece382affa6016954e0f28fb0e35b5 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 10:29:59 +0300 Subject: [PATCH 16/26] Update kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt Co-authored-by: Iaroslav Postovalov <38042667+CommanderTvis@users.noreply.github.com> --- .../space/kscience/kmath/histogram/IndexedHistogramGroup.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt index b1d317a15..22306049c 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt @@ -75,7 +75,7 @@ public interface IndexedHistogramGroup, V : Any> : Group, value: Double): IndexedHistogram { - require(a.histogramSpace == this) { "Can't operate on a histogram produced by external space" } + require(a.histogramSpace == this) { "A histogram belonging to a different group cannot be operated." } return IndexedHistogram(this, histogramValueAlgebra { a.values * value }) } From 229c36b6616f1a24b85e327673c6283f3d2f9279 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 10:32:36 +0300 Subject: [PATCH 17/26] Accept changes --- .../kmath/histogram/IndexedHistogramGroup.kt | 16 ++++++++-------- .../kmath/histogram/UniformHistogram1D.kt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt index 22306049c..6c04f01bf 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt @@ -28,20 +28,20 @@ public data class DomainBin, out V>( * @param V the type of bin value */ public class IndexedHistogram, V : Any>( - public val histogramSpace: IndexedHistogramGroup, + public val histogramGroup: IndexedHistogramGroup, public val values: StructureND, ) : Histogram> { override fun get(point: Point): DomainBin? { - val index = histogramSpace.getIndex(point) ?: return null - return histogramSpace.produceBin(index, values[index]) + val index = histogramGroup.getIndex(point) ?: return null + return histogramGroup.produceBin(index, values[index]) } - override val dimension: Int get() = histogramSpace.shape.size + override val dimension: Int get() = histogramGroup.shape.size override val bins: Iterable> - get() = DefaultStrides(histogramSpace.shape).asSequence().map { - histogramSpace.produceBin(it, values[it]) + get() = DefaultStrides(histogramGroup.shape).asSequence().map { + histogramGroup.produceBin(it, values[it]) }.asIterable() } @@ -68,14 +68,14 @@ public interface IndexedHistogramGroup, V : Any> : Group.() -> Unit): IndexedHistogram override fun add(left: IndexedHistogram, right: IndexedHistogram): IndexedHistogram { - require(left.histogramSpace == this && right.histogramSpace == this) { + require(left.histogramGroup == this && right.histogramGroup == this) { "A histogram belonging to a different group cannot be operated." } return IndexedHistogram(this, histogramValueAlgebra { left.values + right.values }) } override fun scale(a: IndexedHistogram, value: Double): IndexedHistogram { - require(a.histogramSpace == this) { "A histogram belonging to a different group cannot be operated." } + require(a.histogramGroup == this) { "A histogram belonging to a different group cannot be operated." } return IndexedHistogram(this, histogramValueAlgebra { a.values * value }) } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index 93eca192f..cb6572af9 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -46,7 +46,7 @@ public class UniformHistogram1DGroup( public val startPoint: Double = 0.0, ) : Group>, ScaleOperations> where A : Ring, A : ScaleOperations { - override val zero: UniformHistogram1D by lazy { UniformHistogram1D(this, emptyMap()) } + override val zero: UniformHistogram1D = UniformHistogram1D(this, emptyMap()) /** * Get index of a bin From 27a252b63700782b5005ac987686641a9f151031 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 11:31:52 +0300 Subject: [PATCH 18/26] Accept changes, Update documentation --- .../space/kscience/kmath/domains/HyperSquareDomain.kt | 11 ++++++----- .../kscience/kmath/histogram/DoubleHistogramGroup.kt | 4 ++-- .../kscience/kmath/histogram/IndexedHistogramGroup.kt | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt index 2fac442e7..485416a69 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/HyperSquareDomain.kt @@ -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, public val upper: Buffer) : 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." } } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt index a80ed119c..bb66b5dc5 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt @@ -45,7 +45,7 @@ public class DoubleHistogramGroup( else -> floor((value - lower[axis]) / binSize[axis]).toInt() } - override fun getIndex(point: Buffer): IntArray = IntArray(dimension) { + override fun getIndexOrNull(point: Buffer): 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, value: Double) { - val index = getIndex(point) + val index = getIndexOrNull(point) ndCounter[index].add(value) } } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt index 6c04f01bf..70913ecfb 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt @@ -33,7 +33,7 @@ public class IndexedHistogram, V : Any>( ) : Histogram> { override fun get(point: Point): DomainBin? { - 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, V : Any> : Group //= 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): IntArray? + public fun getIndexOrNull(point: Point): IntArray? /** * Get a bin domain represented by given index From 6247e79884069853f2c523013744826147b06354 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 13:41:41 +0300 Subject: [PATCH 19/26] Refactor multivariate histograms --- CHANGELOG.md | 1 + gradle.properties | 2 + .../space/kscience/kmath/nd/AlgebraND.kt | 2 +- .../space/kscience/kmath/nd/BufferND.kt | 23 ++- .../space/kscience/kmath/histogram/Counter.kt | 3 +- .../kmath/histogram/DoubleHistogramGroup.kt | 140 --------------- .../kscience/kmath/histogram/Histogram.kt | 9 + .../kscience/kmath/histogram/HistogramND.kt | 76 ++++++++ .../kmath/histogram/IndexedHistogramGroup.kt | 84 --------- .../histogram/UniformHistogramGroupND.kt | 163 ++++++++++++++++++ .../histogram/MultivariateHistogramTest.kt | 9 +- .../kmath/histogram/TreeHistogramSpace.kt | 2 +- 12 files changed, 275 insertions(+), 239 deletions(-) delete mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt create mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt delete mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt create mode 100644 kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index d710c330b..bc5447449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - Default Buffer and ND algebras are now Ops and lack neutral elements (0, 1) as well as algebra-level shapes. - Tensor algebra takes read-only structures as input and inherits AlgebraND - `UnivariateDistribution` renamed to `Distribution1D` +- Rework of histograms. ### Deprecated - Specialized `DoubleBufferAlgebra` diff --git a/gradle.properties b/gradle.properties index a7cd2f876..847c3dda6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,8 @@ kotlin.code.style=official kotlin.jupyter.add.scanner=false kotlin.mpp.stability.nowarn=true kotlin.native.ignoreDisabledTargets=true +kotlin.incremental.js.ir=true + org.gradle.configureondemand=true org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G org.gradle.parallel=true diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt index a071c1eb3..a9712e870 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt @@ -194,7 +194,7 @@ public interface RingOpsND> : RingOps>, Gro override fun multiply(left: StructureND, right: StructureND): StructureND = zip(left, right) { aValue, bValue -> multiply(aValue, bValue) } - //TODO move to extensions after KEEP-176 + //TODO move to extensions with context receivers /** * Multiplies an ND structure by an element of it. diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferND.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferND.kt index 539499794..2401f6319 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferND.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferND.kt @@ -32,18 +32,23 @@ public open class BufferND( /** * Transform structure to a new structure using provided [BufferFactory] and optimizing if argument is [BufferND] */ -public inline fun StructureND.mapToBuffer( - factory: BufferFactory = Buffer.Companion::auto, +public inline fun StructureND.mapToBuffer( + factory: BufferFactory, crossinline transform: (T) -> R, -): BufferND { - return if (this is BufferND) - BufferND(this.indices, factory.invoke(indices.linearSize) { transform(buffer[it]) }) - else { - val strides = DefaultStrides(shape) - BufferND(strides, factory.invoke(strides.linearSize) { transform(get(strides.index(it))) }) - } +): BufferND = if (this is BufferND) + BufferND(this.indices, factory.invoke(indices.linearSize) { transform(buffer[it]) }) +else { + val strides = DefaultStrides(shape) + BufferND(strides, factory.invoke(strides.linearSize) { transform(get(strides.index(it))) }) } +/** + * Transform structure to a new structure using inferred [BufferFactory] + */ +public inline fun StructureND.mapToBuffer( + crossinline transform: (T) -> R, +): BufferND = mapToBuffer(Buffer.Companion::auto, transform) + /** * Represents [MutableStructureND] over [MutableBuffer]. * diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt index 291284444..fe3278026 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt @@ -18,7 +18,8 @@ public interface Counter { public val value: T public companion object { - public fun double(): ObjectCounter = ObjectCounter(DoubleField) + public fun ofDouble(): ObjectCounter = ObjectCounter(DoubleField) + public fun of(group: Group): ObjectCounter = ObjectCounter(group) } } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt deleted file mode 100644 index bb66b5dc5..000000000 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/DoubleHistogramGroup.kt +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2018-2021 KMath contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package space.kscience.kmath.histogram - -import space.kscience.kmath.domains.HyperSquareDomain -import space.kscience.kmath.linear.Point -import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.* -import space.kscience.kmath.operations.DoubleField -import space.kscience.kmath.structures.* -import kotlin.math.floor - -/** - * Multivariate histogram space for hyper-square real-field bins. - */ -public class DoubleHistogramGroup( - private val lower: Buffer, - private val upper: Buffer, - private val binNums: IntArray = IntArray(lower.size) { 20 }, -) : IndexedHistogramGroup { - - init { - // argument checks - require(lower.size == upper.size) { "Dimension mismatch in histogram lower and upper limits." } - require(lower.size == binNums.size) { "Dimension mismatch in bin count." } - require(!lower.indices.any { upper[it] - lower[it] < 0 }) { "Range for one of axis is not strictly positive" } - } - - public val dimension: Int get() = lower.size - - override val shape: IntArray = IntArray(binNums.size) { binNums[it] + 2 } - override val histogramValueAlgebra: DoubleFieldND = DoubleField.ndAlgebra(*shape) - - private val binSize = DoubleBuffer(dimension) { (upper[it] - lower[it]) / binNums[it] } - - /** - * Get internal [StructureND] bin index for given axis - */ - private fun getIndex(axis: Int, value: Double): Int = when { - value >= upper[axis] -> binNums[axis] + 1 // overflow - value < lower[axis] -> 0 // underflow - else -> floor((value - lower[axis]) / binSize[axis]).toInt() - } - - override fun getIndexOrNull(point: Buffer): IntArray = IntArray(dimension) { - getIndex(it, point[it]) - } - - @OptIn(UnstableKMathAPI::class) - override fun getDomain(index: IntArray): HyperSquareDomain { - val lowerBoundary = index.mapIndexed { axis, i -> - when (i) { - 0 -> Double.NEGATIVE_INFINITY - shape[axis] - 1 -> upper[axis] - else -> lower[axis] + (i.toDouble()) * binSize[axis] - } - }.asBuffer() - - val upperBoundary = index.mapIndexed { axis, i -> - when (i) { - 0 -> lower[axis] - shape[axis] - 1 -> Double.POSITIVE_INFINITY - else -> lower[axis] + (i.toDouble() + 1) * binSize[axis] - } - }.asBuffer() - - return HyperSquareDomain(lowerBoundary, upperBoundary) - } - - @OptIn(UnstableKMathAPI::class) - override fun produceBin(index: IntArray, value: Double): DomainBin { - val domain = getDomain(index) - return DomainBin(domain, value) - } - - override fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram { - val ndCounter = StructureND.auto(shape) { Counter.double() } - val hBuilder = object : HistogramBuilder { - override val defaultValue: Double get() = 1.0 - - override fun putValue(point: Point, value: Double) { - val index = getIndexOrNull(point) - ndCounter[index].add(value) - } - } - hBuilder.apply(builder) - val values: BufferND = ndCounter.mapToBuffer { it.value } - return IndexedHistogram(this, values) - } - - override fun IndexedHistogram.unaryMinus(): IndexedHistogram = this * (-1) - - public companion object { - /** - * Use it like - * ``` - *FastHistogram.fromRanges( - * (-1.0..1.0), - * (-1.0..1.0) - *) - *``` - */ - public fun fromRanges( - vararg ranges: ClosedFloatingPointRange, - ): DoubleHistogramGroup = DoubleHistogramGroup( - ranges.map(ClosedFloatingPointRange::start).asBuffer(), - ranges.map(ClosedFloatingPointRange::endInclusive).asBuffer() - ) - - /** - * Use it like - * ``` - *FastHistogram.fromRanges( - * (-1.0..1.0) to 50, - * (-1.0..1.0) to 32 - *) - *``` - */ - public fun fromRanges( - vararg ranges: Pair, Int>, - ): DoubleHistogramGroup = DoubleHistogramGroup( - ListBuffer( - ranges - .map(Pair, Int>::first) - .map(ClosedFloatingPointRange::start) - ), - - ListBuffer( - ranges - .map(Pair, Int>::first) - .map(ClosedFloatingPointRange::endInclusive) - ), - - ranges.map(Pair, Int>::second).toIntArray() - ) - } -} \ No newline at end of file diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt index f9550df17..12edafd81 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt @@ -20,6 +20,15 @@ public interface Bin : Domain { public val binValue: V } +/** + * A simple histogram bin based on domain + */ +public data class DomainBin, D : Domain, out V>( + public val domain: D, + override val binValue: V, +) : Bin, Domain by domain + + public interface Histogram> { /** * Find existing bin, corresponding to given coordinates diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt new file mode 100644 index 000000000..2af03abd4 --- /dev/null +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.histogram + +import space.kscience.kmath.domains.Domain +import space.kscience.kmath.linear.Point +import space.kscience.kmath.nd.DefaultStrides +import space.kscience.kmath.nd.FieldOpsND +import space.kscience.kmath.nd.Shape +import space.kscience.kmath.nd.StructureND +import space.kscience.kmath.operations.Group +import space.kscience.kmath.operations.ScaleOperations +import space.kscience.kmath.operations.invoke + +/** + * @param T the type of the argument space + * @param V the type of bin value + */ +public class HistogramND, D : Domain, V : Any>( + public val group: HistogramGroupND, + internal val values: StructureND, +) : Histogram> { + + override fun get(point: Point): DomainBin? { + val index = group.getIndexOrNull(point) ?: return null + return group.produceBin(index, values[index]) + } + + override val dimension: Int get() = group.shape.size + + override val bins: Iterable> + get() = DefaultStrides(group.shape).asSequence().map { + group.produceBin(it, values[it]) + }.asIterable() +} + +/** + * A space for producing histograms with values in a NDStructure + */ +public interface HistogramGroupND, D : Domain, V : Any> : + Group>, ScaleOperations> { + public val shape: Shape + public val valueAlgebra: FieldOpsND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), + + /** + * Resolve index of the bin including given [point]. Return null if point is outside histogram area + */ + public fun getIndexOrNull(point: Point): IntArray? + + /** + * Get a bin domain represented by given index + */ + public fun getDomain(index: IntArray): Domain? + + public fun produceBin(index: IntArray, value: V): DomainBin + + public fun produce(builder: HistogramBuilder.() -> Unit): HistogramND + + override fun add(left: HistogramND, right: HistogramND): HistogramND { + require(left.group == this && right.group == this) { + "A histogram belonging to a different group cannot be operated." + } + return HistogramND(this, valueAlgebra { left.values + right.values }) + } + + override fun scale(a: HistogramND, value: Double): HistogramND { + require(a.group == this) { "A histogram belonging to a different group cannot be operated." } + return HistogramND(this, valueAlgebra { a.values * value }) + } + + override val zero: HistogramND get() = produce { } +} + diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt deleted file mode 100644 index 70913ecfb..000000000 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramGroup.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2018-2021 KMath contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package space.kscience.kmath.histogram - -import space.kscience.kmath.domains.Domain -import space.kscience.kmath.linear.Point -import space.kscience.kmath.nd.DefaultStrides -import space.kscience.kmath.nd.FieldND -import space.kscience.kmath.nd.Shape -import space.kscience.kmath.nd.StructureND -import space.kscience.kmath.operations.Group -import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.invoke - -/** - * A simple histogram bin based on domain - */ -public data class DomainBin, out V>( - public val domain: Domain, - override val binValue: V, -) : Bin, Domain by domain - -/** - * @param T the type of the argument space - * @param V the type of bin value - */ -public class IndexedHistogram, V : Any>( - public val histogramGroup: IndexedHistogramGroup, - public val values: StructureND, -) : Histogram> { - - override fun get(point: Point): DomainBin? { - val index = histogramGroup.getIndexOrNull(point) ?: return null - return histogramGroup.produceBin(index, values[index]) - } - - override val dimension: Int get() = histogramGroup.shape.size - - override val bins: Iterable> - get() = DefaultStrides(histogramGroup.shape).asSequence().map { - histogramGroup.produceBin(it, values[it]) - }.asIterable() -} - -/** - * A space for producing histograms with values in a NDStructure - */ -public interface IndexedHistogramGroup, V : Any> : Group>, - ScaleOperations> { - public val shape: Shape - public val histogramValueAlgebra: FieldND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), - - /** - * Resolve index of the bin including given [point]. Return null if point is outside histogram area - */ - public fun getIndexOrNull(point: Point): IntArray? - - /** - * Get a bin domain represented by given index - */ - public fun getDomain(index: IntArray): Domain? - - public fun produceBin(index: IntArray, value: V): DomainBin - - public fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram - - override fun add(left: IndexedHistogram, right: IndexedHistogram): IndexedHistogram { - require(left.histogramGroup == this && right.histogramGroup == this) { - "A histogram belonging to a different group cannot be operated." - } - return IndexedHistogram(this, histogramValueAlgebra { left.values + right.values }) - } - - override fun scale(a: IndexedHistogram, value: Double): IndexedHistogram { - require(a.histogramGroup == this) { "A histogram belonging to a different group cannot be operated." } - return IndexedHistogram(this, histogramValueAlgebra { a.values * value }) - } - - override val zero: IndexedHistogram get() = produce { } -} - diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt new file mode 100644 index 000000000..b93da10b2 --- /dev/null +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt @@ -0,0 +1,163 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:OptIn(UnstableKMathAPI::class) + +package space.kscience.kmath.histogram + +import space.kscience.kmath.domains.HyperSquareDomain +import space.kscience.kmath.linear.Point +import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.nd.* +import space.kscience.kmath.operations.DoubleField +import space.kscience.kmath.operations.Field +import space.kscience.kmath.operations.invoke +import space.kscience.kmath.structures.* +import kotlin.math.floor + +public typealias HyperSquareBin = DomainBin + +/** + * Multivariate histogram space for hyper-square real-field bins. + * @param bufferFactory is an optional parameter used to optimize buffer production. + */ +public class UniformHistogramGroupND>( + override val valueAlgebra: FieldOpsND, + private val lower: Buffer, + private val upper: Buffer, + private val binNums: IntArray = IntArray(lower.size) { 20 }, + private val bufferFactory: BufferFactory = Buffer.Companion::boxing, +) : HistogramGroupND { + + init { + // argument checks + require(lower.size == upper.size) { "Dimension mismatch in histogram lower and upper limits." } + require(lower.size == binNums.size) { "Dimension mismatch in bin count." } + require(!lower.indices.any { upper[it] - lower[it] < 0 }) { "Range for one of axis is not strictly positive" } + } + + public val dimension: Int get() = lower.size + + override val shape: IntArray = IntArray(binNums.size) { binNums[it] + 2 } + + private val binSize = DoubleBuffer(dimension) { (upper[it] - lower[it]) / binNums[it] } + + /** + * Get internal [StructureND] bin index for given axis + */ + private fun getIndex(axis: Int, value: Double): Int = when { + value >= upper[axis] -> binNums[axis] + 1 // overflow + value < lower[axis] -> 0 // underflow + else -> floor((value - lower[axis]) / binSize[axis]).toInt() + } + + override fun getIndexOrNull(point: Buffer): IntArray = IntArray(dimension) { + getIndex(it, point[it]) + } + + override fun getDomain(index: IntArray): HyperSquareDomain { + val lowerBoundary = index.mapIndexed { axis, i -> + when (i) { + 0 -> Double.NEGATIVE_INFINITY + shape[axis] - 1 -> upper[axis] + else -> lower[axis] + (i.toDouble()) * binSize[axis] + } + }.asBuffer() + + val upperBoundary = index.mapIndexed { axis, i -> + when (i) { + 0 -> lower[axis] + shape[axis] - 1 -> Double.POSITIVE_INFINITY + else -> lower[axis] + (i.toDouble() + 1) * binSize[axis] + } + }.asBuffer() + + return HyperSquareDomain(lowerBoundary, upperBoundary) + } + + override fun produceBin(index: IntArray, value: V): HyperSquareBin { + val domain = getDomain(index) + return DomainBin(domain, value) + } + + + override fun produce(builder: HistogramBuilder.() -> Unit): HistogramND { + val ndCounter = StructureND.buffered(shape) { Counter.of(valueAlgebra.elementAlgebra) } + val hBuilder = object : HistogramBuilder { + override val defaultValue: V get() = valueAlgebra.elementAlgebra.one + + override fun putValue(point: Point, value: V) = with(valueAlgebra.elementAlgebra) { + val index = getIndexOrNull(point) + ndCounter[index].add(value) + } + } + hBuilder.apply(builder) + val values: BufferND = ndCounter.mapToBuffer(bufferFactory) { it.value } + return HistogramND(this, values) + } + + override fun HistogramND.unaryMinus(): HistogramND = + this * (-1) +} + +/** + * Use it like + * ``` + *FastHistogram.fromRanges( + * (-1.0..1.0), + * (-1.0..1.0) + *) + *``` + */ +public fun > Histogram.Companion.uniformNDFromRanges( + valueAlgebra: FieldOpsND, + vararg ranges: ClosedFloatingPointRange, + bufferFactory: BufferFactory = Buffer.Companion::boxing, +): UniformHistogramGroupND = UniformHistogramGroupND( + valueAlgebra, + ranges.map(ClosedFloatingPointRange::start).asBuffer(), + ranges.map(ClosedFloatingPointRange::endInclusive).asBuffer(), + bufferFactory = bufferFactory +) + +public fun Histogram.Companion.uniformDoubleNDFromRanges( + vararg ranges: ClosedFloatingPointRange, +): UniformHistogramGroupND = + uniformNDFromRanges(DoubleFieldOpsND, *ranges, bufferFactory = ::DoubleBuffer) + + +/** + * Use it like + * ``` + *FastHistogram.fromRanges( + * (-1.0..1.0) to 50, + * (-1.0..1.0) to 32 + *) + *``` + */ +public fun > Histogram.Companion.uniformNDFromRanges( + valueAlgebra: FieldOpsND, + vararg ranges: Pair, Int>, + bufferFactory: BufferFactory = Buffer.Companion::boxing, +): UniformHistogramGroupND = UniformHistogramGroupND( + valueAlgebra, + ListBuffer( + ranges + .map(Pair, Int>::first) + .map(ClosedFloatingPointRange::start) + ), + ListBuffer( + ranges + .map(Pair, Int>::first) + .map(ClosedFloatingPointRange::endInclusive) + ), + ranges.map(Pair, Int>::second).toIntArray(), + bufferFactory = bufferFactory +) + +public fun Histogram.Companion.uniformDoubleNDFromRanges( + vararg ranges: Pair, Int>, +): UniformHistogramGroupND = + uniformNDFromRanges(DoubleFieldOpsND, *ranges, bufferFactory = ::DoubleBuffer) \ No newline at end of file diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt index 1426b35fa..ca7c2f324 100644 --- a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt @@ -3,8 +3,11 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ +@file:OptIn(UnstableKMathAPI::class) + package space.kscience.kmath.histogram +import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.nd.DefaultStrides import space.kscience.kmath.operations.invoke import space.kscience.kmath.real.DoubleVector @@ -14,7 +17,7 @@ import kotlin.test.* internal class MultivariateHistogramTest { @Test fun testSinglePutHistogram() { - val hSpace = DoubleHistogramGroup.fromRanges( + val hSpace = Histogram.uniformDoubleNDFromRanges( (-1.0..1.0), (-1.0..1.0) ) @@ -29,7 +32,7 @@ internal class MultivariateHistogramTest { @Test fun testSequentialPut() { - val hSpace = DoubleHistogramGroup.fromRanges( + val hSpace = Histogram.uniformDoubleNDFromRanges( (-1.0..1.0), (-1.0..1.0), (-1.0..1.0) @@ -49,7 +52,7 @@ internal class MultivariateHistogramTest { @Test fun testHistogramAlgebra() { - DoubleHistogramGroup.fromRanges( + Histogram.uniformDoubleNDFromRanges( (-1.0..1.0), (-1.0..1.0), (-1.0..1.0) diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt index e85bb0a3c..bff20c22c 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt @@ -45,7 +45,7 @@ internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) override val defaultValue: Double get() = 1.0 - internal class BinCounter(val domain: DoubleDomain1D, val counter: Counter = Counter.double()) : + internal class BinCounter(val domain: DoubleDomain1D, val counter: Counter = Counter.ofDouble()) : ClosedRange by domain.range private val bins: TreeMap = TreeMap() From 1295a407c37db40c0fa993c7b7c45068e623c079 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 15:29:46 +0300 Subject: [PATCH 20/26] Refactor tree histogram --- gradle.properties | 2 +- .../space/kscience/kmath/structures/Buffer.kt | 10 + .../kscience/kmath/histogram/Histogram1D.kt | 1 + .../kscience/kmath/histogram/HistogramND.kt | 6 +- .../kmath/histogram/UniformHistogram1D.kt | 4 +- .../histogram/UniformHistogramGroupND.kt | 16 +- .../kmath/histogram/TreeHistogramGroup.kt | 179 ++++++++++++++++ .../kmath/histogram/TreeHistogramSpace.kt | 199 ------------------ .../kmath/histogram/TreeHistogramTest.kt | 11 +- 9 files changed, 212 insertions(+), 216 deletions(-) create mode 100644 kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramGroup.kt delete mode 100644 kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt diff --git a/gradle.properties b/gradle.properties index 847c3dda6..80108737e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ kotlin.code.style=official kotlin.jupyter.add.scanner=false kotlin.mpp.stability.nowarn=true kotlin.native.ignoreDisabledTargets=true -kotlin.incremental.js.ir=true +#kotlin.incremental.js.ir=true org.gradle.configureondemand=true org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt index 58c6d5ded..a1b0307c4 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt @@ -105,6 +105,16 @@ public interface Buffer { */ public val Buffer<*>.indices: IntRange get() = 0 until size +public fun Buffer.first(): T { + require(size > 0) { "Can't get the first element of empty buffer" } + return get(0) +} + +public fun Buffer.last(): T { + require(size > 0) { "Can't get the last element of empty buffer" } + return get(size - 1) +} + /** * Immutable wrapper for [MutableBuffer]. * diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt index 0c9352e76..710e4478b 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram1D.kt @@ -43,6 +43,7 @@ public interface Histogram1DBuilder : HistogramBuilder, value: V) { + require(point.size == 1) { "Only points with single value could be used in Histogram1D" } putValue(point[0], value) } } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt index 2af03abd4..68b24db5d 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/HistogramND.kt @@ -43,7 +43,7 @@ public class HistogramND, D : Domain, V : Any>( public interface HistogramGroupND, D : Domain, V : Any> : Group>, ScaleOperations> { public val shape: Shape - public val valueAlgebra: FieldOpsND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), + public val valueAlgebraND: FieldOpsND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), /** * Resolve index of the bin including given [point]. Return null if point is outside histogram area @@ -63,12 +63,12 @@ public interface HistogramGroupND, D : Domain, V : Any> : require(left.group == this && right.group == this) { "A histogram belonging to a different group cannot be operated." } - return HistogramND(this, valueAlgebra { left.values + right.values }) + return HistogramND(this, valueAlgebraND { left.values + right.values }) } override fun scale(a: HistogramND, value: Double): HistogramND { require(a.group == this) { "A histogram belonging to a different group cannot be operated." } - return HistogramND(this, valueAlgebra { a.values * value }) + return HistogramND(this, valueAlgebraND { a.values * value }) } override val zero: HistogramND get() = produce { } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt index cb6572af9..e13928394 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogram1D.kt @@ -126,11 +126,11 @@ public class UniformHistogram1DGroup( } public fun Histogram.Companion.uniform1D( - algebra: A, + valueAlgebra: A, binSize: Double, startPoint: Double = 0.0, ): UniformHistogram1DGroup where A : Ring, A : ScaleOperations = - UniformHistogram1DGroup(algebra, binSize, startPoint) + UniformHistogram1DGroup(valueAlgebra, binSize, startPoint) @UnstableKMathAPI public fun UniformHistogram1DGroup.produce( diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt index b93da10b2..90ec29ce3 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/UniformHistogramGroupND.kt @@ -24,7 +24,7 @@ public typealias HyperSquareBin = DomainBin * @param bufferFactory is an optional parameter used to optimize buffer production. */ public class UniformHistogramGroupND>( - override val valueAlgebra: FieldOpsND, + override val valueAlgebraND: FieldOpsND, private val lower: Buffer, private val upper: Buffer, private val binNums: IntArray = IntArray(lower.size) { 20 }, @@ -84,11 +84,11 @@ public class UniformHistogramGroupND>( override fun produce(builder: HistogramBuilder.() -> Unit): HistogramND { - val ndCounter = StructureND.buffered(shape) { Counter.of(valueAlgebra.elementAlgebra) } + val ndCounter = StructureND.buffered(shape) { Counter.of(valueAlgebraND.elementAlgebra) } val hBuilder = object : HistogramBuilder { - override val defaultValue: V get() = valueAlgebra.elementAlgebra.one + override val defaultValue: V get() = valueAlgebraND.elementAlgebra.one - override fun putValue(point: Point, value: V) = with(valueAlgebra.elementAlgebra) { + override fun putValue(point: Point, value: V) = with(valueAlgebraND.elementAlgebra) { val index = getIndexOrNull(point) ndCounter[index].add(value) } @@ -112,11 +112,11 @@ public class UniformHistogramGroupND>( *``` */ public fun > Histogram.Companion.uniformNDFromRanges( - valueAlgebra: FieldOpsND, + valueAlgebraND: FieldOpsND, vararg ranges: ClosedFloatingPointRange, bufferFactory: BufferFactory = Buffer.Companion::boxing, ): UniformHistogramGroupND = UniformHistogramGroupND( - valueAlgebra, + valueAlgebraND, ranges.map(ClosedFloatingPointRange::start).asBuffer(), ranges.map(ClosedFloatingPointRange::endInclusive).asBuffer(), bufferFactory = bufferFactory @@ -138,11 +138,11 @@ public fun Histogram.Companion.uniformDoubleNDFromRanges( *``` */ public fun > Histogram.Companion.uniformNDFromRanges( - valueAlgebra: FieldOpsND, + valueAlgebraND: FieldOpsND, vararg ranges: Pair, Int>, bufferFactory: BufferFactory = Buffer.Companion::boxing, ): UniformHistogramGroupND = UniformHistogramGroupND( - valueAlgebra, + valueAlgebraND, ListBuffer( ranges .map(Pair, Int>::first) diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramGroup.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramGroup.kt new file mode 100644 index 000000000..6bec01f9b --- /dev/null +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramGroup.kt @@ -0,0 +1,179 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:OptIn(UnstableKMathAPI::class) + +package space.kscience.kmath.histogram + +import space.kscience.kmath.domains.DoubleDomain1D +import space.kscience.kmath.domains.center +import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.misc.sorted +import space.kscience.kmath.operations.Group +import space.kscience.kmath.operations.Ring +import space.kscience.kmath.operations.ScaleOperations +import space.kscience.kmath.structures.Buffer +import space.kscience.kmath.structures.first +import space.kscience.kmath.structures.indices +import space.kscience.kmath.structures.last +import java.util.* + +private fun > TreeMap.getBin(value: Double): B? { + // check ceiling entry and return it if it is what needed + val ceil = ceilingEntry(value)?.value + if (ceil != null && value in ceil) return ceil + //check floor entry + val floor = floorEntry(value)?.value + if (floor != null && value in floor) return floor + //neither is valid, not found + return null +} + +//public data class ValueAndError(val value: Double, val error: Double) +// +//public typealias WeightedBin1D = Bin1D + +/** + * A histogram based on a tree map of values + */ +public class TreeHistogram( + private val binMap: TreeMap>, +) : Histogram1D { + override fun get(value: Double): Bin1D? = binMap.getBin(value) + override val bins: Collection> get() = binMap.values +} + +/** + * A space for univariate histograms with variable bin borders based on a tree map + */ +public class TreeHistogramGroup( + public val valueAlgebra: A, + @PublishedApi internal val binFactory: (Double) -> DoubleDomain1D, +) : Group>, ScaleOperations> where A : Ring, A : ScaleOperations { + + internal inner class DomainCounter(val domain: DoubleDomain1D, val counter: Counter = Counter.of(valueAlgebra)) : + ClosedRange by domain.range + + @PublishedApi + internal inner class TreeHistogramBuilder : Histogram1DBuilder { + + override val defaultValue: V get() = valueAlgebra.one + + private val bins: TreeMap = TreeMap() + + private fun createBin(value: Double): DomainCounter { + val binDefinition: DoubleDomain1D = binFactory(value) + val newBin = DomainCounter(binDefinition) + synchronized(this) { + bins[binDefinition.center] = newBin + } + return newBin + } + + /** + * Thread safe put operation + */ + override fun putValue(at: Double, value: V) { + (bins.getBin(at) ?: createBin(at)).counter.add(value) + } + + fun build(): TreeHistogram { + val map = bins.mapValuesTo(TreeMap>()) { (_, binCounter) -> + Bin1D(binCounter.domain, binCounter.counter.value) + } + return TreeHistogram(map) + } + } + + public inline fun produce(block: Histogram1DBuilder.() -> Unit): TreeHistogram = + TreeHistogramBuilder().apply(block).build() + + override fun add( + left: TreeHistogram, + right: TreeHistogram, + ): TreeHistogram { + val bins = TreeMap>().apply { + (left.bins.map { it.domain } union right.bins.map { it.domain }).forEach { def -> + put( + def.center, + Bin1D( + def, + with(valueAlgebra) { + (left[def.center]?.binValue ?: zero) + (right[def.center]?.binValue ?: zero) + } + ) + ) + } + } + return TreeHistogram(bins) + } + + override fun scale(a: TreeHistogram, value: Double): TreeHistogram { + val bins = TreeMap>().apply { + a.bins.forEach { bin -> + put( + bin.domain.center, + Bin1D(bin.domain, valueAlgebra.scale(bin.binValue, value)) + ) + } + } + + return TreeHistogram(bins) + } + + override fun TreeHistogram.unaryMinus(): TreeHistogram = this * (-1) + + override val zero: TreeHistogram = produce { } +} + + +///** +// * Build and fill a histogram with custom borders. Returns a read-only histogram. +// */ +//public inline fun Histogram.custom( +// borders: DoubleArray, +// builder: Histogram1DBuilder.() -> Unit, +//): TreeHistogram = custom(borders).fill(builder) +// +// +///** +// * Build and fill a [DoubleHistogram1D]. Returns a read-only histogram. +// */ +//public fun uniform( +// binSize: Double, +// start: Double = 0.0, +//): TreeHistogramSpace = TreeHistogramSpace { value -> +// val center = start + binSize * floor((value - start) / binSize + 0.5) +// DoubleDomain1D((center - binSize / 2)..(center + binSize / 2)) +//} + +/** + * Create a histogram group with custom cell borders + */ +public fun Histogram.Companion.custom1D( + valueAlgebra: A, + borders: Buffer, +): TreeHistogramGroup where A : Ring, A : ScaleOperations { + val sorted = borders.sorted() + + return TreeHistogramGroup(valueAlgebra) { value -> + when { + value <= sorted.first() -> DoubleDomain1D( + Double.NEGATIVE_INFINITY..sorted.first() + ) + + value > sorted.last() -> DoubleDomain1D( + sorted.last()..Double.POSITIVE_INFINITY + ) + + else -> { + val index = sorted.indices.first { value <= sorted[it] } + val left = sorted[index - 1] + val right = sorted[index] + DoubleDomain1D(left..right) + } + } + } +} \ No newline at end of file diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt deleted file mode 100644 index bff20c22c..000000000 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2018-2021 KMath contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -@file:OptIn(UnstableKMathAPI::class) - -package space.kscience.kmath.histogram - -import space.kscience.kmath.domains.DoubleDomain1D -import space.kscience.kmath.domains.center -import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.operations.Group -import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.structures.Buffer -import java.util.* -import kotlin.math.abs -import kotlin.math.floor -import kotlin.math.sqrt - -private fun > TreeMap.getBin(value: Double): B? { - // check ceiling entry and return it if it is what needed - val ceil = ceilingEntry(value)?.value - if (ceil != null && value in ceil) return ceil - //check floor entry - val floor = floorEntry(value)?.value - if (floor != null && value in floor) return floor - //neither is valid, not found - return null -} - -public data class ValueAndError(val value: Double, val error: Double) - -public typealias WeightedBin1D = Bin1D - -public class TreeHistogram( - private val binMap: TreeMap, -) : Histogram1D { - override fun get(value: Double): WeightedBin1D? = binMap.getBin(value) - override val bins: Collection get() = binMap.values -} - -@PublishedApi -internal class TreeHistogramBuilder(val binFactory: (Double) -> DoubleDomain1D) : Histogram1DBuilder { - - override val defaultValue: Double get() = 1.0 - - internal class BinCounter(val domain: DoubleDomain1D, val counter: Counter = Counter.ofDouble()) : - ClosedRange by domain.range - - private val bins: TreeMap = TreeMap() - - fun get(value: Double): BinCounter? = bins.getBin(value) - - fun createBin(value: Double): BinCounter { - val binDefinition: DoubleDomain1D = binFactory(value) - val newBin = BinCounter(binDefinition) - synchronized(this) { - bins[binDefinition.center] = newBin - } - return newBin - } - - /** - * Thread safe put operation - */ - override fun putValue(at: Double, value: Double) { - (get(at) ?: createBin(at)).apply { - counter.add(value) - } - } - - override fun putValue(point: Buffer, value: Double) { - require(point.size == 1) { "Only points with single value could be used in univariate histogram" } - putValue(point[0], value.toDouble()) - } - - fun build(): TreeHistogram { - val map = bins.mapValuesTo(TreeMap()) { (_, binCounter) -> - val count: Double = binCounter.counter.value - WeightedBin1D(binCounter.domain, ValueAndError(count, sqrt(count))) - } - return TreeHistogram(map) - } -} - -/** - * A space for univariate histograms with variable bin borders based on a tree map - */ -public class TreeHistogramSpace( - @PublishedApi internal val binFactory: (Double) -> DoubleDomain1D, -) : Group, ScaleOperations { - - public inline fun fill(block: Histogram1DBuilder.() -> Unit): TreeHistogram = - TreeHistogramBuilder(binFactory).apply(block).build() - - override fun add( - left: TreeHistogram, - right: TreeHistogram, - ): TreeHistogram { -// require(a.context == this) { "Histogram $a does not belong to this context" } -// require(b.context == this) { "Histogram $b does not belong to this context" } - val bins = TreeMap().apply { - (left.bins.map { it.domain } union right.bins.map { it.domain }).forEach { def -> - put( - def.center, - WeightedBin1D( - def, - ValueAndError( - (left[def.center]?.binValue?.value ?: 0.0) + (right[def.center]?.binValue?.value ?: 0.0), - (left[def.center]?.binValue?.error ?: 0.0) + (right[def.center]?.binValue?.error ?: 0.0) - ) - ) - ) - } - } - return TreeHistogram(bins) - } - - override fun scale(a: TreeHistogram, value: Double): TreeHistogram { - val bins = TreeMap().apply { - a.bins.forEach { bin -> - put( - bin.domain.center, - WeightedBin1D( - bin.domain, - ValueAndError( - bin.binValue.value * value, - abs(bin.binValue.error * value) - ) - ) - ) - } - } - - return TreeHistogram(bins) - } - - override fun TreeHistogram.unaryMinus(): TreeHistogram = this * (-1) - - override val zero: TreeHistogram by lazy { fill { } } - - public companion object { - /** - * Build and fill a [TreeHistogram]. Returns a read-only histogram. - */ - public inline fun uniform( - binSize: Double, - start: Double = 0.0, - builder: Histogram1DBuilder.() -> Unit, - ): TreeHistogram = uniform(binSize, start).fill(builder) - - /** - * Build and fill a histogram with custom borders. Returns a read-only histogram. - */ - public inline fun custom( - borders: DoubleArray, - builder: Histogram1DBuilder.() -> Unit, - ): TreeHistogram = custom(borders).fill(builder) - - - /** - * Build and fill a [DoubleHistogram1D]. Returns a read-only histogram. - */ - public fun uniform( - binSize: Double, - start: Double = 0.0, - ): TreeHistogramSpace = TreeHistogramSpace { value -> - val center = start + binSize * floor((value - start) / binSize + 0.5) - DoubleDomain1D((center - binSize / 2)..(center + binSize / 2)) - } - - /** - * Create a histogram with custom cell borders - */ - public fun custom(borders: DoubleArray): TreeHistogramSpace { - val sorted = borders.sortedArray() - - return TreeHistogramSpace { value -> - when { - value < sorted.first() -> DoubleDomain1D( - Double.NEGATIVE_INFINITY..sorted.first() - ) - - value > sorted.last() -> DoubleDomain1D( - sorted.last()..Double.POSITIVE_INFINITY - ) - - else -> { - val index = sorted.indices.first { value > sorted[it] } - val left = sorted[index] - val right = sorted[index + 1] - DoubleDomain1D(left..right) - } - } - } - } - } -} \ No newline at end of file diff --git a/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt b/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt index f1a8f953b..c4eeb53cc 100644 --- a/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt +++ b/kmath-histograms/src/jvmTest/kotlin/space/kscience/kmath/histogram/TreeHistogramTest.kt @@ -6,19 +6,24 @@ package space.kscience.kmath.histogram import org.junit.jupiter.api.Test +import space.kscience.kmath.operations.DoubleField +import space.kscience.kmath.real.step import kotlin.random.Random +import kotlin.test.assertEquals import kotlin.test.assertTrue class TreeHistogramTest { @Test fun normalFill() { - val histogram = TreeHistogramSpace.uniform(0.1) { + val random = Random(123) + val histogram = Histogram.custom1D(DoubleField, 0.0..1.0 step 0.1).produce { repeat(100_000) { - putValue(Random.nextDouble()) + putValue(random.nextDouble()) } } - assertTrue { histogram.bins.count() > 10 } + assertTrue { histogram.bins.count() > 8} + assertEquals(100_000, histogram.bins.sumOf { it.binValue }.toInt()) } } \ No newline at end of file From b509dc917d1836c4b37e4129138d85e1736ad7ef Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 10 Apr 2022 23:00:55 +0300 Subject: [PATCH 21/26] ValueAndErrorField --- CHANGELOG.md | 2 + .../kscience/kmath/functions/integrate.kt | 2 +- .../kmath/functions/interpolateSquare.kt | 2 +- .../kmath/operations/BufferAlgebra.kt | 22 ++++---- .../kscience/kmath/functions/functionTypes.kt | 4 +- .../kscience/kmath/stat/ValueAndErrorField.kt | 56 +++++++++++++++++++ 6 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/ValueAndErrorField.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index bc5447449..b3c9b7b6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Complex power - Separate methods for UInt, Int and Number powers. NaN safety. - Tensorflow prototype +- `ValueAndErrorField` ### Changed - Exponential operations merged with hyperbolic functions @@ -50,6 +51,7 @@ - Tensor algebra takes read-only structures as input and inherits AlgebraND - `UnivariateDistribution` renamed to `Distribution1D` - Rework of histograms. +- `UnivariateFunction` -> `Function1D`, `MultivariateFunction` -> `FunctionND` ### Deprecated - Specialized `DoubleBufferAlgebra` diff --git a/examples/src/main/kotlin/space/kscience/kmath/functions/integrate.kt b/examples/src/main/kotlin/space/kscience/kmath/functions/integrate.kt index f60b1ab45..59eaba5bd 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/functions/integrate.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/functions/integrate.kt @@ -13,7 +13,7 @@ import kotlin.math.pow fun main() { //Define a function - val function: UnivariateFunction = { x -> 3 * x.pow(2) + 2 * x + 1 } + val function: Function1D = { x -> 3 * x.pow(2) + 2 * x + 1 } //get the result of the integration val result = DoubleField.gaussIntegrator.integrate(0.0..10.0, function = function) diff --git a/examples/src/main/kotlin/space/kscience/kmath/functions/interpolateSquare.kt b/examples/src/main/kotlin/space/kscience/kmath/functions/interpolateSquare.kt index feefedece..a50df0931 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/functions/interpolateSquare.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/functions/interpolateSquare.kt @@ -18,7 +18,7 @@ import space.kscience.plotly.scatter @OptIn(UnstablePlotlyAPI::class) fun main() { - val function: UnivariateFunction = { x -> + val function: Function1D = { x -> if (x in 30.0..50.0) { 1.0 } else { diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BufferAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BufferAlgebra.kt index 653552044..51fff8b69 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BufferAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BufferAlgebra.kt @@ -5,7 +5,6 @@ package space.kscience.kmath.operations -import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.BufferFactory import space.kscience.kmath.structures.DoubleBuffer @@ -53,7 +52,7 @@ public interface BufferAlgebra> : Algebra> { */ private inline fun > BufferAlgebra.mapInline( buffer: Buffer, - crossinline block: A.(T) -> T + crossinline block: A.(T) -> T, ): Buffer = bufferFactory(buffer.size) { elementAlgebra.block(buffer[it]) } /** @@ -61,7 +60,7 @@ private inline fun > BufferAlgebra.mapInline( */ private inline fun > BufferAlgebra.mapIndexedInline( buffer: Buffer, - crossinline block: A.(index: Int, arg: T) -> T + crossinline block: A.(index: Int, arg: T) -> T, ): Buffer = bufferFactory(buffer.size) { elementAlgebra.block(it, buffer[it]) } /** @@ -70,7 +69,7 @@ private inline fun > BufferAlgebra.mapIndexedInline( private inline fun > BufferAlgebra.zipInline( l: Buffer, r: Buffer, - crossinline block: A.(l: T, r: T) -> T + crossinline block: A.(l: T, r: T) -> T, ): Buffer { require(l.size == r.size) { "Incompatible buffer sizes. left: ${l.size}, right: ${r.size}" } return bufferFactory(l.size) { elementAlgebra.block(l[it], r[it]) } @@ -127,13 +126,13 @@ public fun > BufferAlgebra.atanh(arg: Buff mapInline(arg) { atanh(it) } public fun > BufferAlgebra.pow(arg: Buffer, pow: Number): Buffer = - mapInline(arg) {it.pow(pow) } + mapInline(arg) { it.pow(pow) } -public open class BufferRingOps>( +public open class BufferRingOps>( override val elementAlgebra: A, override val bufferFactory: BufferFactory, -) : BufferAlgebra, RingOps>{ +) : BufferAlgebra, RingOps> { override fun add(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l + r } override fun multiply(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l * r } @@ -152,10 +151,11 @@ public val ShortRing.bufferAlgebra: BufferRingOps public open class BufferFieldOps>( elementAlgebra: A, bufferFactory: BufferFactory, -) : BufferRingOps(elementAlgebra, bufferFactory), BufferAlgebra, FieldOps>, ScaleOperations> { +) : BufferRingOps(elementAlgebra, bufferFactory), BufferAlgebra, FieldOps>, + ScaleOperations> { - override fun add(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l + r } - override fun multiply(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l * r } +// override fun add(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l + r } +// override fun multiply(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l * r } override fun divide(left: Buffer, right: Buffer): Buffer = zipInline(left, right) { l, r -> l / r } override fun scale(a: Buffer, value: Double): Buffer = a.map { scale(it, value) } @@ -168,7 +168,7 @@ public open class BufferFieldOps>( public class BufferField>( elementAlgebra: A, bufferFactory: BufferFactory, - override val size: Int + override val size: Int, ) : BufferFieldOps(elementAlgebra, bufferFactory), Field>, WithSize { override val zero: Buffer = bufferFactory(size) { elementAlgebra.zero } diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/functionTypes.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/functionTypes.kt index 88b24c756..0e814993c 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/functionTypes.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/functionTypes.kt @@ -7,6 +7,6 @@ package space.kscience.kmath.functions import space.kscience.kmath.structures.Buffer -public typealias UnivariateFunction = (T) -> T +public typealias Function1D = (T) -> T -public typealias MultivariateFunction = (Buffer) -> T \ No newline at end of file +public typealias FunctionND = (Buffer) -> T \ No newline at end of file diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/ValueAndErrorField.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/ValueAndErrorField.kt new file mode 100644 index 000000000..5949213e7 --- /dev/null +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/ValueAndErrorField.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.stat + +import space.kscience.kmath.operations.Field +import kotlin.math.pow +import kotlin.math.sqrt + +/** + * A combination of a random [value] and its [dispersion]. + * + * [dispersion] must be positive. + */ +public data class ValueAndError(val value: Double, val dispersion: Double) { + init { + require(dispersion >= 0) { "Dispersion must be non-negative" } + } + + val error: Double get() = sqrt(dispersion) +} + +/** + * An algebra for double value + its error combination. The multiplication assumes linear error propagation + */ +public object ValueAndErrorField : Field { + + override val zero: ValueAndError = ValueAndError(0.0, 0.0) + + override val one: ValueAndError = ValueAndError(1.0, 0.0) + + override fun add(left: ValueAndError, right: ValueAndError): ValueAndError = + ValueAndError(left.value + right.value, left.dispersion + right.dispersion) + + override fun ValueAndError.unaryMinus(): ValueAndError = + ValueAndError(-value, dispersion) + + //TODO study performance impact of pow(2). On JVM it does not exist: https://stackoverflow.com/questions/29144275/xx-vs-math-powx-2-java-performance + + override fun multiply(left: ValueAndError, right: ValueAndError): ValueAndError { + val value = left.value * right.value + val dispersion = (left.dispersion / left.value.pow(2) + right.dispersion / right.value.pow(2)) * value.pow(2) + return ValueAndError(value, dispersion) + } + + override fun divide(left: ValueAndError, right: ValueAndError): ValueAndError { + val value = left.value / right.value + val dispersion = (left.dispersion / left.value.pow(2) + right.dispersion / right.value.pow(2)) * value.pow(2) + return ValueAndError(value, dispersion) + } + + override fun scale(a: ValueAndError, value: Double): ValueAndError = + ValueAndError(a.value * value, a.dispersion * value.pow(2)) +} \ No newline at end of file From 7e4d2230444ff8902ef50c667bbeb75c7b1eb900 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 11 Apr 2022 14:56:48 +0300 Subject: [PATCH 22/26] Fixed missing TF basic operations --- .../kmath/tensorflow/TensorFlowAlgebra.kt | 16 ++++++++----- .../tensors/api/AnalyticTensorAlgebra.kt | 24 +++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/kmath-tensorflow/src/main/kotlin/space/kscience/kmath/tensorflow/TensorFlowAlgebra.kt b/kmath-tensorflow/src/main/kotlin/space/kscience/kmath/tensorflow/TensorFlowAlgebra.kt index b40739ee0..7185b84d6 100644 --- a/kmath-tensorflow/src/main/kotlin/space/kscience/kmath/tensorflow/TensorFlowAlgebra.kt +++ b/kmath-tensorflow/src/main/kotlin/space/kscience/kmath/tensorflow/TensorFlowAlgebra.kt @@ -6,11 +6,9 @@ import org.tensorflow.Operand import org.tensorflow.Output import org.tensorflow.Session import org.tensorflow.ndarray.NdArray +import org.tensorflow.ndarray.index.Indices import org.tensorflow.op.Ops -import org.tensorflow.op.core.Constant -import org.tensorflow.op.core.Max -import org.tensorflow.op.core.Min -import org.tensorflow.op.core.Sum +import org.tensorflow.op.core.* import org.tensorflow.types.TInt32 import org.tensorflow.types.family.TNumber import org.tensorflow.types.family.TType @@ -182,7 +180,7 @@ public abstract class TensorFlowAlgebra> internal c override fun StructureND.unaryMinus(): TensorFlowOutput = operate(ops.math::neg) override fun Tensor.get(i: Int): Tensor = operate { - TODO("Not yet implemented") + StridedSliceHelper.stridedSlice(ops.scope(), it, Indices.at(i.toLong())) } override fun Tensor.transpose(i: Int, j: Int): Tensor = operate { @@ -210,7 +208,13 @@ public abstract class TensorFlowAlgebra> internal c dim1: Int, dim2: Int, ): TensorFlowOutput = diagonalEntries.operate { - TODO("Not yet implemented") + ops.linalg.matrixDiagV3( + /* diagonal = */ it, + /* k = */ ops.constant(offset), + /* numRows = */ ops.constant(dim1), + /* numCols = */ ops.constant(dim2), + /* paddingValue = */ const(elementAlgebra.zero) + ) } override fun StructureND.sum(): T = operate { diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt index 3ed34ae5e..b32fcf608 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt @@ -123,27 +123,27 @@ public interface AnalyticTensorAlgebra> : //For information: https://pytorch.org/docs/stable/generated/torch.floor.html#torch.floor public fun StructureND.floor(): Tensor - override fun sin(arg: StructureND): StructureND = arg.sin() + override fun sin(arg: StructureND): Tensor = arg.sin() - override fun cos(arg: StructureND): StructureND = arg.cos() + override fun cos(arg: StructureND): Tensor = arg.cos() - override fun asin(arg: StructureND): StructureND = arg.asin() + override fun asin(arg: StructureND): Tensor = arg.asin() - override fun acos(arg: StructureND): StructureND = arg.acos() + override fun acos(arg: StructureND): Tensor = arg.acos() - override fun atan(arg: StructureND): StructureND = arg.atan() + override fun atan(arg: StructureND): Tensor = arg.atan() - override fun exp(arg: StructureND): StructureND = arg.exp() + override fun exp(arg: StructureND): Tensor = arg.exp() - override fun ln(arg: StructureND): StructureND = arg.ln() + override fun ln(arg: StructureND): Tensor = arg.ln() - override fun sinh(arg: StructureND): StructureND = arg.sinh() + override fun sinh(arg: StructureND): Tensor = arg.sinh() - override fun cosh(arg: StructureND): StructureND = arg.cosh() + override fun cosh(arg: StructureND): Tensor = arg.cosh() - override fun asinh(arg: StructureND): StructureND = arg.asinh() + override fun asinh(arg: StructureND): Tensor = arg.asinh() - override fun acosh(arg: StructureND): StructureND = arg.acosh() + override fun acosh(arg: StructureND): Tensor = arg.acosh() - override fun atanh(arg: StructureND): StructureND = arg.atanh() + override fun atanh(arg: StructureND): Tensor = arg.atanh() } \ No newline at end of file From 916bc69e4b6ff002126c3457ddcb3ea8f5701e0f Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 11 Apr 2022 17:32:16 +0300 Subject: [PATCH 23/26] Revert changes in tensor algebra to remove name conflicts --- .../tensors/api/AnalyticTensorAlgebra.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt index b32fcf608..3ed34ae5e 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt @@ -123,27 +123,27 @@ public interface AnalyticTensorAlgebra> : //For information: https://pytorch.org/docs/stable/generated/torch.floor.html#torch.floor public fun StructureND.floor(): Tensor - override fun sin(arg: StructureND): Tensor = arg.sin() + override fun sin(arg: StructureND): StructureND = arg.sin() - override fun cos(arg: StructureND): Tensor = arg.cos() + override fun cos(arg: StructureND): StructureND = arg.cos() - override fun asin(arg: StructureND): Tensor = arg.asin() + override fun asin(arg: StructureND): StructureND = arg.asin() - override fun acos(arg: StructureND): Tensor = arg.acos() + override fun acos(arg: StructureND): StructureND = arg.acos() - override fun atan(arg: StructureND): Tensor = arg.atan() + override fun atan(arg: StructureND): StructureND = arg.atan() - override fun exp(arg: StructureND): Tensor = arg.exp() + override fun exp(arg: StructureND): StructureND = arg.exp() - override fun ln(arg: StructureND): Tensor = arg.ln() + override fun ln(arg: StructureND): StructureND = arg.ln() - override fun sinh(arg: StructureND): Tensor = arg.sinh() + override fun sinh(arg: StructureND): StructureND = arg.sinh() - override fun cosh(arg: StructureND): Tensor = arg.cosh() + override fun cosh(arg: StructureND): StructureND = arg.cosh() - override fun asinh(arg: StructureND): Tensor = arg.asinh() + override fun asinh(arg: StructureND): StructureND = arg.asinh() - override fun acosh(arg: StructureND): Tensor = arg.acosh() + override fun acosh(arg: StructureND): StructureND = arg.acosh() - override fun atanh(arg: StructureND): Tensor = arg.atanh() + override fun atanh(arg: StructureND): StructureND = arg.atanh() } \ No newline at end of file From 74e6bc65a315dbc0623ac8b1bfbc9fe1bcfd62df Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 11 Apr 2022 20:07:40 +0300 Subject: [PATCH 24/26] 0.3.0 release --- CHANGELOG.md | 28 +- build.gradle.kts | 2 +- kmath-ast/README.md | 6 +- kmath-commons/README.md | 6 +- kmath-complex/README.md | 6 +- kmath-core/README.md | 6 +- kmath-core/api/kmath-core.api | 926 +++++++++++++++++++++--------- kmath-coroutines/README.md | 6 +- kmath-dimensions/README.md | 6 +- kmath-ejml/README.md | 6 +- kmath-for-real/README.md | 6 +- kmath-functions/README.md | 6 +- kmath-geometry/README.md | 6 +- kmath-histograms/README.md | 6 +- kmath-jafama/README.md | 6 +- kmath-jupyter/README.md | 6 +- kmath-kotlingrad/README.md | 6 +- kmath-memory/README.md | 6 +- kmath-multik/README.md | 6 +- kmath-nd4j/README.md | 6 +- kmath-optimization/README.md | 6 +- kmath-stat/README.md | 6 +- kmath-symja/README.md | 6 +- kmath-tensorflow/README.md | 6 +- kmath-tensors/README.md | 6 +- kmath-viktor/README.md | 6 +- kmath-viktor/api/kmath-viktor.api | 72 ++- 27 files changed, 793 insertions(+), 373 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c9b7b6d..28240dc68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ ## [Unreleased] ### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + +## [0.3.0] +### Added - `ScaleOperations` interface - `Field` extends `ScaleOperations` - Basic integration API @@ -21,6 +34,7 @@ - Tensorflow prototype - `ValueAndErrorField` + ### Changed - Exponential operations merged with hyperbolic functions - Space is replaced by Group. Space is reserved for vector spaces. @@ -53,9 +67,11 @@ - Rework of histograms. - `UnivariateFunction` -> `Function1D`, `MultivariateFunction` -> `FunctionND` + ### Deprecated - Specialized `DoubleBufferAlgebra` + ### Removed - Nearest in Domain. To be implemented in geometry package. - Number multiplication and division in main Algebra chain @@ -66,10 +82,12 @@ - Second generic from DifferentiableExpression - Algebra elements are completely removed. Use algebra contexts instead. + ### Fixed - Ring inherits RingOperations, not GroupOperations - Univariate histogram filling + ### Security ## [0.2.0] @@ -92,6 +110,7 @@ - New `MatrixFeature` interfaces for matrix decompositions - Basic Quaternion vector support in `kmath-complex`. + ### Changed - Package changed from `scientifik` to `space.kscience` - Gradle version: 6.6 -> 6.8.2 @@ -116,7 +135,6 @@ - `symbol` method in `Algebra` renamed to `bindSymbol` to avoid ambiguity - Add `out` projection to `Buffer` generic -### Deprecated ### Removed - `kmath-koma` module because it doesn't support Kotlin 1.4. @@ -126,13 +144,11 @@ - `Real` class - StructureND identity and equals + ### Fixed - `symbol` method in `MstExtendedField` (https://github.com/mipt-npm/kmath/pull/140) -### Security - ## [0.1.4] - ### Added - Functional Expressions API - Mathematical Syntax Tree, its interpreter and API @@ -150,6 +166,7 @@ - Full hyperbolic functions support and default implementations within `ExtendedField` - Norm support for `Complex` + ### Changed - `readAsMemory` now has `throws IOException` in JVM signature. - Several functions taking functional types were made `inline`. @@ -161,9 +178,10 @@ - Gradle version: 6.3 -> 6.6 - Moved probability distributions to commons-rng and to `kmath-prob` + ### Fixed - Missing copy method in Memory implementation on JS (https://github.com/mipt-npm/kmath/pull/106) - D3.dim value in `kmath-dimensions` - Multiplication in integer rings in `kmath-core` (https://github.com/mipt-npm/kmath/pull/101) - Commons RNG compatibility (https://github.com/mipt-npm/kmath/issues/93) -- Multiplication of BigInt by scalar +- Multiplication of BigInt by scalar \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 1e703c5e1..10f2385f5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ allprojects { } group = "space.kscience" - version = "0.3.0-dev-21" + version = "0.3.0" } subprojects { diff --git a/kmath-ast/README.md b/kmath-ast/README.md index 4872a3a26..5d5630f46 100644 --- a/kmath-ast/README.md +++ b/kmath-ast/README.md @@ -10,7 +10,7 @@ Extensions to MST API: transformations, dynamic compilation and visualization. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0`. **Gradle Groovy:** ```groovy @@ -20,7 +20,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-ast:0.3.0-dev-20' + implementation 'space.kscience:kmath-ast:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation("space.kscience:kmath-ast:0.3.0-dev-20") + implementation("space.kscience:kmath-ast:0.3.0") } ``` diff --git a/kmath-commons/README.md b/kmath-commons/README.md index a17a39205..7195e6fb1 100644 --- a/kmath-commons/README.md +++ b/kmath-commons/README.md @@ -6,7 +6,7 @@ Commons math binding for kmath ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-commons:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-commons:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-commons:0.3.0-dev-20' + implementation 'space.kscience:kmath-commons:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-commons:0.3.0-dev-20") + implementation("space.kscience:kmath-commons:0.3.0") } ``` diff --git a/kmath-complex/README.md b/kmath-complex/README.md index b55ce0fea..4646c6a80 100644 --- a/kmath-complex/README.md +++ b/kmath-complex/README.md @@ -8,7 +8,7 @@ Complex and hypercomplex number systems in KMath. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0`. **Gradle Groovy:** ```groovy @@ -18,7 +18,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-complex:0.3.0-dev-20' + implementation 'space.kscience:kmath-complex:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -29,6 +29,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-complex:0.3.0-dev-20") + implementation("space.kscience:kmath-complex:0.3.0") } ``` diff --git a/kmath-core/README.md b/kmath-core/README.md index 31965ef92..4fddd327c 100644 --- a/kmath-core/README.md +++ b/kmath-core/README.md @@ -15,7 +15,7 @@ performance calculations to code generation. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0`. **Gradle Groovy:** ```groovy @@ -25,7 +25,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-core:0.3.0-dev-20' + implementation 'space.kscience:kmath-core:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -36,6 +36,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-core:0.3.0-dev-20") + implementation("space.kscience:kmath-core:0.3.0") } ``` diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index b424b59ff..737d33f1c 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -1,17 +1,29 @@ public final class space/kscience/kmath/data/ColumnarDataKt { + public static final fun getIndices (Lspace/kscience/kmath/data/ColumnarData;)Lkotlin/ranges/IntRange; +} + +public final class space/kscience/kmath/data/XYColumnarData$Companion { } public final class space/kscience/kmath/data/XYColumnarDataKt { public static synthetic fun asXYData$default (Lspace/kscience/kmath/nd/Structure2D;IIILjava/lang/Object;)Lspace/kscience/kmath/data/XYColumnarData; } +public final class space/kscience/kmath/data/XYErrorColumnarData$Companion { + public final fun of (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/data/XYErrorColumnarData; +} + public abstract interface class space/kscience/kmath/domains/Domain { public abstract fun contains (Lspace/kscience/kmath/structures/Buffer;)Z public abstract fun getDimension ()I } +public final class space/kscience/kmath/domains/Domain1DKt { + public static final fun getCenter (Lspace/kscience/kmath/domains/Domain1D;)D +} + public abstract interface class space/kscience/kmath/expressions/AutoDiffProcessor { - public abstract fun process (Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/DifferentiableExpression; + public abstract fun differentiate (Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/DifferentiableExpression; } public class space/kscience/kmath/expressions/AutoDiffValue { @@ -35,6 +47,9 @@ public final class space/kscience/kmath/expressions/DifferentiableExpressionKt { public static final fun derivative (Lspace/kscience/kmath/expressions/DifferentiableExpression;Ljava/lang/String;)Lspace/kscience/kmath/expressions/Expression; public static final fun derivative (Lspace/kscience/kmath/expressions/DifferentiableExpression;Ljava/util/List;)Lspace/kscience/kmath/expressions/Expression; public static final fun derivative (Lspace/kscience/kmath/expressions/DifferentiableExpression;[Lspace/kscience/kmath/expressions/Symbol;)Lspace/kscience/kmath/expressions/Expression; + public static final fun derivative (Lspace/kscience/kmath/expressions/SpecialDifferentiableExpression;Ljava/lang/String;)Lspace/kscience/kmath/expressions/Expression; + public static final fun derivative (Lspace/kscience/kmath/expressions/SpecialDifferentiableExpression;Ljava/util/List;)Lspace/kscience/kmath/expressions/Expression; + public static final fun derivative (Lspace/kscience/kmath/expressions/SpecialDifferentiableExpression;[Lspace/kscience/kmath/expressions/Symbol;)Lspace/kscience/kmath/expressions/Expression; } public abstract interface class space/kscience/kmath/expressions/Expression { @@ -46,9 +61,9 @@ public abstract interface class space/kscience/kmath/expressions/ExpressionAlgeb } public final class space/kscience/kmath/expressions/ExpressionKt { - public static final fun binding (Lspace/kscience/kmath/expressions/ExpressionAlgebra;)Lkotlin/properties/ReadOnlyProperty; public static final fun callByString (Lspace/kscience/kmath/expressions/Expression;[Lkotlin/Pair;)Ljava/lang/Object; public static final fun callBySymbol (Lspace/kscience/kmath/expressions/Expression;[Lkotlin/Pair;)Ljava/lang/Object; + public static final fun getBinding (Lspace/kscience/kmath/expressions/ExpressionAlgebra;)Lkotlin/properties/ReadOnlyProperty; public static final fun invoke (Lspace/kscience/kmath/expressions/Expression;)Ljava/lang/Object; } @@ -70,10 +85,11 @@ public abstract class space/kscience/kmath/expressions/FunctionalExpressionAlgeb } public final class space/kscience/kmath/expressions/FunctionalExpressionAlgebraKt { + public static final fun expression (Lspace/kscience/kmath/operations/DoubleField;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun expressionInExtendedField (Lspace/kscience/kmath/operations/ExtendedField;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun expressionInField (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; + public static final fun expressionInGroup (Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun expressionInRing (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; - public static final fun expressionInSpace (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; } public class space/kscience/kmath/expressions/FunctionalExpressionExtendedField : space/kscience/kmath/expressions/FunctionalExpressionField, space/kscience/kmath/operations/ExtendedField { @@ -85,8 +101,6 @@ public class space/kscience/kmath/expressions/FunctionalExpressionExtendedField public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; public fun atan (Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public synthetic fun bindSymbol (Ljava/lang/String;)Ljava/lang/Object; - public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/expressions/Expression; public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; public fun cos (Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; @@ -189,7 +203,6 @@ public final class space/kscience/kmath/expressions/MST$Unary : space/kscience/k } public final class space/kscience/kmath/expressions/MSTKt { - public static final fun evaluate (Lspace/kscience/kmath/operations/Algebra;Lspace/kscience/kmath/expressions/MST;)Ljava/lang/Object; public static final fun interpret (Lspace/kscience/kmath/expressions/MST;Lspace/kscience/kmath/operations/Algebra;Ljava/util/Map;)Ljava/lang/Object; public static final fun interpret (Lspace/kscience/kmath/expressions/MST;Lspace/kscience/kmath/operations/Algebra;[Lkotlin/Pair;)Ljava/lang/Object; public static final fun toExpression (Lspace/kscience/kmath/expressions/MST;Lspace/kscience/kmath/operations/Algebra;)Lspace/kscience/kmath/expressions/Expression; @@ -255,7 +268,7 @@ public final class space/kscience/kmath/expressions/MstExtendedField : space/ksc public fun unaryPlus (Lspace/kscience/kmath/expressions/MST;)Lspace/kscience/kmath/expressions/MST$Unary; } -public final class space/kscience/kmath/expressions/MstField : space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { +public final class space/kscience/kmath/expressions/MstField : space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumbersAddOps, space/kscience/kmath/operations/ScaleOperations { public static final field INSTANCE Lspace/kscience/kmath/expressions/MstField; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/expressions/MST;Lspace/kscience/kmath/expressions/MST;)Lspace/kscience/kmath/expressions/MST$Binary; @@ -317,7 +330,7 @@ public final class space/kscience/kmath/expressions/MstNumericAlgebra : space/ks public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } -public final class space/kscience/kmath/expressions/MstRing : space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/Ring, space/kscience/kmath/operations/ScaleOperations { +public final class space/kscience/kmath/expressions/MstRing : space/kscience/kmath/operations/NumbersAddOps, space/kscience/kmath/operations/Ring, space/kscience/kmath/operations/ScaleOperations { public static final field INSTANCE Lspace/kscience/kmath/expressions/MstRing; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/expressions/MST;Lspace/kscience/kmath/expressions/MST;)Lspace/kscience/kmath/expressions/MST$Binary; @@ -365,8 +378,6 @@ public final class space/kscience/kmath/expressions/SimpleAutoDiffExtendedField public fun atan (Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; public fun atanh (Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; - public synthetic fun bindSymbol (Ljava/lang/String;)Ljava/lang/Object; - public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/expressions/AutoDiffValue; public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; public fun cos (Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; @@ -395,7 +406,7 @@ public final class space/kscience/kmath/expressions/SimpleAutoDiffExtendedField public fun tanh (Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; } -public class space/kscience/kmath/expressions/SimpleAutoDiffField : space/kscience/kmath/expressions/ExpressionAlgebra, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumbersAddOperations { +public class space/kscience/kmath/expressions/SimpleAutoDiffField : space/kscience/kmath/expressions/ExpressionAlgebra, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumbersAddOps { public fun (Lspace/kscience/kmath/operations/Field;Ljava/util/Map;)V public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/expressions/AutoDiffValue;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; @@ -403,7 +414,6 @@ public class space/kscience/kmath/expressions/SimpleAutoDiffField : space/kscien public fun bindSymbolOrNull (Ljava/lang/String;)Lspace/kscience/kmath/expressions/AutoDiffValue; public synthetic fun const (Ljava/lang/Object;)Ljava/lang/Object; public fun const (Ljava/lang/Object;)Lspace/kscience/kmath/expressions/AutoDiffValue; - public final fun const (Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/AutoDiffValue; public final fun derive (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun divide (Lspace/kscience/kmath/expressions/AutoDiffValue;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; @@ -431,6 +441,7 @@ public final class space/kscience/kmath/expressions/SimpleAutoDiffKt { public static final fun asinh (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; public static final fun atan (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; public static final fun atanh (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; + public static final fun const (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/AutoDiffValue; public static final fun cos (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; public static final fun cosh (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; public static final fun exp (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; @@ -450,18 +461,13 @@ public final class space/kscience/kmath/expressions/SimpleAutoDiffKt { public static final fun tanh (Lspace/kscience/kmath/expressions/SimpleAutoDiffField;Lspace/kscience/kmath/expressions/AutoDiffValue;)Lspace/kscience/kmath/expressions/AutoDiffValue; } -public final class space/kscience/kmath/expressions/StringSymbol : space/kscience/kmath/expressions/Symbol { - public static final synthetic fun box-impl (Ljava/lang/String;)Lspace/kscience/kmath/expressions/StringSymbol; - public static fun constructor-impl (Ljava/lang/String;)Ljava/lang/String; - public fun equals (Ljava/lang/Object;)Z - public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z - public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z - public fun getIdentity ()Ljava/lang/String; - public fun hashCode ()I - public static fun hashCode-impl (Ljava/lang/String;)I - public fun toString ()Ljava/lang/String; - public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; - public final synthetic fun unbox-impl ()Ljava/lang/String; +public abstract interface class space/kscience/kmath/expressions/SpecialDifferentiableExpression : space/kscience/kmath/expressions/DifferentiableExpression { + public abstract fun derivativeOrNull (Ljava/util/List;)Lspace/kscience/kmath/expressions/Expression; +} + +public final class space/kscience/kmath/expressions/SpecialExpressionsKt { + public static final fun chiSquaredExpression (Lspace/kscience/kmath/expressions/AutoDiffProcessor;Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/expressions/DifferentiableExpression; + public static final fun genericChiSquaredExpression (Lspace/kscience/kmath/expressions/AutoDiffProcessor;Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/expressions/DifferentiableExpression; } public abstract interface class space/kscience/kmath/expressions/Symbol : space/kscience/kmath/expressions/MST { @@ -470,15 +476,19 @@ public abstract interface class space/kscience/kmath/expressions/Symbol : space/ } public final class space/kscience/kmath/expressions/Symbol$Companion { - public final fun getX-uKgCeAI ()Ljava/lang/String; - public final fun getY-uKgCeAI ()Ljava/lang/String; - public final fun getZ-uKgCeAI ()Ljava/lang/String; + public final fun getX ()Lspace/kscience/kmath/expressions/Symbol; + public final fun getXError ()Lspace/kscience/kmath/expressions/Symbol; + public final fun getY ()Lspace/kscience/kmath/expressions/Symbol; + public final fun getYError ()Lspace/kscience/kmath/expressions/Symbol; + public final fun getZ ()Lspace/kscience/kmath/expressions/Symbol; + public final fun getZError ()Lspace/kscience/kmath/expressions/Symbol; } public final class space/kscience/kmath/expressions/SymbolIndexerKt { } public final class space/kscience/kmath/expressions/SymbolKt { + public static final fun Symbol (Ljava/lang/String;)Lspace/kscience/kmath/expressions/Symbol; public static final fun get (Ljava/util/Map;Ljava/lang/String;)Ljava/lang/Object; public static final fun get (Ljava/util/Map;Lspace/kscience/kmath/expressions/Symbol;)Ljava/lang/Object; public static final fun getSymbol ()Lkotlin/properties/ReadOnlyProperty; @@ -487,7 +497,7 @@ public final class space/kscience/kmath/expressions/SymbolKt { } public final class space/kscience/kmath/linear/BufferedLinearSpace : space/kscience/kmath/linear/LinearSpace { - public fun (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V + public fun (Lspace/kscience/kmath/operations/BufferAlgebra;)V public fun buildMatrix (IILkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/Structure2D; public fun buildVector (ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/structures/Buffer; public fun dot (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; @@ -499,6 +509,10 @@ public final class space/kscience/kmath/linear/BufferedLinearSpace : space/kscie public fun unaryMinus (Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; } +public final class space/kscience/kmath/linear/BufferedLinearSpaceKt { + public static final fun linearSpace (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/linear/BufferedLinearSpace; +} + public abstract interface class space/kscience/kmath/linear/CholeskyDecompositionFeature : space/kscience/kmath/linear/MatrixFeature { public abstract fun getL ()Lspace/kscience/kmath/nd/Structure2D; } @@ -514,6 +528,36 @@ public abstract interface class space/kscience/kmath/linear/DiagonalFeature : sp public final class space/kscience/kmath/linear/DiagonalFeature$Companion : space/kscience/kmath/linear/DiagonalFeature { } +public final class space/kscience/kmath/linear/DoubleLinearSpace : space/kscience/kmath/linear/LinearSpace { + public static final field INSTANCE Lspace/kscience/kmath/linear/DoubleLinearSpace; + public fun buildMatrix (IILkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/Structure2D; + public synthetic fun buildVector (ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/structures/Buffer; + public fun buildVector-CZ9oacQ (ILkotlin/jvm/functions/Function2;)[D + public final fun div-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;D)[D + public fun dot (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; + public synthetic fun dot (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public fun dot-CZ9oacQ (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/structures/Buffer;)[D + public fun getElementAlgebra ()Lspace/kscience/kmath/operations/DoubleField; + public synthetic fun getElementAlgebra ()Lspace/kscience/kmath/operations/Ring; + public fun minus (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; + public synthetic fun minus (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public fun minus-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public fun plus (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; + public synthetic fun plus (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public fun plus-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun times (Ljava/lang/Object;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public fun times (Lspace/kscience/kmath/nd/Structure2D;D)Lspace/kscience/kmath/nd/Structure2D; + public synthetic fun times (Lspace/kscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lspace/kscience/kmath/nd/Structure2D; + public synthetic fun times (Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Object;)Lspace/kscience/kmath/structures/Buffer; + public fun times-CZ9oacQ (DLspace/kscience/kmath/structures/Buffer;)[D + public fun times-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;D)[D + public fun unaryMinus (Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; +} + +public final class space/kscience/kmath/linear/DoubleLinearSpaceKt { + public static final fun getLinearSpace (Lspace/kscience/kmath/operations/DoubleField;)Lspace/kscience/kmath/linear/DoubleLinearSpace; +} + public abstract interface class space/kscience/kmath/linear/InverseMatrixFeature : space/kscience/kmath/linear/MatrixFeature { public abstract fun getInverse ()Lspace/kscience/kmath/nd/Structure2D; } @@ -533,11 +577,6 @@ public abstract interface class space/kscience/kmath/linear/LinearSolver { public fun solve (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; } -public final class space/kscience/kmath/linear/LinearSolverKt { - public static final fun asMatrix (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/linear/VirtualMatrix; - public static final fun asVector (Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/structures/Buffer; -} - public abstract interface class space/kscience/kmath/linear/LinearSpace { public static final field Companion Lspace/kscience/kmath/linear/LinearSpace$Companion; public abstract fun buildMatrix (IILkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/Structure2D; @@ -560,10 +599,12 @@ public abstract interface class space/kscience/kmath/linear/LinearSpace { public final class space/kscience/kmath/linear/LinearSpace$Companion { public final fun buffered (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/linear/LinearSpace; public static synthetic fun buffered$default (Lspace/kscience/kmath/linear/LinearSpace$Companion;Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lspace/kscience/kmath/linear/LinearSpace; - public final fun getReal ()Lspace/kscience/kmath/linear/LinearSpace; + public final fun getDouble ()Lspace/kscience/kmath/linear/LinearSpace; } public final class space/kscience/kmath/linear/LinearSpaceKt { + public static final fun asMatrix (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/linear/VirtualMatrix; + public static final fun asVector (Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/structures/Buffer; public static final fun invoke (Lspace/kscience/kmath/linear/LinearSpace;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; } @@ -587,11 +628,12 @@ public abstract interface class space/kscience/kmath/linear/LupDecompositionFeat public final class space/kscience/kmath/linear/LupDecompositionKt { public static final fun abs (Lspace/kscience/kmath/linear/LinearSpace;Ljava/lang/Comparable;)Ljava/lang/Comparable; - public static final fun inverseWithLup (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; public static final fun lup (Lspace/kscience/kmath/linear/LinearSpace;Lkotlin/jvm/functions/Function2;Lspace/kscience/kmath/nd/Structure2D;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/linear/LupDecomposition; - public static final fun lup (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/linear/LupDecomposition; - public static final fun solveWithLup (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; - public static final fun solveWithLup (Lspace/kscience/kmath/linear/LupDecomposition;Lkotlin/jvm/functions/Function2;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; + public static final fun lup (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/Structure2D;D)Lspace/kscience/kmath/linear/LupDecomposition; + public static synthetic fun lup$default (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/Structure2D;DILjava/lang/Object;)Lspace/kscience/kmath/linear/LupDecomposition; + public static final fun lupSolver (Lspace/kscience/kmath/linear/LinearSpace;D)Lspace/kscience/kmath/linear/LinearSolver; + public static final fun lupSolver (Lspace/kscience/kmath/linear/LinearSpace;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/linear/LinearSolver; + public static synthetic fun lupSolver$default (Lspace/kscience/kmath/linear/LinearSpace;DILjava/lang/Object;)Lspace/kscience/kmath/linear/LinearSolver; } public final class space/kscience/kmath/linear/MatrixBuilder { @@ -607,6 +649,7 @@ public final class space/kscience/kmath/linear/MatrixBuilderKt { public static final fun column (Lspace/kscience/kmath/linear/LinearSpace;[Ljava/lang/Object;)Lspace/kscience/kmath/nd/Structure2D; public static final fun row (Lspace/kscience/kmath/linear/LinearSpace;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/Structure2D; public static final fun row (Lspace/kscience/kmath/linear/LinearSpace;[Ljava/lang/Object;)Lspace/kscience/kmath/nd/Structure2D; + public static final fun symmetric (Lspace/kscience/kmath/linear/MatrixBuilder;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/Structure2D; } public abstract interface class space/kscience/kmath/linear/MatrixFeature : space/kscience/kmath/nd/StructureFeature { @@ -623,7 +666,10 @@ public final class space/kscience/kmath/linear/MatrixWrapper : space/kscience/km public fun getColNum ()I public fun getColumns ()Ljava/util/List; public fun getDimension ()I - public final fun getFeatures ()Ljava/util/Set; + public synthetic fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun getFeature (Lkotlin/reflect/KClass;)Lspace/kscience/kmath/nd/StructureFeature; + public final fun getFeatures-En6fw3w ()Ljava/util/Map; + public fun getIndices ()Lspace/kscience/kmath/nd/ShapeIndexer; public final fun getOrigin ()Lspace/kscience/kmath/nd/Structure2D; public fun getRowNum ()I public fun getRows ()Ljava/util/List; @@ -634,9 +680,10 @@ public final class space/kscience/kmath/linear/MatrixWrapper : space/kscience/km public final class space/kscience/kmath/linear/MatrixWrapperKt { public static final fun getOrigin (Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; public static final fun one (Lspace/kscience/kmath/linear/LinearSpace;II)Lspace/kscience/kmath/nd/Structure2D; - public static final fun plus (Lspace/kscience/kmath/nd/Structure2D;Ljava/util/Collection;)Lspace/kscience/kmath/linear/MatrixWrapper; public static final fun plus (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/linear/MatrixFeature;)Lspace/kscience/kmath/linear/MatrixWrapper; public static final fun transpose (Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; + public static final fun withFeature (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/linear/MatrixFeature;)Lspace/kscience/kmath/linear/MatrixWrapper; + public static final fun withFeatures (Lspace/kscience/kmath/nd/Structure2D;Ljava/lang/Iterable;)Lspace/kscience/kmath/linear/MatrixWrapper; public static final fun zero (Lspace/kscience/kmath/linear/LinearSpace;II)Lspace/kscience/kmath/nd/Structure2D; } @@ -656,6 +703,10 @@ public abstract interface class space/kscience/kmath/linear/SingularValueDecompo public abstract fun getV ()Lspace/kscience/kmath/nd/Structure2D; } +public final class space/kscience/kmath/linear/SymmetricMatrixFeature : space/kscience/kmath/linear/MatrixFeature { + public static final field INSTANCE Lspace/kscience/kmath/linear/SymmetricMatrixFeature; +} + public final class space/kscience/kmath/linear/TransposedFeature : space/kscience/kmath/linear/MatrixFeature { public fun (Lspace/kscience/kmath/nd/Structure2D;)V public final fun getOriginal ()Lspace/kscience/kmath/nd/Structure2D; @@ -678,6 +729,10 @@ public final class space/kscience/kmath/linear/VirtualMatrix : space/kscience/km public fun getShape ()[I } +public final class space/kscience/kmath/linear/VirtualMatrixKt { + public static final fun virtual (Lspace/kscience/kmath/linear/MatrixBuilder;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/linear/VirtualMatrix; +} + public final class space/kscience/kmath/linear/ZeroFeature : space/kscience/kmath/linear/DiagonalFeature { public static final field INSTANCE Lspace/kscience/kmath/linear/ZeroFeature; } @@ -701,82 +756,164 @@ public final class space/kscience/kmath/misc/CumulativeKt { public static final fun cumulativeSumOfLong (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence; } +public abstract interface class space/kscience/kmath/misc/Feature { + public fun getKey ()Lkotlin/reflect/KClass; +} + +public final class space/kscience/kmath/misc/FeatureSet : space/kscience/kmath/misc/Featured { + public static final field Companion Lspace/kscience/kmath/misc/FeatureSet$Companion; + public static final synthetic fun box-impl (Ljava/util/Map;)Lspace/kscience/kmath/misc/FeatureSet; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/util/Map;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/util/Map;Ljava/util/Map;)Z + public synthetic fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun getFeature (Lkotlin/reflect/KClass;)Lspace/kscience/kmath/misc/Feature; + public static fun getFeature-impl (Ljava/util/Map;Lkotlin/reflect/KClass;)Lspace/kscience/kmath/misc/Feature; + public final fun getFeatures ()Ljava/util/Map; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/util/Map;)I + public static final fun iterator-impl (Ljava/util/Map;)Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/util/Map;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/util/Map; + public static final fun with-JVE9-Rk (Ljava/util/Map;Ljava/lang/Iterable;)Ljava/util/Map; + public static final fun with-JVE9-Rk (Ljava/util/Map;[Lspace/kscience/kmath/misc/Feature;)Ljava/util/Map; + public static final fun with-YU1a0hQ (Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map; + public static final fun with-h58Sd8I (Ljava/util/Map;Lspace/kscience/kmath/misc/Feature;Lkotlin/reflect/KClass;)Ljava/util/Map; + public static synthetic fun with-h58Sd8I$default (Ljava/util/Map;Lspace/kscience/kmath/misc/Feature;Lkotlin/reflect/KClass;ILjava/lang/Object;)Ljava/util/Map; +} + +public final class space/kscience/kmath/misc/FeatureSet$Companion { + public final fun of-JVE9-Rk (Ljava/lang/Iterable;)Ljava/util/Map; + public final fun of-JVE9-Rk ([Lspace/kscience/kmath/misc/Feature;)Ljava/util/Map; +} + +public abstract interface class space/kscience/kmath/misc/Featured { + public abstract fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; +} + +public abstract interface class space/kscience/kmath/misc/Loggable { + public static final field Companion Lspace/kscience/kmath/misc/Loggable$Companion; + public static final field INFO Ljava/lang/String; + public abstract fun log (Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V +} + +public final class space/kscience/kmath/misc/Loggable$Companion { + public static final field INFO Ljava/lang/String; + public final fun getConsole ()Lspace/kscience/kmath/misc/Loggable; +} + +public final class space/kscience/kmath/misc/LoggingKt { + public static final fun log (Lspace/kscience/kmath/misc/Loggable;Lkotlin/jvm/functions/Function0;)V +} + +public final class space/kscience/kmath/misc/NumbersJVMKt { + public static final fun toIntExact (J)I +} + public abstract interface annotation class space/kscience/kmath/misc/PerformancePitfall : java/lang/annotation/Annotation { + public abstract fun message ()Ljava/lang/String; +} + +public final class space/kscience/kmath/misc/SortingKt { + public static final fun requireSorted (Lspace/kscience/kmath/structures/Buffer;)V + public static final fun sorted (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun sortedBy (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; + public static final fun sortedByDescending (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; + public static final fun sortedDescending (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; } public abstract interface annotation class space/kscience/kmath/misc/UnstableKMathAPI : java/lang/annotation/Annotation { } -public abstract interface class space/kscience/kmath/nd/AlgebraND { +public abstract interface class space/kscience/kmath/nd/AlgebraND : space/kscience/kmath/operations/Algebra { public static final field Companion Lspace/kscience/kmath/nd/AlgebraND$Companion; - public abstract fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; - public abstract fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; - public abstract fun getShape ()[I + public abstract fun getElementAlgebra ()Lspace/kscience/kmath/operations/Algebra; public fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; - public abstract fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; - public abstract fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; - public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; } public final class space/kscience/kmath/nd/AlgebraND$Companion { } +public final class space/kscience/kmath/nd/AlgebraNDExtentionsKt { + public static final fun one (Lspace/kscience/kmath/nd/AlgebraND;[I)Lspace/kscience/kmath/nd/StructureND; + public static final fun oneVarArg (Lspace/kscience/kmath/nd/AlgebraND;I[I)Lspace/kscience/kmath/nd/StructureND; + public static final fun structureND (Lspace/kscience/kmath/nd/AlgebraND;I[ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public static final fun zero (Lspace/kscience/kmath/nd/AlgebraND;[I)Lspace/kscience/kmath/nd/StructureND; + public static final fun zeroVarArg (Lspace/kscience/kmath/nd/AlgebraND;I[I)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/AlgebraNDKt { + public static final fun Shape (I[I)[I +} + public abstract interface class space/kscience/kmath/nd/BufferAlgebraND : space/kscience/kmath/nd/AlgebraND { - public fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; - public fun getBuffer (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/structures/Buffer; - public abstract fun getBufferFactory ()Lkotlin/jvm/functions/Function2; - public abstract fun getStrides ()Lspace/kscience/kmath/nd/Strides; + public static final field Companion Lspace/kscience/kmath/nd/BufferAlgebraND$Companion; + public abstract fun getBufferAlgebra ()Lspace/kscience/kmath/operations/BufferAlgebra; + public fun getElementAlgebra ()Lspace/kscience/kmath/operations/Algebra; + public abstract fun getIndexerBuilder ()Lkotlin/jvm/functions/Function1; public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/BufferND; public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; - public fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; + public synthetic fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun toBufferND (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/BufferND; + public synthetic fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/BufferAlgebraND$Companion { + public final fun getDefaultIndexerBuilder ()Lkotlin/jvm/functions/Function1; } public final class space/kscience/kmath/nd/BufferAlgebraNDKt { - public static final fun field (Lspace/kscience/kmath/nd/AlgebraND$Companion;Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedFieldND; - public static final fun group (Lspace/kscience/kmath/nd/AlgebraND$Companion;Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedGroupND; - public static final fun ndField (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun ndGroup (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun ndRing (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun ring (Lspace/kscience/kmath/nd/AlgebraND$Companion;Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedRingND; + public static final fun getNd (Lspace/kscience/kmath/operations/BufferAlgebra;)Lspace/kscience/kmath/nd/BufferedFieldOpsND; + public static final fun getNd (Lspace/kscience/kmath/operations/BufferAlgebra;)Lspace/kscience/kmath/nd/BufferedGroupNDOps; + public static final fun getNd (Lspace/kscience/kmath/operations/BufferAlgebra;)Lspace/kscience/kmath/nd/BufferedRingOpsND; + public static final fun mapInline (Lspace/kscience/kmath/nd/BufferAlgebraND;Lspace/kscience/kmath/nd/BufferND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; + public static final fun structureND (Lspace/kscience/kmath/nd/BufferAlgebraND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; + public static final fun structureND (Lspace/kscience/kmath/nd/BufferAlgebraND;[ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; } public class space/kscience/kmath/nd/BufferND : space/kscience/kmath/nd/StructureND { - public fun (Lspace/kscience/kmath/nd/Strides;Lspace/kscience/kmath/structures/Buffer;)V - public fun elements ()Lkotlin/sequences/Sequence; + public fun (Lspace/kscience/kmath/nd/ShapeIndexer;Lspace/kscience/kmath/structures/Buffer;)V public fun get ([I)Ljava/lang/Object; - public final fun getBuffer ()Lspace/kscience/kmath/structures/Buffer; + public fun getBuffer ()Lspace/kscience/kmath/structures/Buffer; + public fun getIndices ()Lspace/kscience/kmath/nd/ShapeIndexer; public fun getShape ()[I - public final fun getStrides ()Lspace/kscience/kmath/nd/Strides; public fun toString ()Ljava/lang/String; } -public class space/kscience/kmath/nd/BufferedFieldND : space/kscience/kmath/nd/BufferedRingND, space/kscience/kmath/nd/FieldND { - public fun ([ILspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;)V +public final class space/kscience/kmath/nd/BufferNDKt { + public static final fun mapToBuffer (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/BufferND; +} + +public class space/kscience/kmath/nd/BufferedFieldOpsND : space/kscience/kmath/nd/BufferedRingOpsND, space/kscience/kmath/nd/FieldOpsND { + public fun (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;)V + public synthetic fun (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)V + public synthetic fun (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; } -public class space/kscience/kmath/nd/BufferedGroupND : space/kscience/kmath/nd/BufferAlgebraND, space/kscience/kmath/nd/GroupND { - public fun ([ILspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;)V - public final fun getBufferFactory ()Lkotlin/jvm/functions/Function2; - public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; - public final fun getElementContext ()Lspace/kscience/kmath/operations/Group; - public final fun getShape ()[I - public fun getStrides ()Lspace/kscience/kmath/nd/Strides; - public synthetic fun getZero ()Ljava/lang/Object; - public fun getZero ()Lspace/kscience/kmath/nd/BufferND; +public class space/kscience/kmath/nd/BufferedGroupNDOps : space/kscience/kmath/nd/BufferAlgebraND, space/kscience/kmath/nd/GroupOpsND { + public fun (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;)V + public synthetic fun (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun getBufferAlgebra ()Lspace/kscience/kmath/operations/BufferAlgebra; + public fun getIndexerBuilder ()Lkotlin/jvm/functions/Function1; public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; } -public class space/kscience/kmath/nd/BufferedRingND : space/kscience/kmath/nd/BufferedGroupND, space/kscience/kmath/nd/RingND { - public fun ([ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/nd/BufferND; +public class space/kscience/kmath/nd/BufferedRingOpsND : space/kscience/kmath/nd/BufferedGroupNDOps, space/kscience/kmath/nd/RingOpsND { + public fun (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;)V + public synthetic fun (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V } public final class space/kscience/kmath/nd/DefaultStrides : space/kscience/kmath/nd/Strides { @@ -794,72 +931,151 @@ public final class space/kscience/kmath/nd/DefaultStrides$Companion { public final fun invoke ([I)Lspace/kscience/kmath/nd/Strides; } -public final class space/kscience/kmath/nd/DoubleFieldND : space/kscience/kmath/nd/BufferedFieldND, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { +public final class space/kscience/kmath/nd/DoubleBufferND : space/kscience/kmath/nd/BufferND { + public synthetic fun (Lspace/kscience/kmath/nd/ShapeIndexer;[DLkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun getBuffer ()Lspace/kscience/kmath/structures/Buffer; + public fun getBuffer-Dv3HvWU ()[D +} + +public final class space/kscience/kmath/nd/DoubleFieldND : space/kscience/kmath/nd/DoubleFieldOpsND, space/kscience/kmath/nd/FieldND, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOps { public fun ([I)V - public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; - public fun acos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; - public fun asin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; - public fun atan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; - public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; - public fun cos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; - public fun exp (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun getBuffer (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/structures/Buffer; - public fun getBuffer-Udx-57Q (Lspace/kscience/kmath/nd/StructureND;)[D - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/nd/BufferND; - public synthetic fun getZero ()Ljava/lang/Object; - public fun getZero ()Lspace/kscience/kmath/nd/BufferND; - public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; - public fun ln (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; - public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun getShape ()[I public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; - public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/BufferND; + public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun power (Ljava/lang/Object;I)Ljava/lang/Object; public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun power (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/BufferND; - public fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; - public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; - public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; - public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; - public fun sin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun power (Lspace/kscience/kmath/nd/StructureND;I)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun power (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun power-Qn1smSk (Ljava/lang/Object;I)Ljava/lang/Object; + public fun power-Qn1smSk (Lspace/kscience/kmath/nd/StructureND;I)Lspace/kscience/kmath/nd/DoubleBufferND; public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; - public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; - public fun tan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun tanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun tanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; } public final class space/kscience/kmath/nd/DoubleFieldNDKt { - public static final fun nd (Lspace/kscience/kmath/operations/DoubleField;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun real (Lspace/kscience/kmath/nd/AlgebraND$Companion;[I)Lspace/kscience/kmath/nd/DoubleFieldND; + public static final fun getNdAlgebra (Lspace/kscience/kmath/operations/DoubleField;)Lspace/kscience/kmath/nd/DoubleFieldOpsND; + public static final fun ndAlgebra (Lspace/kscience/kmath/operations/DoubleField;[I)Lspace/kscience/kmath/nd/DoubleFieldND; } -public abstract interface class space/kscience/kmath/nd/FieldND : space/kscience/kmath/nd/RingND, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/ScaleOperations { +public abstract class space/kscience/kmath/nd/DoubleFieldOpsND : space/kscience/kmath/nd/BufferedFieldOpsND, space/kscience/kmath/operations/ExtendedFieldOps, space/kscience/kmath/operations/ScaleOperations { + public static final field Companion Lspace/kscience/kmath/nd/DoubleFieldOpsND$Companion; + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun div (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; + public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + protected final fun mapInline (Lspace/kscience/kmath/nd/DoubleBufferND;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun minus (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun minus (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun minus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun plus (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun plus (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun plus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; + public fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun times (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun toBufferND (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/BufferND; + public fun toBufferND (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public synthetic fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/DoubleBufferND; + public fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/BufferND; + public synthetic fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/DoubleFieldOpsND$Companion : space/kscience/kmath/nd/DoubleFieldOpsND { +} + +public abstract interface class space/kscience/kmath/nd/FieldND : space/kscience/kmath/nd/FieldOpsND, space/kscience/kmath/nd/RingND, space/kscience/kmath/nd/WithShape, space/kscience/kmath/operations/Field { + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lspace/kscience/kmath/nd/StructureND; +} + +public abstract interface class space/kscience/kmath/nd/FieldOpsND : space/kscience/kmath/nd/RingOpsND, space/kscience/kmath/operations/FieldOps, space/kscience/kmath/operations/ScaleOperations { public fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; } -public abstract interface class space/kscience/kmath/nd/GroupND : space/kscience/kmath/nd/AlgebraND, space/kscience/kmath/operations/Group { - public static final field Companion Lspace/kscience/kmath/nd/GroupND$Companion; +public abstract interface class space/kscience/kmath/nd/GroupND : space/kscience/kmath/nd/GroupOpsND, space/kscience/kmath/nd/WithShape, space/kscience/kmath/operations/Group { + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lspace/kscience/kmath/nd/StructureND; +} + +public abstract interface class space/kscience/kmath/nd/GroupOpsND : space/kscience/kmath/nd/AlgebraND, space/kscience/kmath/operations/GroupOps { + public static final field Companion Lspace/kscience/kmath/nd/GroupOpsND$Companion; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; @@ -868,12 +1084,13 @@ public abstract interface class space/kscience/kmath/nd/GroupND : space/kscience public fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; } -public final class space/kscience/kmath/nd/GroupND$Companion { +public final class space/kscience/kmath/nd/GroupOpsND$Companion { } public final class space/kscience/kmath/nd/MutableBufferND : space/kscience/kmath/nd/BufferND, space/kscience/kmath/nd/MutableStructureND { - public fun (Lspace/kscience/kmath/nd/Strides;Lspace/kscience/kmath/structures/MutableBuffer;)V - public final fun getMutableBuffer ()Lspace/kscience/kmath/structures/MutableBuffer; + public fun (Lspace/kscience/kmath/nd/ShapeIndexer;Lspace/kscience/kmath/structures/MutableBuffer;)V + public synthetic fun getBuffer ()Lspace/kscience/kmath/structures/Buffer; + public fun getBuffer ()Lspace/kscience/kmath/structures/MutableBuffer; public fun set ([ILjava/lang/Object;)V } @@ -891,15 +1108,31 @@ public abstract interface class space/kscience/kmath/nd/MutableStructureND : spa public abstract fun set ([ILjava/lang/Object;)V } -public abstract interface class space/kscience/kmath/nd/RingND : space/kscience/kmath/nd/GroupND, space/kscience/kmath/operations/Ring { - public static final field Companion Lspace/kscience/kmath/nd/RingND$Companion; +public abstract interface class space/kscience/kmath/nd/RingND : space/kscience/kmath/nd/GroupND, space/kscience/kmath/nd/RingOpsND, space/kscience/kmath/nd/WithShape, space/kscience/kmath/operations/Ring { + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lspace/kscience/kmath/nd/StructureND; +} + +public abstract interface class space/kscience/kmath/nd/RingOpsND : space/kscience/kmath/nd/GroupOpsND, space/kscience/kmath/operations/RingOps { + public static final field Companion Lspace/kscience/kmath/nd/RingOpsND$Companion; public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; } -public final class space/kscience/kmath/nd/RingND$Companion { +public final class space/kscience/kmath/nd/RingOpsND$Companion { +} + +public abstract interface class space/kscience/kmath/nd/ShapeIndexer : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker { + public abstract fun asSequence ()Lkotlin/sequences/Sequence; + public abstract fun equals (Ljava/lang/Object;)Z + public abstract fun getLinearSize ()I + public abstract fun getShape ()[I + public abstract fun hashCode ()I + public abstract fun index (I)[I + public fun iterator ()Ljava/util/Iterator; + public abstract fun offset ([I)I } public final class space/kscience/kmath/nd/ShapeMismatchException : java/lang/RuntimeException { @@ -908,27 +1141,28 @@ public final class space/kscience/kmath/nd/ShapeMismatchException : java/lang/Ru public final fun getExpected ()[I } -public final class space/kscience/kmath/nd/ShortRingND : space/kscience/kmath/nd/BufferedRingND, space/kscience/kmath/operations/NumbersAddOperations { +public final class space/kscience/kmath/nd/ShortRingND : space/kscience/kmath/nd/ShortRingOpsND, space/kscience/kmath/nd/RingND, space/kscience/kmath/operations/NumbersAddOps { public fun ([I)V - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/nd/BufferND; - public synthetic fun getZero ()Ljava/lang/Object; - public fun getZero ()Lspace/kscience/kmath/nd/BufferND; + public fun getShape ()[I public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/BufferND; } public final class space/kscience/kmath/nd/ShortRingNDKt { - public static final fun nd (Lspace/kscience/kmath/operations/ShortRing;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun produceInline (Lspace/kscience/kmath/nd/BufferedRingND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/BufferND; + public static final fun withNdAlgebra (Lspace/kscience/kmath/operations/ShortRing;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/nd/Strides { - public abstract fun getLinearSize ()I - public abstract fun getShape ()[I +public abstract class space/kscience/kmath/nd/ShortRingOpsND : space/kscience/kmath/nd/BufferedRingOpsND { + public static final field Companion Lspace/kscience/kmath/nd/ShortRingOpsND$Companion; +} + +public final class space/kscience/kmath/nd/ShortRingOpsND$Companion : space/kscience/kmath/nd/ShortRingOpsND { +} + +public abstract class space/kscience/kmath/nd/Strides : space/kscience/kmath/nd/ShapeIndexer { + public fun ()V + public fun asSequence ()Lkotlin/sequences/Sequence; public abstract fun getStrides ()[I - public abstract fun index (I)[I - public fun indices ()Lkotlin/sequences/Sequence; public fun offset ([I)I } @@ -968,14 +1202,16 @@ public final class space/kscience/kmath/nd/Structure2DKt { public static final fun as2D (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/Structure2D; } -public abstract interface class space/kscience/kmath/nd/StructureFeature { +public abstract interface class space/kscience/kmath/nd/StructureFeature : space/kscience/kmath/misc/Feature { } -public abstract interface class space/kscience/kmath/nd/StructureND { +public abstract interface class space/kscience/kmath/nd/StructureND : space/kscience/kmath/misc/Featured, space/kscience/kmath/nd/WithShape { public static final field Companion Lspace/kscience/kmath/nd/StructureND$Companion; - public abstract fun elements ()Lkotlin/sequences/Sequence; + public fun elements ()Lkotlin/sequences/Sequence; public abstract fun get ([I)Ljava/lang/Object; public fun getDimension ()I + public synthetic fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun getFeature (Lkotlin/reflect/KClass;)Lspace/kscience/kmath/nd/StructureFeature; public abstract fun getShape ()[I } @@ -987,14 +1223,25 @@ public final class space/kscience/kmath/nd/StructureND$Companion { public static synthetic fun buffered$default (Lspace/kscience/kmath/nd/StructureND$Companion;Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/kmath/nd/BufferND; public static synthetic fun buffered$default (Lspace/kscience/kmath/nd/StructureND$Companion;[ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/kmath/nd/BufferND; public final fun contentEquals (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Z + public final fun contentEquals (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;D)Z + public static synthetic fun contentEquals$default (Lspace/kscience/kmath/nd/StructureND$Companion;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;DILjava/lang/Object;)Z public final fun toString (Lspace/kscience/kmath/nd/StructureND;)Ljava/lang/String; } public final class space/kscience/kmath/nd/StructureNDKt { + public static final fun contentEquals (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Z + public static final fun contentEquals (Lspace/kscience/kmath/linear/LinearSpace;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Comparable;)Z + public static final fun contentEquals (Lspace/kscience/kmath/nd/AlgebraND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Z + public static final fun contentEquals (Lspace/kscience/kmath/nd/GroupOpsND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Comparable;)Z public static final fun get (Lspace/kscience/kmath/nd/StructureND;[I)Ljava/lang/Object; public static final fun mapInPlace (Lspace/kscience/kmath/nd/MutableStructureND;Lkotlin/jvm/functions/Function2;)V } +public abstract interface class space/kscience/kmath/nd/WithShape { + public fun getIndices ()Lspace/kscience/kmath/nd/ShapeIndexer; + public abstract fun getShape ()[I +} + public abstract interface class space/kscience/kmath/operations/Algebra { public fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; @@ -1004,21 +1251,16 @@ public abstract interface class space/kscience/kmath/operations/Algebra { public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } -public final class space/kscience/kmath/operations/AlgebraElementsKt { -} - public final class space/kscience/kmath/operations/AlgebraExtensionsKt { - public static final fun abs (Lspace/kscience/kmath/operations/Ring;Ljava/lang/Comparable;)Ljava/lang/Comparable; - public static final fun average (Lspace/kscience/kmath/operations/Ring;Ljava/lang/Iterable;)Ljava/lang/Object; - public static final fun average (Lspace/kscience/kmath/operations/Ring;Lkotlin/sequences/Sequence;)Ljava/lang/Object; - public static final fun averageWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Ring;)Ljava/lang/Object; - public static final fun averageWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Ring;)Ljava/lang/Object; - public static final fun power (Lspace/kscience/kmath/operations/Field;Ljava/lang/Object;I)Ljava/lang/Object; - public static final fun power-jXDDuk8 (Lspace/kscience/kmath/operations/Ring;Ljava/lang/Object;I)Ljava/lang/Object; - public static final fun sum (Lspace/kscience/kmath/operations/Ring;Ljava/lang/Iterable;)Ljava/lang/Object; - public static final fun sum (Lspace/kscience/kmath/operations/Ring;Lkotlin/sequences/Sequence;)Ljava/lang/Object; - public static final fun sumWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Ring;)Ljava/lang/Object; - public static final fun sumWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Ring;)Ljava/lang/Object; + public static final fun abs (Lspace/kscience/kmath/operations/Group;Ljava/lang/Comparable;)Ljava/lang/Comparable; + public static final fun average (Lspace/kscience/kmath/operations/Group;Ljava/lang/Iterable;)Ljava/lang/Object; + public static final fun average (Lspace/kscience/kmath/operations/Group;Lkotlin/sequences/Sequence;)Ljava/lang/Object; + public static final fun averageWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; + public static final fun averageWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; + public static final fun sum (Lspace/kscience/kmath/operations/Group;Ljava/lang/Iterable;)Ljava/lang/Object; + public static final fun sum (Lspace/kscience/kmath/operations/Group;Lkotlin/sequences/Sequence;)Ljava/lang/Object; + public static final fun sumWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; + public static final fun sumWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; } public final class space/kscience/kmath/operations/AlgebraKt { @@ -1061,7 +1303,7 @@ public final class space/kscience/kmath/operations/BigInt$Companion { public final fun getZERO ()Lspace/kscience/kmath/operations/BigInt; } -public final class space/kscience/kmath/operations/BigIntField : space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { +public final class space/kscience/kmath/operations/BigIntField : space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumbersAddOps, space/kscience/kmath/operations/ScaleOperations { public static final field INSTANCE Lspace/kscience/kmath/operations/BigIntField; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/operations/BigInt;Lspace/kscience/kmath/operations/BigInt;)Lspace/kscience/kmath/operations/BigInt; @@ -1085,9 +1327,12 @@ public final class space/kscience/kmath/operations/BigIntField : space/kscience/ public final class space/kscience/kmath/operations/BigIntKt { public static final fun abs (Lspace/kscience/kmath/operations/BigInt;)Lspace/kscience/kmath/operations/BigInt; - public static final fun bigInt (Lspace/kscience/kmath/nd/AlgebraND$Companion;[I)Lspace/kscience/kmath/nd/BufferedRingND; public static final fun bigInt (Lspace/kscience/kmath/structures/Buffer$Companion;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; public static final fun bigInt (Lspace/kscience/kmath/structures/MutableBuffer$Companion;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/MutableBuffer; + public static final fun buffer (Lspace/kscience/kmath/operations/BigInt$Companion;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; + public static final fun getAlgebra (Lspace/kscience/kmath/operations/BigInt;)Lspace/kscience/kmath/operations/BigIntField; + public static final fun getNd (Lspace/kscience/kmath/operations/BigIntField;)Lspace/kscience/kmath/nd/BufferedRingOpsND; + public static final fun mutableBuffer (Lspace/kscience/kmath/operations/BigInt;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; public static final fun parseBigInteger (Ljava/lang/String;)Lspace/kscience/kmath/operations/BigInt; public static final fun toBigInt (I)Lspace/kscience/kmath/operations/BigInt; public static final fun toBigInt (J)Lspace/kscience/kmath/operations/BigInt; @@ -1096,6 +1341,85 @@ public final class space/kscience/kmath/operations/BigIntKt { public static final fun toBigInt-WZ4Q5Ns (I)Lspace/kscience/kmath/operations/BigInt; } +public abstract interface class space/kscience/kmath/operations/BufferAlgebra : space/kscience/kmath/operations/Algebra { + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun buffer (I[Ljava/lang/Object;)Lspace/kscience/kmath/structures/Buffer; + public abstract fun getBufferFactory ()Lkotlin/jvm/functions/Function2; + public abstract fun getElementAlgebra ()Lspace/kscience/kmath/operations/Algebra; + public fun map (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/structures/Buffer; + public fun mapIndexed (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/structures/Buffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public fun zip (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/structures/Buffer; +} + +public final class space/kscience/kmath/operations/BufferAlgebraKt { + public static final fun acos (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun acosh (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun asin (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun asinh (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun atan (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun atanh (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun buffer (Lspace/kscience/kmath/operations/BufferAlgebra;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; + public static final fun buffer (Lspace/kscience/kmath/operations/BufferAlgebra;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; + public static final fun buffer (Lspace/kscience/kmath/operations/BufferField;[Ljava/lang/Number;)Lspace/kscience/kmath/structures/Buffer; + public static final fun bufferAlgebra (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/operations/BufferFieldOps; + public static final fun cos (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun cosh (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun exp (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun getBufferAlgebra (Lspace/kscience/kmath/operations/DoubleField;)Lspace/kscience/kmath/operations/BufferFieldOps; + public static final fun getBufferAlgebra (Lspace/kscience/kmath/operations/ShortRing;)Lspace/kscience/kmath/operations/BufferRingOps; + public static final fun ln (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun pow (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Number;)Lspace/kscience/kmath/structures/Buffer; + public static final fun sin (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun sinh (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun tan (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun tanh (Lspace/kscience/kmath/operations/BufferAlgebra;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun withSize (Lspace/kscience/kmath/operations/BufferFieldOps;I)Lspace/kscience/kmath/operations/BufferField; +} + +public final class space/kscience/kmath/operations/BufferField : space/kscience/kmath/operations/BufferFieldOps, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/WithSize { + public fun (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;I)V + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lspace/kscience/kmath/structures/Buffer; + public fun getSize ()I + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lspace/kscience/kmath/structures/Buffer; +} + +public class space/kscience/kmath/operations/BufferFieldOps : space/kscience/kmath/operations/BufferRingOps, space/kscience/kmath/operations/BufferAlgebra, space/kscience/kmath/operations/FieldOps, space/kscience/kmath/operations/ScaleOperations { + public fun (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;)V + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public fun scale (Lspace/kscience/kmath/structures/Buffer;D)Lspace/kscience/kmath/structures/Buffer; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; +} + +public final class space/kscience/kmath/operations/BufferOperationKt { + public static final fun asIterable (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/Iterable; + public static final fun asSequence (Lspace/kscience/kmath/structures/Buffer;)Lkotlin/sequences/Sequence; + public static final fun fold (Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; + public static final fun map (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; + public static final fun toList (Lspace/kscience/kmath/structures/Buffer;)Ljava/util/List; +} + +public class space/kscience/kmath/operations/BufferRingOps : space/kscience/kmath/operations/BufferAlgebra, space/kscience/kmath/operations/RingOps { + public fun (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun getBufferFactory ()Lkotlin/jvm/functions/Function2; + public synthetic fun getElementAlgebra ()Lspace/kscience/kmath/operations/Algebra; + public fun getElementAlgebra ()Lspace/kscience/kmath/operations/Ring; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + public final class space/kscience/kmath/operations/ByteRing : space/kscience/kmath/operations/Norm, space/kscience/kmath/operations/NumericAlgebra, space/kscience/kmath/operations/Ring { public static final field INSTANCE Lspace/kscience/kmath/operations/ByteRing; public fun add (BB)Ljava/lang/Byte; @@ -1120,6 +1444,90 @@ public final class space/kscience/kmath/operations/ByteRing : space/kscience/kma public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; } +public final class space/kscience/kmath/operations/DoubleBufferField : space/kscience/kmath/operations/DoubleBufferOps, space/kscience/kmath/operations/ExtendedField { + public fun (I)V + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lspace/kscience/kmath/structures/Buffer; + public final fun getSize ()I + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lspace/kscience/kmath/structures/Buffer; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Number;)[D + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public abstract class space/kscience/kmath/operations/DoubleBufferOps : space/kscience/kmath/operations/BufferAlgebra, space/kscience/kmath/operations/ExtendedFieldOps, space/kscience/kmath/operations/Norm { + public static final field Companion Lspace/kscience/kmath/operations/DoubleBufferOps$Companion; + public fun ()V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public fun getBufferFactory ()Lkotlin/jvm/functions/Function2; + public synthetic fun getElementAlgebra ()Lspace/kscience/kmath/operations/Algebra; + public fun getElementAlgebra ()Lspace/kscience/kmath/operations/DoubleField; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun map (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/structures/Buffer; + public fun map-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;)[D + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/Double; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public fun scale-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;D)[D + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class space/kscience/kmath/operations/DoubleBufferOps$Companion : space/kscience/kmath/operations/DoubleBufferOps { + public final fun mapInline-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function1;)[D +} + public final class space/kscience/kmath/operations/DoubleField : space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/Norm, space/kscience/kmath/operations/ScaleOperations { public static final field INSTANCE Lspace/kscience/kmath/operations/DoubleField; public fun acos (D)Ljava/lang/Double; @@ -1171,6 +1579,8 @@ public final class space/kscience/kmath/operations/DoubleField : space/kscience/ public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; public fun sinh (D)Ljava/lang/Double; public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (D)Ljava/lang/Double; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; public fun tan (D)Ljava/lang/Double; public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; public fun tanh (D)Ljava/lang/Double; @@ -1181,6 +1591,12 @@ public final class space/kscience/kmath/operations/DoubleField : space/kscience/ public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; } +public final class space/kscience/kmath/operations/DoubleL2Norm : space/kscience/kmath/operations/Norm { + public static final field INSTANCE Lspace/kscience/kmath/operations/DoubleL2Norm; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/Double; +} + public abstract interface class space/kscience/kmath/operations/ExponentialOperations : space/kscience/kmath/operations/Algebra { public static final field ACOSH_OPERATION Ljava/lang/String; public static final field ASINH_OPERATION Ljava/lang/String; @@ -1212,7 +1628,7 @@ public final class space/kscience/kmath/operations/ExponentialOperations$Compani public static final field TANH_OPERATION Ljava/lang/String; } -public abstract interface class space/kscience/kmath/operations/ExtendedField : space/kscience/kmath/operations/ExtendedFieldOperations, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumericAlgebra, space/kscience/kmath/operations/ScaleOperations { +public abstract interface class space/kscience/kmath/operations/ExtendedField : space/kscience/kmath/operations/ExtendedFieldOps, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/NumericAlgebra, space/kscience/kmath/operations/PowerOperations { public fun acosh (Ljava/lang/Object;)Ljava/lang/Object; public fun asinh (Ljava/lang/Object;)Ljava/lang/Object; public fun atanh (Ljava/lang/Object;)Ljava/lang/Object; @@ -1220,27 +1636,33 @@ public abstract interface class space/kscience/kmath/operations/ExtendedField : public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public fun sinh (Ljava/lang/Object;)Ljava/lang/Object; public fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } -public abstract interface class space/kscience/kmath/operations/ExtendedFieldOperations : space/kscience/kmath/operations/ExponentialOperations, space/kscience/kmath/operations/FieldOperations, space/kscience/kmath/operations/PowerOperations, space/kscience/kmath/operations/TrigonometricOperations { +public abstract interface class space/kscience/kmath/operations/ExtendedFieldOps : space/kscience/kmath/operations/ExponentialOperations, space/kscience/kmath/operations/FieldOps, space/kscience/kmath/operations/ScaleOperations, space/kscience/kmath/operations/TrigonometricOperations { public fun tan (Ljava/lang/Object;)Ljava/lang/Object; public fun tanh (Ljava/lang/Object;)Ljava/lang/Object; public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } -public abstract interface class space/kscience/kmath/operations/Field : space/kscience/kmath/operations/FieldOperations, space/kscience/kmath/operations/NumericAlgebra, space/kscience/kmath/operations/Ring, space/kscience/kmath/operations/ScaleOperations { +public abstract interface class space/kscience/kmath/operations/Field : space/kscience/kmath/operations/FieldOps, space/kscience/kmath/operations/NumericAlgebra, space/kscience/kmath/operations/Ring, space/kscience/kmath/operations/ScaleOperations { + public static final field Companion Lspace/kscience/kmath/operations/Field$Companion; public fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Ljava/lang/Object;I)Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/operations/FieldOperations : space/kscience/kmath/operations/RingOperations { - public static final field Companion Lspace/kscience/kmath/operations/FieldOperations$Companion; +public final class space/kscience/kmath/operations/Field$Companion { +} + +public abstract interface class space/kscience/kmath/operations/FieldOps : space/kscience/kmath/operations/RingOps { + public static final field Companion Lspace/kscience/kmath/operations/FieldOps$Companion; public static final field DIV_OPERATION Ljava/lang/String; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public abstract fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; } -public final class space/kscience/kmath/operations/FieldOperations$Companion { +public final class space/kscience/kmath/operations/FieldOps$Companion { public static final field DIV_OPERATION Ljava/lang/String; } @@ -1295,6 +1717,8 @@ public final class space/kscience/kmath/operations/FloatField : space/kscience/k public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; public fun sinh (F)Ljava/lang/Float; public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (F)Ljava/lang/Float; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; public fun tan (F)Ljava/lang/Float; public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; public fun tanh (F)Ljava/lang/Float; @@ -1305,12 +1729,12 @@ public final class space/kscience/kmath/operations/FloatField : space/kscience/k public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/operations/Group : space/kscience/kmath/operations/GroupOperations { +public abstract interface class space/kscience/kmath/operations/Group : space/kscience/kmath/operations/GroupOps { public abstract fun getZero ()Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/operations/GroupOperations : space/kscience/kmath/operations/Algebra { - public static final field Companion Lspace/kscience/kmath/operations/GroupOperations$Companion; +public abstract interface class space/kscience/kmath/operations/GroupOps : space/kscience/kmath/operations/Algebra { + public static final field Companion Lspace/kscience/kmath/operations/GroupOps$Companion; public static final field MINUS_OPERATION Ljava/lang/String; public static final field PLUS_OPERATION Ljava/lang/String; public abstract fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; @@ -1322,7 +1746,7 @@ public abstract interface class space/kscience/kmath/operations/GroupOperations public fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; } -public final class space/kscience/kmath/operations/GroupOperations$Companion { +public final class space/kscience/kmath/operations/GroupOps$Companion { public static final field MINUS_OPERATION Ljava/lang/String; public static final field PLUS_OPERATION Ljava/lang/String; } @@ -1351,6 +1775,10 @@ public final class space/kscience/kmath/operations/IntRing : space/kscience/kmat public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; } +public final class space/kscience/kmath/operations/IsIntegerKt { + public static final fun isInteger (Ljava/lang/Number;)Z +} + public final class space/kscience/kmath/operations/JBigDecimalField : space/kscience/kmath/operations/JBigDecimalFieldBase { public static final field Companion Lspace/kscience/kmath/operations/JBigDecimalField$Companion; public fun ()V @@ -1441,6 +1869,15 @@ public abstract interface class space/kscience/kmath/operations/Norm { public abstract fun norm (Ljava/lang/Object;)Ljava/lang/Object; } +public final class space/kscience/kmath/operations/NumbersKt { + public static final fun getAlgebra (Lkotlin/jvm/internal/ByteCompanionObject;)Lspace/kscience/kmath/operations/ByteRing; + public static final fun getAlgebra (Lkotlin/jvm/internal/DoubleCompanionObject;)Lspace/kscience/kmath/operations/DoubleField; + public static final fun getAlgebra (Lkotlin/jvm/internal/FloatCompanionObject;)Lspace/kscience/kmath/operations/FloatField; + public static final fun getAlgebra (Lkotlin/jvm/internal/IntCompanionObject;)Lspace/kscience/kmath/operations/IntRing; + public static final fun getAlgebra (Lkotlin/jvm/internal/LongCompanionObject;)Lspace/kscience/kmath/operations/LongRing; + public static final fun getAlgebra (Lkotlin/jvm/internal/ShortCompanionObject;)Lspace/kscience/kmath/operations/ShortRing; +} + public abstract interface class space/kscience/kmath/operations/NumericAlgebra : space/kscience/kmath/operations/Algebra { public fun bindSymbolOrNull (Ljava/lang/String;)Ljava/lang/Object; public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; @@ -1455,10 +1892,7 @@ public final class space/kscience/kmath/operations/NumericAlgebraKt { public static final fun getPi (Lspace/kscience/kmath/operations/NumericAlgebra;)Ljava/lang/Object; } -public final class space/kscience/kmath/operations/OptionalOperationsKt { -} - -public abstract interface class space/kscience/kmath/operations/PowerOperations : space/kscience/kmath/operations/Algebra { +public abstract interface class space/kscience/kmath/operations/PowerOperations : space/kscience/kmath/operations/FieldOps { public static final field Companion Lspace/kscience/kmath/operations/PowerOperations$Companion; public static final field POW_OPERATION Ljava/lang/String; public static final field SQRT_OPERATION Ljava/lang/String; @@ -1472,19 +1906,24 @@ public final class space/kscience/kmath/operations/PowerOperations$Companion { public static final field SQRT_OPERATION Ljava/lang/String; } -public abstract interface class space/kscience/kmath/operations/Ring : space/kscience/kmath/operations/Group, space/kscience/kmath/operations/RingOperations { +public abstract interface class space/kscience/kmath/operations/Ring : space/kscience/kmath/operations/Group, space/kscience/kmath/operations/RingOps { + public static final field Companion Lspace/kscience/kmath/operations/Ring$Companion; public abstract fun getOne ()Ljava/lang/Object; + public fun power-Qn1smSk (Ljava/lang/Object;I)Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/operations/RingOperations : space/kscience/kmath/operations/GroupOperations { - public static final field Companion Lspace/kscience/kmath/operations/RingOperations$Companion; +public final class space/kscience/kmath/operations/Ring$Companion { +} + +public abstract interface class space/kscience/kmath/operations/RingOps : space/kscience/kmath/operations/GroupOps { + public static final field Companion Lspace/kscience/kmath/operations/RingOps$Companion; public static final field TIMES_OPERATION Ljava/lang/String; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public abstract fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; } -public final class space/kscience/kmath/operations/RingOperations$Companion { +public final class space/kscience/kmath/operations/RingOps$Companion { public static final field TIMES_OPERATION Ljava/lang/String; } @@ -1544,6 +1983,10 @@ public final class space/kscience/kmath/operations/TrigonometricOperations$Compa public static final field TAN_OPERATION Ljava/lang/String; } +public abstract interface class space/kscience/kmath/operations/WithSize { + public abstract fun getSize ()I +} + public final class space/kscience/kmath/structures/ArrayBuffer : space/kscience/kmath/structures/MutableBuffer { public fun ([Ljava/lang/Object;)V public fun copy ()Lspace/kscience/kmath/structures/MutableBuffer; @@ -1551,6 +1994,11 @@ public final class space/kscience/kmath/structures/ArrayBuffer : space/kscience/ public fun getSize ()I public fun iterator ()Ljava/util/Iterator; public fun set (ILjava/lang/Object;)V + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/kmath/structures/ArrayBufferKt { + public static final fun asBuffer ([Ljava/lang/Object;)Lspace/kscience/kmath/structures/ArrayBuffer; } public abstract interface class space/kscience/kmath/structures/Buffer { @@ -1558,31 +2006,25 @@ public abstract interface class space/kscience/kmath/structures/Buffer { public abstract fun get (I)Ljava/lang/Object; public abstract fun getSize ()I public abstract fun iterator ()Ljava/util/Iterator; + public abstract fun toString ()Ljava/lang/String; } public final class space/kscience/kmath/structures/Buffer$Companion { public final fun auto (Lkotlin/reflect/KClass;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; public final fun boxing (ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; public final fun contentEquals (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Z + public final fun toString (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/String; } public final class space/kscience/kmath/structures/BufferKt { - public static final fun asBuffer (Ljava/util/List;)Lspace/kscience/kmath/structures/ListBuffer; - public static final fun asBuffer ([Ljava/lang/Object;)Lspace/kscience/kmath/structures/ArrayBuffer; - public static final fun asMutableBuffer (Ljava/util/List;)Ljava/util/List; public static final fun asReadOnly (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; + public static final fun first (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/Object; public static final fun getIndices (Lspace/kscience/kmath/structures/Buffer;)Lkotlin/ranges/IntRange; -} - -public final class space/kscience/kmath/structures/BufferOperationKt { - public static final fun asIterable (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/Iterable; - public static final fun asSequence (Lspace/kscience/kmath/structures/Buffer;)Lkotlin/sequences/Sequence; - public static final fun fold (Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; - public static final fun map (Lspace/kscience/kmath/structures/Buffer;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; - public static final fun toList (Lspace/kscience/kmath/structures/Buffer;)Ljava/util/List; + public static final fun last (Lspace/kscience/kmath/structures/Buffer;)Ljava/lang/Object; } public final class space/kscience/kmath/structures/DoubleBuffer : space/kscience/kmath/structures/MutableBuffer { + public static final field Companion Lspace/kscience/kmath/structures/DoubleBuffer$Companion; public static final synthetic fun box-impl ([D)Lspace/kscience/kmath/structures/DoubleBuffer; public static fun constructor-impl ([D)[D public synthetic fun copy ()Lspace/kscience/kmath/structures/MutableBuffer; @@ -1610,97 +2052,8 @@ public final class space/kscience/kmath/structures/DoubleBuffer : space/kscience public final synthetic fun unbox-impl ()[D } -public final class space/kscience/kmath/structures/DoubleBufferField : space/kscience/kmath/operations/ExtendedField { - public fun (I)V - public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; - public fun acos-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun acosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun add-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; - public fun asin-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun asinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; - public fun atan-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun atanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; - public fun cos-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun cosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun divide-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; - public fun exp-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/structures/Buffer; - public final fun getSize ()I - public synthetic fun getZero ()Ljava/lang/Object; - public fun getZero ()Lspace/kscience/kmath/structures/Buffer; - public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; - public fun ln-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun multiply-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; - public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/structures/Buffer; - public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun power-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Number;)[D - public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; - public fun scale-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;D)[D - public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; - public fun sin-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun sinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; - public fun tan-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun tanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryMinus (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; -} - -public final class space/kscience/kmath/structures/DoubleBufferFieldOperations : space/kscience/kmath/operations/ExtendedFieldOperations { - public static final field INSTANCE Lspace/kscience/kmath/structures/DoubleBufferFieldOperations; - public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; - public fun acos-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun acosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun add-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; - public fun asin-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun asinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; - public fun atan-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun atanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; - public fun cos-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun cosh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun divide-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; - public fun exp-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; - public fun ln-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun multiply-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun power-CZ9oacQ (Lspace/kscience/kmath/structures/Buffer;Ljava/lang/Number;)[D - public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; - public fun sin-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun sinh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; - public fun tan-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun tanh-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D - public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryMinus-Udx-57Q (Lspace/kscience/kmath/structures/Buffer;)[D +public final class space/kscience/kmath/structures/DoubleBuffer$Companion { + public final fun zero-Udx-57Q (I)[D } public final class space/kscience/kmath/structures/DoubleBufferKt { @@ -1731,6 +2084,7 @@ public final class space/kscience/kmath/structures/FlaggedDoubleBuffer : space/k public fun getSize ()I public final fun getValues ()[D public fun iterator ()Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; } public final class space/kscience/kmath/structures/FloatBuffer : space/kscience/kmath/structures/MutableBuffer { @@ -1808,6 +2162,12 @@ public final class space/kscience/kmath/structures/ListBuffer : space/kscience/k public final fun getList ()Ljava/util/List; public fun getSize ()I public fun iterator ()Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; +} + +public final class space/kscience/kmath/structures/ListBufferKt { + public static final fun asBuffer (Ljava/util/List;)Lspace/kscience/kmath/structures/ListBuffer; + public static final fun asMutableBuffer (Ljava/util/List;)Ljava/util/List; } public final class space/kscience/kmath/structures/LongBuffer : space/kscience/kmath/structures/MutableBuffer { @@ -1852,6 +2212,7 @@ public class space/kscience/kmath/structures/MemoryBuffer : space/kscience/kmath public fun getSize ()I protected final fun getSpec ()Lspace/kscience/kmath/memory/MemorySpec; public fun iterator ()Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; } public final class space/kscience/kmath/structures/MemoryBuffer$Companion { @@ -1981,5 +2342,6 @@ public final class space/kscience/kmath/structures/VirtualBuffer : space/kscienc public fun get (I)Ljava/lang/Object; public fun getSize ()I public fun iterator ()Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; } diff --git a/kmath-coroutines/README.md b/kmath-coroutines/README.md index 0d83a6c60..d0fef6e0f 100644 --- a/kmath-coroutines/README.md +++ b/kmath-coroutines/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-coroutines:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-coroutines:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-coroutines:0.3.0-dev-20' + implementation 'space.kscience:kmath-coroutines:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-coroutines:0.3.0-dev-20") + implementation("space.kscience:kmath-coroutines:0.3.0") } ``` diff --git a/kmath-dimensions/README.md b/kmath-dimensions/README.md index 52097cf40..650bcafde 100644 --- a/kmath-dimensions/README.md +++ b/kmath-dimensions/README.md @@ -6,7 +6,7 @@ A proof of concept module for adding type-safe dimensions to structures ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-dimensions:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-dimensions:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-dimensions:0.3.0-dev-20' + implementation 'space.kscience:kmath-dimensions:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-dimensions:0.3.0-dev-20") + implementation("space.kscience:kmath-dimensions:0.3.0") } ``` diff --git a/kmath-ejml/README.md b/kmath-ejml/README.md index 3fe6d9e1a..eaa90120f 100644 --- a/kmath-ejml/README.md +++ b/kmath-ejml/README.md @@ -9,7 +9,7 @@ EJML based linear algebra implementation. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0`. **Gradle Groovy:** ```groovy @@ -19,7 +19,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-ejml:0.3.0-dev-20' + implementation 'space.kscience:kmath-ejml:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -30,6 +30,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-ejml:0.3.0-dev-20") + implementation("space.kscience:kmath-ejml:0.3.0") } ``` diff --git a/kmath-for-real/README.md b/kmath-for-real/README.md index 197190dcd..9e8f95a16 100644 --- a/kmath-for-real/README.md +++ b/kmath-for-real/README.md @@ -9,7 +9,7 @@ Specialization of KMath APIs for Double numbers. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0`. **Gradle Groovy:** ```groovy @@ -19,7 +19,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-for-real:0.3.0-dev-20' + implementation 'space.kscience:kmath-for-real:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -30,6 +30,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-for-real:0.3.0-dev-20") + implementation("space.kscience:kmath-for-real:0.3.0") } ``` diff --git a/kmath-functions/README.md b/kmath-functions/README.md index 6379ad0b5..3f44bd3f9 100644 --- a/kmath-functions/README.md +++ b/kmath-functions/README.md @@ -11,7 +11,7 @@ Functions and interpolations. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0`. **Gradle Groovy:** ```groovy @@ -21,7 +21,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-functions:0.3.0-dev-20' + implementation 'space.kscience:kmath-functions:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -32,6 +32,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-functions:0.3.0-dev-20") + implementation("space.kscience:kmath-functions:0.3.0") } ``` diff --git a/kmath-geometry/README.md b/kmath-geometry/README.md index 6b8fb25a0..6602f5510 100644 --- a/kmath-geometry/README.md +++ b/kmath-geometry/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-geometry:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-geometry:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-geometry:0.3.0-dev-20' + implementation 'space.kscience:kmath-geometry:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-geometry:0.3.0-dev-20") + implementation("space.kscience:kmath-geometry:0.3.0") } ``` diff --git a/kmath-histograms/README.md b/kmath-histograms/README.md index 0b8a632d6..27f1b43ec 100644 --- a/kmath-histograms/README.md +++ b/kmath-histograms/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-histograms:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-histograms:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-histograms:0.3.0-dev-20' + implementation 'space.kscience:kmath-histograms:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-histograms:0.3.0-dev-20") + implementation("space.kscience:kmath-histograms:0.3.0") } ``` diff --git a/kmath-jafama/README.md b/kmath-jafama/README.md index a274b3d88..fe6afb835 100644 --- a/kmath-jafama/README.md +++ b/kmath-jafama/README.md @@ -7,7 +7,7 @@ Integration with [Jafama](https://github.com/jeffhain/jafama). ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-jafama:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-jafama:0.3.0`. **Gradle Groovy:** ```groovy @@ -17,7 +17,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-jafama:0.3.0-dev-20' + implementation 'space.kscience:kmath-jafama:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -28,7 +28,7 @@ repositories { } dependencies { - implementation("space.kscience:kmath-jafama:0.3.0-dev-20") + implementation("space.kscience:kmath-jafama:0.3.0") } ``` diff --git a/kmath-jupyter/README.md b/kmath-jupyter/README.md index 8014b969d..db58ad840 100644 --- a/kmath-jupyter/README.md +++ b/kmath-jupyter/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-jupyter:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-jupyter:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-jupyter:0.3.0-dev-20' + implementation 'space.kscience:kmath-jupyter:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-jupyter:0.3.0-dev-20") + implementation("space.kscience:kmath-jupyter:0.3.0") } ``` diff --git a/kmath-kotlingrad/README.md b/kmath-kotlingrad/README.md index 08c913090..52e8b3116 100644 --- a/kmath-kotlingrad/README.md +++ b/kmath-kotlingrad/README.md @@ -8,7 +8,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0`. **Gradle Groovy:** ```groovy @@ -18,7 +18,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-20' + implementation 'space.kscience:kmath-kotlingrad:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -29,6 +29,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-20") + implementation("space.kscience:kmath-kotlingrad:0.3.0") } ``` diff --git a/kmath-memory/README.md b/kmath-memory/README.md index d37087a66..9f4520bd8 100644 --- a/kmath-memory/README.md +++ b/kmath-memory/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-memory:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-memory:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-memory:0.3.0-dev-20' + implementation 'space.kscience:kmath-memory:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-memory:0.3.0-dev-20") + implementation("space.kscience:kmath-memory:0.3.0") } ``` diff --git a/kmath-multik/README.md b/kmath-multik/README.md index 167445f52..edfce6f79 100644 --- a/kmath-multik/README.md +++ b/kmath-multik/README.md @@ -6,7 +6,7 @@ JetBrains Multik connector ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-multik:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-multik:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-multik:0.3.0-dev-20' + implementation 'space.kscience:kmath-multik:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-multik:0.3.0-dev-20") + implementation("space.kscience:kmath-multik:0.3.0") } ``` diff --git a/kmath-nd4j/README.md b/kmath-nd4j/README.md index 225de18e9..0bcae138e 100644 --- a/kmath-nd4j/README.md +++ b/kmath-nd4j/README.md @@ -9,7 +9,7 @@ ND4J based implementations of KMath abstractions. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0`. **Gradle Groovy:** ```groovy @@ -19,7 +19,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-nd4j:0.3.0-dev-20' + implementation 'space.kscience:kmath-nd4j:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -30,7 +30,7 @@ repositories { } dependencies { - implementation("space.kscience:kmath-nd4j:0.3.0-dev-20") + implementation("space.kscience:kmath-nd4j:0.3.0") } ``` diff --git a/kmath-optimization/README.md b/kmath-optimization/README.md index 137975c90..63e0f43e3 100644 --- a/kmath-optimization/README.md +++ b/kmath-optimization/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-optimization:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-optimization:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-optimization:0.3.0-dev-20' + implementation 'space.kscience:kmath-optimization:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-optimization:0.3.0-dev-20") + implementation("space.kscience:kmath-optimization:0.3.0") } ``` diff --git a/kmath-stat/README.md b/kmath-stat/README.md index 762e61237..80c6e0fcd 100644 --- a/kmath-stat/README.md +++ b/kmath-stat/README.md @@ -6,7 +6,7 @@ ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-stat:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-stat:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-stat:0.3.0-dev-20' + implementation 'space.kscience:kmath-stat:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-stat:0.3.0-dev-20") + implementation("space.kscience:kmath-stat:0.3.0") } ``` diff --git a/kmath-symja/README.md b/kmath-symja/README.md index e3c717cff..ea2d5d68f 100644 --- a/kmath-symja/README.md +++ b/kmath-symja/README.md @@ -6,7 +6,7 @@ Symja integration module ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-symja:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-symja:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-symja:0.3.0-dev-20' + implementation 'space.kscience:kmath-symja:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-symja:0.3.0-dev-20") + implementation("space.kscience:kmath-symja:0.3.0") } ``` diff --git a/kmath-tensorflow/README.md b/kmath-tensorflow/README.md index f1dfa0202..7852c07be 100644 --- a/kmath-tensorflow/README.md +++ b/kmath-tensorflow/README.md @@ -6,7 +6,7 @@ Google tensorflow connector ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-tensorflow:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-tensorflow:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-tensorflow:0.3.0-dev-20' + implementation 'space.kscience:kmath-tensorflow:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-tensorflow:0.3.0-dev-20") + implementation("space.kscience:kmath-tensorflow:0.3.0") } ``` diff --git a/kmath-tensors/README.md b/kmath-tensors/README.md index 3d7dfd1fb..44ee47675 100644 --- a/kmath-tensors/README.md +++ b/kmath-tensors/README.md @@ -9,7 +9,7 @@ Common linear algebra operations on tensors. ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0`. **Gradle Groovy:** ```groovy @@ -19,7 +19,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-tensors:0.3.0-dev-20' + implementation 'space.kscience:kmath-tensors:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -30,6 +30,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-tensors:0.3.0-dev-20") + implementation("space.kscience:kmath-tensors:0.3.0") } ``` diff --git a/kmath-viktor/README.md b/kmath-viktor/README.md index 229d4dcd4..5d7c2dea1 100644 --- a/kmath-viktor/README.md +++ b/kmath-viktor/README.md @@ -6,7 +6,7 @@ Binding for https://github.com/JetBrains-Research/viktor ## Artifact: -The Maven coordinates of this project are `space.kscience:kmath-viktor:0.3.0-dev-20`. +The Maven coordinates of this project are `space.kscience:kmath-viktor:0.3.0`. **Gradle Groovy:** ```groovy @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation 'space.kscience:kmath-viktor:0.3.0-dev-20' + implementation 'space.kscience:kmath-viktor:0.3.0' } ``` **Gradle Kotlin DSL:** @@ -27,6 +27,6 @@ repositories { } dependencies { - implementation("space.kscience:kmath-viktor:0.3.0-dev-20") + implementation("space.kscience:kmath-viktor:0.3.0") } ``` diff --git a/kmath-viktor/api/kmath-viktor.api b/kmath-viktor/api/kmath-viktor.api index 59882627b..3bb7c3b21 100644 --- a/kmath-viktor/api/kmath-viktor.api +++ b/kmath-viktor/api/kmath-viktor.api @@ -1,40 +1,69 @@ public final class space/kscience/kmath/viktor/ViktorBuffer : space/kscience/kmath/structures/MutableBuffer { - public fun (Lorg/jetbrains/bio/viktor/F64FlatArray;)V + public static final synthetic fun box-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Lspace/kscience/kmath/viktor/ViktorBuffer; + public static fun constructor-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Lorg/jetbrains/bio/viktor/F64FlatArray; public fun copy ()Lspace/kscience/kmath/structures/MutableBuffer; + public static fun copy-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Lspace/kscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/jetbrains/bio/viktor/F64FlatArray;Lorg/jetbrains/bio/viktor/F64FlatArray;)Z public fun get (I)Ljava/lang/Double; public synthetic fun get (I)Ljava/lang/Object; + public static fun get-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;I)Ljava/lang/Double; public final fun getFlatArray ()Lorg/jetbrains/bio/viktor/F64FlatArray; public fun getSize ()I + public static fun getSize-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)I + public fun hashCode ()I + public static fun hashCode-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)I public fun iterator ()Ljava/util/Iterator; + public static fun iterator-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Ljava/util/Iterator; public fun set (ID)V public synthetic fun set (ILjava/lang/Object;)V + public static fun set-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;ID)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/jetbrains/bio/viktor/F64FlatArray; } -public final class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/kmath/nd/FieldND, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { +public class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/kmath/viktor/ViktorFieldOpsND, space/kscience/kmath/nd/FieldND, space/kscience/kmath/operations/NumbersAddOps { public fun ([I)V + public synthetic fun getOne ()Ljava/lang/Object; + public synthetic fun getOne ()Lspace/kscience/kmath/nd/StructureND; + public fun getOne ()Lspace/kscience/kmath/viktor/ViktorStructureND; + public fun getShape ()[I + public synthetic fun getZero ()Ljava/lang/Object; + public synthetic fun getZero ()Lspace/kscience/kmath/nd/StructureND; + public fun getZero ()Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND; +} + +public class space/kscience/kmath/viktor/ViktorFieldOpsND : space/kscience/kmath/nd/FieldOpsND, space/kscience/kmath/operations/ExtendedFieldOps, space/kscience/kmath/operations/PowerOperations { + public static final field Companion Lspace/kscience/kmath/viktor/ViktorFieldOpsND$Companion; + public fun ()V public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; public fun acos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; public fun asin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; public fun atan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; - public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; - public fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; public fun cos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; public fun exp (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; - public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; - public fun getElementContext ()Lspace/kscience/kmath/operations/DoubleField; + public synthetic fun getElementAlgebra ()Lspace/kscience/kmath/operations/Algebra; + public fun getElementAlgebra ()Lspace/kscience/kmath/operations/DoubleField; public final fun getF64Buffer (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/viktor/ViktorStructureND; - public fun getShape ()[I - public synthetic fun getZero ()Ljava/lang/Object; - public fun getZero ()Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; public fun ln (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; @@ -43,26 +72,38 @@ public final class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/km public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun minus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; - public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; - public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun plus (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; public fun plus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public fun power (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND; - public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; - public fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; + public synthetic fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; public fun sin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; + public synthetic fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun structureND ([ILkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; public fun tan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND; public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public fun zip (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/viktor/ViktorStructureND; +} + +public final class space/kscience/kmath/viktor/ViktorFieldOpsND$Companion : space/kscience/kmath/viktor/ViktorFieldOpsND { +} + +public final class space/kscience/kmath/viktor/ViktorFieldOpsNDKt { + public static final fun ViktorFieldND ([I)Lspace/kscience/kmath/viktor/ViktorFieldND; + public static final fun getViktorAlgebra (Lspace/kscience/kmath/operations/DoubleField;)Lspace/kscience/kmath/viktor/ViktorFieldOpsND; + public static final fun viktorAlgebra (Lspace/kscience/kmath/operations/DoubleField;[I)Lspace/kscience/kmath/viktor/ViktorFieldND; } public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscience/kmath/nd/MutableStructureND { @@ -77,7 +118,6 @@ public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscienc } public final class space/kscience/kmath/viktor/ViktorStructureNDKt { - public static final fun ViktorNDField ([I)Lspace/kscience/kmath/viktor/ViktorFieldND; public static final fun asStructure (Lorg/jetbrains/bio/viktor/F64Array;)Lspace/kscience/kmath/viktor/ViktorStructureND; } From d862a0a8960703f25a4fbd050ea5890fa3c9b150 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 11 Apr 2022 20:08:13 +0300 Subject: [PATCH 25/26] 0.3.0 release --- kmath-jupyter/api/kmath-jupyter.api | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 kmath-jupyter/api/kmath-jupyter.api diff --git a/kmath-jupyter/api/kmath-jupyter.api b/kmath-jupyter/api/kmath-jupyter.api new file mode 100644 index 000000000..e625e22f7 --- /dev/null +++ b/kmath-jupyter/api/kmath-jupyter.api @@ -0,0 +1,4 @@ +public final class space/kscience/kmath/jupyter/KMathJupyterKt { + public static final fun toMst (Ljava/lang/Number;)Lspace/kscience/kmath/expressions/MST$Numeric; +} + From 358d750226881956b8c8ce4de3f08d24ae2dca4f Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 12 Apr 2022 09:49:35 +0300 Subject: [PATCH 26/26] Add missing @CommanderTvis contributions to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28240dc68..75833602c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,10 @@ - Separate methods for UInt, Int and Number powers. NaN safety. - Tensorflow prototype - `ValueAndErrorField` +- MST compilation to WASM: #286 +- Jafama integration: #176 +- `contentEquals` with tolerance: #364 +- Compilation to TeX for MST: #254 ### Changed