Matrices from tensors test
This commit is contained in:
parent
791f55ee8a
commit
f4454a6cf6
@ -1,6 +1,7 @@
|
|||||||
package space.kscience.kmath.tensors
|
package space.kscience.kmath.tensors
|
||||||
|
|
||||||
|
|
||||||
|
import space.kscience.kmath.nd.as2D
|
||||||
import space.kscience.kmath.structures.toDoubleArray
|
import space.kscience.kmath.structures.toDoubleArray
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
@ -24,7 +25,8 @@ class TestDoubleTensor {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getTest() = DoubleTensorAlgebra {
|
fun getTest() = DoubleTensorAlgebra {
|
||||||
val tensor = DoubleTensor(intArrayOf(2,2), doubleArrayOf(3.5,5.8,58.4,2.4))
|
val tensor = DoubleTensor(intArrayOf(1,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 matrix = tensor[0].as2D()
|
||||||
|
assertEquals(matrix[0,1], 5.8)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user