Update Gradle tooling

This commit is contained in:
Iaroslav Postovalov 2020-09-19 23:19:33 +07:00
parent 220eddd9df
commit ea70c255e9
No known key found for this signature in database
GPG Key ID: 70D5F4DCB0972F1B
4 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,5 @@
import ru.mipt.npm.gradle.KSciencePublishPlugin
plugins { id("ru.mipt.npm.publish") apply false }
val kmathVersion: String by extra("0.1.4")
@ -15,4 +17,4 @@ allprojects {
version = kmathVersion
}
subprojects { if (name.startsWith("kmath")) apply(plugin = "ru.mipt.npm.publish") }
subprojects { if (name.startsWith("kmath")) apply<KSciencePublishPlugin>() }

View File

@ -1,9 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
kotlin("jvm")
kotlin("plugin.allopen") version "1.4.20-dev-3898-14"
kotlin("plugin.allopen") version "1.4.10"
id("kotlinx.benchmark") version "0.2.0-dev-20"
}
@ -28,15 +27,14 @@ dependencies {
implementation(project(":kmath-dimensions"))
implementation("org.jetbrains.kotlinx:kotlinx-io-jvm:0.2.0-npm-dev-6")
implementation("org.jetbrains.kotlinx:kotlinx.benchmark.runtime:0.2.0-dev-20")
"benchmarksCompile"(sourceSets.main.get().output + sourceSets.main.get().compileClasspath) //sourceSets.main.output + sourceSets.main.runtimeClasspath
implementation("org.slf4j:slf4j-simple:1.7.30")
"benchmarksImplementation"("org.jetbrains.kotlinx:kotlinx.benchmark.runtime-jvm:0.2.0-dev-8")
"benchmarksImplementation"(sourceSets.main.get().output + sourceSets.main.get().runtimeClasspath)
}
// Configure benchmark
benchmark {
// Setup configurations
targets
// This one matches sourceSet name above
.register("benchmarks")
targets.register("benchmarks")
configurations.register("fast") {
warmups = 5 // number of warmup iterations

View File

@ -8,15 +8,22 @@ import kotlin.contracts.contract
import kotlin.math.max
import kotlin.math.pow
// TODO make `inline`, when KT-41771 gets fixed
/**
* Polynomial coefficients without fixation on specific context they are applied to
* @param coefficients constant is the leftmost coefficient
*/
public inline class Polynomial<T : Any>(public val coefficients: List<T>)
/**
* Constructs a [Polynomial] with given [coefficients].
*/
public fun <T : Any> Polynomial(vararg coefficients: T): Polynomial<T> = Polynomial(coefficients.toList())
/**
* Constructs a [Polynomial] with given [coefficients].
*/
public fun <T : Any> Polynomial(coefficients: Iterable<T>): Polynomial<T> = Polynomial(coefficients.toList())
public fun Polynomial<Double>.value(): Double = coefficients.reduceIndexed { index, acc, d -> acc + d.pow(index) }
public fun <T : Any, C : Ring<T>> Polynomial<T>.value(ring: C, arg: T): T = ring {
@ -50,7 +57,7 @@ public fun <T : Any, C : Ring<T>> Polynomial<T>.asFunction(ring: C): (T) -> T =
* An algebra for polynomials
*/
public class PolynomialSpace<T : Any, C : Ring<T>>(public val ring: C) : Space<Polynomial<T>> {
public override val zero: Polynomial<T> = Polynomial(emptyList())
public override val zero: Polynomial<T> by lazy { Polynomial(emptyList()) }
public override fun add(a: Polynomial<T>, b: Polynomial<T>): Polynomial<T> {
val dim = max(a.coefficients.size, b.coefficients.size)

View File

@ -1,12 +1,12 @@
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.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") version "1.4.10"
}
repositories {