diff --git a/build.gradle.kts b/build.gradle.kts index 384db5385..838a05771 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,10 @@ -plugins { id("ru.mipt.npm.publish") apply false } plugins { - id("scientifik.publish") apply false + id("ru.mipt.npm.base") id("org.jetbrains.changelog") version "0.4.0" } -val kmathVersion by extra("0.1.4") -val bintrayRepo by extra("scientifik") +val kmathVersion by extra("0.2.0-dev-1") +val bintrayRepo by extra("kscience") val githubProject by extra("kmath") allprojects { @@ -17,14 +16,6 @@ allprojects { group = "kscience.kmath" version = kmathVersion - - afterEvaluate { - extensions.findByType()?.run { - sourceSets.all { - languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") - } - } - } } subprojects { if (name.startsWith("kmath")) apply(plugin = "ru.mipt.npm.publish") } diff --git a/kmath-ast/build.gradle.kts b/kmath-ast/build.gradle.kts index 3e0a441b7..df876df10 100644 --- a/kmath-ast/build.gradle.kts +++ b/kmath-ast/build.gradle.kts @@ -6,7 +6,6 @@ kotlin.sourceSets { commonMain { dependencies { api(project(":kmath-core")) - implementation("com.github.h0tk3y.betterParse:better-parse:0.4.0") } } @@ -14,6 +13,7 @@ kotlin.sourceSets { dependencies { implementation("org.ow2.asm:asm:8.0.1") implementation("org.ow2.asm:asm-commons:8.0.1") + implementation("com.github.h0tk3y.betterParse:better-parse:0.4.0") implementation(kotlin("reflect")) } } diff --git a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/ast/parser.kt similarity index 89% rename from kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt rename to kmath-ast/src/jvmMain/kotlin/scientifik/kmath/ast/parser.kt index e48b2817f..8ccbf4606 100644 --- a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt +++ b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/ast/parser.kt @@ -16,8 +16,7 @@ import scientifik.kmath.operations.RingOperations import scientifik.kmath.operations.SpaceOperations /** - * TODO move to core - * + * TODO move to common after IR version is released * @author Alexander Nozik and Iaroslav Postovalov */ public object ArithmeticsEvaluator : Grammar() { @@ -37,14 +36,14 @@ public object ArithmeticsEvaluator : Grammar() { private val number: Parser by num use { MST.Numeric(text.toDouble()) } private val singular: Parser by id use { MST.Symbolic(text) } - private val unaryFunction: Parser by (id and -lpar and parser(::subSumChain) and -rpar) + private val unaryFunction: Parser by (id and -lpar and parser(ArithmeticsEvaluator::subSumChain) and -rpar) .map { (id, term) -> MST.Unary(id.text, term) } private val binaryFunction: Parser by id .and(-lpar) - .and(parser(::subSumChain)) + .and(parser(ArithmeticsEvaluator::subSumChain)) .and(-comma) - .and(parser(::subSumChain)) + .and(parser(ArithmeticsEvaluator::subSumChain)) .and(-rpar) .map { (id, left, right) -> MST.Binary(id.text, left, right) } @@ -52,8 +51,8 @@ public object ArithmeticsEvaluator : Grammar() { .or(binaryFunction) .or(unaryFunction) .or(singular) - .or(-minus and parser(::term) map { MST.Unary(SpaceOperations.MINUS_OPERATION, it) }) - .or(-lpar and parser(::subSumChain) and -rpar) + .or(-minus and parser(ArithmeticsEvaluator::term) map { MST.Unary(SpaceOperations.MINUS_OPERATION, it) }) + .or(-lpar and parser(ArithmeticsEvaluator::subSumChain) and -rpar) private val powChain: Parser by leftAssociative(term = term, operator = pow) { a, _, b -> MST.Binary(PowerOperations.POW_OPERATION, a, b) diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/AutoDiff.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/AutoDiff.kt index 1c4cc63b6..b09bcff9f 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/AutoDiff.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/AutoDiff.kt @@ -65,7 +65,6 @@ public inline fun > F.deriv(body: AutoDiffField.() - } } - public abstract class AutoDiffField> : Field> { public abstract val context: F @@ -209,39 +208,39 @@ public fun > AutoDiffField.sin(x: Variable> AutoDiffField.cos(x: Variable): Variable = derive(variable { cos(x.value) }) { z -> x.d -= z.d * sin(x.value) } -fun > AutoDiffField.tan(x: Variable): Variable = +public fun > AutoDiffField.tan(x: Variable): Variable = derive(variable { tan(x.value) }) { z -> val c = cos(x.value) x.d += z.d / (c * c) } -fun > AutoDiffField.asin(x: Variable): Variable = +public fun > AutoDiffField.asin(x: Variable): Variable = derive(variable { asin(x.value) }) { z -> x.d += z.d / sqrt(one - x.value * x.value) } -fun > AutoDiffField.acos(x: Variable): Variable = +public fun > AutoDiffField.acos(x: Variable): Variable = derive(variable { acos(x.value) }) { z -> x.d -= z.d / sqrt(one - x.value * x.value) } -fun > AutoDiffField.atan(x: Variable): Variable = +public fun > AutoDiffField.atan(x: Variable): Variable = derive(variable { atan(x.value) }) { z -> x.d += z.d / (one + x.value * x.value) } -fun > AutoDiffField.sinh(x: Variable): Variable = +public fun > AutoDiffField.sinh(x: Variable): Variable = derive(variable { sin(x.value) }) { z -> x.d += z.d * cosh(x.value) } -fun > AutoDiffField.cosh(x: Variable): Variable = +public fun > AutoDiffField.cosh(x: Variable): Variable = derive(variable { cos(x.value) }) { z -> x.d += z.d * sinh(x.value) } -fun > AutoDiffField.tanh(x: Variable): Variable = +public fun > AutoDiffField.tanh(x: Variable): Variable = derive(variable { tan(x.value) }) { z -> val c = cosh(x.value) x.d += z.d / (c * c) } -fun > AutoDiffField.asinh(x: Variable): Variable = +public fun > AutoDiffField.asinh(x: Variable): Variable = derive(variable { asinh(x.value) }) { z -> x.d += z.d / sqrt(one + x.value * x.value) } -fun > AutoDiffField.acosh(x: Variable): Variable = +public fun > AutoDiffField.acosh(x: Variable): Variable = derive(variable { acosh(x.value) }) { z -> x.d += z.d / (sqrt((x.value - one) * (x.value + one))) } -fun > AutoDiffField.atanh(x: Variable): Variable = +public fun > AutoDiffField.atanh(x: Variable): Variable = derive(variable { atanh(x.value) }) { z -> x.d += z.d / (one - x.value * x.value) } diff --git a/settings.gradle.kts b/settings.gradle.kts index b78ed4647..666a05e45 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,12 +1,13 @@ pluginManagement { - val toolsVersion = "0.6.0-dev-5" + val toolsVersion = "0.6.0" plugins { id("kotlinx.benchmark") version "0.2.0-dev-20" + id("ru.mipt.npm.base") version toolsVersion id("ru.mipt.npm.mpp") version toolsVersion id("ru.mipt.npm.jvm") version toolsVersion id("ru.mipt.npm.publish") version toolsVersion - kotlin("plugin.allopen") version "1.4.20-dev-3898-14" + kotlin("plugin.allopen") } repositories { @@ -17,7 +18,6 @@ pluginManagement { maven("https://dl.bintray.com/mipt-npm/scientifik") maven("https://dl.bintray.com/mipt-npm/dev") maven("https://dl.bintray.com/kotlin/kotlinx") - } maven("https://dl.bintray.com/kotlin/kotlin-dev/") } }