From 4c1547ba5c4bcfefbea80a10092c00cdf5682559 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 8 Jan 2019 20:42:45 +0300 Subject: [PATCH] Added strides equality and fixed tests --- .../kotlin/scientifik/kmath/operations/Complex.kt | 4 +--- .../scientifik/kmath/operations/NumberAlgebra.kt | 4 +--- .../scientifik/kmath/structures/NDStructure.kt | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt index a97afdb6b..107bb2f24 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt @@ -56,9 +56,7 @@ data class Complex(val re: Double, val im: Double) : FieldElement { override val context get() = RealField - companion object { - - } + companion object } /** diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/structures/NDStructure.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/structures/NDStructure.kt index 3c422797c..d9601a5d4 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/structures/NDStructure.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/structures/NDStructure.kt @@ -102,6 +102,20 @@ class DefaultStrides private constructor(override val shape: IntArray) : Strides override val linearSize: Int get() = strides[shape.size] + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is DefaultStrides) return false + + if (!shape.contentEquals(other.shape)) return false + + return true + } + + override fun hashCode(): Int { + return shape.contentHashCode() + } + companion object { private val defaultStridesCache = HashMap()