diff --git a/CHANGELOG.md b/CHANGELOG.md index 27b67a4d8..3c6523a0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Deprecated ### Removed +- `asPolynomial` function due to scope pollution ### Fixed - Median statistics diff --git a/build.gradle.kts b/build.gradle.kts index 3050699f0..f40cb88ee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,4 +69,4 @@ ksciencePublish { apiValidation.nonPublicMarkers.add("space.kscience.kmath.UnstableKMathAPI") -val multikVersion by extra("0.2.0") +val multikVersion by extra("0.2.2") diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index 02111ba37..c455f5ae9 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -5,6 +5,10 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" +} + dependencyResolutionManagement { val projectProperties = java.util.Properties() file("../gradle.properties").inputStream().use { diff --git a/gradle.properties b/gradle.properties index b6bb24a6f..0c2a6f455 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,6 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.0-kotlin-1.9.20-Beta2 +toolsVersion=0.15.0-kotlin-1.9.20-RC2 #kotlin.experimental.tryK2=true #kscience.wasm.disabled=true \ No newline at end of file diff --git a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt index f2e1aae83..143ae7ad4 100644 --- a/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt +++ b/kmath-ast/src/jsMain/kotlin/space/kscience/kmath/internal/binaryen/index.binaryen.kt @@ -52,7 +52,7 @@ internal external fun createType(types: Array): Type internal external fun expandType(type: Type): Array -internal external enum class ExpressionIds { +internal external enum class ExpressionIds { Invalid, Block, If, diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/data/XYColumnarData.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/data/XYColumnarData.kt index de7e6f79b..23cbcd0c7 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/data/XYColumnarData.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/data/XYColumnarData.kt @@ -10,6 +10,7 @@ import space.kscience.kmath.UnstableKMathAPI import space.kscience.kmath.expressions.Symbol import space.kscience.kmath.nd.Structure2D import space.kscience.kmath.structures.Buffer +import space.kscience.kmath.structures.VirtualBuffer import kotlin.math.max /** @@ -33,7 +34,10 @@ public interface XYColumnarData : ColumnarData { else -> null } - public companion object{ + public companion object { + /** + * Create data form two buffers (zero-copy) + */ @UnstableKMathAPI public fun of(x: Buffer, y: Buffer): XYColumnarData { require(x.size == y.size) { "Buffer size mismatch. x buffer size is ${x.size}, y buffer size is ${y.size}" } @@ -43,6 +47,26 @@ public interface XYColumnarData : ColumnarData { override val y: Buffer = y } } + + /** + * Create two-column data from a list of row-objects (zero-copy) + */ + @UnstableKMathAPI + public fun ofList( + list: List, + xConverter: (I) -> X, + yConverter: (I) -> Y, + ): XYColumnarData = object : XYColumnarData { + override val size: Int get() = list.size + + override val x: Buffer = VirtualBuffer(list.size) { + xConverter(list[it]) + } + + override val y: Buffer = VirtualBuffer(list.size) { + yConverter(list[it]) + } + } } } @@ -56,9 +80,10 @@ public fun ColumnarData.asXYData( ySymbol: Symbol, ): XYColumnarData = object : XYColumnarData { init { - requireNotNull(this@asXYData[xSymbol]){"The column with name $xSymbol is not present in $this"} - requireNotNull(this@asXYData[ySymbol]){"The column with name $ySymbol is not present in $this"} + requireNotNull(this@asXYData[xSymbol]) { "The column with name $xSymbol is not present in $this" } + requireNotNull(this@asXYData[ySymbol]) { "The column with name $ySymbol is not present in $this" } } + override val size: Int get() = this@asXYData.size override val x: Buffer get() = this@asXYData[xSymbol]!! override val y: Buffer get() = this@asXYData[ySymbol]!! diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt index 2ac8c1eb4..bb07fede1 100644 --- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt +++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt @@ -65,9 +65,7 @@ public class RingBuffer( } } - - @Suppress("NOTHING_TO_INLINE") - private inline fun Int.forward(n: Int): Int = (this + n) % (buffer.size) + private fun Int.forward(n: Int): Int = (this + n) % (buffer.size) override fun toString(): String = Buffer.toString(this) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialConstructors.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialConstructors.kt index 4e9791a87..e07ff764c 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialConstructors.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialConstructors.kt @@ -20,9 +20,4 @@ public fun Polynomial(coefficients: List, reverse: Boolean = false): Poly */ @Suppress("FunctionName") public fun Polynomial(vararg coefficients: C, reverse: Boolean = false): Polynomial = - Polynomial(with(coefficients) { if (reverse) reversed() else toList() }) - -/** - * Represents [this] constant as a [Polynomial]. - */ -public fun C.asPolynomial() : Polynomial = Polynomial(listOf(this)) \ No newline at end of file + Polynomial(with(coefficients) { if (reverse) reversed() else toList() }) \ No newline at end of file