diff --git a/build.gradle.kts b/build.gradle.kts index c3cbcc187..84d03bb56 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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() } diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 40da41d2b..0399920ec 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -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 diff --git a/kmath-functions/src/commonMain/kotlin/scientifik/kmath/functions/Polynomial.kt b/kmath-functions/src/commonMain/kotlin/scientifik/kmath/functions/Polynomial.kt index 3d97936f9..cc066d8df 100644 --- a/kmath-functions/src/commonMain/kotlin/scientifik/kmath/functions/Polynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/scientifik/kmath/functions/Polynomial.kt @@ -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(public val coefficients: List) +/** + * Constructs a [Polynomial] with given [coefficients]. + */ public fun Polynomial(vararg coefficients: T): Polynomial = Polynomial(coefficients.toList()) +/** + * Constructs a [Polynomial] with given [coefficients]. + */ +public fun Polynomial(coefficients: Iterable): Polynomial = Polynomial(coefficients.toList()) + public fun Polynomial.value(): Double = coefficients.reduceIndexed { index, acc, d -> acc + d.pow(index) } public fun > Polynomial.value(ring: C, arg: T): T = ring { @@ -50,7 +57,7 @@ public fun > Polynomial.asFunction(ring: C): (T) -> T = * An algebra for polynomials */ public class PolynomialSpace>(public val ring: C) : Space> { - public override val zero: Polynomial = Polynomial(emptyList()) + public override val zero: Polynomial by lazy { Polynomial(emptyList()) } public override fun add(a: Polynomial, b: Polynomial): Polynomial { val dim = max(a.coefficients.size, b.coefficients.size) diff --git a/settings.gradle.kts b/settings.gradle.kts index 594c727cb..ee6deb0fb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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 {