v0.2.0 #206

Merged
altavir merged 210 commits from dev into master 2021-02-21 16:33:25 +03:00
5 changed files with 12 additions and 8 deletions
Showing only changes of commit 2d1d6c008e - Show all commits

View File

@ -13,7 +13,7 @@ fun main() {
val n = 1000 val n = 1000
val realField = NDField.real(dim, dim) val realField = NDField.real(dim, dim)
val complexField: ComplexNDField = NDField.complex(dim, dim) val complexField = NDField.complex(dim, dim)
val realTime = measureTimeMillis { val realTime = measureTimeMillis {
realField { realField {

View File

@ -6,10 +6,13 @@ import kscience.kmath.structures.*
import kotlin.contracts.InvocationKind import kotlin.contracts.InvocationKind
import kotlin.contracts.contract import kotlin.contracts.contract
/**
* Convenience alias for [BufferedNDFieldElement] of [Complex].
*/
public typealias ComplexNDElement = BufferedNDFieldElement<Complex, ComplexField> public typealias ComplexNDElement = BufferedNDFieldElement<Complex, ComplexField>
/** /**
* An optimized nd-field for complex numbers * An optimized ND field for complex numbers.
*/ */
@OptIn(UnstableKMathAPI::class) @OptIn(UnstableKMathAPI::class)
public class ComplexNDField(override val shape: IntArray) : public class ComplexNDField(override val shape: IntArray) :

View File

@ -3,7 +3,6 @@ package kscience.kmath.complex
import kscience.kmath.operations.invoke import kscience.kmath.operations.invoke
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertTrue
internal class QuaternionFieldTest { internal class QuaternionFieldTest {
@Test @Test
@ -17,7 +16,7 @@ internal class QuaternionFieldTest {
fun testSubtraction() { fun testSubtraction() {
assertEquals(Quaternion(42, 42), QuaternionField { Quaternion(86, 55) - Quaternion(44, 13) }) assertEquals(Quaternion(42, 42), QuaternionField { Quaternion(86, 55) - Quaternion(44, 13) })
assertEquals(Quaternion(42, 56), QuaternionField { Quaternion(86, 56) - 44 }) 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 @Test
@ -31,7 +30,7 @@ internal class QuaternionFieldTest {
fun testDivision() { fun testDivision() {
assertEquals(Quaternion(42, 42), QuaternionField { Quaternion(0, 168) / Quaternion(2, 2) }) assertEquals(Quaternion(42, 42), QuaternionField { Quaternion(0, 168) / Quaternion(2, 2) })
assertEquals(Quaternion(42, 56), QuaternionField { Quaternion(86, 56) - 44 }) 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 @Test

View File

@ -1,13 +1,14 @@
package kscience.kmath.structures 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.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
internal class NDFieldTest { internal class NDFieldTest {
@Test @Test
fun verify() { 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 @Test

View File

@ -12,6 +12,7 @@ kotlin.sourceSets {
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
api(project(":kmath-complex"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${ru.mipt.npm.gradle.KScienceVersions.coroutinesVersion}") api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${ru.mipt.npm.gradle.KScienceVersions.coroutinesVersion}")
} }
} }