Added strides equality and fixed tests

This commit is contained in:
Alexander Nozik 2019-01-08 20:42:45 +03:00
parent f356e8956b
commit 4c1547ba5c
3 changed files with 16 additions and 6 deletions

View File

@ -56,9 +56,7 @@ data class Complex(val re: Double, val im: Double) : FieldElement<Complex, Compl
val abs: Double val abs: Double
get() = kotlin.math.sqrt(square) get() = kotlin.math.sqrt(square)
companion object { companion object
}
} }
fun Double.toComplex() = Complex(this, 0.0) fun Double.toComplex() = Complex(this, 0.0)

View File

@ -24,9 +24,7 @@ inline class Real(val value: Double) : FieldElement<Double, Real, RealField> {
override val context get() = RealField override val context get() = RealField
companion object { companion object
}
} }
/** /**

View File

@ -102,6 +102,20 @@ class DefaultStrides private constructor(override val shape: IntArray) : Strides
override val linearSize: Int override val linearSize: Int
get() = strides[shape.size] 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 { companion object {
private val defaultStridesCache = HashMap<IntArray, Strides>() private val defaultStridesCache = HashMap<IntArray, Strides>()