From 83e24acdc5c17a6e876fe3698e25d639b0b798df Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 7 Jan 2019 17:24:10 +0300 Subject: [PATCH] Added features to Matrix --- .../kotlin/scientifik/kmath/linear/Matrix.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/Matrix.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/Matrix.kt index 2a5765e30..35ad86379 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/Matrix.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/linear/Matrix.kt @@ -66,6 +66,11 @@ interface MatrixSpace> : Space> { } } +/** + * A marker interface representing some matrix feature like diagonal, sparce, zero, etc. Features used to optimize matrix + * operations performance in some cases. + */ +interface MatrixFeature /** * Specialized 2-d structure @@ -91,6 +96,8 @@ interface Matrix> : NDStructure, SpaceElement get(i, j) } } + val features: Set + companion object { fun real(rows: Int, columns: Int, initializer: (Int, Int) -> Double) = MatrixSpace.real(rows, columns).produce(rows, columns, initializer) @@ -147,7 +154,8 @@ data class StructureMatrixSpace>( data class StructureMatrix>( override val context: StructureMatrixSpace, - val structure: NDStructure + val structure: NDStructure, + override val features: Set = emptySet() ) : Matrix { init { if (structure.shape.size != 2 || structure.shape[0] != context.rowNum || structure.shape[1] != context.colNum) {