From e44423192d8b3923893752d4c32056a384fadcb9 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 13 Oct 2020 20:34:17 +0300 Subject: [PATCH] Tools version update --- build.gradle.kts | 2 +- .../main/kotlin/kscience/kmath/operations/ComplexDemo.kt | 4 ++-- .../kscience/kmath/commons/expressions/DiffExpression.kt | 7 ++++--- .../kscience/kmath/commons/expressions/AutoDiffTest.kt | 2 +- .../commonMain/kotlin/kscience/kmath/operations/Complex.kt | 1 + settings.gradle.kts | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 05e2d5979..239ea1296 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,4 +24,4 @@ subprojects { readme { readmeTemplate = file("docs/templates/README-TEMPLATE.md") -} +} \ No newline at end of file diff --git a/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt b/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt index 34b3c9981..e84fd8df3 100644 --- a/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt +++ b/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt @@ -6,8 +6,8 @@ import kscience.kmath.structures.complex fun main() { // 2d element - val element = NDElement.complex(2, 2) { index: IntArray -> - Complex(index[0].toDouble() - index[1].toDouble(), index[0].toDouble() + index[1].toDouble()) + val element = NDElement.complex(2, 2) { (i,j) -> + Complex(i.toDouble() - j.toDouble(), i.toDouble() + j.toDouble()) } println(element) diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/expressions/DiffExpression.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/expressions/DiffExpression.kt index c39f0d04c..1eca1a773 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/expressions/DiffExpression.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/expressions/DiffExpression.kt @@ -16,7 +16,7 @@ import kotlin.properties.ReadOnlyProperty */ public class DerivativeStructureField( public val order: Int, - public val parameters: Map + public val parameters: Map, ) : ExtendedField { public override val zero: DerivativeStructure by lazy { DerivativeStructure(parameters.size, order) } public override val one: DerivativeStructure by lazy { DerivativeStructure(parameters.size, order, 1.0) } @@ -85,8 +85,9 @@ public class DerivativeStructureField( /** * A constructs that creates a derivative structure with required order on-demand */ -public class DiffExpression(public val function: DerivativeStructureField.() -> DerivativeStructure) : - Expression { +public class DiffExpression( + public val function: DerivativeStructureField.() -> DerivativeStructure, +) : Expression { public override operator fun invoke(arguments: Map): Double = DerivativeStructureField( 0, arguments diff --git a/kmath-commons/src/test/kotlin/kscience/kmath/commons/expressions/AutoDiffTest.kt b/kmath-commons/src/test/kotlin/kscience/kmath/commons/expressions/AutoDiffTest.kt index f905e6818..197faaf49 100644 --- a/kmath-commons/src/test/kotlin/kscience/kmath/commons/expressions/AutoDiffTest.kt +++ b/kmath-commons/src/test/kotlin/kscience/kmath/commons/expressions/AutoDiffTest.kt @@ -18,7 +18,7 @@ internal inline fun diff( internal class AutoDiffTest { @Test fun derivativeStructureFieldTest() { - val res = diff(3, "x" to 1.0, "y" to 1.0) { + val res: Double = diff(3, "x" to 1.0, "y" to 1.0) { val x by variable val y = variable("y") val z = x * (-sin(x * y) + y) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt index 37055a5c8..703931c7c 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt @@ -195,6 +195,7 @@ public data class Complex(val re: Double, val im: Double) : FieldElement