From 684227df63b1f4fc6b3345befc3da26a737f96da Mon Sep 17 00:00:00 2001 From: margarita0303 Date: Thu, 14 Jul 2022 14:34:44 +0300 Subject: [PATCH] added new svd tests --- .../core/TestDoubleLinearOpsAlgebra.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/kmath-tensors/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt b/kmath-tensors/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt index 3b305b25a..a5e4954c7 100644 --- a/kmath-tensors/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt +++ b/kmath-tensors/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt @@ -167,6 +167,18 @@ internal class TestDoubleLinearOpsTensorAlgebra { testSVDFor(fromArray(intArrayOf(2, 2), doubleArrayOf(-1.0, 0.0, 239.0, 238.0))) } +// @Test +// fun testSVDError() = DoubleTensorAlgebra{ +// val buffer = doubleArrayOf( +// 1.000000, 2.000000, 3.000000, +// 2.000000, 3.000000, 4.000000, +// 3.000000, 4.000000, 5.000000, +// 4.000000, 5.000000, 6.000000, +// 5.000000, 6.000000, 7.000000 +// ) +// testSVDFor(fromArray(intArrayOf(5, 3), buffer)) +// } + @Test fun testBatchedSVD() = DoubleTensorAlgebra { val tensor = randomNormal(intArrayOf(2, 5, 3), 0) @@ -189,6 +201,28 @@ internal class TestDoubleLinearOpsTensorAlgebra { testSVDGolabKahanFor(fromArray(intArrayOf(5, 3), buffer)) } +// @Test +// fun testSVDGolabKahanError() = DoubleTensorAlgebra{ +// val buffer = doubleArrayOf( +// 1.0, 2.0, 3.0, 2.0, 3.0, +// 4.0, 3.0, 4.0, 5.0, 4.0, +// 5.0, 6.0, 5.0, 6.0, 7.0 +// ) +// testSVDGolabKahanFor(fromArray(intArrayOf(3, 5), buffer)) +// } + + @Test + fun testSVDGolabKahanBig() = DoubleTensorAlgebra{ + val tensor = DoubleTensorAlgebra.randomNormal(intArrayOf(100, 100, 100), 0) + testSVDGolabKahanFor(tensor) + } + + @Test + fun testSVDBig() = DoubleTensorAlgebra{ + val tensor = DoubleTensorAlgebra.randomNormal(intArrayOf(100, 100, 100), 0) + testSVDFor(tensor) + } + @Test fun testBatchedSVDGolabKahan() = DoubleTensorAlgebra{ val tensor = randomNormal(intArrayOf(2, 5, 3), 0)