From 68609d78468f7f72b94b33a332d8c9838d0fa08b Mon Sep 17 00:00:00 2001 From: margarita0303 Date: Tue, 2 Aug 2022 23:01:11 +0300 Subject: [PATCH] removed transposition at the end of the svdGolubKahan --- .../kscience/kmath/tensors/core/DoubleTensorAlgebra.kt | 4 ++-- .../space/kscience/kmath/tensors/core/internal/linUtils.kt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt index 9e1c3942c..8aa3ee76b 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt @@ -841,7 +841,7 @@ public open class DoubleTensorAlgebra : val size = tensor.dimension val commonShape = tensor.shape.sliceArray(0 until size - 2) val (n, m) = tensor.shape.sliceArray(size - 2 until size) - val uTensor = zeros(commonShape + intArrayOf(m, n)) + val uTensor = zeros(commonShape + intArrayOf(n, m)) val sTensor = zeros(commonShape + intArrayOf(m)) val vTensor = zeros(commonShape + intArrayOf(m, m)) @@ -863,7 +863,7 @@ public open class DoubleTensorAlgebra : iterations, epsilon) } - return Triple(uTensor.transpose(), sTensor, vTensor) + return Triple(uTensor, sTensor, vTensor) } /** diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/internal/linUtils.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/internal/linUtils.kt index 825c15006..bb75d1069 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/internal/linUtils.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/internal/linUtils.kt @@ -647,9 +647,9 @@ internal fun MutableStructure2D.svdGolubKahanHelper(u: MutableStructure2 } } - for (i in 0 until m) { - for (j in 0 until n) { - u[j, i] = this[i, j] + for (i in 0 until n) { + for (j in 0 until m) { + u[j, i] = this[j, i] } } }