From 1056fc7200b5fbbb03b75c66ca09c30483f12e5c Mon Sep 17 00:00:00 2001 From: Roland Grinis Date: Fri, 26 Mar 2021 13:48:59 +0000 Subject: [PATCH] Test for scalar product --- .../kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt index 2da79382f..d77f33f9d 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/tensors/core/TestDoubleLinearOpsAlgebra.kt @@ -70,4 +70,14 @@ class TestDoubleLinearOpsTensorAlgebra { assertTrue { invTensor.shape contentEquals expectedShape } assertTrue { invTensor.buffer.array().epsEqual(expectedBuffer) } } + + @Test + fun testScalarProduct() = DoubleLinearOpsTensorAlgebra { + val a = fromArray(intArrayOf(3), doubleArrayOf(1.8,2.5, 6.8)) + val b = fromArray(intArrayOf(3), doubleArrayOf(5.5,2.6, 6.4)) + DoubleReduceOpsTensorAlgebra { + assertEquals(a.dot(b).value(), 59.92) + } + + } }