From 645d81abf037aab334eb3f624660b0cc79f0040b Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 24 Aug 2019 09:00:04 +0300 Subject: [PATCH] Build migrated to gradle-tools 1.4 --- build.gradle.kts | 4 +- kmath-commons/build.gradle.kts | 18 +----- .../commons/transform/Transformations.kt | 2 +- kmath-core/build.gradle.kts | 2 - .../scientifik/kmath/operations/Algebra.kt | 12 +++- .../scientifik/kmath/operations/functions.kt | 34 ++++++++++++ kmath-coroutines/build.gradle.kts | 1 - kmath-io/build.gradle | 55 ------------------- settings.gradle.kts | 1 + 9 files changed, 50 insertions(+), 79 deletions(-) create mode 100644 kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/functions.kt delete mode 100644 kmath-io/build.gradle diff --git a/build.gradle.kts b/build.gradle.kts index 3584b790a..b4b3f032e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("scientifik.mpp") version "0.1.3" apply false - id("scientifik.publish") version "0.1.3" apply false + id("scientifik.mpp") version "0.1.4" apply false + id("scientifik.publish") version "0.1.4" apply false id("kotlinx-atomicfu") version "0.12.9" apply false } diff --git a/kmath-commons/build.gradle.kts b/kmath-commons/build.gradle.kts index ffdc27d43..9b446f872 100644 --- a/kmath-commons/build.gradle.kts +++ b/kmath-commons/build.gradle.kts @@ -1,6 +1,5 @@ plugins { - kotlin("jvm") - `maven-publish` + id("scientifik.jvm") } description = "Commons math binding for kmath" @@ -12,19 +11,4 @@ dependencies { api("org.apache.commons:commons-math3:3.6.1") testImplementation("org.jetbrains.kotlin:kotlin-test") testImplementation("org.jetbrains.kotlin:kotlin-test-junit") -} - - -val sourcesJar by tasks.registering(Jar::class) { - classifier = "sources" - from(sourceSets.main.get().allSource) -} - -publishing { - publications { - register("jvm", MavenPublication::class) { - from(components["java"]) - artifact(sourcesJar.get()) - } - } } \ No newline at end of file diff --git a/kmath-commons/src/main/kotlin/scientifik/kmath/commons/transform/Transformations.kt b/kmath-commons/src/main/kotlin/scientifik/kmath/commons/transform/Transformations.kt index ce51735fe..bcb3ea87b 100644 --- a/kmath-commons/src/main/kotlin/scientifik/kmath/commons/transform/Transformations.kt +++ b/kmath-commons/src/main/kotlin/scientifik/kmath/commons/transform/Transformations.kt @@ -11,7 +11,7 @@ import scientifik.kmath.structures.* /** - * + * Streaming and buffer transformations */ object Transformations { diff --git a/kmath-core/build.gradle.kts b/kmath-core/build.gradle.kts index 34941064b..092f3deb7 100644 --- a/kmath-core/build.gradle.kts +++ b/kmath-core/build.gradle.kts @@ -8,6 +8,4 @@ kotlin.sourceSets { api(project(":kmath-memory")) } } - //mingwMain {} - //mingwTest {} } \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt index ee9833623..03cbe6b55 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt @@ -1,7 +1,14 @@ package scientifik.kmath.operations +/** + * Marker interface for any algebra + */ +interface Algebra -interface SpaceOperations { +/** + * Space-like operations without neutral element + */ +interface SpaceOperations : Algebra { /** * Addition operation for two context elements */ @@ -38,6 +45,9 @@ interface Space : SpaceOperations { val zero: T } +/** + * Operations on ring without multiplication neutral element + */ interface RingOperations : SpaceOperations { /** * Multiplication for two field elements diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/functions.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/functions.kt new file mode 100644 index 000000000..a76167b43 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/functions.kt @@ -0,0 +1,34 @@ +package scientifik.kmath.operations + +import kotlin.jvm.JvmName +import kotlin.reflect.KClass + +/** + * A suspendable univariate function defined in algebraic context + */ +interface UFunction> { + suspend operator fun C.invoke(arg: T): T +} + +suspend fun UFunction.invoke(arg: Double) = RealField.invoke(arg) + +/** + * A suspendable multivariate (N->1) function defined on algebraic context + */ +interface MFunction> { + /** + * The input dimension of the function + */ + val dimension: UInt + + suspend operator fun C.invoke(vararg args: T): T +} + +suspend fun MFunction.invoke(args: DoubleArray) = RealField.invoke(*args.toTypedArray()) +@JvmName("varargInvoke") +suspend fun MFunction.invoke(vararg args: Double) = RealField.invoke(*args.toTypedArray()) + + +interface ParametricUFunction> { + suspend operator fun C.invoke(arg: T, parameter: P): T +} \ No newline at end of file diff --git a/kmath-coroutines/build.gradle.kts b/kmath-coroutines/build.gradle.kts index f54263072..e01c61326 100644 --- a/kmath-coroutines/build.gradle.kts +++ b/kmath-coroutines/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("scientifik.mpp") - id("kotlinx-atomicfu") } kotlin.sourceSets { diff --git a/kmath-io/build.gradle b/kmath-io/build.gradle deleted file mode 100644 index 28fb7eee5..000000000 --- a/kmath-io/build.gradle +++ /dev/null @@ -1,55 +0,0 @@ -plugins { - id "org.jetbrains.kotlin.multiplatform" -} - -kotlin { - targets { - fromPreset(presets.jvm, 'jvm') - fromPreset(presets.js, 'js') - // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64 - // For Linux, preset should be changed to e.g. presets.linuxX64 - // For MacOS, preset should be changed to e.g. presets.macosX64 - //fromPreset(presets.mingwX64, 'mingw') - } - sourceSets { - commonMain { - dependencies { - api project(":kmath-core") - implementation 'org.jetbrains.kotlin:kotlin-stdlib-common' - api "org.jetbrains.kotlinx:kotlinx-io:$ioVersion" - } - } - commonTest { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test-common' - implementation 'org.jetbrains.kotlin:kotlin-test-annotations-common' - } - } - jvmMain { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' - api "org.jetbrains.kotlinx:kotlinx-io-jvm:$ioVersion" - } - } - jvmTest { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test' - implementation 'org.jetbrains.kotlin:kotlin-test-junit' - } - } - jsMain { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-stdlib-js' - } - } - jsTest { - dependencies { - implementation 'org.jetbrains.kotlin:kotlin-test-js' - } - } -// mingwMain { -// } -// mingwTest { -// } - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index b45091a0b..f7ef0fc42 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,5 +32,6 @@ include( ":kmath-commons", ":kmath-koma", ":kmath-prob", + ":kmath-io", ":examples" )