I have an Array[DenseMatrix[Double]]
and i want to find the mean of the same cells. For example:
Array[0]:
+---+---+
| 1 | 2 |
+---+---+
| 2 | 3 |
+---+---+
Array[1]:
+---+---+
| 1 | 1 |
+---+---+
| 3 | 1 |
+---+---+
Array[2]:
+---+---+
| 2 | 3 |
+---+---+
| 4 | 1 |
+---+---+
Result: DenseMatrix:
+----+----+
| 1.3| 2 |
+----+----+
| 3 | 1.6|
+----+----+
This is not a RDD as I want this code to run on the driver.
Spark Scala is new to me and all i can think is something like:
val ar = rdd.collect().foreach(x=> {
val matr = DenseMatrix.zeros[Double](C,2)
matr := x/M
matr
})
But I don't know if it is correct, as it think it is a closure
. Additionally, it expects a DenseMatrix[Double]
return type but I get error, because if RDD is empty I don't have one. Any ideas?