From 2d1d6c008e69b8d2db2b272595e95665b9e666a3 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Wed, 20 Jan 2021 15:07:12 +0700 Subject: [PATCH] Fix after-merge problems --- .../src/main/kotlin/kscience/kmath/structures/ComplexND.kt | 2 +- .../kotlin/kscience/kmath/complex/ComplexNDField.kt | 7 +++++-- .../kotlin/kscience/kmath/complex/QuaternionFieldTest.kt | 5 ++--- .../kotlin/kscience/kmath/structures/NDFieldTest.kt | 5 +++-- kmath-coroutines/build.gradle.kts | 1 + 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt b/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt index 340584185..2fa37b374 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt @@ -13,7 +13,7 @@ fun main() { val n = 1000 val realField = NDField.real(dim, dim) - val complexField: ComplexNDField = NDField.complex(dim, dim) + val complexField = NDField.complex(dim, dim) val realTime = measureTimeMillis { realField { diff --git a/kmath-complex/src/commonMain/kotlin/kscience/kmath/complex/ComplexNDField.kt b/kmath-complex/src/commonMain/kotlin/kscience/kmath/complex/ComplexNDField.kt index 7dc820757..8fa7c882f 100644 --- a/kmath-complex/src/commonMain/kotlin/kscience/kmath/complex/ComplexNDField.kt +++ b/kmath-complex/src/commonMain/kotlin/kscience/kmath/complex/ComplexNDField.kt @@ -6,16 +6,19 @@ import kscience.kmath.structures.* import kotlin.contracts.InvocationKind import kotlin.contracts.contract +/** + * Convenience alias for [BufferedNDFieldElement] of [Complex]. + */ public typealias ComplexNDElement = BufferedNDFieldElement /** - * An optimized nd-field for complex numbers + * An optimized ND field for complex numbers. */ @OptIn(UnstableKMathAPI::class) public class ComplexNDField(override val shape: IntArray) : BufferedNDField, ExtendedNDField>, - RingWithNumbers>{ + RingWithNumbers> { public override val strides: Strides = DefaultStrides(shape) public override val elementContext: ComplexField get() = ComplexField diff --git a/kmath-complex/src/commonTest/kotlin/kscience/kmath/complex/QuaternionFieldTest.kt b/kmath-complex/src/commonTest/kotlin/kscience/kmath/complex/QuaternionFieldTest.kt index 3a7d8cbd1..62099cd26 100644 --- a/kmath-complex/src/commonTest/kotlin/kscience/kmath/complex/QuaternionFieldTest.kt +++ b/kmath-complex/src/commonTest/kotlin/kscience/kmath/complex/QuaternionFieldTest.kt @@ -3,7 +3,6 @@ package kscience.kmath.complex import kscience.kmath.operations.invoke import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertTrue internal class QuaternionFieldTest { @Test @@ -17,7 +16,7 @@ internal class QuaternionFieldTest { fun testSubtraction() { assertEquals(Quaternion(42, 42), QuaternionField { Quaternion(86, 55) - Quaternion(44, 13) }) assertEquals(Quaternion(42, 56), QuaternionField { Quaternion(86, 56) - 44 }) - assertTrue(Quaternion(42, 56) - QuaternionField { 86 - Quaternion(44, -56) } < 1e-10.toQuaternion()) + assertEquals(Quaternion(42, 56), QuaternionField { 86 - Quaternion(44, -56) }) } @Test @@ -31,7 +30,7 @@ internal class QuaternionFieldTest { fun testDivision() { assertEquals(Quaternion(42, 42), QuaternionField { Quaternion(0, 168) / Quaternion(2, 2) }) assertEquals(Quaternion(42, 56), QuaternionField { Quaternion(86, 56) - 44 }) - assertTrue(Quaternion(42, 56) - QuaternionField { 86 - Quaternion(44, -56) } < 1e-10.toQuaternion()) + assertEquals(Quaternion(42, 56) , QuaternionField { 86 - Quaternion(44, -56) }) } @Test diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt index 1129a8a36..f54abce16 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt @@ -1,13 +1,14 @@ package kscience.kmath.structures -import kscience.kmath.operations.internal.FieldVerifier +import kscience.kmath.operations.invoke +import kscience.kmath.testutils.FieldVerifier import kotlin.test.Test import kotlin.test.assertEquals internal class NDFieldTest { @Test fun verify() { - NDField.real(12, 32).run { FieldVerifier(this, one + 3, one - 23, one * 12, 6.66) } + (NDField.real(12, 32)) { FieldVerifier(this, one + 3, one - 23, one * 12, 6.66) } } @Test diff --git a/kmath-coroutines/build.gradle.kts b/kmath-coroutines/build.gradle.kts index e108c2755..8d1487188 100644 --- a/kmath-coroutines/build.gradle.kts +++ b/kmath-coroutines/build.gradle.kts @@ -12,6 +12,7 @@ kotlin.sourceSets { commonMain { dependencies { api(project(":kmath-core")) + api(project(":kmath-complex")) api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${ru.mipt.npm.gradle.KScienceVersions.coroutinesVersion}") } }