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 a7487f916..f40cb88ee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,3 @@ -import space.kscience.gradle.isInDevelopment import space.kscience.gradle.useApache2Licence import space.kscience.gradle.useSPCTeam @@ -64,14 +63,7 @@ ksciencePublish { useApache2Licence() useSPCTeam() } - github("kmath", "SciProgCentre") - space( - if (isInDevelopment) { - "https://maven.pkg.jetbrains.space/spc/p/sci/dev" - } else { - "https://maven.pkg.jetbrains.space/spc/p/sci/maven" - } - ) + repository("spc","https://maven.sciprog.center/kscience") sonatype("https://oss.sonatype.org") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 734f60091..08db49244 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -17,7 +17,7 @@ val benchmarksVersion = spclibs.versions.kotlinx.benchmark.get() dependencies { api("space.kscience:gradle-tools:$toolsVersion") //plugins form benchmarks - api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.7") + api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.9") //api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion") //to be used inside build-script only //implementation(spclibs.kotlinx.serialization.json) diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index e6b69b0b3..c455f5ae9 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -2,10 +2,13 @@ * 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. */ -rootProject.name = "kmath" 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/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt b/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt index a3a475885..83cb786e3 100644 --- a/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt +++ b/buildSrc/src/main/kotlin/space/kscience/kmath/benchmarks/addBenchmarkProperties.kt @@ -54,9 +54,9 @@ fun Project.addBenchmarkProperties() { p.extensions.findByType(KScienceReadmeExtension::class.java)?.run { benchmarksProject.extensions.findByType(BenchmarksExtension::class.java)?.configurations?.forEach { cfg -> property("benchmark${cfg.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}") { - val launches = benchmarksProject.buildDir.resolve("reports/benchmarks/${cfg.name}") + val launches = benchmarksProject.layout.buildDirectory.dir("reports/benchmarks/${cfg.name}").get() - val resDirectory = launches.listFiles()?.maxByOrNull { + val resDirectory = launches.files().maxByOrNull { LocalDateTime.parse(it.name, ISO_DATE_TIME).atZone(ZoneId.systemDefault()).toInstant() } diff --git a/gradle.properties b/gradle.properties index fee75d428..5d62bf88e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,8 +9,9 @@ kotlin.native.ignoreDisabledTargets=true org.gradle.configureondemand=true org.gradle.jvmargs=-Xmx4096m -toolsVersion=0.14.8-kotlin-1.8.20 - - org.gradle.parallel=true org.gradle.workers.max=4 + +toolsVersion=0.15.0-kotlin-1.9.20 +#kotlin.experimental.tryK2=true +#kscience.wasm.disabled=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049a..e411586a5 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-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/kmath-ast/src/commonTest/kotlin/space/kscience/kmath/ast/rendering/TestFeatures.kt b/kmath-ast/src/commonTest/kotlin/space/kscience/kmath/ast/rendering/TestFeatures.kt index 7b5ec5765..bb6d39204 100644 --- a/kmath-ast/src/commonTest/kotlin/space/kscience/kmath/ast/rendering/TestFeatures.kt +++ b/kmath-ast/src/commonTest/kotlin/space/kscience/kmath/ast/rendering/TestFeatures.kt @@ -17,7 +17,7 @@ internal class TestFeatures { fun printNumeric() { val num = object : Number() { override fun toByte(): Byte = throw UnsupportedOperationException() - override fun toChar(): Char = throw UnsupportedOperationException() +// override fun toChar(): Char = throw UnsupportedOperationException() override fun toDouble(): Double = throw UnsupportedOperationException() override fun toFloat(): Float = throw UnsupportedOperationException() override fun toInt(): Int = throw UnsupportedOperationException() 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 d907a12c9..59c9a40a6 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 @@ -8,9 +8,8 @@ "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", - "NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING", "PropertyName", - "ClassName", + "ClassName", "ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING", ) @file:JsModule("binaryen") @@ -53,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-commons/build.gradle.kts b/kmath-commons/build.gradle.kts index 50fef7ac8..5c2c4a304 100644 --- a/kmath-commons/build.gradle.kts +++ b/kmath-commons/build.gradle.kts @@ -1,17 +1,20 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") } description = "Commons math binding for kmath" -dependencies { - api(project(":kmath-core")) - api(project(":kmath-complex")) - api(project(":kmath-coroutines")) - api(project(":kmath-optimization")) - api(project(":kmath-stat")) - api(project(":kmath-functions")) - api("org.apache.commons:commons-math3:3.6.1") +kscience { + jvm() + jvmMain { + api(projects.kmathCore) + api(projects.kmathComplex) + api(projects.kmathCoroutines) + api(projects.kmathOptimization) + api(projects.kmathStat) + api(projects.kmathFunctions) + api("org.apache.commons:commons-math3:3.6.1") + } } readme { diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/expressions/CmDsExpression.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/expressions/CmDsExpression.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/expressions/CmDsExpression.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/expressions/CmDsExpression.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMGaussRuleIntegrator.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/integration/CMGaussRuleIntegrator.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMGaussRuleIntegrator.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/integration/CMGaussRuleIntegrator.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/random/CMRandomGeneratorWrapper.kt diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/transform/Transformations.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/transform/Transformations.kt similarity index 100% rename from kmath-commons/src/main/kotlin/space/kscience/kmath/commons/transform/Transformations.kt rename to kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/transform/Transformations.kt diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt b/kmath-commons/src/jvmTest/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt similarity index 100% rename from kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt rename to kmath-commons/src/jvmTest/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt b/kmath-commons/src/jvmTest/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt similarity index 100% rename from kmath-commons/src/test/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt rename to kmath-commons/src/jvmTest/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt b/kmath-commons/src/jvmTest/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt similarity index 100% rename from kmath-commons/src/test/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt rename to kmath-commons/src/jvmTest/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt diff --git a/kmath-complex/build.gradle.kts b/kmath-complex/build.gradle.kts index 2f8c320cf..3e8b3b75e 100644 --- a/kmath-complex/build.gradle.kts +++ b/kmath-complex/build.gradle.kts @@ -6,7 +6,6 @@ kscience { jvm() js() native() - wasm() dependencies { 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-core/src/commonMain/kotlin/space/kscience/kmath/operations/LogicAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/LogicAlgebra.kt index 7aa5aed80..d8bf0fb57 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/LogicAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/LogicAlgebra.kt @@ -7,7 +7,6 @@ package space.kscience.kmath.operations import space.kscience.kmath.UnstableKMathAPI import space.kscience.kmath.expressions.Symbol -import space.kscience.kmath.expressions.symbol /** * An algebra for generic boolean logic @@ -61,8 +60,8 @@ public interface LogicAlgebra : Algebra { public companion object { - public val TRUE: Symbol by symbol - public val FALSE: Symbol by symbol + public val TRUE: Symbol = Symbol("TRUE")//by symbol + public val FALSE: Symbol = Symbol("FALSE")// by symbol } } diff --git a/kmath-core/src/wasmMain/kotlin/space/kscience/kmath/misc/numbers.kt b/kmath-core/src/wasmJsMain/kotlin/space/kscience/kmath/misc/numbers.kt similarity index 100% rename from kmath-core/src/wasmMain/kotlin/space/kscience/kmath/misc/numbers.kt rename to kmath-core/src/wasmJsMain/kotlin/space/kscience/kmath/misc/numbers.kt diff --git a/kmath-core/src/wasmMain/kotlin/space/kscience/kmath/operations/isInteger.kt b/kmath-core/src/wasmJsMain/kotlin/space/kscience/kmath/operations/isInteger.kt similarity index 100% rename from kmath-core/src/wasmMain/kotlin/space/kscience/kmath/operations/isInteger.kt rename to kmath-core/src/wasmJsMain/kotlin/space/kscience/kmath/operations/isInteger.kt 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 diff --git a/kmath-memory/build.gradle.kts b/kmath-memory/build.gradle.kts index fe422f751..f1dff3b75 100644 --- a/kmath-memory/build.gradle.kts +++ b/kmath-memory/build.gradle.kts @@ -15,3 +15,6 @@ readme { An API and basic implementation for arranging objects in a continuous memory block. """.trimIndent() } + +//rootProject.the().versions.webpack.version = "5.76.2" +//rootProject.the().nodeVersion = "20.8.0" diff --git a/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt b/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt index 32bc8d6a5..0ae3c7ebc 100644 --- a/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt +++ b/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt @@ -5,6 +5,8 @@ package space.kscience.kmath.memory +import kotlin.experimental.ExperimentalNativeApi + @PublishedApi internal class NativeMemory( val array: ByteArray, @@ -26,6 +28,7 @@ internal class NativeMemory( return NativeMemory(copy) } + @OptIn(ExperimentalNativeApi::class) private val reader: MemoryReader = object : MemoryReader { override val memory: Memory get() = this@NativeMemory @@ -48,6 +51,7 @@ internal class NativeMemory( override fun reader(): MemoryReader = reader + @OptIn(ExperimentalNativeApi::class) private val writer: MemoryWriter = object : MemoryWriter { override val memory: Memory get() = this@NativeMemory diff --git a/kmath-memory/src/wasmMain/kotlin/space/kscience/kmath/memory/WasmDataViewMemory.kt b/kmath-memory/src/wasmJsMain/kotlin/space/kscience/kmath/memory/WasmDataViewMemory.kt similarity index 100% rename from kmath-memory/src/wasmMain/kotlin/space/kscience/kmath/memory/WasmDataViewMemory.kt rename to kmath-memory/src/wasmJsMain/kotlin/space/kscience/kmath/memory/WasmDataViewMemory.kt