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] } } }