From 139534fdb343b984c94f5bc089df34b9e1d5946b Mon Sep 17 00:00:00 2001 From: Andrei Kislitsyn Date: Tue, 30 Mar 2021 15:13:45 +0300 Subject: [PATCH] fix --- .../kmath/tensors/core/DoubleLinearOpsTensorAlgebra.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 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 59ec944f2..6be50e710 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 @@ -183,11 +183,7 @@ public class DoubleLinearOpsTensorAlgebra : } private fun MutableStructure1D.l2Norm(): Double { - var squareSum = 0.0 - for (i in 0 until size) { - squareSum += this[i] * this[i] - } - return sqrt(squareSum) + return sqrt((0 until size).sumOf { this[it] * this[it] }) } fun qrHelper( @@ -223,7 +219,7 @@ public class DoubleLinearOpsTensorAlgebra : val (q, r) = qr qrHelper(matrix.as2D(), q.as2D(), r.as2D()) } - return Pair(qTensor, rTensor) + return qTensor to rTensor } override fun DoubleTensor.svd(): Triple {