Move to build tools 0.14

This commit is contained in:
Alexander Nozik 2023-02-03 19:32:53 +03:00
parent d97888f135
commit db30913542
32 changed files with 205 additions and 120 deletions

View File

@ -50,8 +50,6 @@ kotlin {
val jvmMain by getting { val jvmMain by getting {
dependencies { dependencies {
implementation("org.openjdk.jmh:jmh-core:1.36")
implementation("org.openjdk.jmh:jmh-generator-annprocess:1.36")
implementation(project(":kmath-commons")) implementation(project(":kmath-commons"))
implementation(project(":kmath-ejml")) implementation(project(":kmath-ejml"))
implementation(project(":kmath-nd4j")) implementation(project(":kmath-nd4j"))
@ -144,6 +142,11 @@ benchmark {
commonConfiguration() commonConfiguration()
include("ViktorLogBenchmark") include("ViktorLogBenchmark")
} }
configurations.register("integration") {
commonConfiguration()
include("IntegrationBenchmark")
}
} }
kotlin.sourceSets.all { kotlin.sourceSets.all {

View File

@ -0,0 +1,40 @@
/*
* Copyright 2018-2023 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 org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.annotations.Scope
import org.openjdk.jmh.annotations.State
import org.openjdk.jmh.infra.Blackhole
import space.kscience.kmath.complex.Complex
import space.kscience.kmath.complex.algebra
import space.kscience.kmath.integration.gaussIntegrator
import space.kscience.kmath.integration.integrate
import space.kscience.kmath.integration.value
import space.kscience.kmath.operations.algebra
@State(Scope.Benchmark)
internal class IntegrationBenchmark {
@Benchmark
fun doubleIntegration(blackhole: Blackhole) {
val res = Double.algebra.gaussIntegrator.integrate(0.0..1.0, intervals = 1000) { x: Double ->
//sin(1 / x)
1/x
}.value
blackhole.consume(res)
}
@Benchmark
fun complexIntegration(blackhole: Blackhole) = with(Complex.algebra) {
val res = gaussIntegrator.integrate(0.0..1.0, intervals = 1000) { x: Double ->
// sin(1 / x) + i * cos(1 / x)
1/x - i/x
}.value
blackhole.consume(res)
}
}

View File

@ -15,7 +15,7 @@ allprojects {
} }
group = "space.kscience" group = "space.kscience"
version = "0.3.1-dev-9" version = "0.3.1-dev-10"
} }
subprojects { subprojects {

View File

@ -19,7 +19,7 @@ val benchmarksVersion = spclibs.versions.kotlinx.benchmark.get()
dependencies { dependencies {
api("space.kscience:gradle-tools:$toolsVersion") api("space.kscience:gradle-tools:$toolsVersion")
//plugins form benchmarks //plugins form benchmarks
api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:$benchmarksVersion") api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.7")
//api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion") //api("org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion")
//to be used inside build-script only //to be used inside build-script only
//implementation(spclibs.kotlinx.serialization.json) //implementation(spclibs.kotlinx.serialization.json)

View File

@ -5,6 +5,11 @@
package space.kscience.kmath.functions package space.kscience.kmath.functions
import space.kscience.kmath.complex.Complex
import space.kscience.kmath.complex.ComplexField
import space.kscience.kmath.complex.ComplexField.div
import space.kscience.kmath.complex.ComplexField.minus
import space.kscience.kmath.complex.algebra
import space.kscience.kmath.integration.gaussIntegrator import space.kscience.kmath.integration.gaussIntegrator
import space.kscience.kmath.integration.integrate import space.kscience.kmath.integration.integrate
import space.kscience.kmath.integration.value import space.kscience.kmath.integration.value
@ -20,4 +25,12 @@ fun main() {
//the value is nullable because in some cases the integration could not succeed //the value is nullable because in some cases the integration could not succeed
println(result.value) println(result.value)
repeat(100000) {
Complex.algebra.gaussIntegrator.integrate(0.0..1.0, intervals = 1000) { x: Double ->
// sin(1 / x) + i * cos(1 / x)
1 / x - ComplexField.i / x
}.value
}
} }

View File

@ -12,10 +12,9 @@ import space.kscience.kmath.nd.StructureND
import space.kscience.kmath.nd.structureND import space.kscience.kmath.nd.structureND
import space.kscience.kmath.nd.withNdAlgebra import space.kscience.kmath.nd.withNdAlgebra
import space.kscience.kmath.operations.algebra import space.kscience.kmath.operations.algebra
import space.kscience.kmath.operations.invoke import kotlin.math.pow
fun main(): Unit = Double.algebra { fun main(): Unit = Double.algebra.withNdAlgebra(2, 2) {
withNdAlgebra(2, 2) {
//Produce a diagonal StructureND //Produce a diagonal StructureND
fun diagonal(v: Double) = structureND { (i, j) -> fun diagonal(v: Double) = structureND { (i, j) ->
@ -31,4 +30,3 @@ fun main(): Unit = Double.algebra {
//the value is nullable because in some cases the integration could not succeed //the value is nullable because in some cases the integration could not succeed
println(result.value) println(result.value)
} }
}

View File

@ -7,8 +7,10 @@ package space.kscience.kmath.linear
import space.kscience.kmath.operations.algebra import space.kscience.kmath.operations.algebra
import kotlin.random.Random import kotlin.random.Random
import kotlin.system.measureTimeMillis import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
@OptIn(ExperimentalTime::class)
fun main() { fun main() {
val random = Random(12224) val random = Random(12224)
val dim = 1000 val dim = 1000
@ -21,7 +23,7 @@ fun main() {
if (i <= j) random.nextDouble() else 0.0 if (i <= j) random.nextDouble() else 0.0
} }
val time = measureTimeMillis { val time = measureTime {
with(Double.algebra.linearSpace) { with(Double.algebra.linearSpace) {
repeat(10) { repeat(10) {
matrix1 dot matrix2 matrix1 dot matrix2

View File

@ -37,7 +37,7 @@ fun main() = with(Double.algebra.bufferAlgebra.seriesAlgebra()) {
val s3: Buffer<Double> = s1.zip(s2) { l, r -> l + r } //s1 + s2 val s3: Buffer<Double> = s1.zip(s2) { l, r -> l + r } //s1 + s2
val s4 = DoubleBufferOps.ln(s3) val s4 = DoubleBufferOps.ln(s3)
val kmTest: KMComparisonResult<Double> = ksComparisonStatistic(s1, s2) @Suppress("UNUSED_VARIABLE") val kmTest: KMComparisonResult<Double> = ksComparisonStatistic(s1, s2)
Plotly.page { Plotly.page {
h1 { +"This is my plot" } h1 { +"This is my plot" }

View File

@ -9,7 +9,7 @@ kotlin.native.ignoreDisabledTargets=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4096m org.gradle.jvmargs=-Xmx4096m
toolsVersion=0.13.4-kotlin-1.8.0 toolsVersion=0.14.0-kotlin-1.8.10
org.gradle.parallel=true org.gradle.parallel=true

View File

@ -3,10 +3,33 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
dependencies {
api(projects.kmathCore)
api("com.github.h0tk3y.betterParse:better-parse:0.4.4")
} }
kotlin.js { testDependencies {
implementation(projects.kmathComplex)
}
dependencies(jsMain) {
implementation(npm("astring", "1.7.5"))
implementation(npm("binaryen", "101.0.0"))
implementation(npm("js-base64", "3.6.1"))
}
dependencies(jvmMain){
implementation("org.ow2.asm:asm-commons:9.2")
}
}
kotlin {
js {
nodejs { nodejs {
testTask { testTask {
useMocha().timeout = "0" useMocha().timeout = "0"
@ -20,48 +43,18 @@ kotlin.js {
} }
} }
kotlin.sourceSets { sourceSets {
filter { it.name.contains("test", true) } filter { it.name.contains("test", true) }
.map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings) .map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings)
.forEach { it.optIn("space.kscience.kmath.misc.UnstableKMathAPI") } .forEach { it.optIn("space.kscience.kmath.misc.UnstableKMathAPI") }
commonMain {
dependencies {
api("com.github.h0tk3y.betterParse:better-parse:0.4.4")
api(project(":kmath-core"))
} }
} }
commonTest { if (System.getProperty("space.kscience.kmath.ast.dump.generated.classes") == "1") {
dependencies { tasks.withType<org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest> {
implementation(project(":kmath-complex"))
}
}
jsMain {
dependencies {
implementation(npm("astring", "1.7.5"))
implementation(npm("binaryen", "101.0.0"))
implementation(npm("js-base64", "3.6.1"))
}
}
jvmMain {
dependencies {
implementation("org.ow2.asm:asm-commons:9.2")
}
}
}
//Workaround for https://github.com/Kotlin/dokka/issues/1455
tasks.dokkaHtml {
dependsOn(tasks.build)
}
if (System.getProperty("space.kscience.kmath.ast.dump.generated.classes") == "1")
tasks.jvmTest {
jvmArgs("-Dspace.kscience.kmath.ast.dump.generated.classes=1") jvmArgs("-Dspace.kscience.kmath.ast.dump.generated.classes=1")
} }
}
readme { readme {
maturity = space.kscience.gradle.Maturity.EXPERIMENTAL maturity = space.kscience.gradle.Maturity.EXPERIMENTAL

View File

@ -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. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
@file:Suppress("DEPRECATION")
package space.kscience.kmath.commons.expressions package space.kscience.kmath.commons.expressions
import org.apache.commons.math3.analysis.differentiation.DerivativeStructure import org.apache.commons.math3.analysis.differentiation.DerivativeStructure

View File

@ -3,14 +3,12 @@ plugins {
} }
kscience { kscience {
jvm()
js()
native() native()
}
kotlin.sourceSets {
commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(projects.kmathCore)
}
} }
} }

View File

@ -80,6 +80,8 @@ public object ComplexField :
override fun add(left: Complex, right: Complex): Complex = Complex(left.re + right.re, left.im + right.im) override fun add(left: Complex, right: Complex): Complex = Complex(left.re + right.re, left.im + right.im)
// override fun multiply(a: Complex, k: Number): Complex = Complex(a.re * k.toDouble(), a.im * k.toDouble()) // override fun multiply(a: Complex, k: Number): Complex = Complex(a.re * k.toDouble(), a.im * k.toDouble())
// override fun Complex.minus(arg: Complex): Complex = Complex(re - arg.re, im - arg.im)
override fun multiply(left: Complex, right: Complex): Complex = override fun multiply(left: Complex, right: Complex): Complex =
Complex(left.re * right.re - left.im * right.im, left.re * right.im + left.im * right.re) Complex(left.re * right.re - left.im * right.im, left.re * right.im + left.im * right.re)

View File

@ -3,10 +3,12 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
dependencies { dependencies {
api(project(":kmath-memory")) api(projects.kmathMemory)
} }
} }

View File

@ -8,6 +8,7 @@
package space.kscience.kmath.expressions package space.kscience.kmath.expressions
import space.kscience.kmath.linear.Matrix import space.kscience.kmath.linear.Matrix
import space.kscience.kmath.misc.PerformancePitfall
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.structures.getOrNull import space.kscience.kmath.structures.getOrNull
@ -16,6 +17,7 @@ public class NamedMatrix<T>(public val values: Matrix<T>, public val indexer: Sy
public companion object { public companion object {
@OptIn(PerformancePitfall::class)
public fun toStringWithSymbols(values: Matrix<*>, indexer: SymbolIndexer): String = buildString { public fun toStringWithSymbols(values: Matrix<*>, indexer: SymbolIndexer): String = buildString {
appendLine(indexer.symbols.joinToString(separator = "\t", prefix = "\t\t")) appendLine(indexer.symbols.joinToString(separator = "\t", prefix = "\t\t"))
indexer.symbols.forEach { i -> indexer.symbols.forEach { i ->

View File

@ -92,6 +92,17 @@ public fun <T : Comparable<T>> Group<T>.abs(value: T): T = if (value > zero) val
*/ */
public fun <T> Iterable<T>.sumWith(group: Group<T>): T = group.sum(this) public fun <T> Iterable<T>.sumWith(group: Group<T>): T = group.sum(this)
/**
* Sum extracted elements of [Iterable] with given [group]
*
* @receiver the collection to sum up.
* @param group tha algebra that provides addition
* @param extractor the (inline) lambda function to extract value
*/
public inline fun <T, R> Iterable<T>.sumWithGroupOf(group: Group<R>, extractor: (T) -> R): R = this.fold(group.zero) { left: R, right: T ->
group.add(left, extractor(right))
}
/** /**
* Returns the sum of all elements in the sequence in provided space. * Returns the sum of all elements in the sequence in provided space.
* *

View File

@ -3,24 +3,13 @@ plugins {
} }
kscience { kscience {
jvm()
js()
native() native()
}
kotlin.sourceSets {
all {
with(languageSettings) {
optIn("kotlinx.coroutines.InternalCoroutinesApi")
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
optIn("kotlinx.coroutines.FlowPreview")
}
}
commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
api(project(":kmath-complex")) api(project(":kmath-complex"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${space.kscience.gradle.KScienceVersions.coroutinesVersion}") api(spclibs.kotlinx.coroutines.core)
}
} }
} }

View File

@ -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. * 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(ExperimentalCoroutinesApi::class, FlowPreview::class)
package space.kscience.kmath.coroutines package space.kscience.kmath.coroutines
import kotlinx.coroutines.* import kotlinx.coroutines.*

View File

@ -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. * 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(FlowPreview::class)
package space.kscience.kmath.streaming package space.kscience.kmath.streaming
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flatMapConcat import kotlinx.coroutines.flow.flatMapConcat

View File

@ -3,25 +3,21 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
dependencies{
api(projects.kmathCore)
}
dependencies(jvmMain) {
api(kotlin("reflect"))
}
} }
description = "A proof of concept module for adding type-safe dimensions to structures" description = "A proof of concept module for adding type-safe dimensions to structures"
kotlin.sourceSets {
commonMain {
dependencies {
api(project(":kmath-core"))
}
}
jvmMain {
dependencies {
api(kotlin("reflect"))
}
}
}
readme { readme {
maturity = space.kscience.gradle.Maturity.PROTOTYPE maturity = space.kscience.gradle.Maturity.PROTOTYPE
} }

View File

@ -3,11 +3,15 @@ plugins {
} }
kscience { kscience {
jvm()
js()
native() native()
dependencies { dependencies {
api(projects.kmathCore) api(projects.kmathCore)
} }
dependencies("commonTest") {
testDependencies {
implementation(projects.testUtils) implementation(projects.testUtils)
} }
} }

View File

@ -3,6 +3,8 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
} }

View File

@ -3,8 +3,12 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
withContextReceivers()
useContextReceivers()
useSerialization()
dependencies{ dependencies{
api(projects.kmath.kmathComplex) api(projects.kmath.kmathComplex)
} }

View File

@ -3,6 +3,8 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
} }

View File

@ -4,15 +4,12 @@ plugins {
} }
dependencies { dependencies {
api(spclibs.kotlinx.html)
api(project(":kmath-ast")) api(project(":kmath-ast"))
api(project(":kmath-complex")) api(project(":kmath-complex"))
api(project(":kmath-for-real")) api(project(":kmath-for-real"))
} }
kscience {
useHtml()
}
readme { readme {
maturity = space.kscience.gradle.Maturity.PROTOTYPE maturity = space.kscience.gradle.Maturity.PROTOTYPE
} }

View File

@ -3,6 +3,8 @@ plugins {
} }
kscience { kscience {
jvm()
js()
native() native()
} }

View File

@ -6,6 +6,11 @@ description = "JetBrains Multik connector"
val multikVersion: String by rootProject.extra val multikVersion: String by rootProject.extra
kscience {
jvm()
js()
}
kotlin{ kotlin{
sourceSets{ sourceSets{
commonMain{ commonMain{

View File

@ -3,6 +3,8 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
} }

View File

@ -3,6 +3,8 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
} }
@ -14,7 +16,7 @@ kotlin.sourceSets {
} }
} }
jvmMain { getByName("jvmMain") {
dependencies { dependencies {
api("org.apache.commons:commons-rng-sampling:1.3") api("org.apache.commons:commons-rng-sampling:1.3")
api("org.apache.commons:commons-rng-simple:1.3") api("org.apache.commons:commons-rng-simple:1.3")

View File

@ -3,7 +3,10 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
dependencies { dependencies {
api(projects.kmathCore) api(projects.kmathCore)
api(projects.kmathStat) api(projects.kmathStat)

View File

@ -3,8 +3,12 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
withContextReceivers()
useContextReceivers()
useSerialization()
dependencies { dependencies {
api(projects.kmath.kmathGeometry) api(projects.kmath.kmathGeometry)
} }

View File

@ -3,6 +3,8 @@ plugins {
} }
kscience{ kscience{
jvm()
js()
native() native()
} }