From 7064546f835dd8870df0d1482ff76557bfadbef9 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 4 Oct 2024 14:55:15 +0300 Subject: [PATCH] add dokka multimodule --- benchmarks/build.gradle.kts | 19 +++++---- .../kmath/benchmarks/JafamaBenchmark.kt | 39 ------------------- build.gradle.kts | 6 +++ examples/build.gradle.kts | 4 +- .../space/kscience/kmath/jafama/JafamaDemo.kt | 15 ------- gradle.properties | 3 +- kmath-kotlingrad/build.gradle.kts | 19 ++++++--- .../kscience/kmath/kotlingrad/KMathNumber.kt | 0 .../kmath/kotlingrad/KotlingradExpression.kt | 0 .../kmath/kotlingrad/scalarsAdapters.kt | 0 .../kmath/kotlingrad/AdaptingTests.kt | 0 kmath-nd4j/build.gradle.kts | 19 ++++++--- .../kscience/kmath/nd4j/Nd4jArrayAlgebra.kt | 0 .../kscience/kmath/nd4j/Nd4jArrayIterator.kt | 0 .../kscience/kmath/nd4j/Nd4jArrayStructure.kt | 0 .../kscience/kmath/nd4j/Nd4jTensorAlgebra.kt | 0 .../space/kscience/kmath/nd4j/arrays.kt | 0 .../kmath/nd4j/Nd4jArrayAlgebraTest.kt | 0 .../kmath/nd4j/Nd4jArrayStructureTest.kt | 0 .../kmath/stat/RandomSourceGenerator.kt | 3 +- kmath-symja/build.gradle.kts | 32 +++++---------- .../kscience/kmath/symja/SymjaExpression.kt | 0 .../space/kscience/kmath/symja/adapters.kt | 0 kmath-viktor/build.gradle.kts | 11 ++++-- .../kscience/kmath/viktor/ViktorBuffer.kt | 0 .../kscience/kmath/viktor/ViktorFieldOpsND.kt | 0 .../kmath/viktor/ViktorStructureND.kt | 0 settings.gradle.kts | 1 - test-utils/build.gradle.kts | 1 + 29 files changed, 62 insertions(+), 110 deletions(-) delete mode 100644 benchmarks/src/jvmMain/kotlin/space/kscience/kmath/benchmarks/JafamaBenchmark.kt delete mode 100644 examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt rename kmath-kotlingrad/src/{main => jvmMain}/kotlin/space/kscience/kmath/kotlingrad/KMathNumber.kt (100%) rename kmath-kotlingrad/src/{main => jvmMain}/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt (100%) rename kmath-kotlingrad/src/{main => jvmMain}/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt (100%) rename kmath-kotlingrad/src/{test => jvmTest}/kotlin/space/kscience/kmath/kotlingrad/AdaptingTests.kt (100%) rename kmath-nd4j/src/{main => jvmMain}/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt (100%) rename kmath-nd4j/src/{main => jvmMain}/kotlin/space/kscience/kmath/nd4j/Nd4jArrayIterator.kt (100%) rename kmath-nd4j/src/{main => jvmMain}/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt (100%) rename kmath-nd4j/src/{main => jvmMain}/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt (100%) rename kmath-nd4j/src/{main => jvmMain}/kotlin/space/kscience/kmath/nd4j/arrays.kt (100%) rename kmath-nd4j/src/{test => jvmTest}/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt (100%) rename kmath-nd4j/src/{test => jvmTest}/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt (100%) rename kmath-symja/src/{main => jvmMain}/kotlin/space/kscience/kmath/symja/SymjaExpression.kt (100%) rename kmath-symja/src/{main => jvmMain}/kotlin/space/kscience/kmath/symja/adapters.kt (100%) rename kmath-viktor/src/{main => jvmMain}/kotlin/space/kscience/kmath/viktor/ViktorBuffer.kt (100%) rename kmath-viktor/src/{main => jvmMain}/kotlin/space/kscience/kmath/viktor/ViktorFieldOpsND.kt (100%) rename kmath-viktor/src/{main => jvmMain}/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt (100%) diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts index 2bdab89fb..483a71877 100644 --- a/benchmarks/build.gradle.kts +++ b/benchmarks/build.gradle.kts @@ -19,6 +19,14 @@ repositories { } kotlin { + jvmToolchain(17) + + compilerOptions { + optIn.addAll( + "space.kscience.kmath.UnstableKMathAPI" + ) + } + jvm() js(IR) { @@ -58,7 +66,7 @@ kotlin { implementation(project(":kmath-nd4j")) implementation(project(":kmath-kotlingrad")) implementation(project(":kmath-viktor")) - implementation(project(":kmath-jafama")) +// implementation(project(":kmath-jafama")) implementation(projects.kmath.kmathTensorflow) implementation("org.tensorflow:tensorflow-core-platform:0.4.0") implementation("org.nd4j:nd4j-native:1.0.0-M1") @@ -152,15 +160,6 @@ benchmark { } } -kotlin { - jvmToolchain(11) - compilerOptions { - optIn.addAll( - "space.kscience.kmath.UnstableKMathAPI" - ) - } -} - private data class JmhReport( val jmhVersion: String, diff --git a/benchmarks/src/jvmMain/kotlin/space/kscience/kmath/benchmarks/JafamaBenchmark.kt b/benchmarks/src/jvmMain/kotlin/space/kscience/kmath/benchmarks/JafamaBenchmark.kt deleted file mode 100644 index b0e029870..000000000 --- a/benchmarks/src/jvmMain/kotlin/space/kscience/kmath/benchmarks/JafamaBenchmark.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2018-2024 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.benchmarks - -import kotlinx.benchmark.Blackhole -import org.openjdk.jmh.annotations.Benchmark -import org.openjdk.jmh.annotations.Scope -import org.openjdk.jmh.annotations.State -import space.kscience.kmath.jafama.JafamaDoubleField -import space.kscience.kmath.jafama.StrictJafamaDoubleField -import space.kscience.kmath.operations.Float64Field -import space.kscience.kmath.operations.invoke -import kotlin.random.Random - -@State(Scope.Benchmark) -internal class JafamaBenchmark { - @Benchmark - fun jafama(blackhole: Blackhole) = invokeBenchmarks(blackhole) { x -> - JafamaDoubleField { x * power(x, 4) * exp(x) / cos(x) + sin(x) } - } - - @Benchmark - fun core(blackhole: Blackhole) = invokeBenchmarks(blackhole) { x -> - Float64Field { x * power(x, 4) * exp(x) / cos(x) + sin(x) } - } - - @Benchmark - fun strictJafama(blackhole: Blackhole) = invokeBenchmarks(blackhole) { x -> - StrictJafamaDoubleField { x * power(x, 4) * exp(x) / cos(x) + sin(x) } - } -} - -private inline fun invokeBenchmarks(blackhole: Blackhole, expr: (Double) -> Double) { - val rng = Random(0) - repeat(1000000) { blackhole.consume(expr(rng.nextDouble())) } -} diff --git a/build.gradle.kts b/build.gradle.kts index 185df9448..b5e9a76bf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,6 +19,12 @@ allprojects { version = "0.4.1-dev" } +dependencies{ + subprojects.forEach { + dokka(it) + } +} + subprojects { if (name.startsWith("kmath")) apply() diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 74ff891d5..f90b2707c 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -27,8 +27,6 @@ dependencies { implementation(project(":kmath-tensors")) implementation(project(":kmath-symja")) implementation(project(":kmath-for-real")) - //jafama - implementation(project(":kmath-jafama")) //multik implementation(project(":kmath-multik")) implementation(libs.multik.default) @@ -54,7 +52,7 @@ dependencies { } kotlin { - jvmToolchain(11) + jvmToolchain(17) sourceSets.all { languageSettings { optIn("kotlin.contracts.ExperimentalContracts") diff --git a/examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt b/examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt deleted file mode 100644 index b4afa37e4..000000000 --- a/examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2018-2024 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.jafama - -import space.kscience.kmath.operations.invoke - -fun main() { - val a = 2.0 - val b = StrictJafamaDoubleField { exp(a) } - println(JafamaDoubleField { b + a }) - println(StrictJafamaDoubleField { ln(b) }) -} diff --git a/gradle.properties b/gradle.properties index 724a19ce8..229b9374e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,5 @@ org.gradle.jvmargs=-Xmx4096m org.gradle.parallel=true org.gradle.workers.max=4 -toolsVersion=0.15.4-kotlin-2.0.0 \ No newline at end of file +toolsVersion=0.15.6-kotlin-2.1.0-Beta1 +org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers \ No newline at end of file diff --git a/kmath-kotlingrad/build.gradle.kts b/kmath-kotlingrad/build.gradle.kts index 56e191360..924911219 100644 --- a/kmath-kotlingrad/build.gradle.kts +++ b/kmath-kotlingrad/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") } kotlin.sourceSets @@ -9,11 +9,18 @@ kotlin.sourceSets description = "Kotlin∇ integration module" -dependencies { - api("ai.hypergraph:kaliningraph:0.1.9") - api("ai.hypergraph:kotlingrad:0.4.7") - api(project(":kmath-core")) - testImplementation(project(":kmath-ast")) +kscience{ + jvm() + + jvmMain{ + api("ai.hypergraph:kaliningraph:0.1.9") + api("ai.hypergraph:kotlingrad:0.4.7") + api(project(":kmath-core")) + } + + jvmTest{ + implementation(project(":kmath-ast")) + } } readme { diff --git a/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/KMathNumber.kt b/kmath-kotlingrad/src/jvmMain/kotlin/space/kscience/kmath/kotlingrad/KMathNumber.kt similarity index 100% rename from kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/KMathNumber.kt rename to kmath-kotlingrad/src/jvmMain/kotlin/space/kscience/kmath/kotlingrad/KMathNumber.kt diff --git a/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt b/kmath-kotlingrad/src/jvmMain/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt similarity index 100% rename from kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt rename to kmath-kotlingrad/src/jvmMain/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt diff --git a/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt b/kmath-kotlingrad/src/jvmMain/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt similarity index 100% rename from kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt rename to kmath-kotlingrad/src/jvmMain/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt diff --git a/kmath-kotlingrad/src/test/kotlin/space/kscience/kmath/kotlingrad/AdaptingTests.kt b/kmath-kotlingrad/src/jvmTest/kotlin/space/kscience/kmath/kotlingrad/AdaptingTests.kt similarity index 100% rename from kmath-kotlingrad/src/test/kotlin/space/kscience/kmath/kotlingrad/AdaptingTests.kt rename to kmath-kotlingrad/src/jvmTest/kotlin/space/kscience/kmath/kotlingrad/AdaptingTests.kt diff --git a/kmath-nd4j/build.gradle.kts b/kmath-nd4j/build.gradle.kts index bfa09e771..fcfbf62f9 100644 --- a/kmath-nd4j/build.gradle.kts +++ b/kmath-nd4j/build.gradle.kts @@ -1,14 +1,21 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") } description = "ND4J NDStructure implementation and according NDAlgebra classes" -dependencies { - api(project(":kmath-tensors")) - api("org.nd4j:nd4j-api:1.0.0-M1") - testImplementation("org.nd4j:nd4j-native-platform:1.0.0-M1") - testImplementation("org.slf4j:slf4j-simple:1.7.32") + +kscience { + jvm() + + jvmMain { + api(project(":kmath-tensors")) + api("org.nd4j:nd4j-api:1.0.0-M2.1") + } + + jvmTest{ + implementation("org.nd4j:nd4j-native-platform:1.0.0-M1") + } } readme { diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt similarity index 100% rename from kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt rename to kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayIterator.kt b/kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jArrayIterator.kt similarity index 100% rename from kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayIterator.kt rename to kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jArrayIterator.kt diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt b/kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt similarity index 100% rename from kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt rename to kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt b/kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt similarity index 100% rename from kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt rename to kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/arrays.kt b/kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/arrays.kt similarity index 100% rename from kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/arrays.kt rename to kmath-nd4j/src/jvmMain/kotlin/space/kscience/kmath/nd4j/arrays.kt diff --git a/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt b/kmath-nd4j/src/jvmTest/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt similarity index 100% rename from kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt rename to kmath-nd4j/src/jvmTest/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt diff --git a/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt b/kmath-nd4j/src/jvmTest/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt similarity index 100% rename from kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt rename to kmath-nd4j/src/jvmTest/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt diff --git a/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/RandomSourceGenerator.kt b/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/RandomSourceGenerator.kt index 9598109bc..bb0eae463 100644 --- a/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/RandomSourceGenerator.kt +++ b/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/RandomSourceGenerator.kt @@ -18,8 +18,7 @@ public class RandomSourceGenerator internal constructor( public val source: RandomSource, seed: Long?, ) : RandomGenerator { - internal val random: UniformRandomProvider = seed?.let { source.create(seed) } - ?: RandomSource.create(source) + internal val random: UniformRandomProvider = seed?.let { source.create(seed) } ?: source.create() override fun nextBoolean(): Boolean = random.nextBoolean() override fun nextDouble(): Double = random.nextDouble() diff --git a/kmath-symja/build.gradle.kts b/kmath-symja/build.gradle.kts index a996f3bec..a8f4d0776 100644 --- a/kmath-symja/build.gradle.kts +++ b/kmath-symja/build.gradle.kts @@ -4,38 +4,24 @@ */ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") } description = "Symja integration module" -dependencies { - api("org.matheclipse:matheclipse-core:2.0.0") { - // Incorrect transitive dependencies - exclude("org.apfloat", "apfloat") - exclude("org.hipparchus", "hipparchus-clustering") - exclude("org.hipparchus", "hipparchus-core") - exclude("org.hipparchus", "hipparchus-fft") - exclude("org.hipparchus", "hipparchus-fitting") - exclude("org.hipparchus", "hipparchus-ode") - exclude("org.hipparchus", "hipparchus-optim") - exclude("org.hipparchus", "hipparchus-stat") +kscience{ + jvm() + + jvmMain { + api("org.matheclipse:matheclipse-core:3.0.0") + + api(project(":kmath-core")) } - // Replaces for incorrect transitive dependencies - api("org.apfloat:apfloat:1.10.0") - api("org.hipparchus:hipparchus-clustering:1.8") - api("org.hipparchus:hipparchus-core:1.8") - api("org.hipparchus:hipparchus-fft:1.8") - api("org.hipparchus:hipparchus-fitting:1.8") - api("org.hipparchus:hipparchus-ode:1.8") - api("org.hipparchus:hipparchus-optim:1.8") - api("org.hipparchus:hipparchus-stat:1.8") - api(project(":kmath-core")) - testImplementation("org.slf4j:slf4j-simple:1.7.31") } + readme { maturity = space.kscience.gradle.Maturity.PROTOTYPE } diff --git a/kmath-symja/src/main/kotlin/space/kscience/kmath/symja/SymjaExpression.kt b/kmath-symja/src/jvmMain/kotlin/space/kscience/kmath/symja/SymjaExpression.kt similarity index 100% rename from kmath-symja/src/main/kotlin/space/kscience/kmath/symja/SymjaExpression.kt rename to kmath-symja/src/jvmMain/kotlin/space/kscience/kmath/symja/SymjaExpression.kt diff --git a/kmath-symja/src/main/kotlin/space/kscience/kmath/symja/adapters.kt b/kmath-symja/src/jvmMain/kotlin/space/kscience/kmath/symja/adapters.kt similarity index 100% rename from kmath-symja/src/main/kotlin/space/kscience/kmath/symja/adapters.kt rename to kmath-symja/src/jvmMain/kotlin/space/kscience/kmath/symja/adapters.kt diff --git a/kmath-viktor/build.gradle.kts b/kmath-viktor/build.gradle.kts index d15a70e9b..a96e86879 100644 --- a/kmath-viktor/build.gradle.kts +++ b/kmath-viktor/build.gradle.kts @@ -1,12 +1,15 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") } description = "Binding for https://github.com/JetBrains-Research/viktor" -dependencies { - api(project(":kmath-core")) - api("org.jetbrains.bio:viktor:1.2.0") +kscience{ + jvm() + jvmMain{ + api(project(":kmath-core")) + api("org.jetbrains.bio:viktor:1.2.0") + } } readme { diff --git a/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorBuffer.kt b/kmath-viktor/src/jvmMain/kotlin/space/kscience/kmath/viktor/ViktorBuffer.kt similarity index 100% rename from kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorBuffer.kt rename to kmath-viktor/src/jvmMain/kotlin/space/kscience/kmath/viktor/ViktorBuffer.kt diff --git a/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorFieldOpsND.kt b/kmath-viktor/src/jvmMain/kotlin/space/kscience/kmath/viktor/ViktorFieldOpsND.kt similarity index 100% rename from kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorFieldOpsND.kt rename to kmath-viktor/src/jvmMain/kotlin/space/kscience/kmath/viktor/ViktorFieldOpsND.kt diff --git a/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt b/kmath-viktor/src/jvmMain/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt similarity index 100% rename from kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt rename to kmath-viktor/src/jvmMain/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 5e610ca85..2b0faafca 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -61,7 +61,6 @@ include( ":kmath-tensors", ":kmath-jupyter", ":kmath-symja", - ":kmath-jafama", ":examples", ":benchmarks", ) diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 663b1149b..ac3ce95aa 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -14,6 +14,7 @@ kotlin.sourceSets { dependencies { api(projects.kmath.kmathCore) api(kotlin("test")) + api(spclibs.logback.classic) } } }