From 078686a04660e78b9929d2ed9a3c61f3fa888e62 Mon Sep 17 00:00:00 2001 From: Andrei Kislitsyn Date: Tue, 23 Mar 2021 15:59:55 +0300 Subject: [PATCH 1/2] hotfix sequence --- .../space/kscience/kmath/tensors/core/BufferedTensor.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/BufferedTensor.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/BufferedTensor.kt index 4f5e1f9f0..160c61260 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/BufferedTensor.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/BufferedTensor.kt @@ -34,7 +34,8 @@ public open class BufferedTensor( public fun vectorSequence(): Sequence> = sequence { check(shape.size >= 1) {"todo"} - val vectorOffset = linearStructure.strides[0] + val n = shape.size + val vectorOffset = shape[n - 1] val vectorShape = intArrayOf(shape.last()) for (offset in 0 until numel step vectorOffset) { val vector = BufferedTensor(vectorShape, buffer, offset).as1D() @@ -44,8 +45,9 @@ public open class BufferedTensor( public fun matrixSequence(): Sequence> = sequence { check(shape.size >= 2) {"todo"} - val matrixOffset = linearStructure.strides[1] - val matrixShape = intArrayOf(shape[shape.size - 2], shape.last()) //todo better way? + val n = shape.size + val matrixOffset = shape[n - 1] * shape[n - 2] + val matrixShape = intArrayOf(shape[n - 2], shape[n - 1]) //todo better way? for (offset in 0 until numel step matrixOffset) { val matrix = BufferedTensor(matrixShape, buffer, offset).as2D() yield(matrix) From e01ca38fb3a7b05037582f561298928be552100e Mon Sep 17 00:00:00 2001 From: Roland Grinis Date: Tue, 23 Mar 2021 13:51:52 +0000 Subject: [PATCH 2/2] Tasks for Andrei and Alya --- .../kmath/tensors/core/DoubleLinearOpsTensorAlgebra.kt | 8 ++++---- .../kscience/kmath/tensors/core/DoubleTensorAlgebra.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleLinearOpsTensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleLinearOpsTensorAlgebra.kt index e0abc49b7..8a16a991d 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleLinearOpsTensorAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleLinearOpsTensorAlgebra.kt @@ -8,7 +8,7 @@ public class DoubleLinearOpsTensorAlgebra : DoubleTensorAlgebra() { override fun DoubleTensor.inv(): DoubleTensor { - TODO("Not yet implemented") + TODO("ANDREI") } override fun DoubleTensor.lu(tol: Double): Pair { @@ -135,16 +135,16 @@ public class DoubleLinearOpsTensorAlgebra : } override fun DoubleTensor.qr(): DoubleTensor { - TODO("Not yet implemented") + TODO("ANDREI") } override fun DoubleTensor.svd(): Triple { - TODO("Not yet implemented") + TODO("ALYA") } override fun DoubleTensor.symEig(eigenvectors: Boolean): Pair { - TODO("Not yet implemented") + TODO("ANDREI") } } diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt index 67b50970b..c67687a09 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt @@ -262,7 +262,7 @@ public open class DoubleTensorAlgebra : TensorPartialDivisionAlgebra