From f4454a6cf6b8d54b1ecd818e2c39e6287b382189 Mon Sep 17 00:00:00 2001 From: Roland Grinis Date: Mon, 15 Mar 2021 22:45:55 +0000 Subject: [PATCH] Matrices from tensors test --- .../kotlin/space/kscience/kmath/tensors/TestDoubleTensor.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/TestDoubleTensor.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/TestDoubleTensor.kt index b1c8cd6dd..3050f064a 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/TestDoubleTensor.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/TestDoubleTensor.kt @@ -1,6 +1,7 @@ package space.kscience.kmath.tensors +import space.kscience.kmath.nd.as2D import space.kscience.kmath.structures.toDoubleArray import kotlin.test.Test import kotlin.test.assertEquals @@ -24,7 +25,8 @@ class TestDoubleTensor { @Test fun getTest() = DoubleTensorAlgebra { - val tensor = DoubleTensor(intArrayOf(2,2), doubleArrayOf(3.5,5.8,58.4,2.4)) - assertTrue(tensor[0].elements().map{ it.second }.toList().toDoubleArray() contentEquals doubleArrayOf(3.5,5.8)) + val tensor = DoubleTensor(intArrayOf(1,2,2), doubleArrayOf(3.5,5.8,58.4,2.4)) + val matrix = tensor[0].as2D() + assertEquals(matrix[0,1], 5.8) } } \ No newline at end of file