Dev #194
@ -43,7 +43,7 @@ public class BufferMatrix<T : Any>(
|
|||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
|
|
||||||
return when (other) {
|
return when (other) {
|
||||||
is NDStructure<*> -> NDStructure.equals(this, other)
|
is NDStructure<*> -> NDStructure.contentEquals(this, other)
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public interface NDStructure<T> {
|
|||||||
/**
|
/**
|
||||||
* Indicates whether some [NDStructure] is equal to another one.
|
* Indicates whether some [NDStructure] is equal to another one.
|
||||||
*/
|
*/
|
||||||
public fun equals(st1: NDStructure<*>, st2: NDStructure<*>): Boolean {
|
public fun contentEquals(st1: NDStructure<*>, st2: NDStructure<*>): Boolean {
|
||||||
if (st1 === st2) return true
|
if (st1 === st2) return true
|
||||||
|
|
||||||
// fast comparison of buffers if possible
|
// fast comparison of buffers if possible
|
||||||
@ -275,7 +275,7 @@ public abstract class NDBuffer<T> : NDStructure<T> {
|
|||||||
override fun elements(): Sequence<Pair<IntArray, T>> = strides.indices().map { it to this[it] }
|
override fun elements(): Sequence<Pair<IntArray, T>> = strides.indices().map { it to this[it] }
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
return NDStructure.equals(this, other as? NDStructure<*> ?: return false)
|
return NDStructure.contentEquals(this, other as? NDStructure<*> ?: return false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
|
@ -24,7 +24,7 @@ public class LazyNDStructure<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override fun equals(other: Any?): Boolean {
|
public override fun equals(other: Any?): Boolean {
|
||||||
return NDStructure.equals(this, other as? NDStructure<*> ?: return false)
|
return NDStructure.contentEquals(this, other as? NDStructure<*> ?: return false)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun hashCode(): Int {
|
public override fun hashCode(): Int {
|
||||||
|
@ -3,6 +3,7 @@ package kscience.kmath.ejml
|
|||||||
import kscience.kmath.linear.*
|
import kscience.kmath.linear.*
|
||||||
import kscience.kmath.misc.UnstableKMathAPI
|
import kscience.kmath.misc.UnstableKMathAPI
|
||||||
import kscience.kmath.structures.Matrix
|
import kscience.kmath.structures.Matrix
|
||||||
|
import kscience.kmath.structures.NDStructure
|
||||||
import kscience.kmath.structures.RealBuffer
|
import kscience.kmath.structures.RealBuffer
|
||||||
import org.ejml.dense.row.factory.DecompositionFactory_DDRM
|
import org.ejml.dense.row.factory.DecompositionFactory_DDRM
|
||||||
import org.ejml.simple.SimpleMatrix
|
import org.ejml.simple.SimpleMatrix
|
||||||
@ -15,7 +16,7 @@ import kotlin.reflect.cast
|
|||||||
* @property origin the underlying [SimpleMatrix].
|
* @property origin the underlying [SimpleMatrix].
|
||||||
* @author Iaroslav Postovalov
|
* @author Iaroslav Postovalov
|
||||||
*/
|
*/
|
||||||
public inline class EjmlMatrix(
|
public class EjmlMatrix(
|
||||||
public val origin: SimpleMatrix,
|
public val origin: SimpleMatrix,
|
||||||
) : Matrix<Double> {
|
) : Matrix<Double> {
|
||||||
public override val rowNum: Int get() = origin.numRows()
|
public override val rowNum: Int get() = origin.numRows()
|
||||||
@ -76,4 +77,14 @@ public inline class EjmlMatrix(
|
|||||||
}?.let { type.cast(it) }
|
}?.let { type.cast(it) }
|
||||||
|
|
||||||
public override operator fun get(i: Int, j: Int): Double = origin[i, j]
|
public override operator fun get(i: Int, j: Int): Double = origin[i, j]
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other !is Matrix<*>) return false
|
||||||
|
return NDStructure.contentEquals(this, other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int = origin.hashCode()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user