0.1.4-dev-4 #86
@ -1,6 +1,8 @@
|
||||
package scientifik.kmath.linear
|
||||
|
||||
import scientifik.kmath.structures.Matrix
|
||||
import scientifik.kmath.structures.NDStructure
|
||||
import scientifik.kmath.structures.as2D
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@ -44,4 +46,20 @@ class MatrixTest {
|
||||
|
||||
val toTenthPower = transitionMatrix pow 10
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test2DDot() {
|
||||
val firstMatrix = NDStructure.auto(2,3){ (i, j) -> (i + j).toDouble() }.as2D()
|
||||
val secondMatrix = NDStructure.auto(3,2){ (i, j) -> (i + j).toDouble() }.as2D()
|
||||
MatrixContext.real.run {
|
||||
// val firstMatrix = produce(2, 3) { i, j -> (i + j).toDouble() }
|
||||
// val secondMatrix = produce(3, 2) { i, j -> (i + j).toDouble() }
|
||||
val result = firstMatrix dot secondMatrix
|
||||
assertEquals(2, result.rowNum)
|
||||
assertEquals(2, result.colNum)
|
||||
assertEquals(8.0, result[0,1])
|
||||
assertEquals(8.0, result[1,0])
|
||||
assertEquals(14.0, result[1,1])
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user