I have a structure List[Array[Double]]
and I want to convert to a DenseMatrix. I have this solution but I think there might be a better way:
val data = List[Array[Double]]
val rows = data.length;
val cols = data(0).length;
val matrix = DenseMatrix.zeros[Double](rows, cols)
for (i <- 0 until data.length) {
for (j <- 0 until data(i).length) {
matrix(i,j)= data(i)(j)
}
}
I've been through the Breeze docs but didn't find anything. Is there a better way?