forked from kscience/kmath
cholesky fix
This commit is contained in:
parent
41238d8837
commit
25e60f85b8
@ -810,7 +810,7 @@ public open class DoubleTensorAlgebra :
|
||||
val lTensor = zeroesLike()
|
||||
|
||||
for ((a, l) in tensor.matrixSequence().zip(lTensor.matrixSequence()))
|
||||
for (i in 0 until n) choleskyHelper(a.as2D(), l.as2D(), n)
|
||||
choleskyHelper(a.as2D(), l.as2D(), n)
|
||||
|
||||
return lTensor
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ package space.kscience.kmath.tensors.core
|
||||
import space.kscience.kmath.operations.invoke
|
||||
import kotlin.math.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
internal class TestDoubleAnalyticTensorAlgebra {
|
||||
@ -302,11 +303,11 @@ internal class TestDoubleAnalyticTensorAlgebra {
|
||||
|
||||
@Test
|
||||
fun testStd() = DoubleTensorAlgebra {
|
||||
assertTrue { floor(tensor5.std() * 10000 ) / 10000 == 2.9439 }
|
||||
assertEquals(2.9439, floor(tensor5.std() * 10000 ) / 10000)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testVariance() = DoubleTensorAlgebra {
|
||||
assertTrue { floor(tensor5.variance() * 10000 ) / 10000 == 8.6666 }
|
||||
assertEquals(8.6666, floor(tensor5.variance() * 10000 ) / 10000)
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ internal class TestDoubleTensor {
|
||||
val buffer = doubleArrayOf(1.0, 2.0, -3.0, 4.0)
|
||||
val tensor = DoubleTensor(shape, buffer)
|
||||
val value = 3
|
||||
assertTrue { tensor.times(value).toBufferedTensor() eq DoubleTensor(shape, buffer.map { x -> 3 * x }.toDoubleArray()) }
|
||||
assertTrue { tensor.times(value).toBufferedTensor() eq DoubleTensor(shape, buffer.map { x -> value * x }.toDoubleArray()) }
|
||||
val buffer2 = doubleArrayOf(7.0, -8.0, -5.0, 2.0)
|
||||
val tensor2 = DoubleTensor(shape, buffer2)
|
||||
assertTrue {tensor.times(tensor2).toBufferedTensor() eq DoubleTensor(shape, doubleArrayOf(7.0, -16.0, 15.0, 8.0)) }
|
||||
|
Loading…
Reference in New Issue
Block a user