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 26852dc0b..8c1110f33 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 @@ -549,12 +549,13 @@ internal fun MutableStructure2D.svdHelper(u: MutableStructure2D, if (flag != 0) { c = 0.0 s = 1.0 - for (i in l until k) { + for (i in l until k + 1) { f = s * rv1[i] rv1[i] = c * rv1[i] if (abs(f) + anorm == anorm) { break } + g = w.mutableBuffer.array()[w.bufferStart + i] h = pythag(f, g) w.mutableBuffer.array()[w.bufferStart + i] = h h = 1.0 / h @@ -579,11 +580,6 @@ internal fun MutableStructure2D.svdHelper(u: MutableStructure2D, break } -// надо придумать, что сделать - выкинуть ошибку? -// if (its == 30) { -// return -// } - x = w.mutableBuffer.array()[w.bufferStart + l] nm = k - 1 y = w.mutableBuffer.array()[w.bufferStart + nm]