Thomas Dost
07/14/2023, 11:38 AMvar t: Array<Array<Double>> = arrayOf(
arrayOf(1.0,2.0),
arrayOf(1.0,2.0),
arrayOf(1.0,2.0))
var n: RealMatrix = MatrixUtils.createRealMatrix(t)
but I get following error
e: file:///home/td/NLO3/src/main/kotlin/Function.kt:210:58 Type mismatch: inferred type is Array<Array<Double>> but Array<(out) DoubleArray!>! was expected
changing t's type to Array<(out) DoubleArray!>!
did not help. Does anyone have an idea how to fix that. If there is an easier solution e.g. maybe an mathlib in Kotlin I am also interested in that
Thank you very much for your timeJoffrey
07/14/2023, 11:39 AMarrayOf
function, it gives you a generic Array<Double>
. What you want is to use doubleArrayOf()
so you get a DoubleArray
(which is different, because it's an array of primitives instead of an array of Double
object wrappers):
var t = arrayOf(
doubleArrayOf(1.0,2.0),
doubleArrayOf(1.0,2.0),
doubleArrayOf(1.0,2.0),
)
Thomas Dost
07/14/2023, 11:40 AM