Fix things after merge

This commit is contained in:
Alexander Nozik 2020-09-20 22:25:50 +03:00
parent 5032523bbf
commit da742d6c69
5 changed files with 23 additions and 34 deletions

View File

@ -1,11 +1,10 @@
plugins { id("ru.mipt.npm.publish") apply false }
plugins { plugins {
id("scientifik.publish") apply false id("ru.mipt.npm.base")
id("org.jetbrains.changelog") version "0.4.0" id("org.jetbrains.changelog") version "0.4.0"
} }
val kmathVersion by extra("0.1.4") val kmathVersion by extra("0.2.0-dev-1")
val bintrayRepo by extra("scientifik") val bintrayRepo by extra("kscience")
val githubProject by extra("kmath") val githubProject by extra("kmath")
allprojects { allprojects {
@ -17,14 +16,6 @@ allprojects {
group = "kscience.kmath" group = "kscience.kmath"
version = kmathVersion version = kmathVersion
afterEvaluate {
extensions.findByType<KotlinProjectExtension>()?.run {
sourceSets.all {
languageSettings.useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
}
}
}
} }
subprojects { if (name.startsWith("kmath")) apply(plugin = "ru.mipt.npm.publish") } subprojects { if (name.startsWith("kmath")) apply(plugin = "ru.mipt.npm.publish") }

View File

@ -6,7 +6,6 @@ kotlin.sourceSets {
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
implementation("com.github.h0tk3y.betterParse:better-parse:0.4.0")
} }
} }
@ -14,6 +13,7 @@ kotlin.sourceSets {
dependencies { dependencies {
implementation("org.ow2.asm:asm:8.0.1") implementation("org.ow2.asm:asm:8.0.1")
implementation("org.ow2.asm:asm-commons: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")) implementation(kotlin("reflect"))
} }
} }

View File

@ -16,8 +16,7 @@ import scientifik.kmath.operations.RingOperations
import scientifik.kmath.operations.SpaceOperations import scientifik.kmath.operations.SpaceOperations
/** /**
* TODO move to core * TODO move to common after IR version is released
*
* @author Alexander Nozik and Iaroslav Postovalov * @author Alexander Nozik and Iaroslav Postovalov
*/ */
public object ArithmeticsEvaluator : Grammar<MST>() { public object ArithmeticsEvaluator : Grammar<MST>() {
@ -37,14 +36,14 @@ public object ArithmeticsEvaluator : Grammar<MST>() {
private val number: Parser<MST> by num use { MST.Numeric(text.toDouble()) } private val number: Parser<MST> by num use { MST.Numeric(text.toDouble()) }
private val singular: Parser<MST> by id use { MST.Symbolic(text) } private val singular: Parser<MST> by id use { MST.Symbolic(text) }
private val unaryFunction: Parser<MST> by (id and -lpar and parser(::subSumChain) and -rpar) private val unaryFunction: Parser<MST> by (id and -lpar and parser(ArithmeticsEvaluator::subSumChain) and -rpar)
.map { (id, term) -> MST.Unary(id.text, term) } .map { (id, term) -> MST.Unary(id.text, term) }
private val binaryFunction: Parser<MST> by id private val binaryFunction: Parser<MST> by id
.and(-lpar) .and(-lpar)
.and(parser(::subSumChain)) .and(parser(ArithmeticsEvaluator::subSumChain))
.and(-comma) .and(-comma)
.and(parser(::subSumChain)) .and(parser(ArithmeticsEvaluator::subSumChain))
.and(-rpar) .and(-rpar)
.map { (id, left, right) -> MST.Binary(id.text, left, right) } .map { (id, left, right) -> MST.Binary(id.text, left, right) }
@ -52,8 +51,8 @@ public object ArithmeticsEvaluator : Grammar<MST>() {
.or(binaryFunction) .or(binaryFunction)
.or(unaryFunction) .or(unaryFunction)
.or(singular) .or(singular)
.or(-minus and parser(::term) map { MST.Unary(SpaceOperations.MINUS_OPERATION, it) }) .or(-minus and parser(ArithmeticsEvaluator::term) map { MST.Unary(SpaceOperations.MINUS_OPERATION, it) })
.or(-lpar and parser(::subSumChain) and -rpar) .or(-lpar and parser(ArithmeticsEvaluator::subSumChain) and -rpar)
private val powChain: Parser<MST> by leftAssociative(term = term, operator = pow) { a, _, b -> private val powChain: Parser<MST> by leftAssociative(term = term, operator = pow) { a, _, b ->
MST.Binary(PowerOperations.POW_OPERATION, a, b) MST.Binary(PowerOperations.POW_OPERATION, a, b)

View File

@ -65,7 +65,6 @@ public inline fun <T : Any, F : Field<T>> F.deriv(body: AutoDiffField<T, F>.() -
} }
} }
public abstract class AutoDiffField<T : Any, F : Field<T>> : Field<Variable<T>> { public abstract class AutoDiffField<T : Any, F : Field<T>> : Field<Variable<T>> {
public abstract val context: F public abstract val context: F
@ -209,39 +208,39 @@ public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.sin(x: Variable<T
public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.cos(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.cos(x: Variable<T>): Variable<T> =
derive(variable { cos(x.value) }) { z -> x.d -= z.d * sin(x.value) } derive(variable { cos(x.value) }) { z -> x.d -= z.d * sin(x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.tan(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.tan(x: Variable<T>): Variable<T> =
derive(variable { tan(x.value) }) { z -> derive(variable { tan(x.value) }) { z ->
val c = cos(x.value) val c = cos(x.value)
x.d += z.d / (c * c) x.d += z.d / (c * c)
} }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.asin(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.asin(x: Variable<T>): Variable<T> =
derive(variable { asin(x.value) }) { z -> x.d += z.d / sqrt(one - x.value * x.value) } derive(variable { asin(x.value) }) { z -> x.d += z.d / sqrt(one - x.value * x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.acos(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.acos(x: Variable<T>): Variable<T> =
derive(variable { acos(x.value) }) { z -> x.d -= z.d / sqrt(one - x.value * x.value) } derive(variable { acos(x.value) }) { z -> x.d -= z.d / sqrt(one - x.value * x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.atan(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.atan(x: Variable<T>): Variable<T> =
derive(variable { atan(x.value) }) { z -> x.d += z.d / (one + x.value * x.value) } derive(variable { atan(x.value) }) { z -> x.d += z.d / (one + x.value * x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.sinh(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.sinh(x: Variable<T>): Variable<T> =
derive(variable { sin(x.value) }) { z -> x.d += z.d * cosh(x.value) } derive(variable { sin(x.value) }) { z -> x.d += z.d * cosh(x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.cosh(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.cosh(x: Variable<T>): Variable<T> =
derive(variable { cos(x.value) }) { z -> x.d += z.d * sinh(x.value) } derive(variable { cos(x.value) }) { z -> x.d += z.d * sinh(x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.tanh(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.tanh(x: Variable<T>): Variable<T> =
derive(variable { tan(x.value) }) { z -> derive(variable { tan(x.value) }) { z ->
val c = cosh(x.value) val c = cosh(x.value)
x.d += z.d / (c * c) x.d += z.d / (c * c)
} }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.asinh(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.asinh(x: Variable<T>): Variable<T> =
derive(variable { asinh(x.value) }) { z -> x.d += z.d / sqrt(one + x.value * x.value) } derive(variable { asinh(x.value) }) { z -> x.d += z.d / sqrt(one + x.value * x.value) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.acosh(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.acosh(x: Variable<T>): Variable<T> =
derive(variable { acosh(x.value) }) { z -> x.d += z.d / (sqrt((x.value - one) * (x.value + one))) } derive(variable { acosh(x.value) }) { z -> x.d += z.d / (sqrt((x.value - one) * (x.value + one))) }
fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.atanh(x: Variable<T>): Variable<T> = public fun <T : Any, F : ExtendedField<T>> AutoDiffField<T, F>.atanh(x: Variable<T>): Variable<T> =
derive(variable { atanh(x.value) }) { z -> x.d += z.d / (one - x.value * x.value) } derive(variable { atanh(x.value) }) { z -> x.d += z.d / (one - x.value * x.value) }

View File

@ -1,12 +1,13 @@
pluginManagement { pluginManagement {
val toolsVersion = "0.6.0-dev-5" val toolsVersion = "0.6.0"
plugins { plugins {
id("kotlinx.benchmark") version "0.2.0-dev-20" 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.mpp") version toolsVersion
id("ru.mipt.npm.jvm") version toolsVersion id("ru.mipt.npm.jvm") version toolsVersion
id("ru.mipt.npm.publish") version toolsVersion id("ru.mipt.npm.publish") version toolsVersion
kotlin("plugin.allopen") version "1.4.20-dev-3898-14" kotlin("plugin.allopen")
} }
repositories { repositories {
@ -17,7 +18,6 @@ pluginManagement {
maven("https://dl.bintray.com/mipt-npm/scientifik") maven("https://dl.bintray.com/mipt-npm/scientifik")
maven("https://dl.bintray.com/mipt-npm/dev") maven("https://dl.bintray.com/mipt-npm/dev")
maven("https://dl.bintray.com/kotlin/kotlinx") maven("https://dl.bintray.com/kotlin/kotlinx")
}
maven("https://dl.bintray.com/kotlin/kotlin-dev/") maven("https://dl.bintray.com/kotlin/kotlin-dev/")
} }
} }